diff options
Diffstat (limited to 'net/batman-adv/bat_iv_ogm.c')
-rw-r--r-- | net/batman-adv/bat_iv_ogm.c | 44 |
1 files changed, 14 insertions, 30 deletions
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index f0f02d1a10d7..871ba672bdc2 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c | |||
@@ -137,8 +137,6 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface) | |||
137 | batadv_ogm_packet->flags = BATADV_NO_FLAGS; | 137 | batadv_ogm_packet->flags = BATADV_NO_FLAGS; |
138 | batadv_ogm_packet->reserved = 0; | 138 | batadv_ogm_packet->reserved = 0; |
139 | batadv_ogm_packet->tq = BATADV_TQ_MAX_VALUE; | 139 | batadv_ogm_packet->tq = BATADV_TQ_MAX_VALUE; |
140 | batadv_ogm_packet->tt_num_changes = 0; | ||
141 | batadv_ogm_packet->ttvn = 0; | ||
142 | 140 | ||
143 | res = 0; | 141 | res = 0; |
144 | 142 | ||
@@ -257,14 +255,14 @@ static void batadv_iv_ogm_send_to_if(struct batadv_forw_packet *forw_packet, | |||
257 | fwd_str = "Sending own"; | 255 | fwd_str = "Sending own"; |
258 | 256 | ||
259 | batadv_dbg(BATADV_DBG_BATMAN, bat_priv, | 257 | batadv_dbg(BATADV_DBG_BATMAN, bat_priv, |
260 | "%s %spacket (originator %pM, seqno %u, TQ %d, TTL %d, IDF %s, ttvn %d) on interface %s [%pM]\n", | 258 | "%s %spacket (originator %pM, seqno %u, TQ %d, TTL %d, IDF %s) on interface %s [%pM]\n", |
261 | fwd_str, (packet_num > 0 ? "aggregated " : ""), | 259 | fwd_str, (packet_num > 0 ? "aggregated " : ""), |
262 | batadv_ogm_packet->orig, | 260 | batadv_ogm_packet->orig, |
263 | ntohl(batadv_ogm_packet->seqno), | 261 | ntohl(batadv_ogm_packet->seqno), |
264 | batadv_ogm_packet->tq, batadv_ogm_packet->header.ttl, | 262 | batadv_ogm_packet->tq, batadv_ogm_packet->header.ttl, |
265 | (batadv_ogm_packet->flags & BATADV_DIRECTLINK ? | 263 | (batadv_ogm_packet->flags & BATADV_DIRECTLINK ? |
266 | "on" : "off"), | 264 | "on" : "off"), |
267 | batadv_ogm_packet->ttvn, hard_iface->net_dev->name, | 265 | hard_iface->net_dev->name, |
268 | hard_iface->net_dev->dev_addr); | 266 | hard_iface->net_dev->dev_addr); |
269 | 267 | ||
270 | buff_pos += BATADV_OGM_HLEN; | 268 | buff_pos += BATADV_OGM_HLEN; |
@@ -689,17 +687,22 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface) | |||
689 | struct batadv_ogm_packet *batadv_ogm_packet; | 687 | struct batadv_ogm_packet *batadv_ogm_packet; |
690 | struct batadv_hard_iface *primary_if; | 688 | struct batadv_hard_iface *primary_if; |
691 | int *ogm_buff_len = &hard_iface->bat_iv.ogm_buff_len; | 689 | int *ogm_buff_len = &hard_iface->bat_iv.ogm_buff_len; |
692 | int vis_server, tt_num_changes = 0; | 690 | int vis_server; |
693 | uint32_t seqno; | 691 | uint32_t seqno; |
694 | uint16_t tvlv_len = 0; | 692 | uint16_t tvlv_len = 0; |
695 | 693 | ||
696 | vis_server = atomic_read(&bat_priv->vis_mode); | 694 | vis_server = atomic_read(&bat_priv->vis_mode); |
697 | primary_if = batadv_primary_if_get_selected(bat_priv); | 695 | primary_if = batadv_primary_if_get_selected(bat_priv); |
698 | 696 | ||
699 | if (hard_iface == primary_if) | 697 | if (hard_iface == primary_if) { |
698 | /* tt changes have to be committed before the tvlv data is | ||
699 | * appended as it may alter the tt tvlv container | ||
700 | */ | ||
701 | batadv_tt_local_commit_changes(bat_priv); | ||
700 | tvlv_len = batadv_tvlv_container_ogm_append(bat_priv, ogm_buff, | 702 | tvlv_len = batadv_tvlv_container_ogm_append(bat_priv, ogm_buff, |
701 | ogm_buff_len, | 703 | ogm_buff_len, |
702 | BATADV_OGM_HLEN); | 704 | BATADV_OGM_HLEN); |
705 | } | ||
703 | 706 | ||
704 | batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff); | 707 | batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff); |
705 | batadv_ogm_packet->tvlv_len = htons(tvlv_len); | 708 | batadv_ogm_packet->tvlv_len = htons(tvlv_len); |
@@ -709,11 +712,6 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface) | |||
709 | batadv_ogm_packet->seqno = htonl(seqno); | 712 | batadv_ogm_packet->seqno = htonl(seqno); |
710 | atomic_inc(&hard_iface->bat_iv.ogm_seqno); | 713 | atomic_inc(&hard_iface->bat_iv.ogm_seqno); |
711 | 714 | ||
712 | batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn); | ||
713 | batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc); | ||
714 | if (tt_num_changes >= 0) | ||
715 | batadv_ogm_packet->tt_num_changes = tt_num_changes; | ||
716 | |||
717 | if (vis_server == BATADV_VIS_TYPE_SERVER_SYNC) | 715 | if (vis_server == BATADV_VIS_TYPE_SERVER_SYNC) |
718 | batadv_ogm_packet->flags |= BATADV_VIS_SERVER; | 716 | batadv_ogm_packet->flags |= BATADV_VIS_SERVER; |
719 | else | 717 | else |
@@ -814,11 +812,11 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv, | |||
814 | */ | 812 | */ |
815 | router = batadv_orig_node_get_router(orig_node); | 813 | router = batadv_orig_node_get_router(orig_node); |
816 | if (router == neigh_node) | 814 | if (router == neigh_node) |
817 | goto update_tt; | 815 | goto out; |
818 | 816 | ||
819 | /* if this neighbor does not offer a better TQ we won't consider it */ | 817 | /* if this neighbor does not offer a better TQ we won't consider it */ |
820 | if (router && (router->tq_avg > neigh_node->tq_avg)) | 818 | if (router && (router->tq_avg > neigh_node->tq_avg)) |
821 | goto update_tt; | 819 | goto out; |
822 | 820 | ||
823 | /* if the TQ is the same and the link not more symmetric we | 821 | /* if the TQ is the same and the link not more symmetric we |
824 | * won't consider it either | 822 | * won't consider it either |
@@ -837,22 +835,10 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv, | |||
837 | spin_unlock_bh(&orig_node_tmp->ogm_cnt_lock); | 835 | spin_unlock_bh(&orig_node_tmp->ogm_cnt_lock); |
838 | 836 | ||
839 | if (sum_orig >= sum_neigh) | 837 | if (sum_orig >= sum_neigh) |
840 | goto update_tt; | 838 | goto out; |
841 | } | 839 | } |
842 | 840 | ||
843 | batadv_update_route(bat_priv, orig_node, neigh_node); | 841 | batadv_update_route(bat_priv, orig_node, neigh_node); |
844 | |||
845 | update_tt: | ||
846 | /* I have to check for transtable changes only if the OGM has been | ||
847 | * sent through a primary interface | ||
848 | */ | ||
849 | if (((batadv_ogm_packet->orig != ethhdr->h_source) && | ||
850 | (batadv_ogm_packet->header.ttl > 2)) || | ||
851 | (batadv_ogm_packet->flags & BATADV_PRIMARIES_FIRST_HOP)) | ||
852 | batadv_tt_update_orig(bat_priv, orig_node, tt_buff, | ||
853 | batadv_ogm_packet->tt_num_changes, | ||
854 | batadv_ogm_packet->ttvn, | ||
855 | ntohs(batadv_ogm_packet->tt_crc)); | ||
856 | goto out; | 842 | goto out; |
857 | 843 | ||
858 | unlock: | 844 | unlock: |
@@ -1103,13 +1089,11 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr, | |||
1103 | is_single_hop_neigh = true; | 1089 | is_single_hop_neigh = true; |
1104 | 1090 | ||
1105 | batadv_dbg(BATADV_DBG_BATMAN, bat_priv, | 1091 | batadv_dbg(BATADV_DBG_BATMAN, bat_priv, |
1106 | "Received BATMAN packet via NB: %pM, IF: %s [%pM] (from OG: %pM, via prev OG: %pM, seqno %u, ttvn %u, crc %#.4x, changes %u, tq %d, TTL %d, V %d, IDF %d)\n", | 1092 | "Received BATMAN packet via NB: %pM, IF: %s [%pM] (from OG: %pM, via prev OG: %pM, seqno %u, tq %d, TTL %d, V %d, IDF %d)\n", |
1107 | ethhdr->h_source, if_incoming->net_dev->name, | 1093 | ethhdr->h_source, if_incoming->net_dev->name, |
1108 | if_incoming->net_dev->dev_addr, batadv_ogm_packet->orig, | 1094 | if_incoming->net_dev->dev_addr, batadv_ogm_packet->orig, |
1109 | batadv_ogm_packet->prev_sender, | 1095 | batadv_ogm_packet->prev_sender, |
1110 | ntohl(batadv_ogm_packet->seqno), batadv_ogm_packet->ttvn, | 1096 | ntohl(batadv_ogm_packet->seqno), batadv_ogm_packet->tq, |
1111 | ntohs(batadv_ogm_packet->tt_crc), | ||
1112 | batadv_ogm_packet->tt_num_changes, batadv_ogm_packet->tq, | ||
1113 | batadv_ogm_packet->header.ttl, | 1097 | batadv_ogm_packet->header.ttl, |
1114 | batadv_ogm_packet->header.version, has_directlink_flag); | 1098 | batadv_ogm_packet->header.version, has_directlink_flag); |
1115 | 1099 | ||