diff options
| author | Antonio Quartulli <ordex@autistici.org> | 2013-04-03 13:10:26 -0400 |
|---|---|---|
| committer | Antonio Quartulli <ordex@autistici.org> | 2013-04-17 16:31:22 -0400 |
| commit | fe8a93b95145c66adf196eea4a919dfe0b7c57db (patch) | |
| tree | e7251d3c966129aaba6366ca35a74a3d8b4f014a | |
| parent | 361cd29cf9363505c2a35bbf9a034a22feebfb07 (diff) | |
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>
| -rw-r--r-- | net/batman-adv/main.c | 5 | ||||
| -rw-r--r-- | net/batman-adv/main.h | 2 | ||||
| -rw-r--r-- | net/batman-adv/routing.c | 38 | ||||
| -rw-r--r-- | net/batman-adv/translation-table.c | 2 | ||||
| -rw-r--r-- | net/batman-adv/vis.c | 4 |
5 files changed, 28 insertions, 23 deletions
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c index 0488d70c8c35..fa563e497c48 100644 --- a/net/batman-adv/main.c +++ b/net/batman-adv/main.c | |||
| @@ -169,7 +169,7 @@ void batadv_mesh_free(struct net_device *soft_iface) | |||
| 169 | atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE); | 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 | const struct batadv_hard_iface *hard_iface; | 174 | const struct batadv_hard_iface *hard_iface; |
| 175 | 175 | ||
| @@ -178,6 +178,9 @@ int batadv_is_my_mac(const uint8_t *addr) | |||
| 178 | if (hard_iface->if_status != BATADV_IF_ACTIVE) | 178 | if (hard_iface->if_status != BATADV_IF_ACTIVE) |
| 179 | continue; | 179 | continue; |
| 180 | 180 | ||
| 181 | if (hard_iface->soft_iface != bat_priv->soft_iface) | ||
| 182 | continue; | ||
| 183 | |||
| 181 | if (batadv_compare_eth(hard_iface->net_dev->dev_addr, addr)) { | 184 | if (batadv_compare_eth(hard_iface->net_dev->dev_addr, addr)) { |
| 182 | rcu_read_unlock(); | 185 | rcu_read_unlock(); |
| 183 | return 1; | 186 | return 1; |
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index ced08b936a96..d40910dfc8ea 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h | |||
| @@ -162,7 +162,7 @@ extern struct workqueue_struct *batadv_event_workqueue; | |||
| 162 | 162 | ||
| 163 | int batadv_mesh_init(struct net_device *soft_iface); | 163 | int batadv_mesh_init(struct net_device *soft_iface); |
| 164 | void batadv_mesh_free(struct net_device *soft_iface); | 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 | struct batadv_hard_iface * | 166 | struct batadv_hard_iface * |
| 167 | batadv_seq_print_text_primary_if_get(struct seq_file *seq); | 167 | batadv_seq_print_text_primary_if_get(struct seq_file *seq); |
| 168 | int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev, | 168 | int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev, |
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index 5ee21cebbbb0..319f2906c71a 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c | |||
| @@ -402,7 +402,7 @@ int batadv_recv_icmp_packet(struct sk_buff *skb, | |||
| 402 | goto out; | 402 | goto out; |
| 403 | 403 | ||
| 404 | /* not for me */ | 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 | goto out; | 406 | goto out; |
| 407 | 407 | ||
| 408 | icmp_packet = (struct batadv_icmp_packet_rr *)skb->data; | 408 | icmp_packet = (struct batadv_icmp_packet_rr *)skb->data; |
| @@ -416,7 +416,7 @@ int batadv_recv_icmp_packet(struct sk_buff *skb, | |||
| 416 | } | 416 | } |
| 417 | 417 | ||
| 418 | /* packet for me */ | 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 | return batadv_recv_my_icmp_packet(bat_priv, skb, hdr_size); | 420 | return batadv_recv_my_icmp_packet(bat_priv, skb, hdr_size); |
| 421 | 421 | ||
| 422 | /* TTL exceeded */ | 422 | /* TTL exceeded */ |
| @@ -548,7 +548,8 @@ batadv_find_ifalter_router(struct batadv_orig_node *primary_orig, | |||
| 548 | return router; | 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 | struct ethhdr *ethhdr; | 554 | struct ethhdr *ethhdr; |
| 554 | 555 | ||
| @@ -567,7 +568,7 @@ static int batadv_check_unicast_packet(struct sk_buff *skb, int hdr_size) | |||
| 567 | return -1; | 568 | return -1; |
| 568 | 569 | ||
| 569 | /* not for me */ | 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 | return -1; | 572 | return -1; |
| 572 | 573 | ||
| 573 | return 0; | 574 | return 0; |
| @@ -582,7 +583,7 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct batadv_hard_iface *recv_if) | |||
| 582 | char tt_flag; | 583 | char tt_flag; |
| 583 | size_t packet_size; | 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 | return NET_RX_DROP; | 587 | return NET_RX_DROP; |
| 587 | 588 | ||
| 588 | /* I could need to modify it */ | 589 | /* I could need to modify it */ |
| @@ -614,7 +615,7 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct batadv_hard_iface *recv_if) | |||
| 614 | case BATADV_TT_RESPONSE: | 615 | case BATADV_TT_RESPONSE: |
| 615 | batadv_inc_counter(bat_priv, BATADV_CNT_TT_RESPONSE_RX); | 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 | /* packet needs to be linearized to access the TT | 619 | /* packet needs to be linearized to access the TT |
| 619 | * changes | 620 | * changes |
| 620 | */ | 621 | */ |
| @@ -657,14 +658,15 @@ int batadv_recv_roam_adv(struct sk_buff *skb, struct batadv_hard_iface *recv_if) | |||
| 657 | struct batadv_roam_adv_packet *roam_adv_packet; | 658 | struct batadv_roam_adv_packet *roam_adv_packet; |
| 658 | struct batadv_orig_node *orig_node; | 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 | goto out; | 663 | goto out; |
| 662 | 664 | ||
| 663 | batadv_inc_counter(bat_priv, BATADV_CNT_TT_ROAM_ADV_RX); | 665 | batadv_inc_counter(bat_priv, BATADV_CNT_TT_ROAM_ADV_RX); |
| 664 | 666 | ||
| 665 | roam_adv_packet = (struct batadv_roam_adv_packet *)skb->data; | 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 | return batadv_route_unicast_packet(skb, recv_if); | 670 | return batadv_route_unicast_packet(skb, recv_if); |
| 669 | 671 | ||
| 670 | /* check if it is a backbone gateway. we don't accept | 672 | /* check if it is a backbone gateway. we don't accept |
| @@ -967,7 +969,7 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv, | |||
| 967 | * last time) the packet had an updated information or not | 969 | * last time) the packet had an updated information or not |
| 968 | */ | 970 | */ |
| 969 | curr_ttvn = (uint8_t)atomic_read(&bat_priv->tt.vn); | 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 | orig_node = batadv_orig_hash_find(bat_priv, | 973 | orig_node = batadv_orig_hash_find(bat_priv, |
| 972 | unicast_packet->dest); | 974 | unicast_packet->dest); |
| 973 | /* if it is not possible to find the orig_node representing the | 975 | /* if it is not possible to find the orig_node representing the |
| @@ -1044,14 +1046,14 @@ int batadv_recv_unicast_packet(struct sk_buff *skb, | |||
| 1044 | if (is4addr) | 1046 | if (is4addr) |
| 1045 | hdr_size = sizeof(*unicast_4addr_packet); | 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 | return NET_RX_DROP; | 1050 | return NET_RX_DROP; |
| 1049 | 1051 | ||
| 1050 | if (!batadv_check_unicast_ttvn(bat_priv, skb)) | 1052 | if (!batadv_check_unicast_ttvn(bat_priv, skb)) |
| 1051 | return NET_RX_DROP; | 1053 | return NET_RX_DROP; |
| 1052 | 1054 | ||
| 1053 | /* packet for me */ | 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 | if (is4addr) { | 1057 | if (is4addr) { |
| 1056 | batadv_dat_inc_counter(bat_priv, | 1058 | batadv_dat_inc_counter(bat_priv, |
| 1057 | unicast_4addr_packet->subtype); | 1059 | unicast_4addr_packet->subtype); |
| @@ -1088,7 +1090,7 @@ int batadv_recv_ucast_frag_packet(struct sk_buff *skb, | |||
| 1088 | struct sk_buff *new_skb = NULL; | 1090 | struct sk_buff *new_skb = NULL; |
| 1089 | int ret; | 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 | return NET_RX_DROP; | 1094 | return NET_RX_DROP; |
| 1093 | 1095 | ||
| 1094 | if (!batadv_check_unicast_ttvn(bat_priv, skb)) | 1096 | if (!batadv_check_unicast_ttvn(bat_priv, skb)) |
| @@ -1097,7 +1099,7 @@ int batadv_recv_ucast_frag_packet(struct sk_buff *skb, | |||
| 1097 | unicast_packet = (struct batadv_unicast_frag_packet *)skb->data; | 1099 | unicast_packet = (struct batadv_unicast_frag_packet *)skb->data; |
| 1098 | 1100 | ||
| 1099 | /* packet for me */ | 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 | ret = batadv_frag_reassemble_skb(skb, bat_priv, &new_skb); | 1103 | ret = batadv_frag_reassemble_skb(skb, bat_priv, &new_skb); |
| 1102 | 1104 | ||
| 1103 | if (ret == NET_RX_DROP) | 1105 | if (ret == NET_RX_DROP) |
| @@ -1151,13 +1153,13 @@ int batadv_recv_bcast_packet(struct sk_buff *skb, | |||
| 1151 | goto out; | 1153 | goto out; |
| 1152 | 1154 | ||
| 1153 | /* ignore broadcasts sent by myself */ | 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 | goto out; | 1157 | goto out; |
| 1156 | 1158 | ||
| 1157 | bcast_packet = (struct batadv_bcast_packet *)skb->data; | 1159 | bcast_packet = (struct batadv_bcast_packet *)skb->data; |
| 1158 | 1160 | ||
| 1159 | /* ignore broadcasts originated by myself */ | 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 | goto out; | 1163 | goto out; |
| 1162 | 1164 | ||
| 1163 | if (bcast_packet->header.ttl < 2) | 1165 | if (bcast_packet->header.ttl < 2) |
| @@ -1243,14 +1245,14 @@ int batadv_recv_vis_packet(struct sk_buff *skb, | |||
| 1243 | ethhdr = (struct ethhdr *)skb_mac_header(skb); | 1245 | ethhdr = (struct ethhdr *)skb_mac_header(skb); |
| 1244 | 1246 | ||
| 1245 | /* not for me */ | 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 | return NET_RX_DROP; | 1249 | return NET_RX_DROP; |
| 1248 | 1250 | ||
| 1249 | /* ignore own packets */ | 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 | return NET_RX_DROP; | 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 | return NET_RX_DROP; | 1256 | return NET_RX_DROP; |
| 1255 | 1257 | ||
| 1256 | switch (vis_packet->vis_type) { | 1258 | switch (vis_packet->vis_type) { |
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 98a66a021a60..7abee19567e9 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c | |||
| @@ -1953,7 +1953,7 @@ out: | |||
| 1953 | bool batadv_send_tt_response(struct batadv_priv *bat_priv, | 1953 | bool batadv_send_tt_response(struct batadv_priv *bat_priv, |
| 1954 | struct batadv_tt_query_packet *tt_request) | 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 | /* don't answer backbone gws! */ | 1957 | /* don't answer backbone gws! */ |
| 1958 | if (batadv_bla_is_backbone_gw_orig(bat_priv, tt_request->src)) | 1958 | if (batadv_bla_is_backbone_gw_orig(bat_priv, tt_request->src)) |
| 1959 | return true; | 1959 | return true; |
diff --git a/net/batman-adv/vis.c b/net/batman-adv/vis.c index c053244b97bd..6a1e646be96d 100644 --- a/net/batman-adv/vis.c +++ b/net/batman-adv/vis.c | |||
| @@ -477,7 +477,7 @@ void batadv_receive_client_update_packet(struct batadv_priv *bat_priv, | |||
| 477 | 477 | ||
| 478 | /* Are we the target for this VIS packet? */ | 478 | /* Are we the target for this VIS packet? */ |
| 479 | if (vis_server == BATADV_VIS_TYPE_SERVER_SYNC && | 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 | are_target = 1; | 481 | are_target = 1; |
| 482 | 482 | ||
| 483 | spin_lock_bh(&bat_priv->vis.hash_lock); | 483 | spin_lock_bh(&bat_priv->vis.hash_lock); |
| @@ -496,7 +496,7 @@ void batadv_receive_client_update_packet(struct batadv_priv *bat_priv, | |||
| 496 | batadv_send_list_add(bat_priv, info); | 496 | batadv_send_list_add(bat_priv, info); |
| 497 | 497 | ||
| 498 | /* ... we're not the recipient (and thus need to forward). */ | 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 | batadv_send_list_add(bat_priv, info); | 500 | batadv_send_list_add(bat_priv, info); |
| 501 | } | 501 | } |
| 502 | 502 | ||
