Hello people,
this is the last patchset of the TT-VLAN series and requires the last one to be applied (per-VLAN TT CRC).
In a few words... These changes enable BLA2 to filter only those TT entries belonging to the VLAN where BLA discovered other backbone nodes. The current code instead assumes that _all_ the local clients are shared among the backbones, despite of the VLAN used to interconnect them.
Example. Imagine 2 nodes having several vlans over the wired connection. Node1 having eth0.1 and eth0.2 Node2 having eth0.1 and eth0.3
Node1 and Node2 are connected using a cable and so they hear each other on eth0.1. Clients connected to eth0.2 and eth0.3 are reachable only through the respective nodes therefore, if Node1 wanted to talk to a client connected to eth0.3 needs to know that it is served by Node2.
In the current implementation this is not possible because BLA would consider all the clients reachable through any node of the LAN and will reject all the global TT entries from any other backbone, so losing this TT information.
With this patchset, instead, BLA will detect that the backbone connection is only over eth0.1 and so will continue to store all the global clients belonging to the other VLANs.
I hope the example did not create more confusion :)
Cheers,
Antonio Quartulli (2): batman-adv: make the TT global purge routine VLAN specific batman-adv: make the backbone gw check VLAN specific
bridge_loop_avoidance.c | 23 +++++++++++--------- bridge_loop_avoidance.h | 10 +++++---- originator.c | 2 +- routing.c | 2 +- translation-table.c | 58 ++++++++++++++++++++++--------------------------- translation-table.h | 2 +- 6 files changed, 48 insertions(+), 49 deletions(-)
From: Antonio Quartulli antonio@open-mesh.com
Instead of unconditionally remove all the TT entries served by a given originator, make tt_global_orig_del() remove only entries matching a given VLAN identifier provided as argument.
If such argument is negative then all the global entries served by the originator are removed.
This change is used into the BLA code to purge entries served by a newly discovered Backbone node, but limiting the operation only to those connected to the VLAN where the backbone has been discovered.
Cc: Simon Wunderlich siwu@hrz.tu-chemnitz.de Signed-off-by: Antonio Quartulli antonio@open-mesh.com --- bridge_loop_avoidance.c | 4 ++-- originator.c | 2 +- routing.c | 2 +- translation-table.c | 17 ++++++++++++++++- translation-table.h | 2 +- 5 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index 46b74ef..54fa887 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -411,10 +411,10 @@ batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, uint8_t *orig, return NULL; }
- /* this is a gateway now, remove any tt entries */ + /* this is a gateway now, remove any TT entry on this VLAN */ orig_node = batadv_orig_hash_find(bat_priv, orig); if (orig_node) { - batadv_tt_global_del_orig(bat_priv, orig_node, + batadv_tt_global_del_orig(bat_priv, orig_node, vid, "became a backbone gateway"); batadv_orig_node_free_ref(orig_node); } diff --git a/originator.c b/originator.c index 7a499da..ee1d847 100644 --- a/originator.c +++ b/originator.c @@ -230,7 +230,7 @@ static void batadv_orig_node_free_rcu(struct rcu_head *rcu)
batadv_frag_purge_orig(orig_node, NULL);
- batadv_tt_global_del_orig(orig_node->bat_priv, orig_node, + batadv_tt_global_del_orig(orig_node->bat_priv, orig_node, -1, "originator timed out");
kfree(orig_node->tt_buff); diff --git a/routing.c b/routing.c index e63b05d..2b35205 100644 --- a/routing.c +++ b/routing.c @@ -47,7 +47,7 @@ static void _batadv_update_route(struct batadv_priv *bat_priv, if ((curr_router) && (!neigh_node)) { batadv_dbg(BATADV_DBG_ROUTES, bat_priv, "Deleting route towards: %pM\n", orig_node->orig); - batadv_tt_global_del_orig(bat_priv, orig_node, + batadv_tt_global_del_orig(bat_priv, orig_node, -1, "Deleted route towards originator");
/* route added */ diff --git a/translation-table.c b/translation-table.c index 982a3c5..37f34a8 100644 --- a/translation-table.c +++ b/translation-table.c @@ -1581,8 +1581,18 @@ out: batadv_tt_local_entry_free_ref(local_entry); }
+/** + * batadv_tt_global_del_orig - remove all the TT global entries belonging to the + * given originator matching the provided vid + * @bat_priv: the bat priv with all the soft interface information + * @orig_node: the originator owning the entries to remove + * @match_vid: the VLAN identifier to match. If negative all the entries will be + * removed + * @message: debug message to print as "reason" + */ void batadv_tt_global_del_orig(struct batadv_priv *bat_priv, struct batadv_orig_node *orig_node, + int32_t match_vid, const char *message) { struct batadv_tt_global_entry *tt_global; @@ -1604,6 +1614,10 @@ void batadv_tt_global_del_orig(struct batadv_priv *bat_priv, spin_lock_bh(list_lock); hlist_for_each_entry_safe(tt_common_entry, safe, head, hash_entry) { + /* remove only matching entries */ + if (match_vid >= 0 && tt_common_entry->vid != match_vid) + continue; + tt_global = container_of(tt_common_entry, struct batadv_tt_global_entry, common); @@ -2571,7 +2585,8 @@ static void batadv_tt_fill_gtable(struct batadv_priv *bat_priv, goto out;
/* Purge the old table first.. */ - batadv_tt_global_del_orig(bat_priv, orig_node, "Received full table"); + batadv_tt_global_del_orig(bat_priv, orig_node, -1, + "Received full table");
_batadv_tt_update_changes(bat_priv, orig_node, tt_change, num_entries, ttvn); diff --git a/translation-table.h b/translation-table.h index c6bf33c..dc6db4e 100644 --- a/translation-table.h +++ b/translation-table.h @@ -30,7 +30,7 @@ int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset); int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset); void batadv_tt_global_del_orig(struct batadv_priv *bat_priv, struct batadv_orig_node *orig_node, - const char *message); + int32_t match_vid, const char *message); struct batadv_orig_node *batadv_transtable_search(struct batadv_priv *bat_priv, const uint8_t *src, const uint8_t *addr,
From: Antonio Quartulli antonio@open-mesh.com
The backbone gw check has to be VLAN specific so that code using it can specify VID where the check has to be done.
In the TT code, the check has been moved into the tt_global_add() function so that it can be performed on a per-entry basis instead of ignoring all the TT data received from another backbone node. Only TT global entries belonging to the VLAN where the backbone node is connected to are skipped. All the other spots where the TT code was checking whether a node is a backbone have been removed.
Moreover, batadv_bla_is_backbone_gw_orig() now returns bool since it used to return only 1 or 0.
Cc: Simon Wunderlich siwu@hrz.tu-chemnitz.de Signed-off-by: Antonio Quartulli antonio@open-mesh.com --- bridge_loop_avoidance.c | 19 +++++++++++-------- bridge_loop_avoidance.h | 10 ++++++---- translation-table.c | 41 ++++++++++------------------------------- 3 files changed, 27 insertions(+), 43 deletions(-)
diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index 54fa887..ecf1992 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -1315,12 +1315,14 @@ out:
/* @bat_priv: the bat priv with all the soft interface information * @orig: originator mac address + * @vid: VLAN identifier * - * check if the originator is a gateway for any VLAN ID. + * check if the originator is a gateway for the VLAN identified by vid. * - * returns 1 if it is found, 0 otherwise + * returns true if orig is a backbone for this vid, false otherwise */ -int batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, uint8_t *orig) +bool batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, uint8_t *orig, + unsigned short vid) { struct batadv_hashtable *hash = bat_priv->bla.backbone_hash; struct hlist_head *head; @@ -1328,25 +1330,26 @@ int batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, uint8_t *orig) int i;
if (!atomic_read(&bat_priv->bridge_loop_avoidance)) - return 0; + return false;
if (!hash) - return 0; + return false;
for (i = 0; i < hash->size; i++) { head = &hash->table[i];
rcu_read_lock(); hlist_for_each_entry_rcu(backbone_gw, head, hash_entry) { - if (batadv_compare_eth(backbone_gw->orig, orig)) { + if (batadv_compare_eth(backbone_gw->orig, orig) && + backbone_gw->vid == vid) { rcu_read_unlock(); - return 1; + return true; } } rcu_read_unlock(); }
- return 0; + return false; }
diff --git a/bridge_loop_avoidance.h b/bridge_loop_avoidance.h index 4b102e7..da173e7 100644 --- a/bridge_loop_avoidance.h +++ b/bridge_loop_avoidance.h @@ -30,7 +30,8 @@ int batadv_bla_is_backbone_gw(struct sk_buff *skb, int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset); int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, void *offset); -int batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, uint8_t *orig); +bool batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, uint8_t *orig, + unsigned short vid); int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, struct sk_buff *skb); void batadv_bla_update_orig_address(struct batadv_priv *bat_priv, @@ -74,10 +75,11 @@ static inline int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, return 0; }
-static inline int batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, - uint8_t *orig) +static inline bool batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, + uint8_t *orig, + unsigned short vid) { - return 0; + return false; }
static inline int diff --git a/translation-table.c b/translation-table.c index 37f34a8..b6f8a9a 100644 --- a/translation-table.c +++ b/translation-table.c @@ -1153,6 +1153,10 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv, struct batadv_tt_common_entry *common; uint16_t local_flags;
+ /* ignore global entries from backbone nodes */ + if (batadv_bla_is_backbone_gw_orig(bat_priv, orig_node->orig, vid)) + return true; + tt_global_entry = batadv_tt_global_hash_find(bat_priv, tt_addr, vid); tt_local_entry = batadv_tt_local_hash_find(bat_priv, tt_addr, vid);
@@ -2136,7 +2140,8 @@ static bool batadv_tt_global_check_crc(struct batadv_orig_node *orig_node, * the CRC as we ignore all the global entries over it */ if (batadv_bla_is_backbone_gw_orig(orig_node->bat_priv, - orig_node->orig)) + orig_node->orig, + ntohs(tt_vlan_tmp->vid))) continue;
vlan = batadv_orig_node_vlan_get(orig_node, @@ -2184,7 +2189,8 @@ static void batadv_tt_global_update_crc(struct batadv_priv *bat_priv, /* if orig_node is a backbone node for this VLAN, don't compute * the CRC as we ignore all the global entries over it */ - if (batadv_bla_is_backbone_gw_orig(bat_priv, orig_node->orig)) + if (batadv_bla_is_backbone_gw_orig(bat_priv, orig_node->orig, + vlan->vid)) continue;
crc = batadv_tt_global_crc(bat_priv, orig_node, vlan->vid); @@ -2528,16 +2534,11 @@ static bool batadv_send_tt_response(struct batadv_priv *bat_priv, struct batadv_tvlv_tt_data *tt_data, uint8_t *req_src, uint8_t *req_dst) { - if (batadv_is_my_mac(bat_priv, req_dst)) { - /* don't answer backbone gws! */ - if (batadv_bla_is_backbone_gw_orig(bat_priv, req_src)) - return true; - + if (batadv_is_my_mac(bat_priv, req_dst)) return batadv_send_my_tt_response(bat_priv, tt_data, req_src); - } else { + else return batadv_send_other_tt_response(bat_priv, tt_data, req_src, req_dst); - } }
static void _batadv_tt_update_changes(struct batadv_priv *bat_priv, @@ -2669,10 +2670,6 @@ static void batadv_handle_tt_response(struct batadv_priv *bat_priv, resp_src, tt_data->ttvn, num_entries, (tt_data->flags & BATADV_TT_FULL_TABLE ? 'F' : '.'));
- /* we should have never asked a backbone gw */ - if (batadv_bla_is_backbone_gw_orig(bat_priv, resp_src)) - goto out; - orig_node = batadv_orig_hash_find(bat_priv, resp_src); if (!orig_node) goto out; @@ -3053,10 +3050,6 @@ static void batadv_tt_update_orig(struct batadv_priv *bat_priv, struct batadv_tvlv_tt_vlan_data *tt_vlan; bool full_table = true;
- /* don't care about a backbone gateways updates. */ - if (batadv_bla_is_backbone_gw_orig(bat_priv, orig_node->orig)) - return; - tt_vlan = (struct batadv_tvlv_tt_vlan_data *)tt_buff; /* orig table not initialised AND first diff is in the OGM OR the ttvn * increased by one -> we can apply the attached changes @@ -3178,13 +3171,6 @@ bool batadv_tt_add_temporary_global_entry(struct batadv_priv *bat_priv, { bool ret = false;
- /* if the originator is a backbone node (meaning it belongs to the same - * LAN of this node) the temporary client must not be added because to - * reach such destination the node must use the LAN instead of the mesh - */ - if (batadv_bla_is_backbone_gw_orig(bat_priv, orig_node->orig)) - goto out; - if (!batadv_tt_global_add(bat_priv, orig_node, addr, vid, BATADV_TT_CLIENT_TEMP, atomic_read(&orig_node->last_ttvn))) @@ -3345,13 +3331,6 @@ static int batadv_roam_tvlv_unicast_handler_v1(struct batadv_priv *bat_priv, if (!batadv_is_my_mac(bat_priv, dst)) return NET_RX_DROP;
- /* check if it is a backbone gateway. we don't accept - * roaming advertisement from it, as it has the same - * entries as we have. - */ - if (batadv_bla_is_backbone_gw_orig(bat_priv, src)) - goto out; - if (tvlv_value_len < sizeof(*roaming_adv)) goto out;
b.a.t.m.a.n@lists.open-mesh.org