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 | 19 ++++++++++++++++++- translation-table.h | 2 +- 5 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index 72df179..4418534 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 a591dc5..e910fc6 100644 --- a/originator.c +++ b/originator.c @@ -148,7 +148,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 4ced045..8c11644 100644 --- a/translation-table.c +++ b/translation-table.c @@ -1169,6 +1169,7 @@ batadv_tt_global_del_orig_list(struct batadv_tt_global_entry *tt_global_entry) head = &tt_global_entry->orig_list; hlist_for_each_entry_safe(orig_entry, safe, head, list) { hlist_del_rcu(&orig_entry->list); + atomic_dec(&orig_entry->orig_node->tt_size); batadv_tt_orig_list_entry_free_ref(orig_entry); } spin_unlock_bh(&tt_global_entry->list_lock); @@ -1196,6 +1197,7 @@ batadv_tt_global_del_orig_entry(struct batadv_priv *bat_priv, tt_global_entry->common.addr, BATADV_PRINT_VID(vid), message); hlist_del_rcu(&orig_entry->list); + atomic_dec(&orig_entry->orig_node->tt_size); batadv_tt_orig_list_entry_free_ref(orig_entry); } } @@ -1308,8 +1310,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; @@ -1331,6 +1343,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); @@ -2168,7 +2184,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, (struct batadv_tvlv_tt_change *)(tt_data + 1), 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,