Commit fe8a93b95145c66adf196eea4a919dfe0b7c57db
1 parent
361cd29cf9
batman-adv: make is_my_mac() check for the current mesh only
On a multi-mesh node (a node running more than one batman-adv virtual interface) batadv_is_my_mac() has to check MAC addresses of hard interfaces belonging to the current mesh only. Signed-off-by: Antonio Quartulli <ordex@autistici.org> Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Showing 5 changed files with 28 additions and 23 deletions Side-by-side Diff
net/batman-adv/main.c
... | ... | @@ -169,13 +169,16 @@ |
169 | 169 | atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE); |
170 | 170 | } |
171 | 171 | |
172 | -int batadv_is_my_mac(const uint8_t *addr) | |
172 | +int batadv_is_my_mac(struct batadv_priv *bat_priv, const uint8_t *addr) | |
173 | 173 | { |
174 | 174 | const struct batadv_hard_iface *hard_iface; |
175 | 175 | |
176 | 176 | rcu_read_lock(); |
177 | 177 | list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { |
178 | 178 | if (hard_iface->if_status != BATADV_IF_ACTIVE) |
179 | + continue; | |
180 | + | |
181 | + if (hard_iface->soft_iface != bat_priv->soft_iface) | |
179 | 182 | continue; |
180 | 183 | |
181 | 184 | if (batadv_compare_eth(hard_iface->net_dev->dev_addr, addr)) { |
net/batman-adv/main.h
... | ... | @@ -162,7 +162,7 @@ |
162 | 162 | |
163 | 163 | int batadv_mesh_init(struct net_device *soft_iface); |
164 | 164 | void batadv_mesh_free(struct net_device *soft_iface); |
165 | -int batadv_is_my_mac(const uint8_t *addr); | |
165 | +int batadv_is_my_mac(struct batadv_priv *bat_priv, const uint8_t *addr); | |
166 | 166 | struct batadv_hard_iface * |
167 | 167 | batadv_seq_print_text_primary_if_get(struct seq_file *seq); |
168 | 168 | int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev, |
net/batman-adv/routing.c
... | ... | @@ -402,7 +402,7 @@ |
402 | 402 | goto out; |
403 | 403 | |
404 | 404 | /* not for me */ |
405 | - if (!batadv_is_my_mac(ethhdr->h_dest)) | |
405 | + if (!batadv_is_my_mac(bat_priv, ethhdr->h_dest)) | |
406 | 406 | goto out; |
407 | 407 | |
408 | 408 | icmp_packet = (struct batadv_icmp_packet_rr *)skb->data; |
... | ... | @@ -416,7 +416,7 @@ |
416 | 416 | } |
417 | 417 | |
418 | 418 | /* packet for me */ |
419 | - if (batadv_is_my_mac(icmp_packet->dst)) | |
419 | + if (batadv_is_my_mac(bat_priv, icmp_packet->dst)) | |
420 | 420 | return batadv_recv_my_icmp_packet(bat_priv, skb, hdr_size); |
421 | 421 | |
422 | 422 | /* TTL exceeded */ |
... | ... | @@ -548,7 +548,8 @@ |
548 | 548 | return router; |
549 | 549 | } |
550 | 550 | |
551 | -static int batadv_check_unicast_packet(struct sk_buff *skb, int hdr_size) | |
551 | +static int batadv_check_unicast_packet(struct batadv_priv *bat_priv, | |
552 | + struct sk_buff *skb, int hdr_size) | |
552 | 553 | { |
553 | 554 | struct ethhdr *ethhdr; |
554 | 555 | |
... | ... | @@ -567,7 +568,7 @@ |
567 | 568 | return -1; |
568 | 569 | |
569 | 570 | /* not for me */ |
570 | - if (!batadv_is_my_mac(ethhdr->h_dest)) | |
571 | + if (!batadv_is_my_mac(bat_priv, ethhdr->h_dest)) | |
571 | 572 | return -1; |
572 | 573 | |
573 | 574 | return 0; |
... | ... | @@ -582,7 +583,7 @@ |
582 | 583 | char tt_flag; |
583 | 584 | size_t packet_size; |
584 | 585 | |
585 | - if (batadv_check_unicast_packet(skb, hdr_size) < 0) | |
586 | + if (batadv_check_unicast_packet(bat_priv, skb, hdr_size) < 0) | |
586 | 587 | return NET_RX_DROP; |
587 | 588 | |
588 | 589 | /* I could need to modify it */ |
... | ... | @@ -614,7 +615,7 @@ |
614 | 615 | case BATADV_TT_RESPONSE: |
615 | 616 | batadv_inc_counter(bat_priv, BATADV_CNT_TT_RESPONSE_RX); |
616 | 617 | |
617 | - if (batadv_is_my_mac(tt_query->dst)) { | |
618 | + if (batadv_is_my_mac(bat_priv, tt_query->dst)) { | |
618 | 619 | /* packet needs to be linearized to access the TT |
619 | 620 | * changes |
620 | 621 | */ |
621 | 622 | |
... | ... | @@ -657,14 +658,15 @@ |
657 | 658 | struct batadv_roam_adv_packet *roam_adv_packet; |
658 | 659 | struct batadv_orig_node *orig_node; |
659 | 660 | |
660 | - if (batadv_check_unicast_packet(skb, sizeof(*roam_adv_packet)) < 0) | |
661 | + if (batadv_check_unicast_packet(bat_priv, skb, | |
662 | + sizeof(*roam_adv_packet)) < 0) | |
661 | 663 | goto out; |
662 | 664 | |
663 | 665 | batadv_inc_counter(bat_priv, BATADV_CNT_TT_ROAM_ADV_RX); |
664 | 666 | |
665 | 667 | roam_adv_packet = (struct batadv_roam_adv_packet *)skb->data; |
666 | 668 | |
667 | - if (!batadv_is_my_mac(roam_adv_packet->dst)) | |
669 | + if (!batadv_is_my_mac(bat_priv, roam_adv_packet->dst)) | |
668 | 670 | return batadv_route_unicast_packet(skb, recv_if); |
669 | 671 | |
670 | 672 | /* check if it is a backbone gateway. we don't accept |
... | ... | @@ -967,7 +969,7 @@ |
967 | 969 | * last time) the packet had an updated information or not |
968 | 970 | */ |
969 | 971 | curr_ttvn = (uint8_t)atomic_read(&bat_priv->tt.vn); |
970 | - if (!batadv_is_my_mac(unicast_packet->dest)) { | |
972 | + if (!batadv_is_my_mac(bat_priv, unicast_packet->dest)) { | |
971 | 973 | orig_node = batadv_orig_hash_find(bat_priv, |
972 | 974 | unicast_packet->dest); |
973 | 975 | /* if it is not possible to find the orig_node representing the |
974 | 976 | |
... | ... | @@ -1044,14 +1046,14 @@ |
1044 | 1046 | if (is4addr) |
1045 | 1047 | hdr_size = sizeof(*unicast_4addr_packet); |
1046 | 1048 | |
1047 | - if (batadv_check_unicast_packet(skb, hdr_size) < 0) | |
1049 | + if (batadv_check_unicast_packet(bat_priv, skb, hdr_size) < 0) | |
1048 | 1050 | return NET_RX_DROP; |
1049 | 1051 | |
1050 | 1052 | if (!batadv_check_unicast_ttvn(bat_priv, skb)) |
1051 | 1053 | return NET_RX_DROP; |
1052 | 1054 | |
1053 | 1055 | /* packet for me */ |
1054 | - if (batadv_is_my_mac(unicast_packet->dest)) { | |
1056 | + if (batadv_is_my_mac(bat_priv, unicast_packet->dest)) { | |
1055 | 1057 | if (is4addr) { |
1056 | 1058 | batadv_dat_inc_counter(bat_priv, |
1057 | 1059 | unicast_4addr_packet->subtype); |
... | ... | @@ -1088,7 +1090,7 @@ |
1088 | 1090 | struct sk_buff *new_skb = NULL; |
1089 | 1091 | int ret; |
1090 | 1092 | |
1091 | - if (batadv_check_unicast_packet(skb, hdr_size) < 0) | |
1093 | + if (batadv_check_unicast_packet(bat_priv, skb, hdr_size) < 0) | |
1092 | 1094 | return NET_RX_DROP; |
1093 | 1095 | |
1094 | 1096 | if (!batadv_check_unicast_ttvn(bat_priv, skb)) |
... | ... | @@ -1097,7 +1099,7 @@ |
1097 | 1099 | unicast_packet = (struct batadv_unicast_frag_packet *)skb->data; |
1098 | 1100 | |
1099 | 1101 | /* packet for me */ |
1100 | - if (batadv_is_my_mac(unicast_packet->dest)) { | |
1102 | + if (batadv_is_my_mac(bat_priv, unicast_packet->dest)) { | |
1101 | 1103 | ret = batadv_frag_reassemble_skb(skb, bat_priv, &new_skb); |
1102 | 1104 | |
1103 | 1105 | if (ret == NET_RX_DROP) |
1104 | 1106 | |
... | ... | @@ -1151,13 +1153,13 @@ |
1151 | 1153 | goto out; |
1152 | 1154 | |
1153 | 1155 | /* ignore broadcasts sent by myself */ |
1154 | - if (batadv_is_my_mac(ethhdr->h_source)) | |
1156 | + if (batadv_is_my_mac(bat_priv, ethhdr->h_source)) | |
1155 | 1157 | goto out; |
1156 | 1158 | |
1157 | 1159 | bcast_packet = (struct batadv_bcast_packet *)skb->data; |
1158 | 1160 | |
1159 | 1161 | /* ignore broadcasts originated by myself */ |
1160 | - if (batadv_is_my_mac(bcast_packet->orig)) | |
1162 | + if (batadv_is_my_mac(bat_priv, bcast_packet->orig)) | |
1161 | 1163 | goto out; |
1162 | 1164 | |
1163 | 1165 | if (bcast_packet->header.ttl < 2) |
1164 | 1166 | |
1165 | 1167 | |
... | ... | @@ -1243,14 +1245,14 @@ |
1243 | 1245 | ethhdr = (struct ethhdr *)skb_mac_header(skb); |
1244 | 1246 | |
1245 | 1247 | /* not for me */ |
1246 | - if (!batadv_is_my_mac(ethhdr->h_dest)) | |
1248 | + if (!batadv_is_my_mac(bat_priv, ethhdr->h_dest)) | |
1247 | 1249 | return NET_RX_DROP; |
1248 | 1250 | |
1249 | 1251 | /* ignore own packets */ |
1250 | - if (batadv_is_my_mac(vis_packet->vis_orig)) | |
1252 | + if (batadv_is_my_mac(bat_priv, vis_packet->vis_orig)) | |
1251 | 1253 | return NET_RX_DROP; |
1252 | 1254 | |
1253 | - if (batadv_is_my_mac(vis_packet->sender_orig)) | |
1255 | + if (batadv_is_my_mac(bat_priv, vis_packet->sender_orig)) | |
1254 | 1256 | return NET_RX_DROP; |
1255 | 1257 | |
1256 | 1258 | switch (vis_packet->vis_type) { |
net/batman-adv/translation-table.c
... | ... | @@ -1953,7 +1953,7 @@ |
1953 | 1953 | bool batadv_send_tt_response(struct batadv_priv *bat_priv, |
1954 | 1954 | struct batadv_tt_query_packet *tt_request) |
1955 | 1955 | { |
1956 | - if (batadv_is_my_mac(tt_request->dst)) { | |
1956 | + if (batadv_is_my_mac(bat_priv, tt_request->dst)) { | |
1957 | 1957 | /* don't answer backbone gws! */ |
1958 | 1958 | if (batadv_bla_is_backbone_gw_orig(bat_priv, tt_request->src)) |
1959 | 1959 | return true; |
net/batman-adv/vis.c
... | ... | @@ -477,7 +477,7 @@ |
477 | 477 | |
478 | 478 | /* Are we the target for this VIS packet? */ |
479 | 479 | if (vis_server == BATADV_VIS_TYPE_SERVER_SYNC && |
480 | - batadv_is_my_mac(vis_packet->target_orig)) | |
480 | + batadv_is_my_mac(bat_priv, vis_packet->target_orig)) | |
481 | 481 | are_target = 1; |
482 | 482 | |
483 | 483 | spin_lock_bh(&bat_priv->vis.hash_lock); |
... | ... | @@ -496,7 +496,7 @@ |
496 | 496 | batadv_send_list_add(bat_priv, info); |
497 | 497 | |
498 | 498 | /* ... we're not the recipient (and thus need to forward). */ |
499 | - } else if (!batadv_is_my_mac(packet->target_orig)) { | |
499 | + } else if (!batadv_is_my_mac(bat_priv, packet->target_orig)) { | |
500 | 500 | batadv_send_list_add(bat_priv, info); |
501 | 501 | } |
502 | 502 |