[PATCH net-next 09/15] batman-adv: tt: extract removal of the superseded local entry
flat view
COLD36d
From: Simon Wunderlich <sw@simonwunderlich.de>
Date: 2026-09-07 08:18:39
Also in:
batman
Subsystem:
batman advanced, the rest · Maintainers:
Marek Lindner, Simon Wunderlich, Antonio Quartulli, Sven Eckelmann, Linus Torvalds
From: Sven Eckelmann <sven@narfation.org> A client which was announced by another originator is no longer a local client. The code which drops it from the local table and takes over its WIFI flag is the second cleanup stage of batadv_tt_global_add() and needed its own goto to skip over the multicast case. Move it to batadv_tt_global_purge_local(). Signed-off-by: Sven Eckelmann <sven@narfation.org> Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de> --- net/batman-adv/translation-table.c | 61 ++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 20 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 760acc7be973e..b3e45fb5e9dd4 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c@@ -1832,6 +1832,46 @@ batadv_tt_global_orig_entry_add(struct batadv_tt_global_entry *tt_global, spin_unlock_bh(&tt_global->list_lock); } +/** + * batadv_tt_global_purge_local() - drop the local entry of an announced client + * @bat_priv: the bat priv with all the mesh interface information + * @tt_global_entry: the global TT entry of the announced client + * @flags: TT flags announced for this non-mesh client + * + * A client which is announced by another originator is no longer a local + * client. Remove it from the local table and take over the WIFI flag it was + * tracked with. + */ +static void +batadv_tt_global_purge_local(struct batadv_priv *bat_priv, + struct batadv_tt_global_entry *tt_global_entry, + u16 flags) +{ + struct batadv_tt_common_entry *common = &tt_global_entry->common; + u16 local_flags; + + /* Do not remove multicast addresses from the local hash on + * global additions + */ + if (is_multicast_ether_addr(common->addr)) + return; + + /* remove address from local hash if present */ + local_flags = batadv_tt_local_remove(bat_priv, common->addr, common->vid, + "global tt received", + flags & BATADV_TT_CLIENT_ROAM); + + scoped_guard(spinlock_bh, &common->flags_lock) { + common->flags |= local_flags & BATADV_TT_CLIENT_WIFI; + + if (!(flags & BATADV_TT_CLIENT_ROAM)) + /* this is a normal global add. Therefore the client is + * not in a roaming state anymore. + */ + common->flags &= ~BATADV_TT_CLIENT_ROAM; + } +} + /** * batadv_tt_global_merge_flags() - merge announced flags into a global TT entry * @tt_global_entry: the global TT entry to update
@@ -2042,26 +2082,7 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv, ret = true; out_remove: - /* Do not remove multicast addresses from the local hash on - * global additions - */ - if (is_multicast_ether_addr(tt_addr)) - goto out; - - /* remove address from local hash if present */ - local_flags = batadv_tt_local_remove(bat_priv, tt_addr, vid, - "global tt received", - flags & BATADV_TT_CLIENT_ROAM); - - spin_lock_bh(&tt_global_entry->common.flags_lock); - tt_global_entry->common.flags |= local_flags & BATADV_TT_CLIENT_WIFI; - - if (!(flags & BATADV_TT_CLIENT_ROAM)) - /* this is a normal global add. Therefore the client is not in a - * roaming state anymore. - */ - tt_global_entry->common.flags &= ~BATADV_TT_CLIENT_ROAM; - spin_unlock_bh(&tt_global_entry->common.flags_lock); + batadv_tt_global_purge_local(bat_priv, tt_global_entry, flags); out: batadv_tt_global_entry_put(tt_global_entry);
--
2.47.3