* [PATCH net-next 01/15] batman-adv: tt: look up wifi state of incoming interface in helper
2026-09-07 8:18 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-09-07 Simon Wunderlich
@ 2026-09-07 8:18 ` Simon Wunderlich
2026-09-11 1:10 ` patchwork-bot+netdevbpf
2026-09-07 8:18 ` [PATCH net-next 02/15] batman-adv: tt: extract allocation of new local entries Simon Wunderlich
` (13 subsequent siblings)
14 siblings, 1 reply; 21+ messages in thread
From: Simon Wunderlich @ 2026-09-07 8:18 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Sven Eckelmann, Simon Wunderlich
From: Sven Eckelmann <sven@narfation.org>
batadv_tt_local_add() only needs to know whether the client was seen on a
wifi interface. But it kept the net_device reference of the incoming
interface alive until its own cleanup section, together with a "net" and an
"in_dev" variable which are of no interest to the rest of the function.
Move the lookup to a small helper which acquires and releases the
net_device reference itself.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/translation-table.c | 41 +++++++++++++++++++++---------
1 file changed, 29 insertions(+), 12 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 44a8cf89382c6..1c22db348267e 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -41,6 +41,7 @@
#include <linux/string.h>
#include <linux/workqueue.h>
#include <net/genetlink.h>
+#include <net/net_namespace.h>
#include <net/netlink.h>
#include <uapi/linux/batadv_packet.h>
#include <uapi/linux/batman_adv.h>
@@ -693,6 +694,32 @@ static void batadv_tt_local_add_roam(struct batadv_priv *bat_priv,
batadv_tt_global_free(bat_priv, tt_global, "Roaming canceled");
}
+/**
+ * batadv_tt_iif_is_wifi() - check whether a client is connected via wifi
+ * @net: namespace to search the incoming interface in
+ * @ifindex: index of the interface where the client is connected to
+ *
+ * Return: true if @ifindex refers to a wifi interface, false otherwise (which
+ * includes the case of an unknown or missing incoming interface).
+ */
+static bool batadv_tt_iif_is_wifi(struct net *net, int ifindex)
+{
+ struct net_device *in_dev;
+ u32 wifi_flags;
+
+ if (ifindex == BATADV_NULL_IFINDEX)
+ return false;
+
+ in_dev = dev_get_by_index(net, ifindex);
+ if (!in_dev)
+ return false;
+
+ wifi_flags = batadv_netdev_get_wifi_flags(in_dev);
+ dev_put(in_dev);
+
+ return batadv_is_wifi(wifi_flags);
+}
+
/**
* batadv_tt_local_add() - add a new client to the local table or update an
* existing client
@@ -712,12 +739,10 @@ bool batadv_tt_local_add(struct net_device *mesh_iface, const u8 *addr,
struct batadv_priv *bat_priv = netdev_priv(mesh_iface);
struct batadv_tt_global_entry *tt_global = NULL;
struct batadv_tt_local_entry *tt_local;
- struct net *net = dev_net(mesh_iface);
- struct net_device *in_dev = NULL;
struct batadv_meshif_vlan *vlan;
bool roamed_back = false;
- bool iif_is_wifi = false;
int packet_size_max;
+ bool iif_is_wifi;
bool ret = false;
u8 remote_flags;
int hash_added;
@@ -725,14 +750,7 @@ bool batadv_tt_local_add(struct net_device *mesh_iface, const u8 *addr,
u32 match_mark;
bool modified;
- if (ifindex != BATADV_NULL_IFINDEX)
- in_dev = dev_get_by_index(net, ifindex);
-
- if (in_dev) {
- u32 wifi_flags = batadv_netdev_get_wifi_flags(in_dev);
-
- iif_is_wifi = batadv_is_wifi(wifi_flags);
- }
+ iif_is_wifi = batadv_tt_iif_is_wifi(dev_net(mesh_iface), ifindex);
tt_local = batadv_tt_local_hash_find(bat_priv, addr, vid);
@@ -881,7 +899,6 @@ bool batadv_tt_local_add(struct net_device *mesh_iface, const u8 *addr,
ret = true;
out:
- dev_put(in_dev);
batadv_tt_local_entry_put(tt_local);
batadv_tt_global_entry_put(tt_global);
return ret;
--
2.47.3
^ permalink raw reply related [flat|nested] 21+ messages in thread* Re: [PATCH net-next 01/15] batman-adv: tt: look up wifi state of incoming interface in helper
2026-09-07 8:18 ` [PATCH net-next 01/15] batman-adv: tt: look up wifi state of incoming interface in helper Simon Wunderlich
@ 2026-09-11 1:10 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 21+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-09-11 1:10 UTC (permalink / raw)
To: Simon Wunderlich
Cc: netdev, davem, edumazet, kuba, pabeni, horms, b.a.t.m.a.n, sven
Hello:
This series was applied to netdev/net-next.git (main)
by Sven Eckelmann <sven@narfation.org>:
On Mon, 7 Sep 2026 10:18:10 +0200 you wrote:
> From: Sven Eckelmann <sven@narfation.org>
>
> batadv_tt_local_add() only needs to know whether the client was seen on a
> wifi interface. But it kept the net_device reference of the incoming
> interface alive until its own cleanup section, together with a "net" and an
> "in_dev" variable which are of no interest to the rest of the function.
>
> [...]
Here is the summary with links:
- [net-next,01/15] batman-adv: tt: look up wifi state of incoming interface in helper
https://git.kernel.org/netdev/net-next/c/3273a5cd2d74
- [net-next,02/15] batman-adv: tt: extract allocation of new local entries
https://git.kernel.org/netdev/net-next/c/defa87f5ce75
- [net-next,03/15] batman-adv: tt: replace forward gotos in batadv_tt_local_add()
https://git.kernel.org/netdev/net-next/c/a5e5d2709d10
- [net-next,04/15] batman-adv: tt: extract refresh of existing local entries
https://git.kernel.org/netdev/net-next/c/ec6edeb755ec
- [net-next,05/15] batman-adv: tt: extract update of dynamic client flags
https://git.kernel.org/netdev/net-next/c/d72e16b1c5d5
- [net-next,06/15] batman-adv: tt: extract allocation of new global entries
https://git.kernel.org/netdev/net-next/c/d9017aeb40c1
- [net-next,07/15] batman-adv: tt: extract merging of flags into existing global entries
https://git.kernel.org/netdev/net-next/c/b535e61347ba
- [net-next,08/15] batman-adv: tt: replace add_orig_entry goto in batadv_tt_global_add()
https://git.kernel.org/netdev/net-next/c/3f8e8b42f639
- [net-next,09/15] batman-adv: tt: extract removal of the superseded local entry
https://git.kernel.org/netdev/net-next/c/228c70d51b10
- [net-next,10/15] batman-adv: tt: extract marking of a removed local entry
https://git.kernel.org/netdev/net-next/c/5e02403a4c2e
- [net-next,11/15] batman-adv: tt: extract immediate purge of a local entry
https://git.kernel.org/netdev/net-next/c/931de98d3960
- [net-next,12/15] batman-adv: tt: drop the cleanup label from batadv_tt_local_remove()
https://git.kernel.org/netdev/net-next/c/926013fd40f6
- [net-next,13/15] batman-adv: tt: clarify kernel doc for batadv_tt_local_set_pending_event()
https://git.kernel.org/netdev/net-next/c/857fbd765c65
- [net-next,14/15] batman-adv: bat_iv: fix ogm_neigh_is_sob parameters references
https://git.kernel.org/netdev/net-next/c/271f3730fc87
- [net-next,15/15] batman-adv: correct batadv_hash_remove kdoc return type
https://git.kernel.org/netdev/net-next/c/6d7f71ae4cdc
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH net-next 02/15] batman-adv: tt: extract allocation of new local entries
2026-09-07 8:18 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-09-07 Simon Wunderlich
2026-09-07 8:18 ` [PATCH net-next 01/15] batman-adv: tt: look up wifi state of incoming interface in helper Simon Wunderlich
@ 2026-09-07 8:18 ` Simon Wunderlich
2026-09-07 8:18 ` [PATCH net-next 03/15] batman-adv: tt: replace forward gotos in batadv_tt_local_add() Simon Wunderlich
` (12 subsequent siblings)
14 siblings, 0 replies; 21+ messages in thread
From: Simon Wunderlich @ 2026-09-07 8:18 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Sven Eckelmann, Simon Wunderlich
From: Sven Eckelmann <sven@narfation.org>
The code which allocates and initializes a brand new local TT entry makes
up more than a third of batadv_tt_local_add(). It only shares the addr, vid
and iif_is_wifi parameters with the rest of the function.
Move it to batadv_tt_local_create(), which returns the fully initialized
entry. The error paths become plain returns.
The insertion into bat_priv->tt.local_hash intentionally stays in
batadv_tt_local_add(), keeping the extra reference for the hash next to the
error handling which has to drop it again.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/translation-table.c | 135 +++++++++++++++++------------
1 file changed, 79 insertions(+), 56 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 1c22db348267e..2bc243f0fa699 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -720,6 +720,84 @@ static bool batadv_tt_iif_is_wifi(struct net *net, int ifindex)
return batadv_is_wifi(wifi_flags);
}
+/**
+ * batadv_tt_local_create() - allocate and initialize a local TT entry
+ * @mesh_iface: netdev struct of the mesh interface
+ * @addr: the mac address of the client to add
+ * @vid: VLAN identifier
+ * @iif_is_wifi: whether the client is connected via a wifi interface
+ *
+ * The returned entry is not yet part of bat_priv->tt.local_hash. It is marked
+ * as BATADV_TT_CLIENT_NEW to avoid sending it in a full table response going
+ * out before the next ttvn increment (consistency check).
+ *
+ * Return: the new entry with an initialized reference counter on success, NULL
+ * otherwise.
+ */
+static struct batadv_tt_local_entry *
+batadv_tt_local_create(struct net_device *mesh_iface, const u8 *addr,
+ unsigned short vid, bool iif_is_wifi)
+{
+ struct batadv_priv *bat_priv = netdev_priv(mesh_iface);
+ struct batadv_tt_local_entry *tt_local;
+ struct batadv_meshif_vlan *vlan;
+ int packet_size_max;
+ int table_size;
+
+ /* Ignore the client if we cannot send it in a full table response. */
+ table_size = batadv_tt_local_table_transmit_size(bat_priv);
+ table_size += batadv_tt_len(1);
+ packet_size_max = READ_ONCE(bat_priv->packet_size_max);
+ if (table_size > packet_size_max) {
+ net_ratelimited_function(batadv_info, mesh_iface,
+ "Local translation table size (%i) exceeds maximum packet size (%i); Ignoring new local tt entry: %pM\n",
+ table_size, packet_size_max, addr);
+ return NULL;
+ }
+
+ tt_local = kmem_cache_alloc(batadv_tl_cache, GFP_ATOMIC);
+ if (!tt_local)
+ return NULL;
+
+ /* increase the refcounter of the related vlan */
+ vlan = batadv_meshif_vlan_get(bat_priv, vid);
+ if (!vlan) {
+ net_ratelimited_function(batadv_info, mesh_iface,
+ "adding TT local entry %pM to non-existent VLAN %d\n",
+ addr, batadv_print_vid(vid));
+ kmem_cache_free(batadv_tl_cache, tt_local);
+ return NULL;
+ }
+
+ batadv_dbg(BATADV_DBG_TT, bat_priv,
+ "Creating new local tt entry: %pM (vid: %d, ttvn: %d)\n",
+ addr, batadv_print_vid(vid),
+ (u8)atomic_read(&bat_priv->tt.vn));
+
+ ether_addr_copy(tt_local->common.addr, addr);
+ tt_local->common.vid = vid;
+ kref_init(&tt_local->common.refcount);
+ tt_local->last_seen = jiffies;
+ tt_local->common.added_at = tt_local->last_seen;
+ tt_local->vlan = vlan;
+ spin_lock_init(&tt_local->common.flags_lock);
+
+ scoped_guard(spinlock_bh, &tt_local->common.flags_lock) {
+ tt_local->common.flags = BATADV_TT_CLIENT_NEW;
+ if (iif_is_wifi)
+ tt_local->common.flags |= BATADV_TT_CLIENT_WIFI;
+
+ /* the batman interface mac and multicast addresses should never
+ * be purged
+ */
+ if (batadv_compare_eth(addr, mesh_iface->dev_addr) ||
+ is_multicast_ether_addr(addr))
+ tt_local->common.flags |= BATADV_TT_CLIENT_NOPURGE;
+ }
+
+ return tt_local;
+}
+
/**
* batadv_tt_local_add() - add a new client to the local table or update an
* existing client
@@ -739,14 +817,11 @@ bool batadv_tt_local_add(struct net_device *mesh_iface, const u8 *addr,
struct batadv_priv *bat_priv = netdev_priv(mesh_iface);
struct batadv_tt_global_entry *tt_global = NULL;
struct batadv_tt_local_entry *tt_local;
- struct batadv_meshif_vlan *vlan;
bool roamed_back = false;
- int packet_size_max;
bool iif_is_wifi;
bool ret = false;
u8 remote_flags;
int hash_added;
- int table_size;
u32 match_mark;
bool modified;
@@ -793,62 +868,10 @@ bool batadv_tt_local_add(struct net_device *mesh_iface, const u8 *addr,
goto check_roaming;
}
- /* Ignore the client if we cannot send it in a full table response. */
- table_size = batadv_tt_local_table_transmit_size(bat_priv);
- table_size += batadv_tt_len(1);
- packet_size_max = READ_ONCE(bat_priv->packet_size_max);
- if (table_size > packet_size_max) {
- net_ratelimited_function(batadv_info, mesh_iface,
- "Local translation table size (%i) exceeds maximum packet size (%i); Ignoring new local tt entry: %pM\n",
- table_size, packet_size_max, addr);
- goto out;
- }
-
- tt_local = kmem_cache_alloc(batadv_tl_cache, GFP_ATOMIC);
+ tt_local = batadv_tt_local_create(mesh_iface, addr, vid, iif_is_wifi);
if (!tt_local)
goto out;
- /* increase the refcounter of the related vlan */
- vlan = batadv_meshif_vlan_get(bat_priv, vid);
- if (!vlan) {
- net_ratelimited_function(batadv_info, mesh_iface,
- "adding TT local entry %pM to non-existent VLAN %d\n",
- addr, batadv_print_vid(vid));
- kmem_cache_free(batadv_tl_cache, tt_local);
- tt_local = NULL;
- goto out;
- }
-
- batadv_dbg(BATADV_DBG_TT, bat_priv,
- "Creating new local tt entry: %pM (vid: %d, ttvn: %d)\n",
- addr, batadv_print_vid(vid),
- (u8)atomic_read(&bat_priv->tt.vn));
-
- ether_addr_copy(tt_local->common.addr, addr);
- tt_local->common.vid = vid;
- kref_init(&tt_local->common.refcount);
- tt_local->last_seen = jiffies;
- tt_local->common.added_at = tt_local->last_seen;
- tt_local->vlan = vlan;
- spin_lock_init(&tt_local->common.flags_lock);
-
- spin_lock_bh(&tt_local->common.flags_lock);
- /* The local entry has to be marked as NEW to avoid to send it in
- * a full table response going out before the next ttvn increment
- * (consistency check)
- */
- tt_local->common.flags = BATADV_TT_CLIENT_NEW;
- if (iif_is_wifi)
- tt_local->common.flags |= BATADV_TT_CLIENT_WIFI;
-
- /* the batman interface mac and multicast addresses should never be
- * purged
- */
- if (batadv_compare_eth(addr, mesh_iface->dev_addr) ||
- is_multicast_ether_addr(addr))
- tt_local->common.flags |= BATADV_TT_CLIENT_NOPURGE;
- spin_unlock_bh(&tt_local->common.flags_lock);
-
kref_get(&tt_local->common.refcount);
hash_added = batadv_hash_add(bat_priv->tt.local_hash, batadv_compare_tt,
batadv_choose_tt, &tt_local->common,
--
2.47.3
^ permalink raw reply related [flat|nested] 21+ messages in thread* [PATCH net-next 03/15] batman-adv: tt: replace forward gotos in batadv_tt_local_add()
2026-09-07 8:18 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-09-07 Simon Wunderlich
2026-09-07 8:18 ` [PATCH net-next 01/15] batman-adv: tt: look up wifi state of incoming interface in helper Simon Wunderlich
2026-09-07 8:18 ` [PATCH net-next 02/15] batman-adv: tt: extract allocation of new local entries Simon Wunderlich
@ 2026-09-07 8:18 ` Simon Wunderlich
2026-09-07 8:18 ` [PATCH net-next 04/15] batman-adv: tt: extract refresh of existing local entries Simon Wunderlich
` (11 subsequent siblings)
14 siblings, 0 replies; 21+ messages in thread
From: Simon Wunderlich @ 2026-09-07 8:18 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Sven Eckelmann, Simon Wunderlich
From: Sven Eckelmann <sven@narfation.org>
batadv_tt_local_add() used two labels in the middle of the function to
express which parts of the common tail have to be executed: "add_event" to
announce a (re-)added client and "check_roaming" to skip that announcement.
Jumping forward into the middle of a function makes it hard to see which
path ends up sending an ADD event. Especially since the PENDING branch
reached "add_event" while the branch right below it reached "check_roaming"
instead.
Express the same in an "added" variable and turn the two client cases into
a plain if/else. The PENDING check returned early before the ROAM check
could run, so it becomes an "else if".
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/translation-table.c | 43 ++++++++++++++----------------
1 file changed, 20 insertions(+), 23 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 2bc243f0fa699..5d5f270b7eb4c 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -818,6 +818,7 @@ bool batadv_tt_local_add(struct net_device *mesh_iface, const u8 *addr,
struct batadv_tt_global_entry *tt_global = NULL;
struct batadv_tt_local_entry *tt_local;
bool roamed_back = false;
+ bool added = false;
bool iif_is_wifi;
bool ret = false;
u8 remote_flags;
@@ -846,12 +847,8 @@ bool batadv_tt_local_add(struct net_device *mesh_iface, const u8 *addr,
* flag can be reset like it was never enqueued
*/
tt_local->common.flags &= ~BATADV_TT_CLIENT_PENDING;
- spin_unlock_bh(&tt_local->common.flags_lock);
-
- goto add_event;
- }
-
- if (tt_local->common.flags & BATADV_TT_CLIENT_ROAM) {
+ added = true;
+ } else if (tt_local->common.flags & BATADV_TT_CLIENT_ROAM) {
batadv_dbg(BATADV_DBG_TT, bat_priv,
"Roaming client %pM (vid: %d) came back to its original location\n",
addr, batadv_print_vid(vid));
@@ -864,29 +861,29 @@ bool batadv_tt_local_add(struct net_device *mesh_iface, const u8 *addr,
roamed_back = true;
}
spin_unlock_bh(&tt_local->common.flags_lock);
+ } else {
+ tt_local = batadv_tt_local_create(mesh_iface, addr, vid, iif_is_wifi);
+ if (!tt_local)
+ goto out;
- goto check_roaming;
- }
-
- tt_local = batadv_tt_local_create(mesh_iface, addr, vid, iif_is_wifi);
- if (!tt_local)
- goto out;
+ kref_get(&tt_local->common.refcount);
+ hash_added = batadv_hash_add(bat_priv->tt.local_hash, batadv_compare_tt,
+ batadv_choose_tt, &tt_local->common,
+ &tt_local->common.hash_entry);
- kref_get(&tt_local->common.refcount);
- hash_added = batadv_hash_add(bat_priv->tt.local_hash, batadv_compare_tt,
- batadv_choose_tt, &tt_local->common,
- &tt_local->common.hash_entry);
+ if (unlikely(hash_added != 0)) {
+ /* remove the reference for the hash */
+ batadv_tt_local_entry_put(tt_local);
+ goto out;
+ }
- if (unlikely(hash_added != 0)) {
- /* remove the reference for the hash */
- batadv_tt_local_entry_put(tt_local);
- goto out;
+ added = true;
}
-add_event:
- batadv_tt_local_event(bat_priv, tt_local, BATADV_NO_FLAGS);
+ /* announce the (re-)added client to the mesh */
+ if (added)
+ batadv_tt_local_event(bat_priv, tt_local, BATADV_NO_FLAGS);
-check_roaming:
batadv_tt_local_add_roam(bat_priv, tt_global, roamed_back);
spin_lock_bh(&tt_local->common.flags_lock);
--
2.47.3
^ permalink raw reply related [flat|nested] 21+ messages in thread* [PATCH net-next 04/15] batman-adv: tt: extract refresh of existing local entries
2026-09-07 8:18 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-09-07 Simon Wunderlich
` (2 preceding siblings ...)
2026-09-07 8:18 ` [PATCH net-next 03/15] batman-adv: tt: replace forward gotos in batadv_tt_local_add() Simon Wunderlich
@ 2026-09-07 8:18 ` Simon Wunderlich
2026-09-07 8:18 ` [PATCH net-next 05/15] batman-adv: tt: extract update of dynamic client flags Simon Wunderlich
` (10 subsequent siblings)
14 siblings, 0 replies; 21+ messages in thread
From: Simon Wunderlich @ 2026-09-07 8:18 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Sven Eckelmann, Simon Wunderlich
From: Sven Eckelmann <sven@narfation.org>
The handling of a client which is already part of the local translation
table is independent from the rest of batadv_tt_local_add(): it only
refreshes last_seen and evaluates the PENDING and ROAM flags of the entry
which was just looked up.
Move it to batadv_tt_local_add_existing(). It reports via its return value
whether the client has to be announced to the mesh again and whether the
client roamed back to its original location.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/translation-table.c | 78 +++++++++++++++++++-----------
1 file changed, 51 insertions(+), 27 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 5d5f270b7eb4c..91e11e5f10140 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -720,6 +720,55 @@ static bool batadv_tt_iif_is_wifi(struct net *net, int ifindex)
return batadv_is_wifi(wifi_flags);
}
+/**
+ * batadv_tt_local_add_existing() - refresh an already known local TT entry
+ * @bat_priv: the bat priv with all the mesh interface information
+ * @tt_local: the local TT entry which was found in the local table
+ * @roamed_back: set to true when the client returned to its original location
+ *
+ * Return: true when the client has to be announced to the mesh again, false
+ * otherwise.
+ */
+static bool batadv_tt_local_add_existing(struct batadv_priv *bat_priv,
+ struct batadv_tt_local_entry *tt_local,
+ bool *roamed_back)
+{
+ struct batadv_tt_common_entry *common = &tt_local->common;
+
+ tt_local->last_seen = jiffies;
+
+ scoped_guard(spinlock_bh, &common->flags_lock) {
+ if (common->flags & BATADV_TT_CLIENT_PENDING) {
+ batadv_dbg(BATADV_DBG_TT, bat_priv,
+ "Re-adding pending client %pM (vid: %d)\n",
+ common->addr, batadv_print_vid(common->vid));
+ /* whatever the reason why the PENDING flag was set,
+ * this is a client which was enqueued to be removed in
+ * this orig_interval. Since it popped up again, the
+ * flag can be reset like it was never enqueued
+ */
+ common->flags &= ~BATADV_TT_CLIENT_PENDING;
+
+ return true;
+ }
+
+ if (common->flags & BATADV_TT_CLIENT_ROAM) {
+ batadv_dbg(BATADV_DBG_TT, bat_priv,
+ "Roaming client %pM (vid: %d) came back to its original location\n",
+ common->addr, batadv_print_vid(common->vid));
+ /* the ROAM flag is set because this client roamed away
+ * and the node got a roaming_advertisement message. Now
+ * that the client popped up again at its original
+ * location such flag can be unset
+ */
+ common->flags &= ~BATADV_TT_CLIENT_ROAM;
+ *roamed_back = true;
+ }
+ }
+
+ return false;
+}
+
/**
* batadv_tt_local_create() - allocate and initialize a local TT entry
* @mesh_iface: netdev struct of the mesh interface
@@ -834,33 +883,8 @@ bool batadv_tt_local_add(struct net_device *mesh_iface, const u8 *addr,
tt_global = batadv_tt_global_hash_find(bat_priv, addr, vid);
if (tt_local) {
- tt_local->last_seen = jiffies;
-
- spin_lock_bh(&tt_local->common.flags_lock);
- if (tt_local->common.flags & BATADV_TT_CLIENT_PENDING) {
- batadv_dbg(BATADV_DBG_TT, bat_priv,
- "Re-adding pending client %pM (vid: %d)\n",
- addr, batadv_print_vid(vid));
- /* whatever the reason why the PENDING flag was set,
- * this is a client which was enqueued to be removed in
- * this orig_interval. Since it popped up again, the
- * flag can be reset like it was never enqueued
- */
- tt_local->common.flags &= ~BATADV_TT_CLIENT_PENDING;
- added = true;
- } else if (tt_local->common.flags & BATADV_TT_CLIENT_ROAM) {
- batadv_dbg(BATADV_DBG_TT, bat_priv,
- "Roaming client %pM (vid: %d) came back to its original location\n",
- addr, batadv_print_vid(vid));
- /* the ROAM flag is set because this client roamed away
- * and the node got a roaming_advertisement message. Now
- * that the client popped up again at its original
- * location such flag can be unset
- */
- tt_local->common.flags &= ~BATADV_TT_CLIENT_ROAM;
- roamed_back = true;
- }
- spin_unlock_bh(&tt_local->common.flags_lock);
+ added = batadv_tt_local_add_existing(bat_priv, tt_local,
+ &roamed_back);
} else {
tt_local = batadv_tt_local_create(mesh_iface, addr, vid, iif_is_wifi);
if (!tt_local)
--
2.47.3
^ permalink raw reply related [flat|nested] 21+ messages in thread* [PATCH net-next 05/15] batman-adv: tt: extract update of dynamic client flags
2026-09-07 8:18 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-09-07 Simon Wunderlich
` (3 preceding siblings ...)
2026-09-07 8:18 ` [PATCH net-next 04/15] batman-adv: tt: extract refresh of existing local entries Simon Wunderlich
@ 2026-09-07 8:18 ` Simon Wunderlich
2026-09-07 8:18 ` [PATCH net-next 06/15] batman-adv: tt: extract allocation of new global entries Simon Wunderlich
` (9 subsequent siblings)
14 siblings, 0 replies; 21+ messages in thread
From: Simon Wunderlich @ 2026-09-07 8:18 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Sven Eckelmann, Simon Wunderlich
From: Sven Eckelmann <sven@narfation.org>
The WIFI and ISOLA flags are re-evaluated on every batadv_tt_local_add()
call, no matter whether a new entry was created or an existing one was
refreshed. It is mostly isolated from the rest of the
batadv_tt_local_add().
Move it to batadv_tt_local_update_flags(). To allow the caller to trigger
the queuing of ADD events, it returns whether one of the flags announced to
the other nodes actually changed.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/translation-table.c | 79 +++++++++++++++++++-----------
1 file changed, 50 insertions(+), 29 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 91e11e5f10140..e0bcef1eba935 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -847,6 +847,55 @@ batadv_tt_local_create(struct net_device *mesh_iface, const u8 *addr,
return tt_local;
}
+/**
+ * batadv_tt_local_update_flags() - update the dynamic flags of a local entry
+ * @bat_priv: the bat priv with all the mesh interface information
+ * @tt_local: the local TT entry to update
+ * @iif_is_wifi: whether the client is connected via a wifi interface
+ * @mark: the value contained in the skb->mark field of the received packet (if
+ * any)
+ *
+ * Return: true if a flag announced to the other nodes was modified, false
+ * otherwise.
+ */
+static bool
+batadv_tt_local_update_flags(struct batadv_priv *bat_priv,
+ struct batadv_tt_local_entry *tt_local,
+ bool iif_is_wifi, u32 mark)
+{
+ struct batadv_tt_common_entry *common = &tt_local->common;
+ u8 remote_flags;
+ u32 match_mark;
+ bool modified;
+
+ scoped_guard(spinlock_bh, &common->flags_lock) {
+ /* store the current remote flags before altering them. This
+ * helps understanding is flags are changing or not
+ */
+ remote_flags = common->flags & BATADV_TT_REMOTE_MASK;
+
+ if (iif_is_wifi)
+ common->flags |= BATADV_TT_CLIENT_WIFI;
+ else
+ common->flags &= ~BATADV_TT_CLIENT_WIFI;
+
+ /* check the mark in the skb: if it's equal to the configured
+ * isolation_mark, it means the packet is coming from an
+ * isolated non-mesh client
+ */
+ match_mark = (mark & bat_priv->isolation_mark_mask);
+ if (bat_priv->isolation_mark_mask &&
+ match_mark == bat_priv->isolation_mark)
+ common->flags |= BATADV_TT_CLIENT_ISOLA;
+ else
+ common->flags &= ~BATADV_TT_CLIENT_ISOLA;
+
+ modified = remote_flags ^ (common->flags & BATADV_TT_REMOTE_MASK);
+ }
+
+ return modified;
+}
+
/**
* batadv_tt_local_add() - add a new client to the local table or update an
* existing client
@@ -870,10 +919,7 @@ bool batadv_tt_local_add(struct net_device *mesh_iface, const u8 *addr,
bool added = false;
bool iif_is_wifi;
bool ret = false;
- u8 remote_flags;
int hash_added;
- u32 match_mark;
- bool modified;
iif_is_wifi = batadv_tt_iif_is_wifi(dev_net(mesh_iface), ifindex);
@@ -910,35 +956,10 @@ bool batadv_tt_local_add(struct net_device *mesh_iface, const u8 *addr,
batadv_tt_local_add_roam(bat_priv, tt_global, roamed_back);
- spin_lock_bh(&tt_local->common.flags_lock);
- /* store the current remote flags before altering them. This helps
- * understanding is flags are changing or not
- */
- remote_flags = tt_local->common.flags & BATADV_TT_REMOTE_MASK;
-
- if (iif_is_wifi)
- tt_local->common.flags |= BATADV_TT_CLIENT_WIFI;
- else
- tt_local->common.flags &= ~BATADV_TT_CLIENT_WIFI;
-
- /* check the mark in the skb: if it's equal to the configured
- * isolation_mark, it means the packet is coming from an isolated
- * non-mesh client
- */
- match_mark = (mark & bat_priv->isolation_mark_mask);
- if (bat_priv->isolation_mark_mask &&
- match_mark == bat_priv->isolation_mark)
- tt_local->common.flags |= BATADV_TT_CLIENT_ISOLA;
- else
- tt_local->common.flags &= ~BATADV_TT_CLIENT_ISOLA;
-
- modified = remote_flags ^ (tt_local->common.flags & BATADV_TT_REMOTE_MASK);
- spin_unlock_bh(&tt_local->common.flags_lock);
-
/* if any "dynamic" flag has been modified, resend an ADD event for this
* entry so that all the nodes can get the new flags
*/
- if (modified)
+ if (batadv_tt_local_update_flags(bat_priv, tt_local, iif_is_wifi, mark))
batadv_tt_local_event(bat_priv, tt_local, BATADV_NO_FLAGS);
ret = true;
--
2.47.3
^ permalink raw reply related [flat|nested] 21+ messages in thread* [PATCH net-next 06/15] batman-adv: tt: extract allocation of new global entries
2026-09-07 8:18 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-09-07 Simon Wunderlich
` (4 preceding siblings ...)
2026-09-07 8:18 ` [PATCH net-next 05/15] batman-adv: tt: extract update of dynamic client flags Simon Wunderlich
@ 2026-09-07 8:18 ` Simon Wunderlich
2026-09-07 8:18 ` [PATCH net-next 07/15] batman-adv: tt: extract merging of flags into existing " Simon Wunderlich
` (8 subsequent siblings)
14 siblings, 0 replies; 21+ messages in thread
From: Simon Wunderlich @ 2026-09-07 8:18 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Sven Eckelmann, Simon Wunderlich
From: Sven Eckelmann <sven@narfation.org>
The code which allocates and initializes a brand new global TT entry makes
up a third of batadv_tt_global_add() and only needs the tt_addr, vid and
flags arguments. It is also the only part of the "new entry" branch which
does not deal with the global hash.
Move it to batadv_tt_global_create() and let it return the initialized
entry.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/translation-table.c | 76 ++++++++++++++++++++----------
1 file changed, 51 insertions(+), 25 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index e0bcef1eba935..d475f8efd44d7 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -1832,6 +1832,56 @@ batadv_tt_global_orig_entry_add(struct batadv_tt_global_entry *tt_global,
spin_unlock_bh(&tt_global->list_lock);
}
+/**
+ * batadv_tt_global_create() - allocate and initialize a global TT entry
+ * @tt_addr: the mac address of the non-mesh client
+ * @vid: VLAN identifier
+ * @flags: TT flags that have to be set for this non-mesh client
+ *
+ * The returned entry is not yet part of bat_priv->tt.global_hash and has an
+ * empty originator list.
+ *
+ * Return: the new entry with an initialized reference counter on success, NULL
+ * otherwise.
+ */
+static struct batadv_tt_global_entry *
+batadv_tt_global_create(const unsigned char *tt_addr, unsigned short vid,
+ u16 flags)
+{
+ struct batadv_tt_global_entry *tt_global_entry;
+ struct batadv_tt_common_entry *common;
+
+ tt_global_entry = kmem_cache_zalloc(batadv_tg_cache, GFP_ATOMIC);
+ if (!tt_global_entry)
+ return NULL;
+
+ common = &tt_global_entry->common;
+ ether_addr_copy(common->addr, tt_addr);
+ common->vid = vid;
+ spin_lock_init(&common->flags_lock);
+
+ if (!is_multicast_ether_addr(common->addr)) {
+ scoped_guard(spinlock_bh, &common->flags_lock)
+ common->flags = flags & (~BATADV_TT_SYNC_MASK);
+ }
+
+ tt_global_entry->roam_at = 0;
+ /* node must store current time in case of roaming. This is
+ * needed to purge this entry out on timeout (if nobody claims
+ * it)
+ */
+ if (flags & BATADV_TT_CLIENT_ROAM)
+ tt_global_entry->roam_at = jiffies;
+ kref_init(&common->refcount);
+ common->added_at = jiffies;
+
+ INIT_HLIST_HEAD(&tt_global_entry->orig_list);
+ atomic_set(&tt_global_entry->orig_list_count, 0);
+ spin_lock_init(&tt_global_entry->list_lock);
+
+ return tt_global_entry;
+}
+
/**
* batadv_tt_global_add() - add a new TT global entry or update an existing one
* @bat_priv: the bat priv with all the mesh interface information
@@ -1883,35 +1933,11 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
}
if (!tt_global_entry) {
- tt_global_entry = kmem_cache_zalloc(batadv_tg_cache,
- GFP_ATOMIC);
+ tt_global_entry = batadv_tt_global_create(tt_addr, vid, flags);
if (!tt_global_entry)
goto out;
common = &tt_global_entry->common;
- ether_addr_copy(common->addr, tt_addr);
- common->vid = vid;
- spin_lock_init(&common->flags_lock);
-
- if (!is_multicast_ether_addr(common->addr)) {
- spin_lock_bh(&common->flags_lock);
- common->flags = flags & (~BATADV_TT_SYNC_MASK);
- spin_unlock_bh(&common->flags_lock);
- }
-
- tt_global_entry->roam_at = 0;
- /* node must store current time in case of roaming. This is
- * needed to purge this entry out on timeout (if nobody claims
- * it)
- */
- if (flags & BATADV_TT_CLIENT_ROAM)
- tt_global_entry->roam_at = jiffies;
- kref_init(&common->refcount);
- common->added_at = jiffies;
-
- INIT_HLIST_HEAD(&tt_global_entry->orig_list);
- atomic_set(&tt_global_entry->orig_list_count, 0);
- spin_lock_init(&tt_global_entry->list_lock);
kref_get(&common->refcount);
hash_added = batadv_hash_add(bat_priv->tt.global_hash,
--
2.47.3
^ permalink raw reply related [flat|nested] 21+ messages in thread* [PATCH net-next 07/15] batman-adv: tt: extract merging of flags into existing global entries
2026-09-07 8:18 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-09-07 Simon Wunderlich
` (5 preceding siblings ...)
2026-09-07 8:18 ` [PATCH net-next 06/15] batman-adv: tt: extract allocation of new global entries Simon Wunderlich
@ 2026-09-07 8:18 ` Simon Wunderlich
2026-09-07 8:18 ` [PATCH net-next 08/15] batman-adv: tt: replace add_orig_entry goto in batadv_tt_global_add() Simon Wunderlich
` (7 subsequent siblings)
14 siblings, 0 replies; 21+ messages in thread
From: Simon Wunderlich @ 2026-09-07 8:18 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Sven Eckelmann, Simon Wunderlich
From: Sven Eckelmann <sven@narfation.org>
When an already known global TT entry is announced again, its flags have to
be merged with the announced ones. Two of the merge steps also decide
whether the originator list has to be purged before the announced
originator is added.
Move this to batadv_tt_global_merge_flags() and let it report via its
return value whether the originator list has to be purged.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/translation-table.c | 87 ++++++++++++++++++------------
1 file changed, 52 insertions(+), 35 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index d475f8efd44d7..67e4ade5ae997 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -1832,6 +1832,57 @@ batadv_tt_global_orig_entry_add(struct batadv_tt_global_entry *tt_global,
spin_unlock_bh(&tt_global->list_lock);
}
+/**
+ * batadv_tt_global_merge_flags() - merge announced flags into a global TT entry
+ * @tt_global_entry: the global TT entry to update
+ * @flags: TT flags announced for this non-mesh client
+ *
+ * Return: true if the originator list of @tt_global_entry has to be purged
+ * before the announced originator is added, false otherwise.
+ */
+static bool
+batadv_tt_global_merge_flags(struct batadv_tt_global_entry *tt_global_entry,
+ u16 flags)
+{
+ struct batadv_tt_common_entry *common = &tt_global_entry->common;
+ bool delete = false;
+
+ scoped_guard(spinlock_bh, &common->flags_lock) {
+ /* if the client was temporary added before receiving the first
+ * OGM announcing it, we have to clear the TEMP flag. Also,
+ * remove the previous temporary orig node and re-add it
+ * if required. If the orig entry changed, the new one which
+ * is a non-temporary entry is preferred.
+ */
+ if (common->flags & BATADV_TT_CLIENT_TEMP) {
+ delete = true;
+ common->flags &= ~BATADV_TT_CLIENT_TEMP;
+ }
+
+ /* the change can carry possible "attribute" flags like the
+ * TT_CLIENT_TEMP, therefore they have to be copied in the
+ * client entry
+ */
+ if (!is_multicast_ether_addr(common->addr))
+ common->flags |= flags & (~BATADV_TT_SYNC_MASK);
+
+ /* If there is the BATADV_TT_CLIENT_ROAM flag set, there is only
+ * one originator left in the list and we previously received a
+ * delete + roaming change for this originator.
+ *
+ * We should first delete the old originator before adding the
+ * new one.
+ */
+ if (common->flags & BATADV_TT_CLIENT_ROAM) {
+ delete = true;
+ tt_global_entry->roam_at = 0;
+ common->flags &= ~BATADV_TT_CLIENT_ROAM;
+ }
+ }
+
+ return delete;
+}
+
/**
* batadv_tt_global_create() - allocate and initialize a global TT entry
* @tt_addr: the mac address of the non-mesh client
@@ -1974,41 +2025,7 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
goto add_orig_entry;
}
- delete = false;
-
- spin_lock_bh(&common->flags_lock);
- /* if the client was temporary added before receiving the first
- * OGM announcing it, we have to clear the TEMP flag. Also,
- * remove the previous temporary orig node and re-add it
- * if required. If the orig entry changed, the new one which
- * is a non-temporary entry is preferred.
- */
- if (common->flags & BATADV_TT_CLIENT_TEMP) {
- delete = true;
- common->flags &= ~BATADV_TT_CLIENT_TEMP;
- }
-
- /* the change can carry possible "attribute" flags like the
- * TT_CLIENT_TEMP, therefore they have to be copied in the
- * client entry
- */
- if (!is_multicast_ether_addr(common->addr))
- common->flags |= flags & (~BATADV_TT_SYNC_MASK);
-
- /* If there is the BATADV_TT_CLIENT_ROAM flag set, there is only
- * one originator left in the list and we previously received a
- * delete + roaming change for this originator.
- *
- * We should first delete the old originator before adding the
- * new one.
- */
- if (common->flags & BATADV_TT_CLIENT_ROAM) {
- delete = true;
- tt_global_entry->roam_at = 0;
- common->flags &= ~BATADV_TT_CLIENT_ROAM;
- }
- spin_unlock_bh(&common->flags_lock);
-
+ delete = batadv_tt_global_merge_flags(tt_global_entry, flags);
if (delete)
batadv_tt_global_del_orig_list(tt_global_entry);
}
--
2.47.3
^ permalink raw reply related [flat|nested] 21+ messages in thread* [PATCH net-next 08/15] batman-adv: tt: replace add_orig_entry goto in batadv_tt_global_add()
2026-09-07 8:18 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-09-07 Simon Wunderlich
` (6 preceding siblings ...)
2026-09-07 8:18 ` [PATCH net-next 07/15] batman-adv: tt: extract merging of flags into existing " Simon Wunderlich
@ 2026-09-07 8:18 ` Simon Wunderlich
[not found] ` <20260908082701.B6CCD1F00A3A@smtp.kernel.org>
2026-09-07 8:18 ` [PATCH net-next 09/15] batman-adv: tt: extract removal of the superseded local entry Simon Wunderlich
` (6 subsequent siblings)
14 siblings, 1 reply; 21+ messages in thread
From: Simon Wunderlich @ 2026-09-07 8:18 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Sven Eckelmann, Simon Wunderlich
From: Sven Eckelmann <sven@narfation.org>
The "add_orig_entry" label was only used to skip the flag merging of the
non-temporary path. Which means that the code jumping to it and the code
below it are the two halves of an if/else.
Both halves now only decide whether the originator list has to be purged,
so turn them into an if/else and purge the list at a single place.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/translation-table.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 67e4ade5ae997..760acc7be973e 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -2021,15 +2021,16 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
if (batadv_tt_global_entry_has_orig(tt_global_entry,
orig_node, NULL))
goto out_remove;
- batadv_tt_global_del_orig_list(tt_global_entry);
- goto add_orig_entry;
+
+ delete = true;
+ } else {
+ delete = batadv_tt_global_merge_flags(tt_global_entry, flags);
}
- delete = batadv_tt_global_merge_flags(tt_global_entry, flags);
if (delete)
batadv_tt_global_del_orig_list(tt_global_entry);
}
-add_orig_entry:
+
/* add the new orig_entry (if needed) or update it */
batadv_tt_global_orig_entry_add(tt_global_entry, orig_node, ttvn,
flags & BATADV_TT_SYNC_MASK);
--
2.47.3
^ permalink raw reply related [flat|nested] 21+ messages in thread* [PATCH net-next 09/15] batman-adv: tt: extract removal of the superseded local entry
2026-09-07 8:18 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-09-07 Simon Wunderlich
` (7 preceding siblings ...)
2026-09-07 8:18 ` [PATCH net-next 08/15] batman-adv: tt: replace add_orig_entry goto in batadv_tt_global_add() Simon Wunderlich
@ 2026-09-07 8:18 ` Simon Wunderlich
2026-09-08 17:26 ` Sven Eckelmann
2026-09-07 8:18 ` [PATCH net-next 10/15] batman-adv: tt: extract marking of a removed " Simon Wunderlich
` (5 subsequent siblings)
14 siblings, 1 reply; 21+ messages in thread
From: Simon Wunderlich @ 2026-09-07 8:18 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Sven Eckelmann, Simon Wunderlich
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
^ permalink raw reply related [flat|nested] 21+ messages in thread* Re: [PATCH net-next 09/15] batman-adv: tt: extract removal of the superseded local entry
2026-09-07 8:18 ` [PATCH net-next 09/15] batman-adv: tt: extract removal of the superseded local entry Simon Wunderlich
@ 2026-09-08 17:26 ` Sven Eckelmann
0 siblings, 0 replies; 21+ messages in thread
From: Sven Eckelmann @ 2026-09-08 17:26 UTC (permalink / raw)
To: netdev, Simon Wunderlich
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Simon Wunderlich
[-- Attachment #1: Type: text/plain, Size: 1887 bytes --]
https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260907081824.2474040-1-sw%40simonwunderlich.de?part=9
[...]
> > +/**
> > + * 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.
> > + */
>
> Discovered by: opus-5 · Missed by: sonnet-5, gpt-5-6-sol, sashiko-gemini · Confirmed by: gpt-5-6-sol
> This isn't a bug, but should the new kernel-doc for
> batadv_tt_global_purge_local() mention the two things the body actually
> does beyond the summary?
>
> The doc says removal from the local table happens, but multicast addresses
> take an early return and nothing is removed:
>
> if (is_multicast_ether_addr(common->addr))
> return;
>
> The doc also does not mention that the global entry's own flags are
> modified, not just the inherited WIFI flag:
>
> if (!(flags & BATADV_TT_CLIENT_ROAM))
> common->flags &= ~BATADV_TT_CLIENT_ROAM;
>
> Since flags_lock is documented in struct batadv_tt_common_entry as
> protecting both @flags and @batadv_tt_global_entry.roam_at, a reader of the
> new standalone helper might not expect the name purge_local() to also reset
> the global roaming state.
>
> Both behaviours are unchanged from the previous inline code under the
> out_remove label in batadv_tt_global_add(), so this is only about the
> description of the new helper.
See https://patchwork.open-mesh.org/project/b.a.t.m.a.n./patch/20260908-sashiko-kdoc-v1-1-535b498f2519@narfation.org/
Regards,
Sven
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH net-next 10/15] batman-adv: tt: extract marking of a removed local entry
2026-09-07 8:18 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-09-07 Simon Wunderlich
` (8 preceding siblings ...)
2026-09-07 8:18 ` [PATCH net-next 09/15] batman-adv: tt: extract removal of the superseded local entry Simon Wunderlich
@ 2026-09-07 8:18 ` Simon Wunderlich
2026-09-08 17:26 ` Sven Eckelmann
2026-09-07 8:18 ` [PATCH net-next 11/15] batman-adv: tt: extract immediate purge of a " Simon Wunderlich
` (4 subsequent siblings)
14 siblings, 1 reply; 21+ messages in thread
From: Simon Wunderlich @ 2026-09-07 8:18 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Sven Eckelmann, Simon Wunderlich
From: Sven Eckelmann <sven@narfation.org>
The first locked section of batadv_tt_local_remove() does three things at
once
* it snapshots the flags for the return value
* it marks the client as ROAMed
* it decides whether the entry has to survive until the next ttvn increment
But this complex locked section is in the middle of the function and cannot
be written as scoped_guard() due to goto's in this routine.
Move it to batadv_tt_local_mark_removed() and report the decision via its
return value. But leave the batadv_tt_local_set_pending_event() flag
assembly outside the function because it has no locking requirements.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/translation-table.c | 48 ++++++++++++++++++++++--------
1 file changed, 35 insertions(+), 13 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index b3e45fb5e9dd4..f5b753ed1ae1a 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -1443,6 +1443,38 @@ batadv_tt_local_set_pending_event(struct batadv_priv *bat_priv,
batadv_print_vid(tt_local_entry->common.vid), message);
}
+/**
+ * batadv_tt_local_mark_removed() - mark a local entry as removed
+ * @tt_local_entry: local TT entry to mark
+ * @roaming: true if the deletion is due to a roaming event
+ * @curr_flags: pointer to store the flags of the entry before it was marked
+ *
+ * Return: true if the entry has to be kept in the local table until the next
+ * ttvn increment, false if it can be purged immediately.
+ */
+static bool
+batadv_tt_local_mark_removed(struct batadv_tt_local_entry *tt_local_entry,
+ bool roaming, u16 *curr_flags)
+{
+ struct batadv_tt_common_entry *common = &tt_local_entry->common;
+ bool pending = false;
+
+ scoped_guard(spinlock_bh, &common->flags_lock) {
+ *curr_flags = common->flags;
+
+ /* mark the local client as ROAMed */
+ if (roaming)
+ common->flags |= BATADV_TT_CLIENT_ROAM;
+
+ if (!(common->flags & BATADV_TT_CLIENT_NEW)) {
+ common->flags |= BATADV_TT_CLIENT_PENDING;
+ pending = true;
+ }
+ }
+
+ return pending;
+}
+
/**
* batadv_tt_local_remove() - logically remove an entry from the local table
* @bat_priv: the bat priv with all the mesh interface information
@@ -1467,26 +1499,16 @@ u16 batadv_tt_local_remove(struct batadv_priv *bat_priv, const u8 *addr,
if (!tt_local_entry)
goto out;
- spin_lock_bh(&tt_local_entry->common.flags_lock);
- curr_flags = tt_local_entry->common.flags;
-
flags = BATADV_TT_CLIENT_DEL;
/* if this global entry addition is due to a roaming, the node has to
* mark the local entry as "roamed" in order to correctly reroute
* packets later
*/
- if (roaming) {
+ if (roaming)
flags |= BATADV_TT_CLIENT_ROAM;
- /* mark the local client as ROAMed */
- tt_local_entry->common.flags |= BATADV_TT_CLIENT_ROAM;
- }
-
- if (!(tt_local_entry->common.flags & BATADV_TT_CLIENT_NEW)) {
- tt_local_entry->common.flags |= BATADV_TT_CLIENT_PENDING;
- pending = true;
- }
- spin_unlock_bh(&tt_local_entry->common.flags_lock);
+ pending = batadv_tt_local_mark_removed(tt_local_entry, roaming,
+ &curr_flags);
if (pending) {
batadv_tt_local_set_pending_event(bat_priv, tt_local_entry, flags,
message);
--
2.47.3
^ permalink raw reply related [flat|nested] 21+ messages in thread* Re: [PATCH net-next 10/15] batman-adv: tt: extract marking of a removed local entry
2026-09-07 8:18 ` [PATCH net-next 10/15] batman-adv: tt: extract marking of a removed " Simon Wunderlich
@ 2026-09-08 17:26 ` Sven Eckelmann
0 siblings, 0 replies; 21+ messages in thread
From: Sven Eckelmann @ 2026-09-08 17:26 UTC (permalink / raw)
To: netdev, Simon Wunderlich
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Simon Wunderlich
[-- Attachment #1: Type: text/plain, Size: 2271 bytes --]
https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260907081824.2474040-1-sw%40simonwunderlich.de?part=10
[...]
> Discovered by: opus-5, old-prompts · Missed by: gpt-5-6-sol, sashiko-gemini
>
> Two comments in batadv_tt_local_remove() look like they no longer match the
> code after the move.
>
> First, the untouched comment further down in batadv_tt_local_remove() still
> refers to a check "above":
>
> net/batman-adv/translation-table.c:batadv_tt_local_remove() {
> ...
> /* batadv_tt_local_transition_new() may have committed the entry and
> * thus counted it in the local table size since the BATADV_TT_CLIENT_NEW
> * check above.
> */
> if (!(batadv_tt_flags_get(&tt_local_entry->common) & BATADV_TT_CLIENT_NEW))
> batadv_tt_local_size_dec(bat_priv, tt_local_entry->common.vid);
> ...
> }
>
> After this patch there is no BATADV_TT_CLIENT_NEW test left anywhere above
> that point in this function; the only one is now inside the new helper:
>
> net/batman-adv/translation-table.c:batadv_tt_local_mark_removed() {
> ...
> if (!(common->flags & BATADV_TT_CLIENT_NEW)) {
> common->flags |= BATADV_TT_CLIENT_PENDING;
> pending = true;
> }
> ...
> }
>
> Should the wording be updated in this patch to name the helper, so the
> size-accounting race stays traceable from the function it is documented in?
See patch 11 "batman-adv: tt: extract immediate purge of a local entry"
> Second, the retained comment above the "if (roaming)" line still says the
> node "has to mark the local entry as roamed", but the code it now precedes
> only assembles the announcement flag word; the actual
> common->flags |= BATADV_TT_CLIENT_ROAM happens in the
> batadv_tt_local_mark_removed() call two lines below. Would it read better
> moved or reworded so it describes the flag assembly?
>
> No functional change is apparent here: flags is fully computed before the
> call, *curr_flags is written unconditionally inside the guard so curr_flags
> is always initialized for the caller, and the helper is only reached after
> the !tt_local_entry early goto.
See https://patchwork.open-mesh.org/project/b.a.t.m.a.n./patch/20260908-sashiko-kdoc-v1-2-535b498f2519@narfation.org/
Regards,
Sven
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH net-next 11/15] batman-adv: tt: extract immediate purge of a local entry
2026-09-07 8:18 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-09-07 Simon Wunderlich
` (9 preceding siblings ...)
2026-09-07 8:18 ` [PATCH net-next 10/15] batman-adv: tt: extract marking of a removed " Simon Wunderlich
@ 2026-09-07 8:18 ` Simon Wunderlich
2026-09-08 17:26 ` Sven Eckelmann
2026-09-07 8:18 ` [PATCH net-next 12/15] batman-adv: tt: drop the cleanup label from batadv_tt_local_remove() Simon Wunderlich
` (3 subsequent siblings)
14 siblings, 1 reply; 21+ messages in thread
From: Simon Wunderlich @ 2026-09-07 8:18 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Sven Eckelmann, Simon Wunderlich
From: Sven Eckelmann <sven@narfation.org>
A client which was added after the last ttvn increment was never announced
and can be dropped from the local table right away. The code doing so is
the second half of batadv_tt_local_remove() and needed a goto to skip the
accounting when the entry was already gone from the hash.
Move it to batadv_tt_local_remove_now().
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/translation-table.c | 57 +++++++++++++++++++-----------
1 file changed, 37 insertions(+), 20 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index f5b753ed1ae1a..9f61797c64920 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -1475,6 +1475,42 @@ batadv_tt_local_mark_removed(struct batadv_tt_local_entry *tt_local_entry,
return pending;
}
+/**
+ * batadv_tt_local_remove_now() - purge a local entry which was never announced
+ * @bat_priv: the bat priv with all the mesh interface information
+ * @tt_local_entry: local TT entry to purge
+ *
+ * A client which was added right after the last ttvn increment was never sent
+ * to the other nodes. It can therefore be dropped from the local table without
+ * waiting for the next ttvn increment.
+ */
+static void
+batadv_tt_local_remove_now(struct batadv_priv *bat_priv,
+ struct batadv_tt_local_entry *tt_local_entry)
+{
+ struct batadv_tt_common_entry *common = &tt_local_entry->common;
+ struct hlist_node *tt_removed_node;
+
+ batadv_tt_local_event(bat_priv, tt_local_entry, BATADV_TT_CLIENT_DEL);
+
+ /* remove exactly this object when still present in hash */
+ tt_removed_node = batadv_hash_remove(bat_priv->tt.local_hash,
+ batadv_compare_tt_entry,
+ batadv_choose_tt, common);
+ if (!tt_removed_node)
+ return;
+
+ /* batadv_tt_local_transition_new() may have committed the entry and
+ * thus counted it in the local table size since the
+ * BATADV_TT_CLIENT_NEW check in batadv_tt_local_mark_removed().
+ */
+ if (!(batadv_tt_flags_get(common) & BATADV_TT_CLIENT_NEW))
+ batadv_tt_local_size_dec(bat_priv, common->vid);
+
+ /* drop reference of remove hash entry */
+ batadv_tt_local_entry_put(tt_local_entry);
+}
+
/**
* batadv_tt_local_remove() - logically remove an entry from the local table
* @bat_priv: the bat priv with all the mesh interface information
@@ -1490,7 +1526,6 @@ u16 batadv_tt_local_remove(struct batadv_priv *bat_priv, const u8 *addr,
bool roaming)
{
struct batadv_tt_local_entry *tt_local_entry;
- struct hlist_node *tt_removed_node;
u16 curr_flags = BATADV_NO_FLAGS;
bool pending = false;
u16 flags;
@@ -1518,25 +1553,7 @@ u16 batadv_tt_local_remove(struct batadv_priv *bat_priv, const u8 *addr,
/* if this client has been added right now, it is possible to
* immediately purge it
*/
- batadv_tt_local_event(bat_priv, tt_local_entry, BATADV_TT_CLIENT_DEL);
-
- /* remove exactly this object when still present in hash */
- tt_removed_node = batadv_hash_remove(bat_priv->tt.local_hash,
- batadv_compare_tt_entry,
- batadv_choose_tt,
- &tt_local_entry->common);
- if (!tt_removed_node)
- goto out;
-
- /* batadv_tt_local_transition_new() may have committed the entry and
- * thus counted it in the local table size since the BATADV_TT_CLIENT_NEW
- * check above.
- */
- if (!(batadv_tt_flags_get(&tt_local_entry->common) & BATADV_TT_CLIENT_NEW))
- batadv_tt_local_size_dec(bat_priv, tt_local_entry->common.vid);
-
- /* drop reference of remove hash entry */
- batadv_tt_local_entry_put(tt_local_entry);
+ batadv_tt_local_remove_now(bat_priv, tt_local_entry);
out:
batadv_tt_local_entry_put(tt_local_entry);
--
2.47.3
^ permalink raw reply related [flat|nested] 21+ messages in thread* Re: [PATCH net-next 11/15] batman-adv: tt: extract immediate purge of a local entry
2026-09-07 8:18 ` [PATCH net-next 11/15] batman-adv: tt: extract immediate purge of a " Simon Wunderlich
@ 2026-09-08 17:26 ` Sven Eckelmann
0 siblings, 0 replies; 21+ messages in thread
From: Sven Eckelmann @ 2026-09-08 17:26 UTC (permalink / raw)
To: netdev, Simon Wunderlich
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Simon Wunderlich
[-- Attachment #1: Type: text/plain, Size: 2332 bytes --]
https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260907081824.2474040-1-sw%40simonwunderlich.de?part=11
[...]
> Discovered by: opus-5 · Missed by: opus-4-7, gpt-5-6-sol, sashiko-gemini · Confirmed by: gpt-5-6-sol
> Is the "was never announced" wording in this new kernel doc a bit too
> strong? The body of the same function documents the opposite case a few
> lines later:
>
> net/batman-adv/translation-table.c:batadv_tt_local_remove_now() {
> /* batadv_tt_local_transition_new() may have committed the entry and
> * thus counted it in the local table size since the
> * BATADV_TT_CLIENT_NEW check in batadv_tt_local_mark_removed().
> */
> if (!(batadv_tt_flags_get(common) & BATADV_TT_CLIENT_NEW))
> batadv_tt_local_size_dec(bat_priv, common->vid);
> }
>
> batadv_tt_local_mark_removed() drops common->flags_lock before returning
> and batadv_tt_local_remove() holds no other lock, while
> batadv_tt_local_transition_new() only holds the local list_lock and
> flags_lock:
>
> batadv_tt_local_commit_changes_nolock()
> batadv_tt_local_transition_new() /* clears BATADV_TT_CLIENT_NEW,
> batadv_tt_local_size_inc() */
> batadv_tt_local_update_crc()
> atomic_inc(&bat_priv->tt.vn)
>
> So in that window the entry can be committed, counted and announced under
> the current ttvn, and batadv_tt_local_remove_now() still unlinks it from
> bat_priv->tt.local_hash instead of leaving it BATADV_TT_CLIENT_PENDING
> until the next ttvn increment, as described by
> batadv_tt_local_set_pending_event():
>
> * Schedule the TT change announcement for the entry. The entry is kept in the
> * local table until the next TTVN increment so that a consistency-check
> * response can still be answered.
>
> Would it make sense either to soften the new kernel doc (and the matching
> sentence in the commit message, "A client which was added after the last
> ttvn increment was never announced and can be dropped from the local table
> right away") to mention that the entry may already have been committed, or
> to fall back to the pending path when the NEW flag turns out to be cleared?
See https://patchwork.open-mesh.org/project/b.a.t.m.a.n./patch/20260908-sashiko-kdoc-v1-3-535b498f2519@narfation.org/
Regards,
Sven
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH net-next 12/15] batman-adv: tt: drop the cleanup label from batadv_tt_local_remove()
2026-09-07 8:18 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-09-07 Simon Wunderlich
` (10 preceding siblings ...)
2026-09-07 8:18 ` [PATCH net-next 11/15] batman-adv: tt: extract immediate purge of a " Simon Wunderlich
@ 2026-09-07 8:18 ` Simon Wunderlich
2026-09-07 8:18 ` [PATCH net-next 13/15] batman-adv: tt: clarify kernel doc for batadv_tt_local_set_pending_event() Simon Wunderlich
` (2 subsequent siblings)
14 siblings, 0 replies; 21+ messages in thread
From: Simon Wunderlich @ 2026-09-07 8:18 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Sven Eckelmann, Simon Wunderlich
From: Sven Eckelmann <sven@narfation.org>
With both locked sections moved to their own helpers, the only thing left
in the cleanup section is the reference of the looked up entry. The "out"
label is therefore only reached with a valid entry, except for the lookup
failure at the very beginning.
Return BATADV_NO_FLAGS directly when there is no entry and let the two
remaining cases be an if/else.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/translation-table.c | 26 ++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 9f61797c64920..6c65d195f3756 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -1526,13 +1526,12 @@ u16 batadv_tt_local_remove(struct batadv_priv *bat_priv, const u8 *addr,
bool roaming)
{
struct batadv_tt_local_entry *tt_local_entry;
- u16 curr_flags = BATADV_NO_FLAGS;
- bool pending = false;
+ u16 curr_flags;
u16 flags;
tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr, vid);
if (!tt_local_entry)
- goto out;
+ return BATADV_NO_FLAGS;
flags = BATADV_TT_CLIENT_DEL;
/* if this global entry addition is due to a roaming, the node has to
@@ -1542,20 +1541,15 @@ u16 batadv_tt_local_remove(struct batadv_priv *bat_priv, const u8 *addr,
if (roaming)
flags |= BATADV_TT_CLIENT_ROAM;
- pending = batadv_tt_local_mark_removed(tt_local_entry, roaming,
- &curr_flags);
- if (pending) {
- batadv_tt_local_set_pending_event(bat_priv, tt_local_entry, flags,
- message);
- goto out;
- }
-
- /* if this client has been added right now, it is possible to
- * immediately purge it
- */
- batadv_tt_local_remove_now(bat_priv, tt_local_entry);
+ if (batadv_tt_local_mark_removed(tt_local_entry, roaming, &curr_flags))
+ batadv_tt_local_set_pending_event(bat_priv, tt_local_entry,
+ flags, message);
+ else
+ /* if this client has been added right now, it is possible to
+ * immediately purge it
+ */
+ batadv_tt_local_remove_now(bat_priv, tt_local_entry);
-out:
batadv_tt_local_entry_put(tt_local_entry);
return curr_flags;
--
2.47.3
^ permalink raw reply related [flat|nested] 21+ messages in thread* [PATCH net-next 13/15] batman-adv: tt: clarify kernel doc for batadv_tt_local_set_pending_event()
2026-09-07 8:18 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-09-07 Simon Wunderlich
` (11 preceding siblings ...)
2026-09-07 8:18 ` [PATCH net-next 12/15] batman-adv: tt: drop the cleanup label from batadv_tt_local_remove() Simon Wunderlich
@ 2026-09-07 8:18 ` Simon Wunderlich
2026-09-07 8:18 ` [PATCH net-next 14/15] batman-adv: bat_iv: fix ogm_neigh_is_sob parameters references Simon Wunderlich
2026-09-07 8:18 ` [PATCH net-next 15/15] batman-adv: correct batadv_hash_remove kdoc return type Simon Wunderlich
14 siblings, 0 replies; 21+ messages in thread
From: Simon Wunderlich @ 2026-09-07 8:18 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Sven Eckelmann, Sashiko,
Simon Wunderlich
From: Sven Eckelmann <sven@narfation.org>
The function batadv_tt_local_set_pending_event() is no longer setting the
BATADV_TT_CLIENT_PENDING because it must be done with the flags_lock held.
The kernel-doc must therefore correctly state that the flag must already be
set.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260831135117.574836-1-sw%40simonwunderlich.de?part=12
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/translation-table.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 6c65d195f3756..12ea557cb8033 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -1422,13 +1422,12 @@ int batadv_tt_local_dump(struct sk_buff *msg, struct netlink_callback *cb)
/**
* batadv_tt_local_set_pending_event() - trigger events for TT pending removal
* @bat_priv: the bat priv with all the mesh interface information
- * @tt_local_entry: local TT entry to mark
+ * @tt_local_entry: local TT entry which was marked as BATADV_TT_CLIENT_PENDING
* @flags: TT change flags to announce together with the pending removal
* @message: debug message describing the reason for the change
*
- * Schedule the TT change announcement for the entry. The entry is kept in the
- * local table until the next TTVN increment so that a consistency-check
- * response can still be answered.
+ * Schedule the TT change announcement for the entry. The caller must already
+ * have added BATADV_TT_CLIENT_PENDING to the @tt_local_entry
*/
static void
batadv_tt_local_set_pending_event(struct batadv_priv *bat_priv,
--
2.47.3
^ permalink raw reply related [flat|nested] 21+ messages in thread* [PATCH net-next 14/15] batman-adv: bat_iv: fix ogm_neigh_is_sob parameters references
2026-09-07 8:18 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-09-07 Simon Wunderlich
` (12 preceding siblings ...)
2026-09-07 8:18 ` [PATCH net-next 13/15] batman-adv: tt: clarify kernel doc for batadv_tt_local_set_pending_event() Simon Wunderlich
@ 2026-09-07 8:18 ` Simon Wunderlich
2026-09-07 8:18 ` [PATCH net-next 15/15] batman-adv: correct batadv_hash_remove kdoc return type Simon Wunderlich
14 siblings, 0 replies; 21+ messages in thread
From: Simon Wunderlich @ 2026-09-07 8:18 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Sven Eckelmann, Sashiko,
Simon Wunderlich
From: Sven Eckelmann <sven@narfation.org>
The batadv_iv_ogm_neigh_is_sob() kernel-doc summary line is still
referencing the old parameter names "neigh1" and "neigh2". But these are
now called "candidate" and "reference".
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260831135117.574836-1-sw%40simonwunderlich.de?part=5
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/bat_iv_ogm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 3fe09b4c30463..89b499f7a37dd 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -2422,8 +2422,8 @@ static int batadv_iv_ogm_neigh_cmp(struct batadv_neigh_node *neigh1,
}
/**
- * batadv_iv_ogm_neigh_is_sob() - check if neigh1 is similarly good or better
- * than neigh2 from the metric prospective
+ * batadv_iv_ogm_neigh_is_sob() - check if @candidate is similarly good or
+ * better than @reference from the metric prospective
* @candidate: the first neighbor object of the comparison
* @if_outgoing_cand: outgoing interface for the @candidate neighbor
* @reference: the second neighbor object of the comparison
--
2.47.3
^ permalink raw reply related [flat|nested] 21+ messages in thread* [PATCH net-next 15/15] batman-adv: correct batadv_hash_remove kdoc return type
2026-09-07 8:18 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-09-07 Simon Wunderlich
` (13 preceding siblings ...)
2026-09-07 8:18 ` [PATCH net-next 14/15] batman-adv: bat_iv: fix ogm_neigh_is_sob parameters references Simon Wunderlich
@ 2026-09-07 8:18 ` Simon Wunderlich
14 siblings, 0 replies; 21+ messages in thread
From: Simon Wunderlich @ 2026-09-07 8:18 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Sven Eckelmann, Sashiko,
Simon Wunderlich
From: Sven Eckelmann <sven@narfation.org>
Not the data is returned after a batadv_hash_remove() but the pointer to
the hlist_node which was used to look up the entry in the hash.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260831135117.574836-1-sw%40simonwunderlich.de?part=8
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/hash.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/batman-adv/hash.h b/net/batman-adv/hash.h
index e67afe01304ce..45a432cc15789 100644
--- a/net/batman-adv/hash.h
+++ b/net/batman-adv/hash.h
@@ -137,7 +137,7 @@ static inline int batadv_hash_add(struct batadv_hashtable *hash,
* data could be the structure you use with just the key filled, we just need
* the key for comparing.
*
- * Return: returns pointer to data on success, so you can remove the used
+ * Return: returns pointer to hlist_node on success, so you can remove the used
* structure yourself, or NULL on error
*/
static inline void *batadv_hash_remove(struct batadv_hashtable *hash,
--
2.47.3
^ permalink raw reply related [flat|nested] 21+ messages in thread