diff options
author | Simon Wunderlich <simon.wunderlich@s2003.tu-chemnitz.de> | 2012-01-22 14:00:23 -0500 |
---|---|---|
committer | Antonio Quartulli <ordex@autistici.org> | 2012-04-11 08:28:59 -0400 |
commit | 20ff9d593f8ff20c2ef24498f77a8bc30b3a059a (patch) | |
tree | e64f51254b230d9d6441e09a2c81fbcb68dcf2d6 /net | |
parent | db08e6e557ebc8ffedf6530693937d0e51b8f6b9 (diff) |
batman-adv: don't let backbone gateways exchange tt entries
As the backbone gateways are connected to the same backbone, they
should announce the same clients on the backbone non-exclusively.
Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/batman-adv/bridge_loop_avoidance.c | 50 | ||||
-rw-r--r-- | net/batman-adv/bridge_loop_avoidance.h | 1 | ||||
-rw-r--r-- | net/batman-adv/routing.c | 7 | ||||
-rw-r--r-- | net/batman-adv/translation-table.c | 18 |
4 files changed, 74 insertions, 2 deletions
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c index 56b9b4924763..6186f6e92e33 100644 --- a/net/batman-adv/bridge_loop_avoidance.c +++ b/net/batman-adv/bridge_loop_avoidance.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include "hard-interface.h" | 24 | #include "hard-interface.h" |
25 | #include "originator.h" | 25 | #include "originator.h" |
26 | #include "bridge_loop_avoidance.h" | 26 | #include "bridge_loop_avoidance.h" |
27 | #include "translation-table.h" | ||
27 | #include "send.h" | 28 | #include "send.h" |
28 | 29 | ||
29 | #include <linux/etherdevice.h> | 30 | #include <linux/etherdevice.h> |
@@ -359,6 +360,7 @@ static struct backbone_gw *bla_get_backbone_gw(struct bat_priv *bat_priv, | |||
359 | uint8_t *orig, short vid) | 360 | uint8_t *orig, short vid) |
360 | { | 361 | { |
361 | struct backbone_gw *entry; | 362 | struct backbone_gw *entry; |
363 | struct orig_node *orig_node; | ||
362 | int hash_added; | 364 | int hash_added; |
363 | 365 | ||
364 | entry = backbone_hash_find(bat_priv, orig, vid); | 366 | entry = backbone_hash_find(bat_priv, orig, vid); |
@@ -393,6 +395,13 @@ static struct backbone_gw *bla_get_backbone_gw(struct bat_priv *bat_priv, | |||
393 | return NULL; | 395 | return NULL; |
394 | } | 396 | } |
395 | 397 | ||
398 | /* this is a gateway now, remove any tt entries */ | ||
399 | orig_node = orig_hash_find(bat_priv, orig); | ||
400 | if (orig_node) { | ||
401 | tt_global_del_orig(bat_priv, orig_node, | ||
402 | "became a backbone gateway"); | ||
403 | orig_node_free_ref(orig_node); | ||
404 | } | ||
396 | return entry; | 405 | return entry; |
397 | } | 406 | } |
398 | 407 | ||
@@ -1050,6 +1059,47 @@ int bla_init(struct bat_priv *bat_priv) | |||
1050 | } | 1059 | } |
1051 | 1060 | ||
1052 | /** | 1061 | /** |
1062 | * @bat_priv: the bat priv with all the soft interface information | ||
1063 | * @orig: originator mac address | ||
1064 | * | ||
1065 | * check if the originator is a gateway for any VLAN ID. | ||
1066 | * | ||
1067 | * returns 1 if it is found, 0 otherwise | ||
1068 | * | ||
1069 | */ | ||
1070 | |||
1071 | int bla_is_backbone_gw_orig(struct bat_priv *bat_priv, uint8_t *orig) | ||
1072 | { | ||
1073 | struct hashtable_t *hash = bat_priv->backbone_hash; | ||
1074 | struct hlist_head *head; | ||
1075 | struct hlist_node *node; | ||
1076 | struct backbone_gw *backbone_gw; | ||
1077 | int i; | ||
1078 | |||
1079 | if (!atomic_read(&bat_priv->bridge_loop_avoidance)) | ||
1080 | return 0; | ||
1081 | |||
1082 | if (!hash) | ||
1083 | return 0; | ||
1084 | |||
1085 | for (i = 0; i < hash->size; i++) { | ||
1086 | head = &hash->table[i]; | ||
1087 | |||
1088 | rcu_read_lock(); | ||
1089 | hlist_for_each_entry_rcu(backbone_gw, node, head, hash_entry) { | ||
1090 | if (compare_eth(backbone_gw->orig, orig)) { | ||
1091 | rcu_read_unlock(); | ||
1092 | return 1; | ||
1093 | } | ||
1094 | } | ||
1095 | rcu_read_unlock(); | ||
1096 | } | ||
1097 | |||
1098 | return 0; | ||
1099 | } | ||
1100 | |||
1101 | |||
1102 | /** | ||
1053 | * @skb: the frame to be checked | 1103 | * @skb: the frame to be checked |
1054 | * @orig_node: the orig_node of the frame | 1104 | * @orig_node: the orig_node of the frame |
1055 | * @hdr_size: maximum length of the frame | 1105 | * @hdr_size: maximum length of the frame |
diff --git a/net/batman-adv/bridge_loop_avoidance.h b/net/batman-adv/bridge_loop_avoidance.h index d9e34803a465..b74940f09baf 100644 --- a/net/batman-adv/bridge_loop_avoidance.h +++ b/net/batman-adv/bridge_loop_avoidance.h | |||
@@ -27,6 +27,7 @@ int bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid); | |||
27 | int bla_is_backbone_gw(struct sk_buff *skb, | 27 | int bla_is_backbone_gw(struct sk_buff *skb, |
28 | struct orig_node *orig_node, int hdr_size); | 28 | struct orig_node *orig_node, int hdr_size); |
29 | int bla_claim_table_seq_print_text(struct seq_file *seq, void *offset); | 29 | int bla_claim_table_seq_print_text(struct seq_file *seq, void *offset); |
30 | int bla_is_backbone_gw_orig(struct bat_priv *bat_priv, uint8_t *orig); | ||
30 | void bla_update_orig_address(struct bat_priv *bat_priv, | 31 | void bla_update_orig_address(struct bat_priv *bat_priv, |
31 | struct hard_iface *primary_if, | 32 | struct hard_iface *primary_if, |
32 | struct hard_iface *oldif); | 33 | struct hard_iface *oldif); |
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index a1d8c9b0f902..1d1fd04c9c3a 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c | |||
@@ -673,6 +673,13 @@ int recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if) | |||
673 | if (!is_my_mac(roam_adv_packet->dst)) | 673 | if (!is_my_mac(roam_adv_packet->dst)) |
674 | return route_unicast_packet(skb, recv_if); | 674 | return route_unicast_packet(skb, recv_if); |
675 | 675 | ||
676 | /* check if it is a backbone gateway. we don't accept | ||
677 | * roaming advertisement from it, as it has the same | ||
678 | * entries as we have. | ||
679 | */ | ||
680 | if (bla_is_backbone_gw_orig(bat_priv, roam_adv_packet->src)) | ||
681 | goto out; | ||
682 | |||
676 | orig_node = orig_hash_find(bat_priv, roam_adv_packet->src); | 683 | orig_node = orig_hash_find(bat_priv, roam_adv_packet->src); |
677 | if (!orig_node) | 684 | if (!orig_node) |
678 | goto out; | 685 | goto out; |
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 9648b0dc57ef..e16a3690bdb2 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include "hash.h" | 27 | #include "hash.h" |
28 | #include "originator.h" | 28 | #include "originator.h" |
29 | #include "routing.h" | 29 | #include "routing.h" |
30 | #include "bridge_loop_avoidance.h" | ||
30 | 31 | ||
31 | #include <linux/crc16.h> | 32 | #include <linux/crc16.h> |
32 | 33 | ||
@@ -1615,10 +1616,15 @@ out: | |||
1615 | bool send_tt_response(struct bat_priv *bat_priv, | 1616 | bool send_tt_response(struct bat_priv *bat_priv, |
1616 | struct tt_query_packet *tt_request) | 1617 | struct tt_query_packet *tt_request) |
1617 | { | 1618 | { |
1618 | if (is_my_mac(tt_request->dst)) | 1619 | if (is_my_mac(tt_request->dst)) { |
1620 | /* don't answer backbone gws! */ | ||
1621 | if (bla_is_backbone_gw_orig(bat_priv, tt_request->src)) | ||
1622 | return true; | ||
1623 | |||
1619 | return send_my_tt_response(bat_priv, tt_request); | 1624 | return send_my_tt_response(bat_priv, tt_request); |
1620 | else | 1625 | } else { |
1621 | return send_other_tt_response(bat_priv, tt_request); | 1626 | return send_other_tt_response(bat_priv, tt_request); |
1627 | } | ||
1622 | } | 1628 | } |
1623 | 1629 | ||
1624 | static void _tt_update_changes(struct bat_priv *bat_priv, | 1630 | static void _tt_update_changes(struct bat_priv *bat_priv, |
@@ -1722,6 +1728,10 @@ void handle_tt_response(struct bat_priv *bat_priv, | |||
1722 | tt_response->src, tt_response->ttvn, tt_response->tt_data, | 1728 | tt_response->src, tt_response->ttvn, tt_response->tt_data, |
1723 | (tt_response->flags & TT_FULL_TABLE ? 'F' : '.')); | 1729 | (tt_response->flags & TT_FULL_TABLE ? 'F' : '.')); |
1724 | 1730 | ||
1731 | /* we should have never asked a backbone gw */ | ||
1732 | if (bla_is_backbone_gw_orig(bat_priv, tt_response->src)) | ||
1733 | goto out; | ||
1734 | |||
1725 | orig_node = orig_hash_find(bat_priv, tt_response->src); | 1735 | orig_node = orig_hash_find(bat_priv, tt_response->src); |
1726 | if (!orig_node) | 1736 | if (!orig_node) |
1727 | goto out; | 1737 | goto out; |
@@ -2052,6 +2062,10 @@ void tt_update_orig(struct bat_priv *bat_priv, struct orig_node *orig_node, | |||
2052 | uint8_t orig_ttvn = (uint8_t)atomic_read(&orig_node->last_ttvn); | 2062 | uint8_t orig_ttvn = (uint8_t)atomic_read(&orig_node->last_ttvn); |
2053 | bool full_table = true; | 2063 | bool full_table = true; |
2054 | 2064 | ||
2065 | /* don't care about a backbone gateways updates. */ | ||
2066 | if (bla_is_backbone_gw_orig(bat_priv, orig_node->orig)) | ||
2067 | return; | ||
2068 | |||
2055 | /* orig table not initialised AND first diff is in the OGM OR the ttvn | 2069 | /* orig table not initialised AND first diff is in the OGM OR the ttvn |
2056 | * increased by one -> we can apply the attached changes */ | 2070 | * increased by one -> we can apply the attached changes */ |
2057 | if ((!orig_node->tt_initialised && ttvn == 1) || | 2071 | if ((!orig_node->tt_initialised && ttvn == 1) || |