* [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-11-23
@ 2026-11-23 17:18 Simon Wunderlich
2026-11-23 17:18 ` [PATCH net-next 01/15] batman-adv: document refcount of returned objects Simon Wunderlich
` (14 more replies)
0 siblings, 15 replies; 31+ messages in thread
From: Simon Wunderlich @ 2026-11-23 17:18 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, b.a.t.m.a.n, Simon Wunderlich
Dear net maintainers,
here is another pull request of batman-adv to go into net-next.
Please pull or let me know of any problem!
Thank you,
Simon
The following changes since commit e2c4b4b08e96e8ada2674ce26ff9e4abc33897bb:
batman-adv: annotate functions returning objects with __must_check (2026-11-01 18:13:10 +0100)
are available in the Git repository at:
https://git.open-mesh.org/batadv.git tags/batadv-next-pullrequest-20261123
for you to fetch changes up to a859ae9d28de739ad791a5f83482808665d706f9:
batman-adv: tt: drop ADD+DEL events of never announced clients (2026-11-20 08:33:06 +0100)
----------------------------------------------------------------
This feature/cleanup patchset includes the following patches, all by
Sven Eckelmann:
- document refcount of returned objects
- mcast: use mla_lock also during mcast_free
- mark functions inheriting critical sections
- bla: register own backbone gw when claiming for local node
- tt: rework local entry hash and locking handling (11 patches)
----------------------------------------------------------------
Sven Eckelmann (15):
batman-adv: document refcount of returned objects
batman-adv: mcast: use mla_lock also during mcast_free
batman-adv: mark functions inheriting critical sections
batman-adv: bla: register own backbone gw when claiming for local node
batman-adv: tt: unhash local entries with hlist_del_init_rcu()
batman-adv: tt: refresh local entry in single flags_lock section
batman-adv: tt: don't remove unhashed local entries
batman-adv: tt: don't queue local events for unhashed entries
batman-adv: tt: remove unannounced local entries via pending state
batman-adv: tt: keep local entry unchanged when ADD can't be queued
batman-adv: tt: requeue DEL of pending local entry after failed allocation
batman-adv: tt: extract removal of pending local entry
batman-adv: tt: commit only the announced local changes
batman-adv: tt: avoid list_lock for unchanged local clients
batman-adv: tt: drop ADD+DEL events of never announced clients
net/batman-adv/bat_iv_ogm.c | 9 +-
net/batman-adv/bat_v.c | 5 +-
net/batman-adv/bat_v_ogm.c | 5 +
net/batman-adv/bridge_loop_avoidance.c | 15 +-
net/batman-adv/distributed-arp-table.c | 1 +
net/batman-adv/fragmentation.c | 1 +
net/batman-adv/fragmentation.h | 1 +
net/batman-adv/gateway_client.c | 8 +-
net/batman-adv/hard-interface.c | 6 +-
net/batman-adv/hard-interface.h | 3 +-
net/batman-adv/multicast.c | 18 +-
net/batman-adv/multicast_forw.c | 2 +
net/batman-adv/netlink.c | 28 +-
net/batman-adv/originator.c | 16 +-
net/batman-adv/routing.c | 1 +
net/batman-adv/tp_meter.c | 12 +-
net/batman-adv/translation-table.c | 930 ++++++++++++++++++++++++---------
net/batman-adv/tvlv.c | 5 +
net/batman-adv/types.h | 14 +
19 files changed, 787 insertions(+), 293 deletions(-)
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH net-next 01/15] batman-adv: document refcount of returned objects
2026-11-23 17:18 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-11-23 Simon Wunderlich
@ 2026-11-23 17:18 ` Simon Wunderlich
2026-11-23 17:23 ` netdev-bot+sinfo
2026-11-24 17:20 ` netdev-bot+sashiko
2026-11-23 17:18 ` [PATCH net-next 02/15] batman-adv: mcast: use mla_lock also during mcast_free Simon Wunderlich
` (13 subsequent siblings)
14 siblings, 2 replies; 31+ messages in thread
From: Simon Wunderlich @ 2026-11-23 17: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>
Callers of lookup, get and create functions have to know whether they own a
reference to the returned object (and have to release it with the matching
batadv_*_put() or dev_put()), or only borrow it. Some functions document
this already (e.g. "(with increased refcnt)" or "The object is returned
with refcounter increased by 1."), but many say nothing.
Add a note to the kerneldoc of the __must_check functions that return an
object with an increased refcounter and did not document this yet. For the
exceptions:
* batadv_transtable_best_orig()
* batadv_mcast_forw_orig_entry()
the opposite is stated to make the difference clear ("no increased refcnt",
"only valid in current RCU read-side critical section")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/bat_iv_ogm.c | 6 +++++-
net/batman-adv/bat_v.c | 3 ++-
net/batman-adv/bat_v_ogm.c | 1 +
net/batman-adv/bridge_loop_avoidance.c | 7 +++++--
net/batman-adv/distributed-arp-table.c | 1 +
net/batman-adv/gateway_client.c | 7 +++++--
net/batman-adv/hard-interface.c | 6 +++++-
net/batman-adv/hard-interface.h | 3 ++-
net/batman-adv/multicast.c | 1 +
net/batman-adv/multicast_forw.c | 2 ++
net/batman-adv/netlink.c | 28 +++++++++++++-------------
net/batman-adv/originator.c | 16 ++++++++++++---
net/batman-adv/routing.c | 1 +
net/batman-adv/tp_meter.c | 12 +++++++----
net/batman-adv/translation-table.c | 18 ++++++++++++-----
net/batman-adv/tvlv.c | 2 ++
16 files changed, 80 insertions(+), 34 deletions(-)
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index a7b5d5a1cc02..4f60e50dbad2 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -136,6 +136,7 @@ static u8 batadv_ring_buffer_avg(const u8 lq_recv[])
* Return: the originator object corresponding to the passed mac address or NULL
* on failure.
* If the object does not exist, it is created and initialised.
+ * The returned object has an increased refcounter.
*/
static struct batadv_orig_node * __must_check
batadv_iv_ogm_orig_get(struct batadv_priv *bat_priv, const u8 *addr)
@@ -177,7 +178,8 @@ batadv_iv_ogm_orig_get(struct batadv_priv *bat_priv, const u8 *addr)
* @neigh_addr: the mac address of the neighbour
* @orig_node: originator object representing the neighbour
*
- * Return: pointer to the neigh_node or NULL in case of failure
+ * Return: pointer to the neigh_node or NULL in case of failure.
+ * The returned object has an increased refcounter.
*/
static struct batadv_neigh_node * __must_check
batadv_iv_ogm_neigh_new(struct batadv_hard_iface *hard_iface,
@@ -1483,6 +1485,7 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
*
* Return: A neighbor node which is the best router towards the given originator
* address. Bonding candidates are ignored.
+ * The returned object has an increased refcounter.
*/
static struct batadv_neigh_node * __must_check
batadv_orig_to_direct_router(struct batadv_priv *bat_priv, const u8 *orig_addr,
@@ -2489,6 +2492,7 @@ static void batadv_iv_init_sel_class(struct batadv_priv *bat_priv)
*
* Return: gateway node with the highest score for the current selection class,
* or NULL if no eligible gateway exists.
+ * The returned object has an increased refcounter.
*/
static struct batadv_gw_node * __must_check
batadv_iv_gw_get_best_gw_node(struct batadv_priv *bat_priv)
diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c
index 1ee9f966e548..1214e6f9c43c 100644
--- a/net/batman-adv/bat_v.c
+++ b/net/batman-adv/bat_v.c
@@ -612,7 +612,8 @@ static int batadv_v_gw_throughput_get(struct batadv_gw_node *gw_node, u32 *bw)
* batadv_v_gw_get_best_gw_node() - retrieve the best GW node
* @bat_priv: the bat priv with all the mesh interface information
*
- * Return: the GW node having the best GW-metric, NULL if no GW is known
+ * Return: the GW node having the best GW-metric, NULL if no GW is known.
+ * The returned object has an increased refcounter.
*/
static struct batadv_gw_node * __must_check
batadv_v_gw_get_best_gw_node(struct batadv_priv *bat_priv)
diff --git a/net/batman-adv/bat_v_ogm.c b/net/batman-adv/bat_v_ogm.c
index 4abb4c871e8c..c2ad9ac0d6e7 100644
--- a/net/batman-adv/bat_v_ogm.c
+++ b/net/batman-adv/bat_v_ogm.c
@@ -51,6 +51,7 @@
* Return: the orig_node corresponding to the specified address. If such an
* object does not exist, it is allocated here. In case of allocation failure
* returns NULL.
+ * The returned object has an increased refcounter.
*/
struct batadv_orig_node *batadv_v_ogm_orig_get(struct batadv_priv *bat_priv,
const u8 *addr)
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index 729534eb19fb..68ff2f94cf49 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -213,6 +213,7 @@ static void batadv_claim_put(struct batadv_bla_claim *claim)
* @key: key of the searched claim
*
* Return: claim if found or NULL otherwise.
+ * The returned object has an increased refcounter.
*/
static struct batadv_bla_claim * __must_check
batadv_claim_hash_find(struct batadv_priv *bat_priv,
@@ -252,7 +253,8 @@ batadv_claim_hash_find(struct batadv_priv *bat_priv,
* @addr: the address of the originator
* @vid: the VLAN ID
*
- * Return: backbone gateway if found or NULL otherwise
+ * Return: backbone gateway if found or NULL otherwise.
+ * The returned object has an increased refcounter.
*/
static struct batadv_bla_backbone_gw * __must_check
batadv_backbone_hash_find(struct batadv_priv *bat_priv, const u8 *addr,
@@ -479,7 +481,8 @@ static void batadv_bla_loopdetect_report(struct work_struct *work)
* @vid: the VLAN ID
* @own_backbone: set if the requested backbone is local
*
- * Return: the (possibly created) backbone gateway or NULL on error
+ * Return: the (possibly created) backbone gateway or NULL on error.
+ * The returned object has an increased refcounter.
*/
static struct batadv_bla_backbone_gw * __must_check
batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, const u8 *orig,
diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c
index 2bb6716a124a..a6145383e6d7 100644
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -395,6 +395,7 @@ static u32 batadv_hash_dat(const void *data, u32 size)
* @vid: VLAN identifier
*
* Return: the dat_entry if found, NULL otherwise.
+ * The returned object has an increased refcounter.
*/
static struct batadv_dat_entry * __must_check
batadv_dat_entry_hash_find(struct batadv_priv *bat_priv, __be32 ip,
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c
index e6e97c0478cc..0dddcea7def9 100644
--- a/net/batman-adv/gateway_client.c
+++ b/net/batman-adv/gateway_client.c
@@ -74,7 +74,8 @@ void batadv_gw_node_release(struct kref *ref)
* batadv_gw_get_selected_gw_node() - Get currently selected gateway
* @bat_priv: the bat priv with all the mesh interface information
*
- * Return: selected gateway (with increased refcnt), NULL on errors
+ * Return: selected gateway, NULL on errors.
+ * The returned object has an increased refcounter.
*/
struct batadv_gw_node *
batadv_gw_get_selected_gw_node(struct batadv_priv *bat_priv)
@@ -98,7 +99,8 @@ batadv_gw_get_selected_gw_node(struct batadv_priv *bat_priv)
* batadv_gw_get_selected_orig() - Get originator of currently selected gateway
* @bat_priv: the bat priv with all the mesh interface information
*
- * Return: orig_node of selected gateway (with increased refcnt), NULL on errors
+ * Return: orig_node of selected gateway, NULL on errors.
+ * The returned object has an increased refcounter.
*/
struct batadv_orig_node *
batadv_gw_get_selected_orig(struct batadv_priv *bat_priv)
@@ -374,6 +376,7 @@ static void batadv_gw_node_add(struct batadv_priv *bat_priv,
* @orig_node: originator announcing gateway capabilities
*
* Return: gateway node if found or NULL otherwise.
+ * The returned object has an increased refcounter.
*/
struct batadv_gw_node *batadv_gw_node_get(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node)
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index 46dcbba0379b..b692b5b83d7c 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -73,7 +73,8 @@ void batadv_hardif_release(struct kref *ref)
* batadv_hardif_get_by_netdev() - Get hard interface object of a net_device
* @net_dev: net_device to search for
*
- * Return: batadv_hard_iface of net_dev (with increased refcnt), NULL on errors
+ * Return: batadv_hard_iface of net_dev, NULL on errors.
+ * The returned object has an increased refcounter.
*/
struct batadv_hard_iface *
batadv_hardif_get_by_netdev(struct net_device *net_dev)
@@ -236,6 +237,7 @@ static bool batadv_is_valid_iface(const struct net_device *net_dev)
*
* Return: the 'real' net device or the original net device and NULL in case
* of an error.
+ * The returned object has an increased refcounter.
*/
struct net_device *__batadv_get_real_netdev(struct net_device *netdev)
{
@@ -284,6 +286,7 @@ struct net_device *__batadv_get_real_netdev(struct net_device *netdev)
*
* Return: the 'real' net device or the original net device and NULL in case
* of an error.
+ * The returned object has an increased refcounter.
*/
struct net_device *batadv_get_real_netdev(struct net_device *net_device)
{
@@ -485,6 +488,7 @@ int batadv_hardif_no_broadcast(struct batadv_hard_iface *if_outgoing,
*
* Return: first hard interface in BATADV_IF_ACTIVE state attached to
* @mesh_iface, or NULL if none is active.
+ * The returned object has an increased refcounter.
*/
static struct batadv_hard_iface * __must_check
batadv_hardif_get_active(struct net_device *mesh_iface)
diff --git a/net/batman-adv/hard-interface.h b/net/batman-adv/hard-interface.h
index 6bdef0ae1419..ad53e6086bae 100644
--- a/net/batman-adv/hard-interface.h
+++ b/net/batman-adv/hard-interface.h
@@ -99,7 +99,8 @@ static inline void batadv_hardif_put(struct batadv_hard_iface *hard_iface)
* batadv_primary_if_get_selected() - Get reference to primary interface
* @bat_priv: the bat priv with all the mesh interface information
*
- * Return: primary interface (with increased refcnt), otherwise NULL
+ * Return: primary interface, otherwise NULL.
+ * The returned object has an increased refcounter.
*/
static inline struct batadv_hard_iface * __must_check
batadv_primary_if_get_selected(struct batadv_priv *bat_priv)
diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c
index 29bfeb800fa5..415981fe6dc6 100644
--- a/net/batman-adv/multicast.c
+++ b/net/batman-adv/multicast.c
@@ -80,6 +80,7 @@ static void batadv_mcast_start_timer(struct batadv_priv *bat_priv)
*
* Return: NULL if no such bridge exists. Otherwise the net device of the
* bridge.
+ * The returned object has an increased refcounter.
*/
static struct net_device * __must_check
batadv_mcast_get_bridge(struct net_device *mesh_iface)
diff --git a/net/batman-adv/multicast_forw.c b/net/batman-adv/multicast_forw.c
index 0120d1ea30ac..863ada459480 100644
--- a/net/batman-adv/multicast_forw.c
+++ b/net/batman-adv/multicast_forw.c
@@ -109,6 +109,8 @@ batadv_mcast_forw_push_est_padding(struct sk_buff *skb, int count,
* @entry_offset: the offset of the hlist node within the orig_node struct
*
* Return: The orig_node containing the hlist node on success, NULL on error.
+ * The returned object has no increased refcounter and is only valid inside
+ * the RCU read-side critical section of the caller.
*/
static struct batadv_orig_node *
batadv_mcast_forw_orig_entry(struct hlist_node *node,
diff --git a/net/batman-adv/netlink.c b/net/batman-adv/netlink.c
index fd58523cea7c..361660371726 100644
--- a/net/batman-adv/netlink.c
+++ b/net/batman-adv/netlink.c
@@ -1135,8 +1135,8 @@ static int batadv_netlink_set_vlan(struct sk_buff *skb, struct genl_info *info)
* @net: the applicable net namespace
* @ifindex: index of the mesh interface
*
- * Return: Pointer to mesh interface (with increased refcnt) on success, error
- * pointer on error
+ * Return: Pointer to mesh interface on success, error pointer on error.
+ * The returned object has an increased refcounter.
*/
static struct net_device * __must_check
batadv_netlink_get_meshif_from_ifindex(struct net *net, int ifindex)
@@ -1163,8 +1163,8 @@ batadv_netlink_get_meshif_from_ifindex(struct net *net, int ifindex)
* @net: the applicable net namespace
* @info: receiver information
*
- * Return: Pointer to mesh interface (with increased refcnt) on success, error
- * pointer on error
+ * Return: Pointer to mesh interface on success, error pointer on error.
+ * The returned object has an increased refcounter.
*/
static struct net_device * __must_check
batadv_netlink_get_meshif_from_info(struct net *net, struct genl_info *info)
@@ -1183,8 +1183,8 @@ batadv_netlink_get_meshif_from_info(struct net *net, struct genl_info *info)
* batadv_netlink_get_meshif() - Retrieve mesh interface from netlink callback
* @cb: callback structure containing arguments
*
- * Return: Pointer to mesh interface (with increased refcnt) on success, error
- * pointer on error
+ * Return: Pointer to mesh interface on success, error pointer on error.
+ * The returned object has an increased refcounter.
*/
struct net_device *batadv_netlink_get_meshif(struct netlink_callback *cb)
{
@@ -1203,8 +1203,8 @@ struct net_device *batadv_netlink_get_meshif(struct netlink_callback *cb)
* @net: the applicable net namespace
* @ifindex: index of the hard interface
*
- * Return: Pointer to hard interface (with increased refcnt) on success, error
- * pointer on error
+ * Return: Pointer to hard interface on success, error pointer on error.
+ * The returned object has an increased refcounter.
*/
static struct batadv_hard_iface * __must_check
batadv_netlink_get_hardif_from_ifindex(struct batadv_priv *bat_priv,
@@ -1245,8 +1245,8 @@ batadv_netlink_get_hardif_from_ifindex(struct batadv_priv *bat_priv,
* @net: the applicable net namespace
* @info: receiver information
*
- * Return: Pointer to hard interface (with increased refcnt) on success, error
- * pointer on error
+ * Return: Pointer to hard interface on success, error pointer on error.
+ * The returned object has an increased refcounter.
*/
static struct batadv_hard_iface * __must_check
batadv_netlink_get_hardif_from_info(struct batadv_priv *bat_priv,
@@ -1267,8 +1267,8 @@ batadv_netlink_get_hardif_from_info(struct batadv_priv *bat_priv,
* @bat_priv: the bat priv with all the mesh interface information
* @cb: callback structure containing arguments
*
- * Return: Pointer to hard interface (with increased refcnt) on success, error
- * pointer on error
+ * Return: Pointer to hard interface on success, error pointer on error.
+ * The returned object has an increased refcounter.
*/
struct batadv_hard_iface *
batadv_netlink_get_hardif(struct batadv_priv *bat_priv,
@@ -1290,8 +1290,8 @@ batadv_netlink_get_hardif(struct batadv_priv *bat_priv,
* @net: the applicable net namespace
* @info: receiver information
*
- * Return: Pointer to vlan on success (with increased refcnt), error pointer
- * on error
+ * Return: Pointer to vlan on success, error pointer on error.
+ * The returned object has an increased refcounter.
*/
static struct batadv_meshif_vlan * __must_check
batadv_get_vlan_from_info(struct batadv_priv *bat_priv, struct net *net,
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
index 0a5ee918cf50..25a3f78aca1a 100644
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -48,7 +48,8 @@ static struct lock_class_key batadv_orig_hash_lock_class_key;
* @bat_priv: the bat priv with all the mesh interface information
* @addr: mac address of the originator
*
- * Return: orig_node (with increased refcnt), NULL on errors
+ * Return: orig_node, NULL on errors.
+ * The returned object has an increased refcounter.
*/
struct batadv_orig_node *
batadv_orig_hash_find(struct batadv_priv *bat_priv, const u8 *addr)
@@ -106,6 +107,7 @@ bool batadv_compare_orig(const struct hlist_node *node, const void *data2)
*
* Return: the vlan object identified by vid and belonging to orig_node or NULL
* if it does not exist.
+ * The returned object has an increased refcounter.
*/
struct batadv_orig_node_vlan *
batadv_orig_node_vlan_get(struct batadv_orig_node *orig_node,
@@ -346,6 +348,7 @@ batadv_orig_router_get(struct batadv_orig_node *orig_node,
*
* Return: A neighbor node which is the best router towards the given originator
* address.
+ * The returned object has an increased refcounter.
*/
struct batadv_neigh_node *
batadv_orig_to_router(struct batadv_priv *bat_priv, const u8 *orig_addr,
@@ -528,7 +531,8 @@ batadv_neigh_ifinfo_new(struct batadv_neigh_node *neigh,
* Looks for and possibly returns a neighbour belonging to this originator list
* which is connected through the provided hard interface.
*
- * Return: neighbor when found. Otherwise NULL
+ * Return: neighbor when found. Otherwise NULL.
+ * The returned object has an increased refcounter.
*/
static struct batadv_neigh_node * __must_check
batadv_neigh_node_get(const struct batadv_orig_node *orig_node,
@@ -564,6 +568,7 @@ batadv_neigh_node_get(const struct batadv_orig_node *orig_node,
* @orig_node: originator object representing the neighbour
*
* Return: the hardif neighbour node if found or created or NULL otherwise.
+ * The returned object has an increased refcounter.
*/
static struct batadv_hardif_neigh_node * __must_check
batadv_hardif_neigh_create(struct batadv_hard_iface *hard_iface,
@@ -611,6 +616,7 @@ batadv_hardif_neigh_create(struct batadv_hard_iface *hard_iface,
* @orig_node: originator object representing the neighbour
*
* Return: the hardif neighbour node if found or created or NULL otherwise.
+ * The returned object has an increased refcounter.
*/
static struct batadv_hardif_neigh_node * __must_check
batadv_hardif_neigh_get_or_create(struct batadv_hard_iface *hard_iface,
@@ -634,7 +640,8 @@ batadv_hardif_neigh_get_or_create(struct batadv_hard_iface *hard_iface,
*
* Looks for and possibly returns a neighbour belonging to this hard interface.
*
- * Return: neighbor when found. Otherwise NULL
+ * Return: neighbor when found. Otherwise NULL.
+ * The returned object has an increased refcounter.
*/
struct batadv_hardif_neigh_node *
batadv_hardif_neigh_get(const struct batadv_hard_iface *hard_iface,
@@ -669,6 +676,7 @@ batadv_hardif_neigh_get(const struct batadv_hard_iface *hard_iface,
* Allocates a new neigh_node object and initialises all the generic fields.
*
* Return: the neighbour node if found or created or NULL otherwise.
+ * The returned object has an increased refcounter.
*/
static struct batadv_neigh_node * __must_check
batadv_neigh_node_create(struct batadv_orig_node *orig_node,
@@ -734,6 +742,7 @@ batadv_neigh_node_create(struct batadv_orig_node *orig_node,
* @neigh_addr: the mac address of the neighbour interface
*
* Return: the neighbour node if found or created or NULL otherwise.
+ * The returned object has an increased refcounter.
*/
struct batadv_neigh_node *
batadv_neigh_node_get_or_create(struct batadv_orig_node *orig_node,
@@ -945,6 +954,7 @@ void batadv_originator_free(struct batadv_priv *bat_priv)
* The new object is not added to the originator list.
*
* Return: the newly created object or NULL on failure.
+ * The returned object has an increased refcounter.
*/
struct batadv_orig_node *batadv_orig_node_new(struct batadv_priv *bat_priv,
const u8 *addr)
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index 6bcd9d9496ba..821fb5addbfe 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -587,6 +587,7 @@ batadv_last_bonding_replace(struct batadv_orig_node *orig_node,
*
* Return: the router which should be used for this orig_node on
* this interface, or NULL if not available.
+ * The returned object has an increased refcounter.
*/
struct batadv_neigh_node *
batadv_find_router(struct batadv_priv *bat_priv,
diff --git a/net/batman-adv/tp_meter.c b/net/batman-adv/tp_meter.c
index 4014a431951e..d3ffcc3aa44b 100644
--- a/net/batman-adv/tp_meter.c
+++ b/net/batman-adv/tp_meter.c
@@ -262,7 +262,8 @@ static void batadv_tp_batctl_error_notify(enum batadv_tp_meter_reason reason,
* Look for a tp_vars object matching dst as end_point and return it after
* having increment the refcounter. Return NULL is not found
*
- * Return: matching tp_vars or NULL when no tp_vars with @dst was found
+ * Return: matching tp_vars or NULL when no tp_vars with @dst was found.
+ * The returned object has an increased refcounter.
*/
static struct batadv_tp_sender * __must_check
batadv_tp_list_find_sender(struct batadv_priv *bat_priv, const u8 *dst)
@@ -327,7 +328,8 @@ static bool batadv_tp_list_active(struct batadv_priv *bat_priv, const u8 *dst)
* session and return it after having increment the refcounter. Return NULL
* is not found
*
- * Return: matching tp_vars or NULL when no tp_vars was found
+ * Return: matching tp_vars or NULL when no tp_vars was found.
+ * The returned object has an increased refcounter.
*/
static struct batadv_tp_sender * __must_check
batadv_tp_list_find_sender_session(struct batadv_priv *bat_priv, const u8 *dst,
@@ -1210,7 +1212,8 @@ void batadv_tp_stop(struct batadv_priv *bat_priv, const u8 *dst,
* session and return it after having increment the refcounter. Return NULL
* is not found
*
- * Return: matching tp_vars or NULL when no tp_vars was found
+ * Return: matching tp_vars or NULL when no tp_vars was found.
+ * The returned object has an increased refcounter.
*/
static struct batadv_tp_receiver * __must_check
batadv_tp_list_find_receiver_session(struct batadv_priv *bat_priv, const u8 *dst,
@@ -1567,7 +1570,8 @@ static void batadv_tp_ack_unordered(struct batadv_tp_receiver *tp_vars)
* @bat_priv: the bat priv with all the mesh interface information
* @icmp: received icmp tp msg
*
- * Return: corresponding tp_vars or NULL on errors
+ * Return: corresponding tp_vars or NULL on errors.
+ * The returned object has an increased refcounter.
*/
static struct batadv_tp_receiver * __must_check
batadv_tp_init_recv(struct batadv_priv *bat_priv,
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index f9de255ef0df..216f41387afa 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -149,6 +149,7 @@ static inline u32 batadv_choose_tt(const void *data, u32 size)
*
* Return: a pointer to the tt_common struct belonging to the searched client if
* found, NULL otherwise.
+ * The returned object has an increased refcounter.
*/
static struct batadv_tt_common_entry * __must_check
batadv_tt_hash_find(struct batadv_hashtable *hash, const u8 *addr,
@@ -193,6 +194,7 @@ batadv_tt_hash_find(struct batadv_hashtable *hash, const u8 *addr,
*
* Return: a pointer to the corresponding tt_local_entry struct if the client is
* found, NULL otherwise.
+ * The returned object has an increased refcounter.
*/
static struct batadv_tt_local_entry * __must_check
batadv_tt_local_hash_find(struct batadv_priv *bat_priv, const u8 *addr,
@@ -218,6 +220,7 @@ batadv_tt_local_hash_find(struct batadv_priv *bat_priv, const u8 *addr,
*
* Return: a pointer to the corresponding tt_global_entry struct if the client
* is found, NULL otherwise.
+ * The returned object has an increased refcounter.
*/
struct batadv_tt_global_entry *
batadv_tt_global_hash_find(struct batadv_priv *bat_priv, const u8 *addr,
@@ -962,8 +965,8 @@ static bool batadv_tt_local_add_existing(struct batadv_priv *bat_priv,
* 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.
+ * Return: the new entry on success, NULL otherwise.
+ * The returned object has an increased refcounter.
*/
static struct batadv_tt_local_entry * __must_check
batadv_tt_local_create(struct net_device *mesh_iface, const u8 *addr,
@@ -1954,7 +1957,8 @@ static void batadv_tt_changes_list_free(struct batadv_priv *bat_priv)
* retrieve the orig_tt_list_entry belonging to orig_node from the
* batadv_tt_global_entry list
*
- * Return: it with an increased refcounter, NULL if not found
+ * Return: found entry on success, NULL if not found.
+ * The returned object has an increased refcounter.
*/
static struct batadv_tt_orig_list_entry * __must_check
batadv_tt_global_orig_entry_find(const struct batadv_tt_global_entry *entry,
@@ -2191,8 +2195,8 @@ batadv_tt_global_merge_flags(struct batadv_tt_global_entry *tt_global_entry,
* 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.
+ * Return: the new entry on success, NULL otherwise.
+ * The returned object has an increased refcounter.
*/
static struct batadv_tt_global_entry * __must_check
batadv_tt_global_create(const unsigned char *tt_addr, unsigned short vid,
@@ -2356,6 +2360,8 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
*
* This function assumes the caller holds rcu_read_lock().
* Return: best originator list entry or NULL on errors.
+ * The returned object has no increased refcounter and is only valid inside
+ * the RCU read-side critical section of the caller.
*/
static struct batadv_tt_orig_list_entry *
batadv_transtable_best_orig(struct batadv_priv *bat_priv,
@@ -3024,6 +3030,7 @@ _batadv_is_ap_isolated(struct batadv_tt_local_entry *tt_local_entry,
* mesh for contacting the client 'addr', NULL otherwise.
* In case of multiple originators serving the same client, the function returns
* the best one (best in terms of metric towards the destination node).
+ * The returned object has an increased refcounter.
*
* If the two clients are AP isolated the function returns NULL.
*/
@@ -3346,6 +3353,7 @@ static void batadv_tt_req_purge(struct batadv_priv *bat_priv)
*
* Return: the pointer to the new tt_req_node struct if no request
* has already been issued for this orig_node, NULL otherwise.
+ * The returned object has an increased refcounter.
*/
static struct batadv_tt_req_node * __must_check
batadv_tt_req_node_new(struct batadv_priv *bat_priv,
diff --git a/net/batman-adv/tvlv.c b/net/batman-adv/tvlv.c
index a4f7e474b424..d26f3f7754a2 100644
--- a/net/batman-adv/tvlv.c
+++ b/net/batman-adv/tvlv.c
@@ -68,6 +68,7 @@ static void batadv_tvlv_handler_put(struct batadv_tvlv_handler *tvlv_handler)
* @version: tvlv handler version to look for
*
* Return: tvlv handler if found or NULL otherwise.
+ * The returned object has an increased refcounter.
*/
static struct batadv_tvlv_handler * __must_check
batadv_tvlv_handler_get(struct batadv_priv *bat_priv, u8 type, u8 version)
@@ -131,6 +132,7 @@ static void batadv_tvlv_container_put(struct batadv_tvlv_container *tvlv)
* (tvlv.container_list_lock).
*
* Return: tvlv container if found or NULL otherwise.
+ * The returned object has an increased refcounter.
*/
static struct batadv_tvlv_container * __must_check
batadv_tvlv_container_get(struct batadv_priv *bat_priv, u8 type, u8 version)
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH net-next 02/15] batman-adv: mcast: use mla_lock also during mcast_free
2026-11-23 17:18 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-11-23 Simon Wunderlich
2026-11-23 17:18 ` [PATCH net-next 01/15] batman-adv: document refcount of returned objects Simon Wunderlich
@ 2026-11-23 17:18 ` Simon Wunderlich
2026-11-23 17:18 ` [PATCH net-next 03/15] batman-adv: mark functions inheriting critical sections Simon Wunderlich
` (12 subsequent siblings)
14 siblings, 0 replies; 31+ messages in thread
From: Simon Wunderlich @ 2026-11-23 17: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>
While it is technical ok to not hold the mcast.mla_lock when calling
batadv_mcast_mla_tt_retract() in batadv_mcast_free(), it is more clear to
always require the lock when calling batadv_mcast_mla_tt_retract(). This
strict + simple rule will later make it also possible to check the lock
requirements automatically via the LLVM/clang CONTEXT_ANALYSIS.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/multicast.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c
index 415981fe6dc6..703f61955083 100644
--- a/net/batman-adv/multicast.c
+++ b/net/batman-adv/multicast.c
@@ -2184,8 +2184,9 @@ void batadv_mcast_free(struct batadv_priv *bat_priv)
batadv_tvlv_handler_unregister(bat_priv, BATADV_TVLV_MCAST_TRACKER, 1);
batadv_tvlv_handler_unregister(bat_priv, BATADV_TVLV_MCAST, 2);
- /* safely calling outside of worker, as worker was canceled above */
+ spin_lock(&bat_priv->mcast.mla_lock);
batadv_mcast_mla_tt_retract(bat_priv, NULL);
+ spin_unlock(&bat_priv->mcast.mla_lock);
}
/**
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH net-next 03/15] batman-adv: mark functions inheriting critical sections
2026-11-23 17:18 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-11-23 Simon Wunderlich
2026-11-23 17:18 ` [PATCH net-next 01/15] batman-adv: document refcount of returned objects Simon Wunderlich
2026-11-23 17:18 ` [PATCH net-next 02/15] batman-adv: mcast: use mla_lock also during mcast_free Simon Wunderlich
@ 2026-11-23 17:18 ` Simon Wunderlich
2026-11-23 17:18 ` [PATCH net-next 04/15] batman-adv: bla: register own backbone gw when claiming for local node Simon Wunderlich
` (11 subsequent siblings)
14 siblings, 0 replies; 31+ messages in thread
From: Simon Wunderlich @ 2026-11-23 17: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>
Various functions are not taking a lock themselves but are expecting the
caller to take care of holding the lock/RCU critical section. These are a
perfect use case for Compiler-Based Context Analysis.
For now, just mark these functions as preparation for __guarded_by().
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/bat_iv_ogm.c | 3 +++
net/batman-adv/bat_v.c | 2 ++
net/batman-adv/bat_v_ogm.c | 4 ++++
net/batman-adv/fragmentation.c | 1 +
net/batman-adv/fragmentation.h | 1 +
net/batman-adv/gateway_client.c | 1 +
net/batman-adv/multicast.c | 14 ++++++++++++++
net/batman-adv/translation-table.c | 4 ++++
net/batman-adv/tvlv.c | 3 +++
9 files changed, 33 insertions(+)
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 4f60e50dbad2..7b47c253a00d 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -893,6 +893,7 @@ batadv_iv_ogm_slide_own_bcast_window(struct batadv_hard_iface *hard_iface)
* @hard_iface: interface whose ogm buffer should be transmitted
*/
static void batadv_iv_ogm_schedule_buff(struct batadv_hard_iface *hard_iface)
+ __must_hold(&hard_iface->bat_iv.ogm_buff_mutex)
{
struct batadv_priv *bat_priv = netdev_priv(hard_iface->mesh_iface);
struct batadv_ogm_buf *ogm_buff = &hard_iface->bat_iv.ogm_buff;
@@ -2108,6 +2109,7 @@ batadv_iv_ogm_orig_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
struct batadv_priv *bat_priv,
struct batadv_hard_iface *if_outgoing,
struct batadv_orig_node *orig_node, int *sub_s)
+ __must_hold_shared(RCU)
{
struct batadv_neigh_node *neigh_node_best;
struct batadv_neigh_node *neigh_node;
@@ -2336,6 +2338,7 @@ batadv_iv_ogm_neigh_dump_hardif(struct sk_buff *msg, u32 portid, u32 seq,
struct batadv_priv *bat_priv,
struct batadv_hard_iface *hard_iface,
int *idx_s)
+ __must_hold_shared(RCU)
{
struct batadv_hardif_neigh_node *hardif_neigh;
int idx = 0;
diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c
index 1214e6f9c43c..8de71a2c220c 100644
--- a/net/batman-adv/bat_v.c
+++ b/net/batman-adv/bat_v.c
@@ -213,6 +213,7 @@ batadv_v_neigh_dump_hardif(struct sk_buff *msg, u32 portid, u32 seq,
struct batadv_priv *bat_priv,
struct batadv_hard_iface *hard_iface,
int *idx_s)
+ __must_hold_shared(RCU)
{
struct batadv_hardif_neigh_node *hardif_neigh;
int idx = 0;
@@ -370,6 +371,7 @@ batadv_v_orig_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
struct batadv_priv *bat_priv,
struct batadv_hard_iface *if_outgoing,
struct batadv_orig_node *orig_node, int *sub_s)
+ __must_hold_shared(RCU)
{
struct batadv_neigh_node *neigh_node_best;
struct batadv_neigh_node *neigh_node;
diff --git a/net/batman-adv/bat_v_ogm.c b/net/batman-adv/bat_v_ogm.c
index c2ad9ac0d6e7..108bb144cd88 100644
--- a/net/batman-adv/bat_v_ogm.c
+++ b/net/batman-adv/bat_v_ogm.c
@@ -163,6 +163,7 @@ static unsigned int batadv_v_ogm_len(struct sk_buff *skb)
*/
static bool batadv_v_ogm_queue_left(struct sk_buff *skb,
struct batadv_hard_iface *hard_iface)
+ __must_hold(&hard_iface->bat_v.aggr_list.lock)
{
unsigned int max = min_t(unsigned int, hard_iface->net_dev->mtu,
BATADV_MAX_AGGREGATION_BYTES);
@@ -182,6 +183,7 @@ static bool batadv_v_ogm_queue_left(struct sk_buff *skb,
* Caller needs to hold the hard_iface->bat_v.aggr_list.lock.
*/
static void batadv_v_ogm_aggr_list_free(struct batadv_hard_iface *hard_iface)
+ __must_hold(&hard_iface->bat_v.aggr_list.lock)
{
lockdep_assert_held(&hard_iface->bat_v.aggr_list.lock);
@@ -201,6 +203,7 @@ static void batadv_v_ogm_aggr_list_free(struct batadv_hard_iface *hard_iface)
* Caller needs to hold the hard_iface->bat_v.aggr_list.lock.
*/
static void batadv_v_ogm_aggr_send(struct batadv_hard_iface *hard_iface)
+ __must_hold(&hard_iface->bat_v.aggr_list.lock)
{
unsigned int aggr_len = hard_iface->bat_v.aggr_len;
struct sk_buff *skb_aggr;
@@ -269,6 +272,7 @@ static void batadv_v_ogm_queue_on_if(struct sk_buff *skb,
* @bat_priv: the bat priv with all the mesh interface information
*/
static void batadv_v_ogm_send_meshif(struct batadv_priv *bat_priv)
+ __must_hold(&bat_priv->bat_v.ogm_buff_mutex)
{
struct batadv_ogm2_packet *ogm_packet;
struct batadv_hard_iface *hard_iface;
diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c
index 3a9c4ea860b9..1224155bc5f3 100644
--- a/net/batman-adv/fragmentation.c
+++ b/net/batman-adv/fragmentation.c
@@ -107,6 +107,7 @@ static size_t batadv_frag_size_limit(void)
*/
static bool batadv_frag_init_chain(struct batadv_frag_table_entry *chain,
u16 seqno)
+ __must_hold(&chain->lock)
{
lockdep_assert_held(&chain->lock);
diff --git a/net/batman-adv/fragmentation.h b/net/batman-adv/fragmentation.h
index 3c98a4f82286..a0b93a4c10b9 100644
--- a/net/batman-adv/fragmentation.h
+++ b/net/batman-adv/fragmentation.h
@@ -36,6 +36,7 @@ int batadv_frag_send_packet(struct sk_buff *skb,
*/
static inline bool
batadv_frag_check_entry(struct batadv_frag_table_entry *frags_entry)
+ __must_hold(&frags_entry->lock)
{
if (!hlist_empty(&frags_entry->fragment_list) &&
batadv_has_timed_out(frags_entry->timestamp, BATADV_FRAG_TIMEOUT))
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c
index 0dddcea7def9..2053516433b5 100644
--- a/net/batman-adv/gateway_client.c
+++ b/net/batman-adv/gateway_client.c
@@ -335,6 +335,7 @@ void batadv_gw_check_election(struct batadv_priv *bat_priv,
static void batadv_gw_node_add(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node,
struct batadv_tvlv_gateway_data *gateway)
+ __must_hold(&bat_priv->gw.list_lock)
{
struct batadv_gw_node *gw_node;
diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c
index 703f61955083..d3580c937438 100644
--- a/net/batman-adv/multicast.c
+++ b/net/batman-adv/multicast.c
@@ -110,6 +110,7 @@ batadv_mcast_get_bridge(struct net_device *mesh_iface)
* Return: BATADV_NO_FLAGS if present, BATADV_MCAST_WANT_NO_RTR4 otherwise.
*/
static u8 batadv_mcast_mla_rtr_flags_meshif_get_ipv4(struct net_device *dev)
+ __must_hold_shared(RCU)
{
struct in_device *in_dev = __in_dev_get_rcu(dev);
@@ -132,6 +133,7 @@ static u8 batadv_mcast_mla_rtr_flags_meshif_get_ipv4(struct net_device *dev)
*/
#if IS_ENABLED(CONFIG_IPV6_MROUTE)
static u8 batadv_mcast_mla_rtr_flags_meshif_get_ipv6(struct net_device *dev)
+ __must_hold_shared(RCU)
{
struct inet6_dev *in6_dev = __in6_dev_get(dev);
@@ -685,6 +687,7 @@ static void batadv_mcast_mla_list_free(struct hlist_head *mcast_list)
*/
static void batadv_mcast_mla_tt_retract(struct batadv_priv *bat_priv,
struct hlist_head *mcast_list)
+ __must_hold(&bat_priv->mcast.mla_lock)
{
struct batadv_hw_addr *mcast_entry;
struct hlist_node *tmp;
@@ -715,6 +718,7 @@ static void batadv_mcast_mla_tt_retract(struct batadv_priv *bat_priv,
*/
static void batadv_mcast_mla_tt_add(struct batadv_priv *bat_priv,
struct hlist_head *mcast_list)
+ __must_hold(&bat_priv->mcast.mla_lock)
{
struct batadv_hw_addr *mcast_entry;
struct hlist_node *tmp;
@@ -763,6 +767,7 @@ static void
batadv_mcast_querier_log(struct batadv_priv *bat_priv, char *str_proto,
struct batadv_mcast_querier_state *old_state,
struct batadv_mcast_querier_state *new_state)
+ __must_hold(&bat_priv->mcast.mla_lock)
{
if (!old_state->exists && new_state->exists)
batadv_info(bat_priv->mesh_iface, "%s Querier appeared\n",
@@ -808,6 +813,7 @@ batadv_mcast_querier_log(struct batadv_priv *bat_priv, char *str_proto,
static void
batadv_mcast_bridge_log(struct batadv_priv *bat_priv,
struct batadv_mcast_mla_flags *new_flags)
+ __must_hold(&bat_priv->mcast.mla_lock)
{
struct batadv_mcast_mla_flags *old_flags = &bat_priv->mcast.mla_flags;
@@ -837,6 +843,7 @@ batadv_mcast_bridge_log(struct batadv_priv *bat_priv,
* should be used to notify userspace about the change.
*/
static void batadv_mcast_flags_log(struct batadv_priv *bat_priv, u8 flags)
+ __must_hold(&bat_priv->mcast.mla_lock)
{
bool old_enabled = bat_priv->mcast.mla_flags.enabled;
u8 old_flags = bat_priv->mcast.mla_flags.tvlv_flags;
@@ -872,6 +879,7 @@ static void batadv_mcast_flags_log(struct batadv_priv *bat_priv, u8 flags)
static void
batadv_mcast_mla_flags_update(struct batadv_priv *bat_priv,
struct batadv_mcast_mla_flags *flags)
+ __must_hold(&bat_priv->mcast.mla_lock)
{
struct batadv_tvlv_mcast_data mcast_data;
@@ -1618,6 +1626,7 @@ int batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb,
static void batadv_mcast_want_unsnoop_update(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig,
u8 mcast_flags)
+ __must_hold(&orig->mcast_handler_lock)
{
struct hlist_head *head = &bat_priv->mcast.want_all_unsnoopables_list;
struct hlist_node *node = &orig->mcast_want_all_unsnoopables_node;
@@ -1663,6 +1672,7 @@ static void batadv_mcast_want_unsnoop_update(struct batadv_priv *bat_priv,
static void batadv_mcast_want_ipv4_update(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig,
u8 mcast_flags)
+ __must_hold(&orig->mcast_handler_lock)
{
struct hlist_head *head = &bat_priv->mcast.want_all_ipv4_list;
struct hlist_node *node = &orig->mcast_want_all_ipv4_node;
@@ -1708,6 +1718,7 @@ static void batadv_mcast_want_ipv4_update(struct batadv_priv *bat_priv,
static void batadv_mcast_want_ipv6_update(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig,
u8 mcast_flags)
+ __must_hold(&orig->mcast_handler_lock)
{
struct hlist_head *head = &bat_priv->mcast.want_all_ipv6_list;
struct hlist_node *node = &orig->mcast_want_all_ipv6_node;
@@ -1753,6 +1764,7 @@ static void batadv_mcast_want_ipv6_update(struct batadv_priv *bat_priv,
static void batadv_mcast_want_rtr4_update(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig,
u8 mcast_flags)
+ __must_hold(&orig->mcast_handler_lock)
{
struct hlist_head *head = &bat_priv->mcast.want_all_rtr4_list;
struct hlist_node *node = &orig->mcast_want_all_rtr4_node;
@@ -1798,6 +1810,7 @@ static void batadv_mcast_want_rtr4_update(struct batadv_priv *bat_priv,
static void batadv_mcast_want_rtr6_update(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig,
u8 mcast_flags)
+ __must_hold(&orig->mcast_handler_lock)
{
struct hlist_head *head = &bat_priv->mcast.want_all_rtr6_list;
struct hlist_node *node = &orig->mcast_want_all_rtr6_node;
@@ -1841,6 +1854,7 @@ static void batadv_mcast_want_rtr6_update(struct batadv_priv *bat_priv,
static void batadv_mcast_have_mc_ptype_update(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig,
u8 mcast_flags)
+ __must_hold(&orig->mcast_handler_lock)
{
lockdep_assert_held(&orig->mcast_handler_lock);
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 216f41387afa..1807a498d694 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -2366,6 +2366,7 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
static struct batadv_tt_orig_list_entry *
batadv_transtable_best_orig(struct batadv_priv *bat_priv,
struct batadv_tt_global_entry *tt_global_entry)
+ __must_hold_shared(RCU)
{
struct batadv_tt_orig_list_entry *best_entry = NULL;
struct batadv_algo_ops *bao = bat_priv->algo_ops;
@@ -2479,6 +2480,7 @@ static int
batadv_tt_global_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
struct batadv_priv *bat_priv,
struct batadv_tt_common_entry *common, int *sub_s)
+ __must_hold_shared(RCU)
{
struct batadv_tt_orig_list_entry *orig_entry;
struct batadv_tt_orig_list_entry *best_entry;
@@ -2619,6 +2621,7 @@ int batadv_tt_global_dump(struct sk_buff *msg, struct netlink_callback *cb)
static void
_batadv_tt_global_del_orig_entry(struct batadv_tt_global_entry *tt_global_entry,
struct batadv_tt_orig_list_entry *orig_entry)
+ __must_hold(&tt_global_entry->list_lock)
{
lockdep_assert_held(&tt_global_entry->list_lock);
@@ -4492,6 +4495,7 @@ static void batadv_tt_local_purge_pending_clients(struct batadv_priv *bat_priv)
* Caller must hold tt->commit_lock.
*/
static void batadv_tt_local_commit_changes_nolock(struct batadv_priv *bat_priv)
+ __must_hold(&bat_priv->tt.commit_lock)
{
LIST_HEAD(changes_list);
int changes_num;
diff --git a/net/batman-adv/tvlv.c b/net/batman-adv/tvlv.c
index d26f3f7754a2..aa8dbaa5ef78 100644
--- a/net/batman-adv/tvlv.c
+++ b/net/batman-adv/tvlv.c
@@ -136,6 +136,7 @@ static void batadv_tvlv_container_put(struct batadv_tvlv_container *tvlv)
*/
static struct batadv_tvlv_container * __must_check
batadv_tvlv_container_get(struct batadv_priv *bat_priv, u8 type, u8 version)
+ __must_hold(&bat_priv->tvlv.container_list_lock)
{
struct batadv_tvlv_container *tvlv = NULL;
struct batadv_tvlv_container *tvlv_tmp;
@@ -168,6 +169,7 @@ batadv_tvlv_container_get(struct batadv_priv *bat_priv, u8 type, u8 version)
* Return: size of all currently registered tvlv containers in bytes.
*/
static size_t batadv_tvlv_container_list_size(struct batadv_priv *bat_priv)
+ __must_hold(&bat_priv->tvlv.container_list_lock)
{
struct batadv_tvlv_container *tvlv;
size_t tvlv_len = 0;
@@ -193,6 +195,7 @@ static size_t batadv_tvlv_container_list_size(struct batadv_priv *bat_priv)
*/
static void batadv_tvlv_container_remove(struct batadv_priv *bat_priv,
struct batadv_tvlv_container *tvlv)
+ __must_hold(&bat_priv->tvlv.container_list_lock)
{
lockdep_assert_held(&bat_priv->tvlv.container_list_lock);
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH net-next 04/15] batman-adv: bla: register own backbone gw when claiming for local node
2026-11-23 17:18 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-11-23 Simon Wunderlich
` (2 preceding siblings ...)
2026-11-23 17:18 ` [PATCH net-next 03/15] batman-adv: mark functions inheriting critical sections Simon Wunderlich
@ 2026-11-23 17:18 ` Simon Wunderlich
2026-11-24 17:20 ` netdev-bot+sashiko
2026-11-23 17:18 ` [PATCH net-next 05/15] batman-adv: tt: unhash local entries with hlist_del_init_rcu() Simon Wunderlich
` (10 subsequent siblings)
14 siblings, 1 reply; 31+ messages in thread
From: Simon Wunderlich @ 2026-11-23 17: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>
batadv_bla_rx() claims an unclaimed client (or a client which migrated to
the local node) by calling batadv_handle_claim() with the address of the
primary interface as backbone address. batadv_handle_claim() then registers
the backbone gateway via batadv_bla_get_backbone_gw() - but always with
own_backbone set to false.
When no backbone gateway entry for the local node exists yet on this VLAN
(for example due to an earlier error), the entry is therefore created like
a foreign backbone gateway. No initial announcement is sent and the entry
doesn't enter the BATADV_BLA_BACKBONE_GW_UNSYNCED state with the startup
grace period (wait_periods and bla.num_requests). The following call of
batadv_bla_update_own_backbone_gw() finds the already existing entry and
returns early without fixing this up.
As a result, the first announcement is delayed by up to one BLA period and
multicast traffic is not held back while the local claim table isn't
synced yet.
Pass the correct own_backbone value to batadv_bla_get_backbone_gw() by
checking whether the backbone address is the address of the primary
interface.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/bug/linux-dba9d95d-5eeb-40fd-abf4-e054aee1f735
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/bridge_loop_avoidance.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index 68ff2f94cf49..3da070a087da 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -986,18 +986,22 @@ static bool batadv_handle_claim(struct batadv_priv *bat_priv,
unsigned short vid)
{
struct batadv_bla_backbone_gw *backbone_gw;
+ bool own_backbone;
+
+ own_backbone = batadv_compare_eth(backbone_addr,
+ primary_if->net_dev->dev_addr);
/* register the gateway if not yet available, and add the claim. */
backbone_gw = batadv_bla_get_backbone_gw(bat_priv, backbone_addr, vid,
- false);
+ own_backbone);
if (unlikely(!backbone_gw))
return true;
/* this must be a CLAIM frame */
batadv_bla_add_claim(bat_priv, claim_addr, vid, backbone_gw);
- if (batadv_compare_eth(backbone_addr, primary_if->net_dev->dev_addr))
+ if (own_backbone)
batadv_bla_send_claim(bat_priv, claim_addr, vid,
BATADV_CLAIM_TYPE_CLAIM);
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH net-next 05/15] batman-adv: tt: unhash local entries with hlist_del_init_rcu()
2026-11-23 17:18 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-11-23 Simon Wunderlich
` (3 preceding siblings ...)
2026-11-23 17:18 ` [PATCH net-next 04/15] batman-adv: bla: register own backbone gw when claiming for local node Simon Wunderlich
@ 2026-11-23 17:18 ` Simon Wunderlich
2026-11-23 17:18 ` [PATCH net-next 06/15] batman-adv: tt: refresh local entry in single flags_lock section Simon Wunderlich
` (9 subsequent siblings)
14 siblings, 0 replies; 31+ messages in thread
From: Simon Wunderlich @ 2026-11-23 17: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 context which looked up a local TT entry via RCU has no way to find out
whether the entry was removed from the local hash in the meantime.
hlist_del_rcu() leaves the pprev pointer of the node untouched and
hlist_unhashed() therefore still reports the entry as hashed.
Use hlist_del_init_rcu() when a local entry is unhashed by
batadv_tt_local_purge_pending_clients() and batadv_tt_local_table_free().
hlist_unhashed() can then be used under the hash bucket list_lock to check
whether an entry is still part of the local table.
batadv_tt_local_remove_now() still unhashes via batadv_hash_remove(). It is
converted when it is merged into the locked removal path.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/translation-table.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 1807a498d694..1c784a0e8c9b 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -1887,7 +1887,7 @@ static void batadv_tt_local_table_free(struct batadv_priv *bat_priv)
spin_lock_bh(list_lock);
hlist_for_each_entry_safe(tt_common_entry, node_tmp,
head, hash_entry) {
- hlist_del_rcu(&tt_common_entry->hash_entry);
+ hlist_del_init_rcu(&tt_common_entry->hash_entry);
tt_local = container_of(tt_common_entry,
struct batadv_tt_local_entry,
common);
@@ -4464,7 +4464,7 @@ static void batadv_tt_local_purge_pending_clients(struct batadv_priv *bat_priv)
tt_common->key.addr,
batadv_print_vid(tt_common->key.vid));
- hlist_del_rcu(&tt_common->hash_entry);
+ hlist_del_init_rcu(&tt_common->hash_entry);
atomic_inc(&hash->generation);
/* An entry which still carries BATADV_TT_CLIENT_NEW was
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH net-next 06/15] batman-adv: tt: refresh local entry in single flags_lock section
2026-11-23 17:18 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-11-23 Simon Wunderlich
` (4 preceding siblings ...)
2026-11-23 17:18 ` [PATCH net-next 05/15] batman-adv: tt: unhash local entries with hlist_del_init_rcu() Simon Wunderlich
@ 2026-11-23 17:18 ` Simon Wunderlich
2026-11-24 17:20 ` netdev-bot+sashiko
2026-11-23 17:18 ` [PATCH net-next 07/15] batman-adv: tt: don't remove unhashed local entries Simon Wunderlich
` (8 subsequent siblings)
14 siblings, 1 reply; 31+ messages in thread
From: Simon Wunderlich @ 2026-11-23 17: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>
batadv_tt_local_add() modifies the flags of a local entry in two steps.
batadv_tt_local_add_existing() cancels a pending removal and
batadv_tt_local_update_flags() updates the dynamic flags. Each of them has
its own flags_lock section and the ADD events are queued by
batadv_tt_local_add() with a snapshot of the flags which is taken after the
lock was released.
Merge both helpers into batadv_tt_local_refresh(). It modifies the flags
and queues the (single) ADD event in the same flags_lock section. The
announced flags are therefore always the ones which were just stored in the
entry.
The initial ADD of a new entry is requested via the announce parameter
after the entry was added to the hash.
This is a preparation for the validation of the entry under the hash bucket
list_lock, which then only needs to cover a single region.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/bug/linux-7602d89e-b2cd-43ca-8aca-c165e5d674b2
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/translation-table.c | 129 ++++++++++++-----------------
1 file changed, 55 insertions(+), 74 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 1c784a0e8c9b..63eac1e1c65e 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -903,57 +903,6 @@ 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;
- bool readded = false;
-
- WRITE_ONCE(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->key.addr,
- batadv_print_vid(common->key.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;
- readded = 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->key.addr,
- batadv_print_vid(common->key.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 readded;
-}
-
/**
* batadv_tt_local_create() - allocate and initialize a local TT entry
* @mesh_iface: netdev struct of the mesh interface
@@ -1028,27 +977,63 @@ batadv_tt_local_create(struct net_device *mesh_iface, const u8 *addr,
}
/**
- * batadv_tt_local_update_flags() - update the dynamic flags of a local entry
+ * batadv_tt_local_refresh() - refresh a local TT entry of an active client
* @bat_priv: the bat priv with all the mesh interface information
- * @tt_local: the local TT entry to update
+ * @tt_local: the local TT entry to refresh
* @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)
+ * @announce: whether an ADD event has to be queued even when no announced
+ * flag was modified
+ * @roamed_back: set to true when the client returned to its original location
*
- * Return: true if a flag announced to the other nodes was modified, false
- * otherwise.
+ * A pending removal of the entry is cancelled and its dynamic flags are
+ * updated. An ADD event is queued when @announce is set, the pending removal
+ * was cancelled or a flag announced to the other nodes was modified.
+ *
+ * All checks and modifications of the flags and the queueing of the ADD event
+ * happen in a single flags_lock section. The announced flags are therefore the
+ * ones which were just stored in the entry.
*/
-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)
+static void
+batadv_tt_local_refresh(struct batadv_priv *bat_priv,
+ struct batadv_tt_local_entry *tt_local,
+ bool iif_is_wifi, u32 mark, bool announce,
+ bool *roamed_back)
{
struct batadv_tt_common_entry *common = &tt_local->common;
u8 remote_flags;
u32 match_mark;
- bool modified;
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->key.addr,
+ batadv_print_vid(common->key.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;
+ announce = 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->key.addr,
+ batadv_print_vid(common->key.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;
+ }
+
/* store the current remote flags before altering them. This
* helps understanding is flags are changing or not
*/
@@ -1070,10 +1055,13 @@ batadv_tt_local_update_flags(struct batadv_priv *bat_priv,
else
common->flags &= ~BATADV_TT_CLIENT_ISOLA;
- modified = remote_flags ^ (common->flags & BATADV_TT_REMOTE_MASK);
- }
+ if (remote_flags ^ (common->flags & BATADV_TT_REMOTE_MASK))
+ announce = true;
- return modified;
+ if (announce)
+ __batadv_tt_local_event(bat_priv, common,
+ common->flags);
+ }
}
/**
@@ -1109,8 +1097,7 @@ 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) {
- added = batadv_tt_local_add_existing(bat_priv, tt_local,
- &roamed_back);
+ WRITE_ONCE(tt_local->last_seen, jiffies);
} else {
tt_local = batadv_tt_local_create(mesh_iface, addr, vid, iif_is_wifi);
if (!tt_local)
@@ -1130,18 +1117,12 @@ bool batadv_tt_local_add(struct net_device *mesh_iface, const u8 *addr,
added = true;
}
- /* announce the (re-)added client to the mesh */
- if (added)
- batadv_tt_local_event(bat_priv, tt_local, BATADV_NO_FLAGS);
+ /* announce the (re-)added client or its modified flags to the mesh */
+ batadv_tt_local_refresh(bat_priv, tt_local, iif_is_wifi, mark, added,
+ &roamed_back);
batadv_tt_local_add_roam(bat_priv, tt_global, roamed_back);
- /* 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 (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;
out:
batadv_tt_local_entry_put(tt_local);
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH net-next 07/15] batman-adv: tt: don't remove unhashed local entries
2026-11-23 17:18 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-11-23 Simon Wunderlich
` (5 preceding siblings ...)
2026-11-23 17:18 ` [PATCH net-next 06/15] batman-adv: tt: refresh local entry in single flags_lock section Simon Wunderlich
@ 2026-11-23 17:18 ` Simon Wunderlich
2026-11-24 17:20 ` netdev-bot+sashiko
2026-11-23 17:18 ` [PATCH net-next 08/15] batman-adv: tt: don't queue local events for unhashed entries Simon Wunderlich
` (7 subsequent siblings)
14 siblings, 1 reply; 31+ messages in thread
From: Simon Wunderlich @ 2026-11-23 17: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>
batadv_tt_local_remove() looks up the local entry via RCU only.
batadv_tt_local_purge_pending_clients() can unhash it before
batadv_tt_local_mark_removed() acquired the hash bucket list_lock. The DEL
is then queued for a client which is no longer part of the local table (and
its CRC). And it might replace the queued ADD of a new entry which was
added for the same client in the meantime.
The removal of an entry which still carries BATADV_TT_CLIENT_NEW has a
similar problem. The flag is checked by batadv_tt_local_mark_removed() but
the entry is only unhashed by batadv_tt_local_remove_now() after the
list_lock was released. batadv_tt_local_transition_new() can commit the
entry between both steps.
Merge batadv_tt_local_mark_removed() and batadv_tt_local_remove_now() into
batadv_tt_local_remove_entry() to get a single region which is protected by
the list_lock and the flags_lock of the entry:
* An entry which was unhashed after it was looked up is ignored: no DEL is
queued and BATADV_NO_FLAGS is reported as previous flags.
* An entry which still carries BATADV_TT_CLIENT_NEW is unhashed under the
list_lock which was used to check this flag.
batadv_tt_local_transition_new() can therefore no longer commit the entry
between the check and the removal. The workaround for the local table
size is no longer needed.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/bug/linux-c3e34735-5286-4ed0-9338-a77e64fef540
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/translation-table.c | 144 +++++++++++++----------------
1 file changed, 62 insertions(+), 82 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 63eac1e1c65e..7968931d5d3c 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -652,10 +652,14 @@ static u16 batadv_tt_flags_get(struct batadv_tt_common_entry *common)
*
* Only a single change per client is queued. It describes the latest state of
* the client and a new event therefore replaces an already queued one.
+ *
+ * The caller must hold the flags_lock of @common. The events of an entry are
+ * then queued in the same order in which its flags were modified.
*/
static void __batadv_tt_local_event(struct batadv_priv *bat_priv,
const struct batadv_tt_common_entry *common,
u8 flags)
+ __must_hold(&common->flags_lock)
{
struct batadv_tt_change_node *tt_change_node;
struct batadv_tt_change_node *entry;
@@ -663,6 +667,8 @@ static void __batadv_tt_local_event(struct batadv_priv *bat_priv,
bool del_op_requested;
size_t changes;
+ lockdep_assert_held(&common->flags_lock);
+
tt_change_node = kmem_cache_alloc(batadv_tt_change_cache, GFP_ATOMIC);
if (!tt_change_node)
return;
@@ -714,23 +720,6 @@ static void __batadv_tt_local_event(struct batadv_priv *bat_priv,
spin_unlock_bh(&bat_priv->tt.changes_list_lock);
}
-/**
- * batadv_tt_local_event() - store a local TT event (ADD/DEL)
- * @bat_priv: the bat priv with all the mesh interface information
- * @tt_local_entry: the TT entry involved in the event
- * @event_flags: flags to store in the event structure
- */
-static void batadv_tt_local_event(struct batadv_priv *bat_priv,
- struct batadv_tt_local_entry *tt_local_entry,
- u8 event_flags)
-{
- struct batadv_tt_common_entry *common = &tt_local_entry->common;
- u8 flags;
-
- flags = batadv_tt_flags_get(common) | event_flags;
- __batadv_tt_local_event(bat_priv, common, flags);
-}
-
/**
* batadv_tt_entries() - compute the number of entries fitting in tt_len bytes
* @tt_len: available space
@@ -1614,10 +1603,14 @@ int batadv_tt_local_dump(struct sk_buff *msg, struct netlink_callback *cb)
* entry. The entry is kept in the local table until the next TTVN increment
* so that a consistency-check response can still be answered.
*
- * Next to the flags_lock of the entry, the caller must hold the hash bucket
- * list_lock of @tt_local_entry. Otherwise
- * batadv_tt_local_purge_pending_clients() could remove the entry before its
- * change was queued.
+ * The caller must hold the flags_lock of @tt_local_entry and must not have
+ * released it since it checked that the entry has to be removed. Both the
+ * queue-then-mark order and this single flags_lock section are required.
+ *
+ * The caller must also hold the hash bucket list_lock of @tt_local_entry and
+ * must have ensured that the entry is still part of the local table. A DEL for
+ * an entry which was already purged could otherwise cancel the ADD of a new
+ * entry for the same client.
*/
static void
batadv_tt_local_set_pending(struct batadv_priv *bat_priv,
@@ -1643,31 +1636,39 @@ batadv_tt_local_set_pending(struct batadv_priv *bat_priv,
}
/**
- * batadv_tt_local_mark_removed() - mark a local entry as removed and queue DEL
+ * batadv_tt_local_remove_entry() - logically remove a local entry
* @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 to remove
* @message: message to append to the log on deletion
* @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
+ * @curr_flags: pointer to store the flags of the entry before it was removed
*
- * An already announced entry is marked as BATADV_TT_CLIENT_PENDING and the
- * (roamed) DEL change is queued. Both happen under the hash bucket list_lock
- * of the entry to prevent concurrent batadv_tt_local_purge_pending_clients()
- * from removing the entry and batadv_tt_local_transition_new() from clearing
- * BATADV_TT_CLIENT_NEW after it was checked.
+ * For an already announced entry, the (roamed) DEL change is queued and the
+ * entry is marked as BATADV_TT_CLIENT_PENDING by batadv_tt_local_set_pending().
+ * It stays in the local table until the next ttvn increment.
*
- * 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.
+ * An entry which still carries BATADV_TT_CLIENT_NEW was added right after the
+ * last ttvn increment and was not (yet) announced. It is therefore removed
+ * from the local table immediately.
+ *
+ * An entry which was already removed from the local table after it was looked
+ * up is ignored and BATADV_NO_FLAGS is stored in @curr_flags.
+ *
+ * All checks and modifications happen under the hash bucket list_lock and the
+ * flags_lock of the entry. This prevents a concurrent
+ * batadv_tt_local_purge_pending_clients() from removing the entry,
+ * batadv_tt_local_transition_new() from clearing BATADV_TT_CLIENT_NEW and
+ * batadv_tt_local_refresh() from modifying the entry after it was checked.
*/
-static bool
-batadv_tt_local_mark_removed(struct batadv_priv *bat_priv,
+static void
+batadv_tt_local_remove_entry(struct batadv_priv *bat_priv,
struct batadv_tt_local_entry *tt_local_entry,
const char *message, bool roaming, u16 *curr_flags)
{
spinlock_t *list_lock; /* protects write access to the hash lists */
struct batadv_tt_common_entry *common = &tt_local_entry->common;
struct batadv_hashtable *hash = bat_priv->tt.local_hash;
- bool pending = false;
+ bool unhashed = false;
u16 flags;
u32 i;
@@ -1676,6 +1677,12 @@ batadv_tt_local_mark_removed(struct batadv_priv *bat_priv,
spin_lock_bh(list_lock);
+ if (hlist_unhashed(&common->hash_entry)) {
+ *curr_flags = BATADV_NO_FLAGS;
+ spin_unlock_bh(list_lock);
+ return;
+ }
+
scoped_guard(spinlock_bh, &common->flags_lock) {
*curr_flags = common->flags;
@@ -1686,8 +1693,23 @@ batadv_tt_local_mark_removed(struct batadv_priv *bat_priv,
if (roaming)
common->flags |= BATADV_TT_CLIENT_ROAM;
- if (common->flags & BATADV_TT_CLIENT_NEW)
+ if (common->flags & BATADV_TT_CLIENT_NEW) {
+ batadv_dbg(BATADV_DBG_TT, bat_priv,
+ "Deleting local tt entry (%pM, vid: %d): %s\n",
+ common->key.addr,
+ batadv_print_vid(common->key.vid), message);
+
+ hlist_del_init_rcu(&common->hash_entry);
+ atomic_inc(&hash->generation);
+
+ /* The entry was never announced and was therefore
+ * never counted in the local table size.
+ */
+ __batadv_tt_local_event(bat_priv, common,
+ common->flags | BATADV_TT_CLIENT_DEL);
+ unhashed = true;
break;
+ }
flags = BATADV_TT_CLIENT_DEL;
if (roaming)
@@ -1695,51 +1717,13 @@ batadv_tt_local_mark_removed(struct batadv_priv *bat_priv,
batadv_tt_local_set_pending(bat_priv, tt_local_entry, flags,
message);
- pending = true;
}
spin_unlock_bh(list_lock);
- return pending;
-}
-
-/**
- * batadv_tt_local_remove_now() - purge a local entry which was not (yet) 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 not (yet)
- * sent to the other nodes. It can therefore be dropped from the local table
- * without waiting for the next ttvn increment.
- *
- * If it was still announced by a parallel context before it was removed from
- * the hash, then the local TT size adjustment will be handled automatically.
- */
-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;
-
- /* 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->key);
- if (!tt_removed_node)
- return;
-
- batadv_tt_local_event(bat_priv, tt_local_entry, BATADV_TT_CLIENT_DEL);
-
- /* 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->key.vid);
-
- /* drop reference of remove hash entry */
- batadv_tt_local_entry_put(tt_local_entry);
+ /* drop reference of removed hash entry */
+ if (unhashed)
+ batadv_tt_local_entry_put(tt_local_entry);
}
/**
@@ -1763,12 +1747,8 @@ u16 batadv_tt_local_remove(struct batadv_priv *bat_priv, const u8 *addr,
if (!tt_local_entry)
return BATADV_NO_FLAGS;
- /* if this client has been added right now, it is possible to
- * immediately purge it
- */
- if (!batadv_tt_local_mark_removed(bat_priv, tt_local_entry, message,
- roaming, &curr_flags))
- batadv_tt_local_remove_now(bat_priv, tt_local_entry);
+ batadv_tt_local_remove_entry(bat_priv, tt_local_entry, message,
+ roaming, &curr_flags);
batadv_tt_local_entry_put(tt_local_entry);
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH net-next 08/15] batman-adv: tt: don't queue local events for unhashed entries
2026-11-23 17:18 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-11-23 Simon Wunderlich
` (6 preceding siblings ...)
2026-11-23 17:18 ` [PATCH net-next 07/15] batman-adv: tt: don't remove unhashed local entries Simon Wunderlich
@ 2026-11-23 17:18 ` Simon Wunderlich
2026-11-23 17:18 ` [PATCH net-next 09/15] batman-adv: tt: remove unannounced local entries via pending state Simon Wunderlich
` (6 subsequent siblings)
14 siblings, 0 replies; 31+ messages in thread
From: Simon Wunderlich @ 2026-11-23 17: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>
batadv_tt_local_add() looks up the local entry via RCU only.
batadv_tt_local_purge_pending_clients() or batadv_tt_local_remove() can
unhash it before the entry is modified and an event is queued for it:
CPU0 CPU1
/* DEL#1 queued, PENDING set */
batadv_tt_local_hash_find()
batadv_tt_local_commit_changes()
..._purge_pending_clients()
hlist_del_rcu(&...->hash_entry);
/* DEL#1 announced */
batadv_tt_local_refresh()
flags &= ~..._PENDING;
/* ADD queued for unhashed entry */
The queued event will then be announced for a client which is not part
anymore of the table (+ its CRC). A full table request in this and similar
scenarios is required to fix the inconsistency.
Only the hash bucket list_lock can ensure that an entry is still part of
the local table. batadv_tt_local_refresh() therefore checks with
hlist_unhashed() under this lock whether the entry is still hashed. An
entry which is no longer hashed is not refreshed and batadv_tt_local_add()
creates a new entry instead. batadv_tt_local_insert() adds this entry to
the hash and queues its initial ADD under the same list_lock. Otherwise
batadv_tt_local_commit_changes() could count the entry in the CRC of a ttvn
before its ADD was queued or batadv_tt_local_remove() could unhash it
before the ADD was queued.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260930094558.3723766-2-sw%40simonwunderlich.de?part=7
Closes: https://sashiko.dev/#/bug/linux-557fd001-5041-4b0a-a2ea-cdf22526ee84
Closes: https://sashiko.dev/#/bug/linux-c7f17a4b-620f-4307-a058-be6523cc6fa2
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/translation-table.c | 156 ++++++++++++++++++++++++-----
1 file changed, 129 insertions(+), 27 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 7968931d5d3c..2828e362640a 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -966,7 +966,7 @@ batadv_tt_local_create(struct net_device *mesh_iface, const u8 *addr,
}
/**
- * batadv_tt_local_refresh() - refresh a local TT entry of an active client
+ * batadv_tt_local_refresh_locked() - refresh a hashed local TT entry
* @bat_priv: the bat priv with all the mesh interface information
* @tt_local: the local TT entry to refresh
* @iif_is_wifi: whether the client is connected via a wifi interface
@@ -980,19 +980,23 @@ batadv_tt_local_create(struct net_device *mesh_iface, const u8 *addr,
* updated. An ADD event is queued when @announce is set, the pending removal
* was cancelled or a flag announced to the other nodes was modified.
*
- * All checks and modifications of the flags and the queueing of the ADD event
- * happen in a single flags_lock section. The announced flags are therefore the
- * ones which were just stored in the entry.
+ * The caller must hold the hash bucket list_lock of the entry and must have
+ * checked that the entry is still part of the local table.
*/
static void
-batadv_tt_local_refresh(struct batadv_priv *bat_priv,
- struct batadv_tt_local_entry *tt_local,
- bool iif_is_wifi, u32 mark, bool announce,
- bool *roamed_back)
+batadv_tt_local_refresh_locked(struct batadv_priv *bat_priv,
+ struct batadv_tt_local_entry *tt_local,
+ bool iif_is_wifi, u32 mark, bool announce,
+ bool *roamed_back)
{
struct batadv_tt_common_entry *common = &tt_local->common;
+ struct batadv_hashtable *hash = bat_priv->tt.local_hash;
u8 remote_flags;
u32 match_mark;
+ u32 i;
+
+ i = batadv_choose_tt(&common->key, hash->size);
+ lockdep_assert_held(&hash->list_locks[i]);
scoped_guard(spinlock_bh, &common->flags_lock) {
if (common->flags & BATADV_TT_CLIENT_PENDING) {
@@ -1053,6 +1057,109 @@ batadv_tt_local_refresh(struct batadv_priv *bat_priv,
}
}
+/**
+ * batadv_tt_local_refresh() - refresh a local TT entry of an active client
+ * @bat_priv: the bat priv with all the mesh interface information
+ * @tt_local: the local TT entry to refresh
+ * @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)
+ * @roamed_back: set to true when the client returned to its original location
+ *
+ * See batadv_tt_local_refresh_locked() for the actual refresh.
+ *
+ * Return: 0 if the entry was refreshed, -ENOENT if the entry is no longer part
+ * of the local table.
+ */
+static int
+batadv_tt_local_refresh(struct batadv_priv *bat_priv,
+ struct batadv_tt_local_entry *tt_local,
+ bool iif_is_wifi, u32 mark, bool *roamed_back)
+{
+ spinlock_t *list_lock; /* protects write access to the hash lists */
+ struct batadv_tt_common_entry *common = &tt_local->common;
+ struct batadv_hashtable *hash = bat_priv->tt.local_hash;
+ u32 i;
+
+ i = batadv_choose_tt(&common->key, hash->size);
+ list_lock = &hash->list_locks[i];
+
+ WRITE_ONCE(tt_local->last_seen, jiffies);
+
+ spin_lock_bh(list_lock);
+
+ /* the entry was removed from the local table after it was looked up */
+ if (hlist_unhashed(&common->hash_entry)) {
+ spin_unlock_bh(list_lock);
+ return -ENOENT;
+ }
+
+ batadv_tt_local_refresh_locked(bat_priv, tt_local, iif_is_wifi, mark,
+ false, roamed_back);
+
+ spin_unlock_bh(list_lock);
+
+ return 0;
+}
+
+/**
+ * batadv_tt_local_insert() - add a new local TT entry to the local table
+ * @bat_priv: the bat priv with all the mesh interface information
+ * @tt_local: the new local TT entry (not yet hashed)
+ * @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)
+ * @roamed_back: set to true when the client returned to its original location
+ *
+ * The entry is inserted into the local hash and its initial ADD event is
+ * queued under the same hash bucket list_lock. A concurrent
+ * batadv_tt_local_commit_changes() can therefore not count the entry in the
+ * CRC of a ttvn before its ADD was queued and a concurrent
+ * batadv_tt_local_remove() can not unhash it before the ADD was queued.
+ *
+ * Return: true if the entry was added, false if the client already has an
+ * entry in the local table.
+ */
+static bool batadv_tt_local_insert(struct batadv_priv *bat_priv,
+ struct batadv_tt_local_entry *tt_local,
+ bool iif_is_wifi, u32 mark,
+ bool *roamed_back)
+{
+ spinlock_t *list_lock; /* protects write access to the hash lists */
+ struct batadv_tt_common_entry *common = &tt_local->common;
+ struct batadv_hashtable *hash = bat_priv->tt.local_hash;
+ struct hlist_head *head;
+ struct hlist_node *node;
+ u32 i;
+
+ i = batadv_choose_tt(&common->key, hash->size);
+ head = &hash->table[i];
+ list_lock = &hash->list_locks[i];
+
+ spin_lock_bh(list_lock);
+
+ hlist_for_each(node, head) {
+ if (!batadv_compare_tt(node, &common->key))
+ continue;
+
+ spin_unlock_bh(list_lock);
+ return false;
+ }
+
+ /* reference for the hash */
+ kref_get(&common->refcount);
+ hlist_add_head_rcu(&common->hash_entry, head);
+ atomic_inc(&hash->generation);
+
+ /* announce the added client to the mesh */
+ batadv_tt_local_refresh_locked(bat_priv, tt_local, iif_is_wifi, mark,
+ true, roamed_back);
+
+ spin_unlock_bh(list_lock);
+
+ return true;
+}
+
/**
* batadv_tt_local_add() - add a new client to the local table or update an
* existing client
@@ -1073,10 +1180,9 @@ 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;
- int hash_added;
+ int err;
iif_is_wifi = batadv_tt_iif_is_wifi(dev_net(mesh_iface), ifindex);
@@ -1086,30 +1192,26 @@ 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) {
- WRITE_ONCE(tt_local->last_seen, jiffies);
- } else {
+ err = batadv_tt_local_refresh(bat_priv, tt_local, iif_is_wifi,
+ mark, &roamed_back);
+ if (err == -ENOENT) {
+ /* stale entry which has to be replaced by a new one */
+ batadv_tt_local_entry_put(tt_local);
+ tt_local = NULL;
+ }
+ }
+
+ if (!tt_local) {
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.key,
- &tt_local->common.hash_entry);
-
- if (unlikely(hash_added != 0)) {
- /* remove the reference for the hash */
- batadv_tt_local_entry_put(tt_local);
+ if (unlikely(!batadv_tt_local_insert(bat_priv, tt_local,
+ iif_is_wifi, mark,
+ &roamed_back)))
goto out;
- }
-
- added = true;
}
- /* announce the (re-)added client or its modified flags to the mesh */
- batadv_tt_local_refresh(bat_priv, tt_local, iif_is_wifi, mark, added,
- &roamed_back);
-
batadv_tt_local_add_roam(bat_priv, tt_global, roamed_back);
ret = true;
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH net-next 09/15] batman-adv: tt: remove unannounced local entries via pending state
2026-11-23 17:18 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-11-23 Simon Wunderlich
` (7 preceding siblings ...)
2026-11-23 17:18 ` [PATCH net-next 08/15] batman-adv: tt: don't queue local events for unhashed entries Simon Wunderlich
@ 2026-11-23 17:18 ` Simon Wunderlich
2026-11-23 17:18 ` [PATCH net-next 10/15] batman-adv: tt: keep local entry unchanged when ADD can't be queued Simon Wunderlich
` (5 subsequent siblings)
14 siblings, 0 replies; 31+ messages in thread
From: Simon Wunderlich @ 2026-11-23 17: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_remove_entry() unhashes an entry which still carries
BATADV_TT_CLIENT_NEW immediately because it was not yet announced to the
other nodes. But the flag is only cleared at the end of the commit. The ADD
of the entry might therefore already have been taken for the next TTVN when
the flag is checked.
Handle such an entry like an already announced one: queue the DEL and mark
the entry as BATADV_TT_CLIENT_PENDING. It is then removed from the local
table when the pending entries are purged by the next commit.
batadv_tt_local_purge_pending_clients() already takes care of not
uncounting an entry which was never counted.
This also leaves the commit as the only place which finishes the removal of
a local entry. A follow-up change relies on this to apply exactly the
announced changes to the local table.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/translation-table.c | 35 +++++-------------------------
1 file changed, 5 insertions(+), 30 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 2828e362640a..977f62c88da7 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -1745,13 +1745,11 @@ batadv_tt_local_set_pending(struct batadv_priv *bat_priv,
* @roaming: true if the deletion is due to a roaming event
* @curr_flags: pointer to store the flags of the entry before it was removed
*
- * For an already announced entry, the (roamed) DEL change is queued and the
- * entry is marked as BATADV_TT_CLIENT_PENDING by batadv_tt_local_set_pending().
- * It stays in the local table until the next ttvn increment.
- *
- * An entry which still carries BATADV_TT_CLIENT_NEW was added right after the
- * last ttvn increment and was not (yet) announced. It is therefore removed
- * from the local table immediately.
+ * The (roamed) DEL change is queued and the entry is marked as
+ * BATADV_TT_CLIENT_PENDING by batadv_tt_local_set_pending(). It stays in the
+ * local table until the DEL is committed with the next ttvn increment. This
+ * also applies to an entry which still carries BATADV_TT_CLIENT_NEW because its
+ * ADD might already have been taken for the next ttvn.
*
* An entry which was already removed from the local table after it was looked
* up is ignored and BATADV_NO_FLAGS is stored in @curr_flags.
@@ -1770,7 +1768,6 @@ batadv_tt_local_remove_entry(struct batadv_priv *bat_priv,
spinlock_t *list_lock; /* protects write access to the hash lists */
struct batadv_tt_common_entry *common = &tt_local_entry->common;
struct batadv_hashtable *hash = bat_priv->tt.local_hash;
- bool unhashed = false;
u16 flags;
u32 i;
@@ -1795,24 +1792,6 @@ batadv_tt_local_remove_entry(struct batadv_priv *bat_priv,
if (roaming)
common->flags |= BATADV_TT_CLIENT_ROAM;
- if (common->flags & BATADV_TT_CLIENT_NEW) {
- batadv_dbg(BATADV_DBG_TT, bat_priv,
- "Deleting local tt entry (%pM, vid: %d): %s\n",
- common->key.addr,
- batadv_print_vid(common->key.vid), message);
-
- hlist_del_init_rcu(&common->hash_entry);
- atomic_inc(&hash->generation);
-
- /* The entry was never announced and was therefore
- * never counted in the local table size.
- */
- __batadv_tt_local_event(bat_priv, common,
- common->flags | BATADV_TT_CLIENT_DEL);
- unhashed = true;
- break;
- }
-
flags = BATADV_TT_CLIENT_DEL;
if (roaming)
flags |= BATADV_TT_CLIENT_ROAM;
@@ -1822,10 +1801,6 @@ batadv_tt_local_remove_entry(struct batadv_priv *bat_priv,
}
spin_unlock_bh(list_lock);
-
- /* drop reference of removed hash entry */
- if (unhashed)
- batadv_tt_local_entry_put(tt_local_entry);
}
/**
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH net-next 10/15] batman-adv: tt: keep local entry unchanged when ADD can't be queued
2026-11-23 17:18 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-11-23 Simon Wunderlich
` (8 preceding siblings ...)
2026-11-23 17:18 ` [PATCH net-next 09/15] batman-adv: tt: remove unannounced local entries via pending state Simon Wunderlich
@ 2026-11-23 17:18 ` Simon Wunderlich
2026-11-24 17:20 ` netdev-bot+sashiko
2026-11-23 17:18 ` [PATCH net-next 11/15] batman-adv: tt: requeue DEL of pending local entry after failed allocation Simon Wunderlich
` (4 subsequent siblings)
14 siblings, 1 reply; 31+ messages in thread
From: Simon Wunderlich @ 2026-11-23 17: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 allocation of a local TT change can fail. __batadv_tt_local_event()
drops the event silently in this case. But the local entry was already
modified at this point: a new entry was inserted, the removal of a pending
entry was cancelled or the flags of the entry were changed. The other nodes
are never informed about this new state and the local table no longer
matches the announced one.
Let __batadv_tt_local_event() report whether the event was stored and only
modify the entry afterwards:
* batadv_tt_local_refresh_locked() prepares the new flags, queues the ADD
and only then stores the flags in the entry. The entry stays untouched
when the ADD could not be queued and the refresh is retried with the next
packet of the client.
* batadv_tt_local_insert() queues the initial ADD before it inserts the
entry in the hash. Both still happen under the same hash bucket
list_lock. A new entry is not inserted when its ADD could not be queued
and batadv_tt_local_add() fails.
* batadv_tt_local_refresh() reports the failed refresh to
batadv_tt_local_add() which fails too. The caller would otherwise
continue with an entry which is still in its previous state: the
multicast code would stop to retry the add of a listener whose entry is
still pending to be removed and batadv_interface_tx() would forward a
packet of a client with outdated flags. A client which came back is also
still marked as BATADV_TT_CLIENT_ROAM. batadv_tt_local_add_roam() is
therefore skipped. It would otherwise treat the client as newly roamed
instead of cancelling the roaming.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/translation-table.c | 139 ++++++++++++++++++++---------
1 file changed, 98 insertions(+), 41 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 977f62c88da7..c94b292a1c4a 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -653,10 +653,18 @@ static u16 batadv_tt_flags_get(struct batadv_tt_common_entry *common)
* Only a single change per client is queued. It describes the latest state of
* the client and a new event therefore replaces an already queued one.
*
+ * The other nodes only learn about the modification of a local entry through
+ * the queued change. The caller must therefore not modify the entry in a way
+ * which depends on this change (e.g. hash it as BATADV_TT_CLIENT_NEW or mark it
+ * as BATADV_TT_CLIENT_PENDING) when the event could not be stored.
+ *
* The caller must hold the flags_lock of @common. The events of an entry are
* then queued in the same order in which its flags were modified.
+ *
+ * Return: true if the event was stored, false if the memory for it could not
+ * be allocated.
*/
-static void __batadv_tt_local_event(struct batadv_priv *bat_priv,
+static bool __batadv_tt_local_event(struct batadv_priv *bat_priv,
const struct batadv_tt_common_entry *common,
u8 flags)
__must_hold(&common->flags_lock)
@@ -671,7 +679,7 @@ static void __batadv_tt_local_event(struct batadv_priv *bat_priv,
tt_change_node = kmem_cache_alloc(batadv_tt_change_cache, GFP_ATOMIC);
if (!tt_change_node)
- return;
+ return false;
memset(tt_change_node->change.reserved, 0,
sizeof(tt_change_node->change.reserved));
@@ -718,6 +726,8 @@ static void __batadv_tt_local_event(struct batadv_priv *bat_priv,
update_changes:
WRITE_ONCE(bat_priv->tt.local_changes, changes);
spin_unlock_bh(&bat_priv->tt.changes_list_lock);
+
+ return true;
}
/**
@@ -966,7 +976,7 @@ batadv_tt_local_create(struct net_device *mesh_iface, const u8 *addr,
}
/**
- * batadv_tt_local_refresh_locked() - refresh a hashed local TT entry
+ * batadv_tt_local_refresh_locked() - refresh a local TT entry
* @bat_priv: the bat priv with all the mesh interface information
* @tt_local: the local TT entry to refresh
* @iif_is_wifi: whether the client is connected via a wifi interface
@@ -980,10 +990,19 @@ batadv_tt_local_create(struct net_device *mesh_iface, const u8 *addr,
* updated. An ADD event is queued when @announce is set, the pending removal
* was cancelled or a flag announced to the other nodes was modified.
*
+ * The entry is left untouched when the ADD event could not be queued. The
+ * other nodes would otherwise never be informed about the new state. An already
+ * hashed entry is simply refreshed again when the next packet of the client is
+ * received.
+ *
* The caller must hold the hash bucket list_lock of the entry and must have
- * checked that the entry is still part of the local table.
+ * checked that the entry is still part of the local table or is inserting it
+ * under this list_lock.
+ *
+ * Return: true if the entry was refreshed, false if the required ADD event
+ * could not be queued.
*/
-static void
+static bool
batadv_tt_local_refresh_locked(struct batadv_priv *bat_priv,
struct batadv_tt_local_entry *tt_local,
bool iif_is_wifi, u32 mark, bool announce,
@@ -991,51 +1010,49 @@ batadv_tt_local_refresh_locked(struct batadv_priv *bat_priv,
{
struct batadv_tt_common_entry *common = &tt_local->common;
struct batadv_hashtable *hash = bat_priv->tt.local_hash;
+ bool readded = false;
+ bool roamed = false;
u8 remote_flags;
u32 match_mark;
+ u16 flags;
u32 i;
i = batadv_choose_tt(&common->key, hash->size);
lockdep_assert_held(&hash->list_locks[i]);
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->key.addr,
- batadv_print_vid(common->key.vid));
+ flags = common->flags;
+
+ if (flags & BATADV_TT_CLIENT_PENDING) {
/* 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;
+ flags &= ~BATADV_TT_CLIENT_PENDING;
+ readded = true;
announce = 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->key.addr,
- batadv_print_vid(common->key.vid));
+ if (flags & BATADV_TT_CLIENT_ROAM) {
/* 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;
+ flags &= ~BATADV_TT_CLIENT_ROAM;
+ roamed = true;
}
/* 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;
+ remote_flags = flags & BATADV_TT_REMOTE_MASK;
if (iif_is_wifi)
- common->flags |= BATADV_TT_CLIENT_WIFI;
+ flags |= BATADV_TT_CLIENT_WIFI;
else
- common->flags &= ~BATADV_TT_CLIENT_WIFI;
+ 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
@@ -1044,17 +1061,38 @@ batadv_tt_local_refresh_locked(struct batadv_priv *bat_priv,
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;
+ flags |= BATADV_TT_CLIENT_ISOLA;
else
- common->flags &= ~BATADV_TT_CLIENT_ISOLA;
+ flags &= ~BATADV_TT_CLIENT_ISOLA;
- if (remote_flags ^ (common->flags & BATADV_TT_REMOTE_MASK))
+ if (remote_flags ^ (flags & BATADV_TT_REMOTE_MASK))
announce = true;
- if (announce)
- __batadv_tt_local_event(bat_priv, common,
- common->flags);
+ /* queue-then-modify: the new state must not become visible
+ * without a queued change which commits/announces it
+ */
+ if (announce &&
+ !__batadv_tt_local_event(bat_priv, common, flags))
+ return false;
+
+ common->flags = flags;
}
+
+ if (readded)
+ batadv_dbg(BATADV_DBG_TT, bat_priv,
+ "Re-adding pending client %pM (vid: %d)\n",
+ common->key.addr,
+ batadv_print_vid(common->key.vid));
+
+ if (roamed) {
+ batadv_dbg(BATADV_DBG_TT, bat_priv,
+ "Roaming client %pM (vid: %d) came back to its original location\n",
+ common->key.addr,
+ batadv_print_vid(common->key.vid));
+ *roamed_back = true;
+ }
+
+ return true;
}
/**
@@ -1068,8 +1106,11 @@ batadv_tt_local_refresh_locked(struct batadv_priv *bat_priv,
*
* See batadv_tt_local_refresh_locked() for the actual refresh.
*
+ * An entry whose modification could not be announced stays in its previous
+ * state. The refresh is then retried with the next packet of the client.
+ *
* Return: 0 if the entry was refreshed, -ENOENT if the entry is no longer part
- * of the local table.
+ * of the local table, -ENOMEM if the required ADD event could not be queued.
*/
static int
batadv_tt_local_refresh(struct batadv_priv *bat_priv,
@@ -1079,6 +1120,7 @@ batadv_tt_local_refresh(struct batadv_priv *bat_priv,
spinlock_t *list_lock; /* protects write access to the hash lists */
struct batadv_tt_common_entry *common = &tt_local->common;
struct batadv_hashtable *hash = bat_priv->tt.local_hash;
+ int ret = 0;
u32 i;
i = batadv_choose_tt(&common->key, hash->size);
@@ -1094,12 +1136,13 @@ batadv_tt_local_refresh(struct batadv_priv *bat_priv,
return -ENOENT;
}
- batadv_tt_local_refresh_locked(bat_priv, tt_local, iif_is_wifi, mark,
- false, roamed_back);
+ if (!batadv_tt_local_refresh_locked(bat_priv, tt_local, iif_is_wifi,
+ mark, false, roamed_back))
+ ret = -ENOMEM;
spin_unlock_bh(list_lock);
- return 0;
+ return ret;
}
/**
@@ -1111,14 +1154,17 @@ batadv_tt_local_refresh(struct batadv_priv *bat_priv,
* any)
* @roamed_back: set to true when the client returned to its original location
*
- * The entry is inserted into the local hash and its initial ADD event is
- * queued under the same hash bucket list_lock. A concurrent
- * batadv_tt_local_commit_changes() can therefore not count the entry in the
- * CRC of a ttvn before its ADD was queued and a concurrent
- * batadv_tt_local_remove() can not unhash it before the ADD was queued.
+ * The initial ADD event is queued and the entry is inserted into the local
+ * hash under the same hash bucket list_lock. A concurrent
+ * batadv_tt_local_commit_changes() can therefore not commit the entry without
+ * its ADD (or the ADD without the entry) and a concurrent
+ * batadv_tt_local_remove() can not unhash the entry before the ADD was queued.
+ *
+ * The entry is not inserted when its ADD could not be queued. The other nodes
+ * would otherwise never be informed about the new client.
*
* Return: true if the entry was added, false if the client already has an
- * entry in the local table.
+ * entry in the local table or the ADD event could not be queued.
*/
static bool batadv_tt_local_insert(struct batadv_priv *bat_priv,
struct batadv_tt_local_entry *tt_local,
@@ -1146,15 +1192,18 @@ static bool batadv_tt_local_insert(struct batadv_priv *bat_priv,
return false;
}
+ /* announce the added client to the mesh */
+ if (!batadv_tt_local_refresh_locked(bat_priv, tt_local, iif_is_wifi,
+ mark, true, roamed_back)) {
+ spin_unlock_bh(list_lock);
+ return false;
+ }
+
/* reference for the hash */
kref_get(&common->refcount);
hlist_add_head_rcu(&common->hash_entry, head);
atomic_inc(&hash->generation);
- /* announce the added client to the mesh */
- batadv_tt_local_refresh_locked(bat_priv, tt_local, iif_is_wifi, mark,
- true, roamed_back);
-
spin_unlock_bh(list_lock);
return true;
@@ -1198,6 +1247,14 @@ bool batadv_tt_local_add(struct net_device *mesh_iface, const u8 *addr,
/* stale entry which has to be replaced by a new one */
batadv_tt_local_entry_put(tt_local);
tt_local = NULL;
+ } else if (err) {
+ /* The entry is still in its previous state (e.g.
+ * pending to be removed). The caller must not treat
+ * the client as added and the roaming is handled
+ * together with the refresh which is retried with the
+ * next packet of the client.
+ */
+ goto out;
}
}
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH net-next 11/15] batman-adv: tt: requeue DEL of pending local entry after failed allocation
2026-11-23 17:18 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-11-23 Simon Wunderlich
` (9 preceding siblings ...)
2026-11-23 17:18 ` [PATCH net-next 10/15] batman-adv: tt: keep local entry unchanged when ADD can't be queued Simon Wunderlich
@ 2026-11-23 17:18 ` Simon Wunderlich
2026-11-24 17:20 ` netdev-bot+sashiko
2026-11-23 17:18 ` [PATCH net-next 12/15] batman-adv: tt: extract removal of pending local entry Simon Wunderlich
` (3 subsequent siblings)
14 siblings, 1 reply; 31+ messages in thread
From: Simon Wunderlich @ 2026-11-23 17: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_set_pending() marks a local entry as
BATADV_TT_CLIENT_PENDING even when the DEL could not be queued because the
allocation of the change failed. The other nodes are then never informed
about the removal of the client. And nothing queues the DEL again because
an already pending entry is skipped by the purge.
The removal can also not simply be rejected. The callers of
batadv_tt_local_remove() don't retry it and a BATADV_TT_CLIENT_NOPURGE
entry would never be removed by the purge. And a roamed client must be
marked as BATADV_TT_CLIENT_ROAM right away to get its packets rerouted to
the new originator.
The entry is therefore still marked as before. But a pending entry whose
DEL could not be queued is now marked as del_unqueued:
* batadv_tt_local_purge_list() queues the DEL of such an entry again. This
is retried every BATADV_TT_WORK_PERIOD until it succeeds.
* batadv_tt_local_purge_pending_clients() keeps such an entry in the local
table until its DEL was queued. The local table then still matches the
table which was announced to the other nodes.
* batadv_tt_local_refresh_locked() drops the mark when the client was
detected again and the ADD for it was queued.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/translation-table.c | 61 ++++++++++++++++++++++++------
net/batman-adv/types.h | 7 ++++
2 files changed, 57 insertions(+), 11 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index c94b292a1c4a..0c5e21f3ba75 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -655,8 +655,10 @@ static u16 batadv_tt_flags_get(struct batadv_tt_common_entry *common)
*
* The other nodes only learn about the modification of a local entry through
* the queued change. The caller must therefore not modify the entry in a way
- * which depends on this change (e.g. hash it as BATADV_TT_CLIENT_NEW or mark it
- * as BATADV_TT_CLIENT_PENDING) when the event could not be stored.
+ * which depends on this change (e.g. hash it as BATADV_TT_CLIENT_NEW) when the
+ * event could not be stored. The only exception is the DEL of
+ * batadv_tt_local_set_pending(). Its entry is marked as del_unqueued to get the
+ * DEL requeued by batadv_tt_local_purge_list().
*
* The caller must hold the flags_lock of @common. The events of an entry are
* then queued in the same order in which its flags were modified.
@@ -955,6 +957,7 @@ batadv_tt_local_create(struct net_device *mesh_iface, const u8 *addr,
kref_init(&tt_local->common.refcount);
last_seen = jiffies;
WRITE_ONCE(tt_local->last_seen, last_seen);
+ tt_local->del_unqueued = false;
tt_local->common.added_at = last_seen;
tt_local->vlan = vlan;
spin_lock_init(&tt_local->common.flags_lock);
@@ -1076,6 +1079,12 @@ batadv_tt_local_refresh_locked(struct batadv_priv *bat_priv,
return false;
common->flags = flags;
+
+ /* the queued ADD replaces the DEL which still had to be
+ * queued for the no longer pending entry
+ */
+ if (readded)
+ tt_local->del_unqueued = false;
}
if (readded)
@@ -1762,6 +1771,11 @@ int batadv_tt_local_dump(struct sk_buff *msg, struct netlink_callback *cb)
* entry. The entry is kept in the local table until the next TTVN increment
* so that a consistency-check response can still be answered.
*
+ * The entry is also marked as BATADV_TT_CLIENT_PENDING when the DEL could not
+ * be queued. The removal must not be lost because not all callers are able to
+ * retry it. Such an entry is marked as del_unqueued instead. It stays in the
+ * local table until batadv_tt_local_purge_list() was able to queue its DEL.
+ *
* The caller must hold the flags_lock of @tt_local_entry and must not have
* released it since it checked that the entry has to be removed. Both the
* queue-then-mark order and this single flags_lock section are required.
@@ -1779,13 +1793,24 @@ batadv_tt_local_set_pending(struct batadv_priv *bat_priv,
{
struct batadv_tt_common_entry *common = &tt_local_entry->common;
struct batadv_hashtable *hash = bat_priv->tt.local_hash;
+ bool queued;
u32 i;
i = batadv_choose_tt(&common->key, hash->size);
lockdep_assert_held(&hash->list_locks[i]);
lockdep_assert_held(&common->flags_lock);
- __batadv_tt_local_event(bat_priv, common, common->flags | flags);
+ queued = __batadv_tt_local_event(bat_priv, common,
+ common->flags | flags);
+
+ /* a failed attempt must not hide the still queued DEL of an already
+ * pending entry
+ */
+ if (queued)
+ tt_local_entry->del_unqueued = false;
+ else if (!(common->flags & BATADV_TT_CLIENT_PENDING))
+ tt_local_entry->del_unqueued = true;
+
common->flags |= BATADV_TT_CLIENT_PENDING;
batadv_dbg(BATADV_DBG_TT, bat_priv,
@@ -1911,11 +1936,18 @@ static void batadv_tt_local_purge_list(struct batadv_priv *bat_priv,
common);
scoped_guard(spinlock_bh, &tt_local_entry->common.flags_lock) {
- if (tt_local_entry->common.flags & BATADV_TT_CLIENT_NOPURGE)
+ /* entry already marked for deletion */
+ if (tt_local_entry->common.flags & BATADV_TT_CLIENT_PENDING) {
+ /* but its removal must still be announced */
+ if (tt_local_entry->del_unqueued)
+ batadv_tt_local_set_pending(bat_priv,
+ tt_local_entry,
+ BATADV_TT_CLIENT_DEL,
+ "requeued");
break;
+ }
- /* entry already marked for deletion */
- if (tt_local_entry->common.flags & BATADV_TT_CLIENT_PENDING)
+ if (tt_local_entry->common.flags & BATADV_TT_CLIENT_NOPURGE)
break;
if (!batadv_has_timed_out(READ_ONCE(tt_local_entry->last_seen),
@@ -4524,7 +4556,8 @@ static void batadv_tt_local_transition_new(struct batadv_priv *bat_priv)
* @bat_priv: the bat priv with all the mesh interface information
*
* Iterate over the local TT and physically remove every entry that has been
- * marked as BATADV_TT_CLIENT_PENDING.
+ * marked as BATADV_TT_CLIENT_PENDING and whose DEL was queued. An entry which
+ * still waits for its DEL (del_unqueued) stays in the local table.
*/
static void batadv_tt_local_purge_pending_clients(struct batadv_priv *bat_priv)
{
@@ -4548,12 +4581,22 @@ static void batadv_tt_local_purge_pending_clients(struct batadv_priv *bat_priv)
hash_entry) {
bool cont = false;
+ tt_local = container_of(tt_common,
+ struct batadv_tt_local_entry,
+ common);
+
scoped_guard(spinlock_bh, &tt_common->flags_lock) {
if (!(tt_common->flags & BATADV_TT_CLIENT_PENDING)) {
cont = true;
break;
}
+ /* the removal must be announced first */
+ if (tt_local->del_unqueued) {
+ cont = true;
+ break;
+ }
+
batadv_dbg(BATADV_DBG_TT, bat_priv,
"Deleting local tt entry (%pM, vid: %d): pending\n",
tt_common->key.addr,
@@ -4572,10 +4615,6 @@ static void batadv_tt_local_purge_pending_clients(struct batadv_priv *bat_priv)
if (cont)
continue;
- tt_local = container_of(tt_common,
- struct batadv_tt_local_entry,
- common);
-
batadv_tt_local_entry_put(tt_local);
}
spin_unlock_bh(list_lock);
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index 8e590f19d236..d443143f190b 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -1939,6 +1939,13 @@ struct batadv_tt_local_entry {
/** @last_seen: timestamp used for purging stale tt local entries */
unsigned long last_seen;
+ /**
+ * @del_unqueued: the DEL of this BATADV_TT_CLIENT_PENDING entry could
+ * not be queued and must be queued by the next purge. Protected by
+ * common.flags_lock
+ */
+ bool del_unqueued;
+
/** @vlan: mesh-interface vlan of the entry */
struct batadv_meshif_vlan *vlan;
};
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH net-next 12/15] batman-adv: tt: extract removal of pending local entry
2026-11-23 17:18 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-11-23 Simon Wunderlich
` (10 preceding siblings ...)
2026-11-23 17:18 ` [PATCH net-next 11/15] batman-adv: tt: requeue DEL of pending local entry after failed allocation Simon Wunderlich
@ 2026-11-23 17:18 ` Simon Wunderlich
2026-11-24 17:20 ` netdev-bot+sashiko
2026-11-23 17:18 ` [PATCH net-next 13/15] batman-adv: tt: commit only the announced local changes Simon Wunderlich
` (2 subsequent siblings)
14 siblings, 1 reply; 31+ messages in thread
From: Simon Wunderlich @ 2026-11-23 17: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_purge_pending_clients() removes the entries which are
marked as BATADV_TT_CLIENT_PENDING from the local table. The actual removal
of a single entry has to follow some rules: an entry whose DEL still has to
be queued must stay in the local table and an entry which still carries
BATADV_TT_CLIENT_NEW was never counted and must not be uncounted.
Move the removal of a single entry to batadv_tt_local_unhash_pending(). It
can then be shared with the upcoming code which removes only the entry of a
committed DEL. The actual unhash steps are placed in
batadv_tt_local_unhash() because they will also be needed for entries which
are removed without going through the pending state. There is no functional
change.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/translation-table.c | 108 +++++++++++++++++++++--------
1 file changed, 80 insertions(+), 28 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 0c5e21f3ba75..2a7f50de70fc 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -1760,6 +1760,44 @@ int batadv_tt_local_dump(struct sk_buff *msg, struct netlink_callback *cb)
return ret;
}
+/**
+ * batadv_tt_local_unhash() - remove an entry from the local table
+ * @bat_priv: the bat priv with all the mesh interface information
+ * @tt_local: the local TT entry to remove
+ * @message: message to append to the log on deletion
+ *
+ * The caller must hold the hash bucket list_lock and the flags_lock of the
+ * entry. It must have checked that the entry is still part of the local table
+ * and has to drop the reference of the hash after it released the flags_lock.
+ */
+static void batadv_tt_local_unhash(struct batadv_priv *bat_priv,
+ struct batadv_tt_local_entry *tt_local,
+ const char *message)
+ __must_hold(&tt_local->common.flags_lock)
+{
+ struct batadv_tt_common_entry *tt_common = &tt_local->common;
+ struct batadv_hashtable *hash = bat_priv->tt.local_hash;
+ u32 i;
+
+ i = batadv_choose_tt(&tt_common->key, hash->size);
+ lockdep_assert_held(&hash->list_locks[i]);
+ lockdep_assert_held(&tt_common->flags_lock);
+
+ batadv_dbg(BATADV_DBG_TT, bat_priv,
+ "Deleting local tt entry (%pM, vid: %d): %s\n",
+ tt_common->key.addr, batadv_print_vid(tt_common->key.vid),
+ message);
+
+ hlist_del_init_rcu(&tt_common->hash_entry);
+ atomic_inc(&hash->generation);
+
+ /* An entry which still carries BATADV_TT_CLIENT_NEW was never counted
+ * and must not be uncounted here.
+ */
+ if (!(tt_common->flags & BATADV_TT_CLIENT_NEW))
+ batadv_tt_local_size_dec(bat_priv, tt_common->key.vid);
+}
+
/**
* batadv_tt_local_set_pending() - mark local TT entry as pending removal
* @bat_priv: the bat priv with all the mesh interface information
@@ -4550,6 +4588,43 @@ static void batadv_tt_local_transition_new(struct batadv_priv *bat_priv)
}
}
+/**
+ * batadv_tt_local_unhash_pending() - remove a pending entry from the local table
+ * @bat_priv: the bat priv with all the mesh interface information
+ * @tt_local: the local TT entry to remove
+ *
+ * Only an entry which is marked as BATADV_TT_CLIENT_PENDING and whose DEL was
+ * queued is removed. An entry which still waits for its DEL (del_unqueued) must
+ * stay in the local table until batadv_tt_local_purge_list() was able to queue
+ * it.
+ *
+ * The caller must hold the hash bucket list_lock and the flags_lock of the
+ * entry.
+ *
+ * Return: true if the entry was unhashed and the caller has to drop the
+ * reference of the hash, false otherwise.
+ */
+static bool
+batadv_tt_local_unhash_pending(struct batadv_priv *bat_priv,
+ struct batadv_tt_local_entry *tt_local)
+ __must_hold(&tt_local->common.flags_lock)
+{
+ struct batadv_tt_common_entry *tt_common = &tt_local->common;
+
+ lockdep_assert_held(&tt_common->flags_lock);
+
+ if (!(tt_common->flags & BATADV_TT_CLIENT_PENDING))
+ return false;
+
+ /* the removal must be announced first */
+ if (tt_local->del_unqueued)
+ return false;
+
+ batadv_tt_local_unhash(bat_priv, tt_local, "pending");
+
+ return true;
+}
+
/**
* batadv_tt_local_purge_pending_clients() - finalise removal of pending local
* clients
@@ -4579,40 +4654,17 @@ static void batadv_tt_local_purge_pending_clients(struct batadv_priv *bat_priv)
spin_lock_bh(list_lock);
hlist_for_each_entry_safe(tt_common, node_tmp, head,
hash_entry) {
- bool cont = false;
+ bool unhashed;
tt_local = container_of(tt_common,
struct batadv_tt_local_entry,
common);
- scoped_guard(spinlock_bh, &tt_common->flags_lock) {
- if (!(tt_common->flags & BATADV_TT_CLIENT_PENDING)) {
- cont = true;
- break;
- }
-
- /* the removal must be announced first */
- if (tt_local->del_unqueued) {
- cont = true;
- break;
- }
+ scoped_guard(spinlock_bh, &tt_common->flags_lock)
+ unhashed = batadv_tt_local_unhash_pending(bat_priv,
+ tt_local);
- batadv_dbg(BATADV_DBG_TT, bat_priv,
- "Deleting local tt entry (%pM, vid: %d): pending\n",
- tt_common->key.addr,
- batadv_print_vid(tt_common->key.vid));
-
- hlist_del_init_rcu(&tt_common->hash_entry);
- atomic_inc(&hash->generation);
-
- /* An entry which still carries BATADV_TT_CLIENT_NEW was
- * never counted and must not be uncounted here.
- */
- if (!(tt_common->flags & BATADV_TT_CLIENT_NEW))
- batadv_tt_local_size_dec(bat_priv, tt_common->key.vid);
- }
-
- if (cont)
+ if (!unhashed)
continue;
batadv_tt_local_entry_put(tt_local);
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH net-next 13/15] batman-adv: tt: commit only the announced local changes
2026-11-23 17:18 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-11-23 Simon Wunderlich
` (11 preceding siblings ...)
2026-11-23 17:18 ` [PATCH net-next 12/15] batman-adv: tt: extract removal of pending local entry Simon Wunderlich
@ 2026-11-23 17:18 ` Simon Wunderlich
2026-11-24 17:20 ` netdev-bot+sashiko
2026-11-23 17:18 ` [PATCH net-next 14/15] batman-adv: tt: avoid list_lock for unchanged local clients Simon Wunderlich
2026-11-23 17:18 ` [PATCH net-next 15/15] batman-adv: tt: drop ADD+DEL events of never announced clients Simon Wunderlich
14 siblings, 1 reply; 31+ messages in thread
From: Simon Wunderlich @ 2026-11-23 17: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>
batadv_tt_local_commit_changes_nolock() takes the queued changes for the
new TTVN and then scans the complete local table: every
BATADV_TT_CLIENT_NEW entry is committed and every BATADV_TT_CLIENT_PENDING
entry is removed. But the local table is modified in parallel by
batadv_tt_local_add() and batadv_tt_local_remove(). An entry which was
added or marked for removal after the changes were taken is then already
part of the CRC (or already missing from it) of the new TTVN although its
ADD/DEL is only announced with the next one. The other nodes detect the CRC
mismatch and have to request the full table.
But there is already the list of batadv_tvlv_tt_change which belong to the
TTVN which is currently committed. Since its state it atomically extracted
by batadv_tt_local_commit_changes_nolock(), it can be used as stable source
for the operations which need to be applied on the local TT. The changes
are applied similar to the patching done for the global TT table after
receiving a TTVN changeset - but with the local TT specific flags state in
mind:
The ADD of an entry finishes its NEW state and the DEL of an entry removes
it from the local table.
An entry which was marked for removal after the changes were taken stays in
the table until its DEL is committed. This also applies to entries which
still carry BATADV_TT_CLIENT_NEW. But batadv_tt_local_resize_to_mtu() still
drops the pending entries directly. It holds the commit_lock and commits
the queued changes right away. The DEL of each dropped entry is therefore
announced with this commit.
The scan of the complete table also finished the entries whose ADD or DEL
was never queued because the allocation of the change failed. This is no
longer needed: an entry is not brought into the BATADV_TT_CLIENT_NEW state
without a queued ADD anymore and the DEL of a BATADV_TT_CLIENT_PENDING
entry is requeued by the purge until it was stored.
The client of a committed DEL might have been detected again after the
changes were taken. Its entry is then no longer pending or it was marked
for removal again but the new DEL could not be queued. Such an entry is not
removed because its ADD is queued for the next TTVN. But the other nodes
remove the client with the DEL of the current TTVN. The entry is therefore
brought back into the BATADV_TT_CLIENT_NEW state. It is then not part of
the CRC and of the full table responses until its ADD is committed.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/bug/linux-0de54f93-3f78-4500-b5ea-3c6973e51bf3
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/translation-table.c | 176 +++++++++++++++++++++--------
1 file changed, 128 insertions(+), 48 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 2a7f50de70fc..b03d6c74732f 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -539,6 +539,12 @@ static void batadv_tt_local_size_inc(struct batadv_priv *bat_priv,
* was removed from bat_priv->tt.local_hash (under the specific
* list_locks[i]) or when it is ensured that it is not accessible
* in this list.
+ *
+ * The only exception is an entry which stays in bat_priv->tt.local_hash but is
+ * brought back into the NEW state by batadv_tt_local_commit_change(). The NEW
+ * flag must then be set under the same list_locks[i] and the flags_lock of the
+ * entry. batadv_tt_local_size_inc() counts the entry again when its NEW flag
+ * is removed.
*/
static void batadv_tt_local_size_dec(struct batadv_priv *bat_priv,
unsigned short vid)
@@ -1876,9 +1882,8 @@ batadv_tt_local_set_pending(struct batadv_priv *bat_priv,
*
* All checks and modifications happen under the hash bucket list_lock and the
* flags_lock of the entry. This prevents a concurrent
- * batadv_tt_local_purge_pending_clients() from removing the entry,
- * batadv_tt_local_transition_new() from clearing BATADV_TT_CLIENT_NEW and
- * batadv_tt_local_refresh() from modifying the entry after it was checked.
+ * batadv_tt_local_commit_change() from removing the entry and
+ * batadv_tt_local_refresh() from modifying it after it was checked.
*/
static void
batadv_tt_local_remove_entry(struct batadv_priv *bat_priv,
@@ -4545,49 +4550,6 @@ void batadv_tt_free(struct batadv_priv *bat_priv)
kfree(bat_priv->tt.last_changeset);
}
-/**
- * batadv_tt_local_transition_new() - unset the NEW flag on the local
- * table and count them in the TT size
- * @bat_priv: the bat priv with all the mesh interface information
- */
-static void batadv_tt_local_transition_new(struct batadv_priv *bat_priv)
-{
- spinlock_t *list_lock; /* protects write access to the hash lists */
- struct batadv_hashtable *hash = bat_priv->tt.local_hash;
- struct batadv_tt_common_entry *tt_common_entry;
- struct hlist_head *head;
- u32 i;
-
- if (!hash)
- return;
-
- for (i = 0; i < hash->size; i++) {
- head = &hash->table[i];
- list_lock = &hash->list_locks[i];
-
- spin_lock_bh(list_lock);
- hlist_for_each_entry(tt_common_entry, head, hash_entry) {
- bool cont = false;
-
- scoped_guard(spinlock_bh, &tt_common_entry->flags_lock) {
- if (!(tt_common_entry->flags & BATADV_TT_CLIENT_NEW)) {
- cont = true;
- break;
- }
-
- tt_common_entry->flags &= ~BATADV_TT_CLIENT_NEW;
- }
-
- if (cont)
- continue;
-
- batadv_tt_local_size_inc(bat_priv,
- tt_common_entry->key.vid);
- }
- spin_unlock_bh(list_lock);
- }
-}
-
/**
* batadv_tt_local_unhash_pending() - remove a pending entry from the local table
* @bat_priv: the bat priv with all the mesh interface information
@@ -4625,6 +4587,112 @@ batadv_tt_local_unhash_pending(struct batadv_priv *bat_priv,
return true;
}
+/**
+ * batadv_tt_local_commit_change() - apply a committed change to the local table
+ * @bat_priv: the bat priv with all the mesh interface information
+ * @change: the change which is announced with the new ttvn
+ *
+ * The CRC and the full table responses of a ttvn must reflect exactly the
+ * changes announced with it. Only the entry affected by a committed change is
+ * therefore modified. An entry which was added or marked for removal after the
+ * change set was taken stays in its current state until its own change is
+ * committed with a later ttvn.
+ *
+ * An ADD finishes the BATADV_TT_CLIENT_NEW state of the entry and it is counted
+ * as part of the local table from now on. A DEL removes the entry which is
+ * marked as BATADV_TT_CLIENT_PENDING from the local table.
+ *
+ * The entry is not protected by bat_priv->tt.commit_lock against a concurrent
+ * refresh and removal. The client of a committed DEL can therefore be detected
+ * again after the change set was taken. Its entry is then no longer
+ * BATADV_TT_CLIENT_PENDING or it was marked for removal again without a queued
+ * DEL (del_unqueued). Such an entry must stay hashed because its ADD is queued
+ * for a later ttvn. But the other nodes remove the client with the new ttvn.
+ * The entry is therefore brought back into the BATADV_TT_CLIENT_NEW state and
+ * is not counted as part of the local table until its ADD is committed.
+ *
+ * The caller must hold tt->commit_lock. It is the one which took @change from
+ * the queued changes of the new ttvn.
+ */
+static void
+batadv_tt_local_commit_change(struct batadv_priv *bat_priv,
+ const struct batadv_tvlv_tt_change *change)
+ __must_hold(&bat_priv->tt.commit_lock)
+{
+ spinlock_t *list_lock; /* protects write access to the hash lists */
+ struct batadv_hashtable *hash = bat_priv->tt.local_hash;
+ struct batadv_tt_local_entry *tt_local = NULL;
+ struct batadv_tt_common_entry *tt_common;
+ struct batadv_tt_common_entry_key key;
+ struct hlist_head *head;
+ bool committed = false;
+ bool del_op;
+ u32 i;
+
+ lockdep_assert_held(&bat_priv->tt.commit_lock);
+
+ if (!hash)
+ return;
+
+ ether_addr_copy(key.addr, change->addr);
+ key.vid = ntohs(change->vid);
+ del_op = change->flags & BATADV_TT_CLIENT_DEL;
+
+ i = batadv_choose_tt(&key, hash->size);
+ head = &hash->table[i];
+ list_lock = &hash->list_locks[i];
+
+ spin_lock_bh(list_lock);
+
+ hlist_for_each_entry(tt_common, head, hash_entry) {
+ if (!batadv_compare_tt(&tt_common->hash_entry, &key))
+ continue;
+
+ scoped_guard(spinlock_bh, &tt_common->flags_lock) {
+ if (!del_op) {
+ /* an ADD of an already committed entry only
+ * announces new flags or cancels its removal
+ */
+ if (!(tt_common->flags & BATADV_TT_CLIENT_NEW))
+ break;
+
+ tt_common->flags &= ~BATADV_TT_CLIENT_NEW;
+ committed = true;
+ break;
+ }
+
+ tt_local = container_of(tt_common,
+ struct batadv_tt_local_entry,
+ common);
+ if (batadv_tt_local_unhash_pending(bat_priv, tt_local))
+ break;
+
+ tt_local = NULL;
+
+ /* The client was detected again after its DEL was
+ * taken. The other nodes remove it with this ttvn and
+ * only add it again with the still queued ADD. The
+ * entry must be hidden from the CRC and the full table
+ * responses until this ADD is committed.
+ */
+ if (!(tt_common->flags & BATADV_TT_CLIENT_NEW)) {
+ tt_common->flags |= BATADV_TT_CLIENT_NEW;
+ batadv_tt_local_size_dec(bat_priv, key.vid);
+ }
+ }
+
+ if (committed)
+ batadv_tt_local_size_inc(bat_priv, key.vid);
+
+ break;
+ }
+
+ spin_unlock_bh(list_lock);
+
+ /* drop reference of removed hash entry */
+ batadv_tt_local_entry_put(tt_local);
+}
+
/**
* batadv_tt_local_purge_pending_clients() - finalise removal of pending local
* clients
@@ -4633,8 +4701,14 @@ batadv_tt_local_unhash_pending(struct batadv_priv *bat_priv,
* Iterate over the local TT and physically remove every entry that has been
* marked as BATADV_TT_CLIENT_PENDING and whose DEL was queued. An entry which
* still waits for its DEL (del_unqueued) stays in the local table.
+ *
+ * The caller must hold tt->commit_lock and has to commit the queued changes
+ * right away. The DEL of each removed entry is still queued because no commit
+ * could have taken it since the entry was marked. All removals are therefore
+ * announced with the next ttvn.
*/
static void batadv_tt_local_purge_pending_clients(struct batadv_priv *bat_priv)
+ __must_hold(&bat_priv->tt.commit_lock)
{
spinlock_t *list_lock; /* protects write access to the hash lists */
struct batadv_hashtable *hash = bat_priv->tt.local_hash;
@@ -4644,6 +4718,8 @@ static void batadv_tt_local_purge_pending_clients(struct batadv_priv *bat_priv)
struct hlist_head *head;
u32 i;
+ lockdep_assert_held(&bat_priv->tt.commit_lock);
+
if (!hash)
return;
@@ -4683,6 +4759,7 @@ static void batadv_tt_local_purge_pending_clients(struct batadv_priv *bat_priv)
static void batadv_tt_local_commit_changes_nolock(struct batadv_priv *bat_priv)
__must_hold(&bat_priv->tt.commit_lock)
{
+ struct batadv_tt_change_node *tt_change_node;
LIST_HEAD(changes_list);
int changes_num;
@@ -4705,9 +4782,12 @@ static void batadv_tt_local_commit_changes_nolock(struct batadv_priv *bat_priv)
return;
}
- batadv_tt_local_transition_new(bat_priv);
+ /* bring the affected local entries into the state announced with the
+ * new ttvn
+ */
+ list_for_each_entry(tt_change_node, &changes_list, list)
+ batadv_tt_local_commit_change(bat_priv, &tt_change_node->change);
- batadv_tt_local_purge_pending_clients(bat_priv);
batadv_tt_local_update_crc(bat_priv);
/* Increment the TTVN only once per OGM interval */
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH net-next 14/15] batman-adv: tt: avoid list_lock for unchanged local clients
2026-11-23 17:18 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-11-23 Simon Wunderlich
` (12 preceding siblings ...)
2026-11-23 17:18 ` [PATCH net-next 13/15] batman-adv: tt: commit only the announced local changes Simon Wunderlich
@ 2026-11-23 17:18 ` Simon Wunderlich
2026-11-23 17:18 ` [PATCH net-next 15/15] batman-adv: tt: drop ADD+DEL events of never announced clients Simon Wunderlich
14 siblings, 0 replies; 31+ messages in thread
From: Simon Wunderlich @ 2026-11-23 17: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() is called for every packet transmitted by a local
client. batadv_tt_local_refresh() takes the hash bucket list_lock for each
of them, although this lock is shared by all entries of the bucket and is
only needed when the entry has to be modified or announced.
For the common case, the entry is neither BATADV_TT_CLIENT_PENDING nor
BATADV_TT_CLIENT_ROAM, the dynamic flags (BATADV_TT_CLIENT_WIFI and
BATADV_TT_CLIENT_ISOLA) are unchanged and the entry is still hashed. Only
last_seen has to be refreshed then.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/translation-table.c | 115 ++++++++++++++++++++++-------
1 file changed, 89 insertions(+), 26 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index b03d6c74732f..998c7f285e1d 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -984,13 +984,77 @@ batadv_tt_local_create(struct net_device *mesh_iface, const u8 *addr,
return tt_local;
}
+/* flags of a local TT entry which depend on the packets of the client */
+#define BATADV_TT_LOCAL_DYNAMIC_MASK \
+ (BATADV_TT_CLIENT_WIFI | BATADV_TT_CLIENT_ISOLA)
+
/**
- * batadv_tt_local_refresh_locked() - refresh a local TT entry
+ * batadv_tt_local_dynamic_flags() - get the dynamic flags of a local client
* @bat_priv: the bat priv with all the mesh interface information
- * @tt_local: the local TT entry to refresh
* @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: the BATADV_TT_CLIENT_WIFI and BATADV_TT_CLIENT_ISOLA flags which the
+ * local entry of the client has to carry.
+ */
+static u16 batadv_tt_local_dynamic_flags(struct batadv_priv *bat_priv,
+ bool iif_is_wifi, u32 mark)
+{
+ u32 match_mark;
+ u16 flags = 0;
+
+ if (iif_is_wifi)
+ 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)
+ flags |= BATADV_TT_CLIENT_ISOLA;
+
+ return flags;
+}
+
+/**
+ * batadv_tt_local_refresh_needed() - check if a local entry has to be modified
+ * @tt_local: the local TT entry to check
+ * @dynamic_flags: the dynamic flags the entry has to carry
+ *
+ * The bucket list_lock which is shared by many entries is only needed when
+ * the entry has to be modified or announced. For the common case of an
+ * already announced client with unchanged flags, it is enough to refresh the
+ * last_seen timestamp.
+ *
+ * Return: true if the slow path of batadv_tt_local_refresh() is required,
+ * false otherwise.
+ */
+static bool
+batadv_tt_local_refresh_needed(struct batadv_tt_local_entry *tt_local,
+ u16 dynamic_flags)
+{
+ struct batadv_tt_common_entry *common = &tt_local->common;
+ u16 flags;
+
+ flags = batadv_tt_flags_get(common);
+
+ if (flags & (BATADV_TT_CLIENT_PENDING | BATADV_TT_CLIENT_ROAM))
+ return true;
+
+ if ((flags & BATADV_TT_LOCAL_DYNAMIC_MASK) != dynamic_flags)
+ return true;
+
+ return hlist_unhashed_lockless(&common->hash_entry);
+}
+
+/**
+ * batadv_tt_local_refresh_locked() - refresh a local TT entry
+ * @bat_priv: the bat priv with all the mesh interface information
+ * @tt_local: the local TT entry to refresh
+ * @dynamic_flags: the dynamic flags the entry has to carry
* @announce: whether an ADD event has to be queued even when no announced
* flag was modified
* @roamed_back: set to true when the client returned to its original location
@@ -1014,7 +1078,7 @@ batadv_tt_local_create(struct net_device *mesh_iface, const u8 *addr,
static bool
batadv_tt_local_refresh_locked(struct batadv_priv *bat_priv,
struct batadv_tt_local_entry *tt_local,
- bool iif_is_wifi, u32 mark, bool announce,
+ u16 dynamic_flags, bool announce,
bool *roamed_back)
{
struct batadv_tt_common_entry *common = &tt_local->common;
@@ -1022,7 +1086,6 @@ batadv_tt_local_refresh_locked(struct batadv_priv *bat_priv,
bool readded = false;
bool roamed = false;
u8 remote_flags;
- u32 match_mark;
u16 flags;
u32 i;
@@ -1058,21 +1121,8 @@ batadv_tt_local_refresh_locked(struct batadv_priv *bat_priv,
*/
remote_flags = flags & BATADV_TT_REMOTE_MASK;
- if (iif_is_wifi)
- flags |= BATADV_TT_CLIENT_WIFI;
- else
- 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)
- flags |= BATADV_TT_CLIENT_ISOLA;
- else
- flags &= ~BATADV_TT_CLIENT_ISOLA;
+ flags &= ~BATADV_TT_LOCAL_DYNAMIC_MASK;
+ flags |= dynamic_flags;
if (remote_flags ^ (flags & BATADV_TT_REMOTE_MASK))
announce = true;
@@ -1119,7 +1169,8 @@ batadv_tt_local_refresh_locked(struct batadv_priv *bat_priv,
* any)
* @roamed_back: set to true when the client returned to its original location
*
- * See batadv_tt_local_refresh_locked() for the actual refresh.
+ * See batadv_tt_local_refresh_locked() for the actual refresh. The hash bucket
+ * list_lock is only taken when the entry has to be modified or announced.
*
* An entry whose modification could not be announced stays in its previous
* state. The refresh is then retried with the next packet of the client.
@@ -1135,14 +1186,22 @@ batadv_tt_local_refresh(struct batadv_priv *bat_priv,
spinlock_t *list_lock; /* protects write access to the hash lists */
struct batadv_tt_common_entry *common = &tt_local->common;
struct batadv_hashtable *hash = bat_priv->tt.local_hash;
+ u16 dynamic_flags;
int ret = 0;
u32 i;
- i = batadv_choose_tt(&common->key, hash->size);
- list_lock = &hash->list_locks[i];
+ dynamic_flags = batadv_tt_local_dynamic_flags(bat_priv, iif_is_wifi,
+ mark);
WRITE_ONCE(tt_local->last_seen, jiffies);
+ /* fast path: nothing to modify or to announce */
+ if (!batadv_tt_local_refresh_needed(tt_local, dynamic_flags))
+ return 0;
+
+ i = batadv_choose_tt(&common->key, hash->size);
+ list_lock = &hash->list_locks[i];
+
spin_lock_bh(list_lock);
/* the entry was removed from the local table after it was looked up */
@@ -1151,8 +1210,8 @@ batadv_tt_local_refresh(struct batadv_priv *bat_priv,
return -ENOENT;
}
- if (!batadv_tt_local_refresh_locked(bat_priv, tt_local, iif_is_wifi,
- mark, false, roamed_back))
+ if (!batadv_tt_local_refresh_locked(bat_priv, tt_local, dynamic_flags,
+ false, roamed_back))
ret = -ENOMEM;
spin_unlock_bh(list_lock);
@@ -1191,8 +1250,12 @@ static bool batadv_tt_local_insert(struct batadv_priv *bat_priv,
struct batadv_hashtable *hash = bat_priv->tt.local_hash;
struct hlist_head *head;
struct hlist_node *node;
+ u16 dynamic_flags;
u32 i;
+ dynamic_flags = batadv_tt_local_dynamic_flags(bat_priv, iif_is_wifi,
+ mark);
+
i = batadv_choose_tt(&common->key, hash->size);
head = &hash->table[i];
list_lock = &hash->list_locks[i];
@@ -1208,8 +1271,8 @@ static bool batadv_tt_local_insert(struct batadv_priv *bat_priv,
}
/* announce the added client to the mesh */
- if (!batadv_tt_local_refresh_locked(bat_priv, tt_local, iif_is_wifi,
- mark, true, roamed_back)) {
+ if (!batadv_tt_local_refresh_locked(bat_priv, tt_local, dynamic_flags,
+ true, roamed_back)) {
spin_unlock_bh(list_lock);
return false;
}
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH net-next 15/15] batman-adv: tt: drop ADD+DEL events of never announced clients
2026-11-23 17:18 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-11-23 Simon Wunderlich
` (13 preceding siblings ...)
2026-11-23 17:18 ` [PATCH net-next 14/15] batman-adv: tt: avoid list_lock for unchanged local clients Simon Wunderlich
@ 2026-11-23 17:18 ` Simon Wunderlich
2026-11-24 17:20 ` netdev-bot+sashiko
14 siblings, 1 reply; 31+ messages in thread
From: Simon Wunderlich @ 2026-11-23 17: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>
If a detected client was not yet announced, a DEL event can directly drop
the ADD event. The other nodes never heard about the client and don't need
a DEL for it. The entry can then also be removed from the local table
immediately instead of waiting for the commit of its DEL.
Only the initial ADD queued by batadv_tt_local_insert() can be cancelled.
The BATADV_TT_CLIENT_NEW flag of the entry is not enough to identify such a
change: batadv_tt_local_commit_changes_nolock() takes the queued changes
before it clears this flag. An ADD queued by batadv_tt_local_refresh() in
this window (for example for a changed BATADV_TT_CLIENT_WIFI flag) must
still be announced together with a following DEL because the initial ADD is
already on its way to the other nodes. Each change entry therefore stores
whether it is the initial ADD of its client.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
net/batman-adv/translation-table.c | 119 ++++++++++++++++++++++-------
net/batman-adv/types.h | 7 ++
2 files changed, 100 insertions(+), 26 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 998c7f285e1d..c17cfee6ff84 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -651,13 +651,20 @@ static u16 batadv_tt_flags_get(struct batadv_tt_common_entry *common)
}
/**
- * __batadv_tt_local_event() - store a local TT event (ADD/DEL) with given flags
+ * batadv_tt_local_event() - store a local TT event (ADD/DEL) with given flags
* @bat_priv: the bat priv with all the mesh interface information
* @common: the TT entry involved in the event
* @flags: flags of the TT entry combined with the event flags
+ * @initial_add: whether the ADD is the first one of a client which was never
+ * announced to the other nodes
+ * @cancelled: set to true if a DEL cancelled the initial ADD of the client and
+ * to false otherwise (optional)
*
* Only a single change per client is queued. It describes the latest state of
- * the client and a new event therefore replaces an already queued one.
+ * the client and a new event therefore replaces an already queued one. The
+ * only exception is a DEL for a client whose initial ADD is still queued. The
+ * other nodes don't need to know anything about such a client and the ADD is
+ * cancelled instead.
*
* The other nodes only learn about the modification of a local entry through
* the queued change. The caller must therefore not modify the entry in a way
@@ -669,12 +676,12 @@ static u16 batadv_tt_flags_get(struct batadv_tt_common_entry *common)
* The caller must hold the flags_lock of @common. The events of an entry are
* then queued in the same order in which its flags were modified.
*
- * Return: true if the event was stored, false if the memory for it could not
- * be allocated.
+ * Return: true if the event was stored (or cancelled a queued ADD), false if
+ * the memory for it could not be allocated.
*/
-static bool __batadv_tt_local_event(struct batadv_priv *bat_priv,
- const struct batadv_tt_common_entry *common,
- u8 flags)
+static bool batadv_tt_local_event(struct batadv_priv *bat_priv,
+ const struct batadv_tt_common_entry *common,
+ u8 flags, bool initial_add, bool *cancelled)
__must_hold(&common->flags_lock)
{
struct batadv_tt_change_node *tt_change_node;
@@ -685,6 +692,9 @@ static bool __batadv_tt_local_event(struct batadv_priv *bat_priv,
lockdep_assert_held(&common->flags_lock);
+ if (cancelled)
+ *cancelled = false;
+
tt_change_node = kmem_cache_alloc(batadv_tt_change_cache, GFP_ATOMIC);
if (!tt_change_node)
return false;
@@ -704,6 +714,7 @@ static bool __batadv_tt_local_event(struct batadv_priv *bat_priv,
flags &= ~BATADV_TT_CLIENT_ROAM;
tt_change_node->change.flags = flags;
+ tt_change_node->initial_add = initial_add && !del_op_requested;
/* check for ADD+DEL, DEL+ADD, ADD+ADD or DEL+DEL events */
spin_lock_bh(&bat_priv->tt.changes_list_lock);
@@ -716,12 +727,31 @@ static bool __batadv_tt_local_event(struct batadv_priv *bat_priv,
if (entry->change.vid != tt_change_node->change.vid)
continue;
- /* the other nodes may know the client with different
- * flags. A DEL+ADD must therefore still announce the
- * current flags and an ADD+DEL must still remove the
- * client. ADD+ADD and DEL+DEL only update the flags
- */
- entry->change.flags = flags;
+ if (del_op_requested && entry->initial_add) {
+ /* ADD+DEL of a client which was never announced (e.g.
+ * roaming of a client still in the NEW state) have no
+ * effect and can be removed.
+ */
+ list_del(&entry->list);
+ kmem_cache_free(batadv_tt_change_cache, entry);
+ changes--;
+ if (cancelled)
+ *cancelled = true;
+ } else {
+ /* the other nodes may know the client with different
+ * flags. A DEL+ADD must therefore still announce the
+ * current flags and an ADD+DEL must still remove the
+ * client. ADD+ADD and DEL+DEL only update the flags.
+ *
+ * The queued change keeps its initial_add state. An
+ * ADD which only updates the flags of a still queued
+ * initial ADD stays cancellable. But an ADD queued
+ * after the initial ADD was committed (and before the
+ * entry left the NEW state) must not become
+ * cancellable.
+ */
+ entry->change.flags = flags;
+ }
kmem_cache_free(batadv_tt_change_cache, tt_change_node);
goto update_changes;
@@ -1063,6 +1093,10 @@ batadv_tt_local_refresh_needed(struct batadv_tt_local_entry *tt_local,
* updated. An ADD event is queued when @announce is set, the pending removal
* was cancelled or a flag announced to the other nodes was modified.
*
+ * @announce is only set for an entry which is just being inserted. Its ADD is
+ * therefore the initial ADD of a client which was never announced to the other
+ * nodes.
+ *
* The entry is left untouched when the ADD event could not be queued. The
* other nodes would otherwise never be informed about the new state. An already
* hashed entry is simply refreshed again when the next packet of the client is
@@ -1083,6 +1117,7 @@ batadv_tt_local_refresh_locked(struct batadv_priv *bat_priv,
{
struct batadv_tt_common_entry *common = &tt_local->common;
struct batadv_hashtable *hash = bat_priv->tt.local_hash;
+ bool initial_add = announce;
bool readded = false;
bool roamed = false;
u8 remote_flags;
@@ -1131,7 +1166,8 @@ batadv_tt_local_refresh_locked(struct batadv_priv *bat_priv,
* without a queued change which commits/announces it
*/
if (announce &&
- !__batadv_tt_local_event(bat_priv, common, flags))
+ !batadv_tt_local_event(bat_priv, common, flags,
+ initial_add, NULL))
return false;
common->flags = flags;
@@ -1883,6 +1919,11 @@ static void batadv_tt_local_unhash(struct batadv_priv *bat_priv,
* retry it. Such an entry is marked as del_unqueued instead. It stays in the
* local table until batadv_tt_local_purge_list() was able to queue its DEL.
*
+ * A client whose initial ADD is still queued was never announced to the other
+ * nodes. Its DEL cancels the ADD and the entry is removed from the local table
+ * right away. The caller has to drop the hash reference of the entry after it
+ * released the flags_lock.
+ *
* The caller must hold the flags_lock of @tt_local_entry and must not have
* released it since it checked that the entry has to be removed. Both the
* queue-then-mark order and this single flags_lock section are required.
@@ -1891,8 +1932,11 @@ static void batadv_tt_local_unhash(struct batadv_priv *bat_priv,
* must have ensured that the entry is still part of the local table. A DEL for
* an entry which was already purged could otherwise cancel the ADD of a new
* entry for the same client.
+ *
+ * Return: true if the entry was removed from the local table instead of being
+ * marked as pending, false otherwise.
*/
-static void
+static bool
batadv_tt_local_set_pending(struct batadv_priv *bat_priv,
struct batadv_tt_local_entry *tt_local_entry,
u16 flags, const char *message)
@@ -1900,6 +1944,7 @@ batadv_tt_local_set_pending(struct batadv_priv *bat_priv,
{
struct batadv_tt_common_entry *common = &tt_local_entry->common;
struct batadv_hashtable *hash = bat_priv->tt.local_hash;
+ bool cancelled;
bool queued;
u32 i;
@@ -1907,8 +1952,13 @@ batadv_tt_local_set_pending(struct batadv_priv *bat_priv,
lockdep_assert_held(&hash->list_locks[i]);
lockdep_assert_held(&common->flags_lock);
- queued = __batadv_tt_local_event(bat_priv, common,
- common->flags | flags);
+ queued = batadv_tt_local_event(bat_priv, common, common->flags | flags,
+ false, &cancelled);
+ if (cancelled) {
+ /* the entry was never announced */
+ batadv_tt_local_unhash(bat_priv, tt_local_entry, message);
+ return true;
+ }
/* a failed attempt must not hide the still queued DEL of an already
* pending entry
@@ -1924,6 +1974,8 @@ batadv_tt_local_set_pending(struct batadv_priv *bat_priv,
"Local tt entry (%pM, vid: %d) pending to be removed: %s\n",
tt_local_entry->common.key.addr,
batadv_print_vid(tt_local_entry->common.key.vid), message);
+
+ return false;
}
/**
@@ -1940,6 +1992,9 @@ batadv_tt_local_set_pending(struct batadv_priv *bat_priv,
* also applies to an entry which still carries BATADV_TT_CLIENT_NEW because its
* ADD might already have been taken for the next ttvn.
*
+ * Only an entry whose initial ADD is still queued is removed from the local
+ * table immediately. Nothing was announced about it to the other nodes.
+ *
* An entry which was already removed from the local table after it was looked
* up is ignored and BATADV_NO_FLAGS is stored in @curr_flags.
*
@@ -1956,6 +2011,7 @@ batadv_tt_local_remove_entry(struct batadv_priv *bat_priv,
spinlock_t *list_lock; /* protects write access to the hash lists */
struct batadv_tt_common_entry *common = &tt_local_entry->common;
struct batadv_hashtable *hash = bat_priv->tt.local_hash;
+ bool unhashed = false;
u16 flags;
u32 i;
@@ -1984,11 +2040,15 @@ batadv_tt_local_remove_entry(struct batadv_priv *bat_priv,
if (roaming)
flags |= BATADV_TT_CLIENT_ROAM;
- batadv_tt_local_set_pending(bat_priv, tt_local_entry, flags,
- message);
+ unhashed = batadv_tt_local_set_pending(bat_priv, tt_local_entry,
+ flags, message);
}
spin_unlock_bh(list_lock);
+
+ /* drop reference of removed hash entry */
+ if (unhashed)
+ batadv_tt_local_entry_put(tt_local_entry);
}
/**
@@ -2037,6 +2097,8 @@ static void batadv_tt_local_purge_list(struct batadv_priv *bat_priv,
hlist_for_each_entry_safe(tt_common_entry, node_tmp, head,
hash_entry) {
+ bool unhashed = false;
+
tt_local_entry = container_of(tt_common_entry,
struct batadv_tt_local_entry,
common);
@@ -2046,10 +2108,10 @@ static void batadv_tt_local_purge_list(struct batadv_priv *bat_priv,
if (tt_local_entry->common.flags & BATADV_TT_CLIENT_PENDING) {
/* but its removal must still be announced */
if (tt_local_entry->del_unqueued)
- batadv_tt_local_set_pending(bat_priv,
- tt_local_entry,
- BATADV_TT_CLIENT_DEL,
- "requeued");
+ unhashed = batadv_tt_local_set_pending(bat_priv,
+ tt_local_entry,
+ BATADV_TT_CLIENT_DEL,
+ "requeued");
break;
}
@@ -2060,10 +2122,15 @@ static void batadv_tt_local_purge_list(struct batadv_priv *bat_priv,
timeout))
break;
- batadv_tt_local_set_pending(bat_priv, tt_local_entry,
- BATADV_TT_CLIENT_DEL,
- "timed out");
+ unhashed = batadv_tt_local_set_pending(bat_priv,
+ tt_local_entry,
+ BATADV_TT_CLIENT_DEL,
+ "timed out");
}
+
+ /* drop reference of removed hash entry */
+ if (unhashed)
+ batadv_tt_local_entry_put(tt_local_entry);
}
}
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index d443143f190b..0a2db6583c11 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -2005,6 +2005,13 @@ struct batadv_tt_change_node {
/** @change: holds the actual translation table diff data */
struct batadv_tvlv_tt_change change;
+
+ /**
+ * @initial_add: the change is the initial ADD of a client which was
+ * never announced to the other nodes. A DEL of this client cancels
+ * the change instead of being queued
+ */
+ bool initial_add:1;
};
/**
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH net-next 01/15] batman-adv: document refcount of returned objects
2026-11-23 17:18 ` [PATCH net-next 01/15] batman-adv: document refcount of returned objects Simon Wunderlich
@ 2026-11-23 17:23 ` netdev-bot+sinfo
2026-11-23 18:13 ` Sven Eckelmann
2026-11-24 17:20 ` netdev-bot+sashiko
1 sibling, 1 reply; 31+ messages in thread
From: netdev-bot+sinfo @ 2026-11-23 17:23 UTC (permalink / raw)
To: Simon Wunderlich
Cc: netdev, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, b.a.t.m.a.n, Sven Eckelmann
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- Whether the issue was actually triggered, or is only theoretical
(e.g. found by LLM and not proven at runtime). If it was triggered
please include the symptoms, like the stack trace or kernel messages.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH net-next 01/15] batman-adv: document refcount of returned objects
2026-11-23 17:23 ` netdev-bot+sinfo
@ 2026-11-23 18:13 ` Sven Eckelmann
0 siblings, 0 replies; 31+ messages in thread
From: Sven Eckelmann @ 2026-11-23 18:13 UTC (permalink / raw)
To: netdev-bot+sinfo
Cc: Simon Wunderlich, netdev, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, b.a.t.m.a.n
[-- Attachment #1: Type: text/plain, Size: 1003 bytes --]
On Monday, 23 November 2026 18:23:03 CET netdev-bot+sinfo@kernel.org wrote:
> This is an automated message. This series looks like a fix, but its
> commit messages seem to be missing some information:
>
> - Whether the issue was actually triggered, or is only theoretical
> (e.g. found by LLM and not proven at runtime). If it was triggered
> please include the symptoms, like the stack trace or kernel messages.
They are things found by an LLM and they were marked with "Closed"+
"Reported-by" tags. None of them are reproduced. The marked ones are about the
logical consistency of the local translation table (ok, and bridge-loop-
avoidance in one patch) and the data reported to other nodes.
They are corner cases but definitely problems in the implementation. They are
not meant for backporting to stable or to net because they are no known
affected users. And it looks to me like affected users would have the problem
solved by some extra full translation table syncs.
Regards,
Sven
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH net-next 01/15] batman-adv: document refcount of returned objects
2026-11-23 17:18 ` [PATCH net-next 01/15] batman-adv: document refcount of returned objects Simon Wunderlich
2026-11-23 17:23 ` netdev-bot+sinfo
@ 2026-11-24 17:20 ` netdev-bot+sashiko
1 sibling, 0 replies; 31+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 17:20 UTC (permalink / raw)
To: sw; +Cc: netdev, davem, edumazet, kuba, pabeni, horms, b.a.t.m.a.n, sven
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message does not match the diff.
--
batman-adv: document refcount of returned objects
This patch adds a kerneldoc note to the batman-adv lookup, get and create
functions that return an object with an increased refcounter. For
batadv_transtable_best_orig() and batadv_mcast_forw_orig_entry(), it notes
the opposite: the returned object is only borrowed within the caller's
RCU read-side critical section.
> Add a note to the kerneldoc of the __must_check functions that return an
> object with an increased refcounter and did not document this yet. For the
> exceptions:
[Severity: Low]
This isn't a bug, but the commit message doesn't quite match the diff.
Earlier, the message gives "(with increased refcnt)" as an example of
wording that already documents this. The diff then removes that wording
and rewrites it in batadv_gw_get_selected_gw_node(),
batadv_gw_get_selected_orig(), batadv_hardif_get_by_netdev(),
batadv_primary_if_get_selected(), batadv_orig_hash_find() and all of the
netlink.c getters.
The same happens to "with an initialized reference counter" in
batadv_tt_local_create() and batadv_tt_global_create(). It also happens to
"it with an increased refcounter" in batadv_tt_global_orig_entry_find().
On the other hand, the other existing phrasing is left alone:
* The object is returned with refcounter increased by 1.
It is still in batadv_orig_node_vlan_new(), batadv_orig_router_get(),
batadv_orig_ifinfo_get(), batadv_orig_ifinfo_new(),
batadv_neigh_ifinfo_get(), batadv_neigh_ifinfo_new() and
batadv_last_bonding_get().
So the patch does more than add notes where none existed, but it also
doesn't make all of the refcount wording consistent. Could the commit
message say that existing refcount wording is being rewritten?
Alternatively, could the remaining "increased by 1" comments be converted
too, so the wording is consistent?
> diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c
> index e6e97c0478cc4..0dddcea7def9d 100644
> --- a/net/batman-adv/gateway_client.c
> +++ b/net/batman-adv/gateway_client.c
> @@ -74,7 +74,8 @@ void batadv_gw_node_release(struct kref *ref)
> * batadv_gw_get_selected_gw_node() - Get currently selected gateway
> * @bat_priv: the bat priv with all the mesh interface information
> *
> - * Return: selected gateway (with increased refcnt), NULL on errors
> + * Return: selected gateway, NULL on errors.
> + * The returned object has an increased refcounter.
> */
[ ... ]
> diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
> index f9de255ef0dfd..216f41387afa7 100644
> --- a/net/batman-adv/translation-table.c
> +++ b/net/batman-adv/translation-table.c
[ ... ]
> @@ -962,8 +965,8 @@ static bool batadv_tt_local_add_existing(struct batadv_priv *bat_priv,
> * 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.
> + * Return: the new entry on success, NULL otherwise.
> + * The returned object has an increased refcounter.
> */
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123171827.3294525-2-sw%40simonwunderlich.de
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH net-next 04/15] batman-adv: bla: register own backbone gw when claiming for local node
2026-11-23 17:18 ` [PATCH net-next 04/15] batman-adv: bla: register own backbone gw when claiming for local node Simon Wunderlich
@ 2026-11-24 17:20 ` netdev-bot+sashiko
2026-11-24 19:19 ` Sven Eckelmann
0 siblings, 1 reply; 31+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 17:20 UTC (permalink / raw)
To: sw; +Cc: netdev, davem, edumazet, kuba, pabeni, horms, b.a.t.m.a.n, sven
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit fixes a real BLA bug that users can see on the LAN,
but it has no Fixes: tag.
- [Low] The commit message says the own backbone gateway entry may be
missing "for example due to an earlier error".
--
batman-adv: bla: register own backbone gw when claiming for local node
With this patch, batadv_handle_claim() passes own_backbone=true to
batadv_bla_get_backbone_gw() when the backbone address is the primary
interface address. Before, an own backbone gateway entry created on the
rx claim path was set up like a foreign one. No initial announcement was
sent and the UNSYNCED grace period was skipped.
Closes: https://sashiko.dev/#/bug/linux-dba9d95d-5eeb-40fd-abf4-e054aee1f735
> When no backbone gateway entry for the local node exists yet on this VLAN
> (for example due to an earlier error), the entry is therefore created like
> a foreign backbone gateway.
[Severity: Low]
Is "for example due to an earlier error" the usual way to reach this state?
In batadv_bla_rx(), batadv_handle_claim() is called with the primary
interface address before batadv_bla_update_own_backbone_gw() runs at the
allow label:
net/batman-adv/bridge_loop_avoidance.c:batadv_bla_rx() {
...
batadv_handle_claim(bat_priv, primary_if,
primary_if->net_dev->dev_addr,
ethhdr->h_source, vid);
goto allow;
...
allow:
batadv_bla_update_own_backbone_gw(bat_priv, primary_if, vid);
...
}
batadv_bla_update_orig_address() also purges every backbone entry when
there is no old primary interface or BLA is disabled:
net/batman-adv/bridge_loop_avoidance.c:batadv_bla_update_orig_address() {
...
if (!oldif) {
batadv_bla_purge_claims(bat_priv, NULL, 1);
batadv_bla_purge_backbone_gw(bat_priv, 1);
return;
}
...
}
This runs when the primary interface is selected and when BLA is toggled
through batadv_bla_status_update().
After bring-up or a BLA toggle, the first frame on a VLAN received from
the mesh with an unclaimed source (or a unicast source claimed by a
foreign gateway) seems to create the own entry through
batadv_handle_claim(). That happens in normal operation, without any
earlier error.
Could the commit message say that this is the normal startup path? Stable
maintainers would then have an accurate picture of how often the bug
occurs.
> diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
> index 68ff2f94cf49d..3da070a087da6 100644
> --- a/net/batman-adv/bridge_loop_avoidance.c
> +++ b/net/batman-adv/bridge_loop_avoidance.c
> @@ -986,18 +986,22 @@ static bool batadv_handle_claim(struct batadv_priv *bat_priv,
> unsigned short vid)
> {
> struct batadv_bla_backbone_gw *backbone_gw;
> + bool own_backbone;
> +
> + own_backbone = batadv_compare_eth(backbone_addr,
> + primary_if->net_dev->dev_addr);
>
> /* register the gateway if not yet available, and add the claim. */
>
> backbone_gw = batadv_bla_get_backbone_gw(bat_priv, backbone_addr, vid,
> - false);
> + own_backbone);
[Severity: Low]
Should this patch have a Fixes: tag?
The false argument replaced here came from commit 52aebd6a9fe4
("batman-adv: send announcement when backbone gw is registered"). That
commit's message says the announcement should go out as soon as a
backbone gw is added, for example when "a packet passes the rx or tx
path". This rx call site never passed own_backbone=true, though.
Commit d807f2728708 later added the UNSYNCED/num_requests hold-back. It
sits in the same if (own_backbone) block in batadv_bla_get_backbone_gw(),
so this call site skipped it too.
Would something like this work?
Fixes: 52aebd6a9fe4 ("batman-adv: send announcement when backbone gw is registered")
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123171827.3294525-2-sw%40simonwunderlich.de
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH net-next 06/15] batman-adv: tt: refresh local entry in single flags_lock section
2026-11-23 17:18 ` [PATCH net-next 06/15] batman-adv: tt: refresh local entry in single flags_lock section Simon Wunderlich
@ 2026-11-24 17:20 ` netdev-bot+sashiko
2026-11-24 19:22 ` Sven Eckelmann
0 siblings, 1 reply; 31+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 17:20 UTC (permalink / raw)
To: sw; +Cc: netdev, davem, edumazet, kuba, pabeni, horms, b.a.t.m.a.n, sven
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message of "batman-adv: tt: refresh local entry in
single flags_lock section" tells reviewers and backporters less than…
--
batman-adv: tt: refresh local entry in single flags_lock section
This commit merges batadv_tt_local_add_existing() and
batadv_tt_local_update_flags() into batadv_tt_local_refresh(). Clearing
PENDING/ROAM, updating the dynamic flags and queueing the ADD event now all
happen in one flags_lock section. A new announce parameter requests the
initial ADD for a new entry.
Closes: https://sashiko.dev/#/bug/linux-7602d89e-b2cd-43ca-8aca-c165e5d674b2
> This is a preparation for the validation of the entry under the hash bucket
> list_lock, which then only needs to cover a single region.
>
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Closes: https://sashiko.dev/#/bug/linux-7602d89e-b2cd-43ca-8aca-c165e5d674b2
[Severity: Low]
The Reported-by: and Closes: tags suggest this is a bug fix. The message
calls it a preparation patch, though, and there is no Fixes: tag. Could the
message describe the race being fixed and what users see as a result?
Before this patch, batadv_tt_local_add() cleared PENDING in the flags_lock
section of batadv_tt_local_add_existing(). It then queued the ADD with
batadv_tt_local_event(), which reads the flags again after the lock has
been dropped:
flags = batadv_tt_flags_get(common) | event_flags;
__batadv_tt_local_event(bat_priv, common, flags);
That leaves a window like this:
CPU1 CPU2
batadv_tt_local_add()
batadv_tt_local_add_existing()
clear BATADV_TT_CLIENT_PENDING
batadv_tt_local_remove()
batadv_tt_local_set_pending()
set PENDING, queue DEL
batadv_tt_local_event()
__batadv_tt_local_event()
entry->change.flags = flags;
The late ADD is merged into the queued DEL, and its flags replace the DEL's
flags. The local entry still has PENDING set, so it is purged at the next
commit. The mesh is told ADD while the local table drops the client. The
CRC then no longer matches and a full table resync follows.
batadv_tt_local_refresh() now queues the event under the same flags_lock
that modifies the flags, which closes this window.
Could the commit message state this consequence and add a Fixes: tag? The
flag-update helpers being replaced seem to come from ec6edeb755ece6 and
d72e16b1c5d527.
Is this patch enough on its own to resolve the Closes: report? Or is the
later "batman-adv: tt: don't queue local events for unhashed entries" patch
also needed? Saying so in the message would help with backporting.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123171827.3294525-2-sw%40simonwunderlich.de
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH net-next 07/15] batman-adv: tt: don't remove unhashed local entries
2026-11-23 17:18 ` [PATCH net-next 07/15] batman-adv: tt: don't remove unhashed local entries Simon Wunderlich
@ 2026-11-24 17:20 ` netdev-bot+sashiko
2026-11-24 19:24 ` Sven Eckelmann
0 siblings, 1 reply; 31+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 17:20 UTC (permalink / raw)
To: sw; +Cc: netdev, davem, edumazet, kuba, pabeni, horms, b.a.t.m.a.n, sven
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit "batman-adv: tt: don't remove unhashed local entries"
fixes two real races in the local translation table but has no Fixes:…
--
batman-adv: tt: don't remove unhashed local entries
This patch merges batadv_tt_local_mark_removed() and
batadv_tt_local_remove_now() into batadv_tt_local_remove_entry(). The
hashed check, the BATADV_TT_CLIENT_NEW check and the unhash now all run
under the bucket list_lock and the flags_lock of the entry. This closes a
race with batadv_tt_local_purge_pending_clients() and a second race with
batadv_tt_local_transition_new().
> batadv_tt_local_remove() looks up the local entry via RCU only.
> batadv_tt_local_purge_pending_clients() can unhash it before
> batadv_tt_local_mark_removed() acquired the hash bucket list_lock. The DEL
> is then queued for a client which is no longer part of the local table (and
> its CRC). And it might replace the queued ADD of a new entry which was
> added for the same client in the meantime.
[ ... ]
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Closes: https://sashiko.dev/#/bug/linux-c3e34735-5286-4ed0-9338-a77e64fef540
> Signed-off-by: Sven Eckelmann <sven@narfation.org>
> Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
[Severity: Low]
This isn't a bug, but should this commit have a Fixes: tag?
The commit message describes two races that already exist in the tree:
- batadv_tt_local_mark_removed() queues a DEL without checking whether
batadv_tt_local_purge_pending_clients() has unhashed the entry after
the RCU lookup in batadv_tt_local_remove().
- batadv_tt_local_mark_removed() checks BATADV_TT_CLIENT_NEW under the
bucket list_lock, but batadv_tt_local_remove_now() unhashes the entry
via batadv_hash_remove() only after that lock has been dropped.
Two earlier fixes to the same functions both carry a Fixes: tag:
f95b9f28a9df ("batman-adv: tt: queue local DEL event under bucket lock")
a6746cb19076 ("batman-adv: tt: queue local DEL event before marking
entry as pending")
Both of them use:
Fixes: 976b159b3c12 ("batman-adv: tt: use protected flag modifications")
batadv_tt_local_remove_now(), which this patch removes, was added by
931de98d3960 ("batman-adv: tt: extract immediate purge of a local entry").
The missing hashed check in the first race was already there before
f95b9f28a9df. Its origin may therefore be a different commit than the one
behind the second race.
Without a Fixes: tag, backporters and the stable tooling cannot tell which
trees contain the broken logic. If leaving out the tag is intentional for
a net-next submission, as with the other fixes later in this series, please
disregard this.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123171827.3294525-2-sw%40simonwunderlich.de
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH net-next 10/15] batman-adv: tt: keep local entry unchanged when ADD can't be queued
2026-11-23 17:18 ` [PATCH net-next 10/15] batman-adv: tt: keep local entry unchanged when ADD can't be queued Simon Wunderlich
@ 2026-11-24 17:20 ` netdev-bot+sashiko
2026-11-24 19:30 ` Sven Eckelmann
0 siblings, 1 reply; 31+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 17:20 UTC (permalink / raw)
To: sw; +Cc: netdev, davem, edumazet, kuba, pabeni, horms, b.a.t.m.a.n, sven
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] Resolved later in the series.
--
batman-adv: tt: keep local entry unchanged when ADD can't be queued
This patch makes __batadv_tt_local_event() return whether the change was
stored. Callers that queue an ADD now modify the local entry only after
the ADD was queued: batadv_tt_local_refresh_locked() for flag updates and
batadv_tt_local_insert() for hashing a new entry. A failed refresh is
passed back up to batadv_tt_local_add().
> diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
> index 977f62c88da76..c94b292a1c4a8 100644
> --- a/net/batman-adv/translation-table.c
> +++ b/net/batman-adv/translation-table.c
> @@ -653,10 +653,18 @@ static u16 batadv_tt_flags_get(struct batadv_tt_common_entry *common)
> * Only a single change per client is queued. It describes the latest state of
> * the client and a new event therefore replaces an already queued one.
> *
> + * The other nodes only learn about the modification of a local entry through
> + * the queued change. The caller must therefore not modify the entry in a way
> + * which depends on this change (e.g. hash it as BATADV_TT_CLIENT_NEW or mark it
> + * as BATADV_TT_CLIENT_PENDING) when the event could not be stored.
> + *
> * The caller must hold the flags_lock of @common. The events of an entry are
> * then queued in the same order in which its flags were modified.
> + *
> + * Return: true if the event was stored, false if the memory for it could not
> + * be allocated.
> */
> -static void __batadv_tt_local_event(struct batadv_priv *bat_priv,
> +static bool __batadv_tt_local_event(struct batadv_priv *bat_priv,
> const struct batadv_tt_common_entry *common,
> u8 flags)
> __must_hold(&common->flags_lock)
[Severity: Low]
At this commit, batadv_tt_local_set_pending() in
net/batman-adv/translation-table.c doesn't follow the new rule. It still
ignores the return value and always sets the PENDING flag:
net/batman-adv/translation-table.c:batadv_tt_local_set_pending() {
...
__batadv_tt_local_event(bat_priv, common, common->flags | flags);
common->flags |= BATADV_TT_CLIENT_PENDING;
...
}
This DEL path has two callers. One is batadv_tt_local_remove_entry(),
including the roaming DEL with BATADV_TT_CLIENT_ROAM. The other is
batadv_tt_local_purge_list() for timed out clients.
If the GFP_ATOMIC allocation in __batadv_tt_local_event() fails there,
the entry ends up marked PENDING, and possibly ROAM, with no DEL queued.
At the next commit, batadv_tt_local_purge_pending_clients() unhashes
every PENDING entry. So the removal is never announced to the other
nodes.
The silent loss of the DEL already happened before this patch. What this
patch adds is a kerneldoc rule that this caller breaks. Should the
kerneldoc name batadv_tt_local_set_pending() as an exception here, or
should set_pending check the new return value?
The next patch in the series, "batman-adv: tt: requeue DEL of pending
local entry after failed allocation", seems to fix both. It adds
tt_local->del_unqueued, which batadv_tt_local_set_pending() sets when
the DEL was not queued. batadv_tt_local_purge_list() then requeues the
DEL, and pending entries with del_unqueued set are not unhashed. That
patch also rewords the kerneldoc to say that the DEL of
batadv_tt_local_set_pending() is the only exception.
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123171827.3294525-2-sw%40simonwunderlich.de
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH net-next 11/15] batman-adv: tt: requeue DEL of pending local entry after failed allocation
2026-11-23 17:18 ` [PATCH net-next 11/15] batman-adv: tt: requeue DEL of pending local entry after failed allocation Simon Wunderlich
@ 2026-11-24 17:20 ` netdev-bot+sashiko
0 siblings, 0 replies; 31+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 17:20 UTC (permalink / raw)
To: sw; +Cc: netdev, davem, edumazet, kuba, pabeni, horms, b.a.t.m.a.n, sven
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] A failed DEL|ROAM for a local entry that is already
BATADV_TT_CLIENT_PENDING is never retried, and the new kernel-doc says…
- [Low] The concern: the patch has no Fixes: tag and does not say that it
depends on the preceding commit "batman-adv: tt: keep local entry…
Pre-existing issues:
- [Low] The concern: the periodic batadv_tt_local_purge_list() requeue
runs without tt.commit_lock and can clear del_unqueued after…
--
batman-adv: tt: requeue DEL of pending local entry after failed allocation
Sometimes batadv_tt_local_set_pending() cannot queue the DEL for a local
entry because the change allocation failed. This patch marks such an
entry as del_unqueued. batadv_tt_local_purge_list() then retries the
DEL, and batadv_tt_local_purge_pending_clients() keeps the entry in the
local table until the DEL is queued. batadv_tt_local_refresh_locked()
clears the mark when the client is added again.
> diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
> index c94b292a1c4a8..0c5e21f3ba756 100644
> --- a/net/batman-adv/translation-table.c
> +++ b/net/batman-adv/translation-table.c
[ ... ]
> @@ -1779,13 +1793,24 @@ batadv_tt_local_set_pending(struct batadv_priv *bat_priv,
> {
> struct batadv_tt_common_entry *common = &tt_local_entry->common;
> struct batadv_hashtable *hash = bat_priv->tt.local_hash;
> + bool queued;
> u32 i;
>
> i = batadv_choose_tt(&common->key, hash->size);
> lockdep_assert_held(&hash->list_locks[i]);
> lockdep_assert_held(&common->flags_lock);
>
> - __batadv_tt_local_event(bat_priv, common, common->flags | flags);
> + queued = __batadv_tt_local_event(bat_priv, common,
> + common->flags | flags);
[Severity: Low]
This isn't a bug, but this code now relies on __batadv_tt_local_event()
returning bool. That return value was added by the preceding patch,
"batman-adv: tt: keep local entry unchanged when ADD can't be queued".
The commit message doesn't mention this dependency, and there is no
Fixes: tag. No patch in the series has a Fixes: tag, so this may be
intentional. Is the series meant to stay out of stable?
> +
> + /* a failed attempt must not hide the still queued DEL of an already
> + * pending entry
> + */
> + if (queued)
> + tt_local_entry->del_unqueued = false;
> + else if (!(common->flags & BATADV_TT_CLIENT_PENDING))
> + tt_local_entry->del_unqueued = true;
[Severity: Low]
What happens here when the entry is already BATADV_TT_CLIENT_PENDING and
the new event carries BATADV_TT_CLIENT_ROAM?
batadv_tt_local_remove_entry() doesn't check for PENDING. With roaming
set, it does this:
if (roaming)
common->flags |= BATADV_TT_CLIENT_ROAM;
flags = BATADV_TT_CLIENT_DEL;
if (roaming)
flags |= BATADV_TT_CLIENT_ROAM;
batadv_tt_local_set_pending(bat_priv, tt_local_entry, flags,
message);
A remote node can reach this path:
batadv_handle_roam_adv()
batadv_tt_global_add(..., BATADV_TT_CLIENT_ROAM)
batadv_tt_global_purge_local()
batadv_tt_local_remove(..., roaming=true)
batadv_tt_local_set_pending(DEL | ROAM)
Say a plain DEL was already queued earlier in the same OGM interval, for
example by the timeout in batadv_tt_local_purge_list(). The DEL+DEL
update can still fail, because __batadv_tt_local_event() allocates
before it looks for the queued change to merge into:
tt_change_node = kmem_cache_alloc(batadv_tt_change_cache, GFP_ATOMIC);
if (!tt_change_node)
return false;
In that case the else-if above leaves del_unqueued false. So
batadv_tt_local_purge_list() never requeues the DEL with the ROAM flag.
Only the plain DEL is announced. Receivers then call
batadv_tt_global_del() with roaming=false. That removes the old
originator right away instead of going through
batadv_tt_global_del_roaming().
Could unicast traffic to the client be lost until the ADD from the new
originator arrives?
The kernel-doc this patch adds to __batadv_tt_local_event() says:
The only exception is the DEL of batadv_tt_local_set_pending(). Its
entry is marked as del_unqueued to get the DEL requeued by
batadv_tt_local_purge_list().
The new batadv_tt_local_set_pending() kernel-doc says the same: "Such an
entry is marked as del_unqueued instead". Neither seems to hold for this
case.
The lost ROAM upgrade was already possible before this series. The
kernel-doc claiming this case is covered is new, though, and this part
looks the same at the end of the series.
Could __batadv_tt_local_event() look up the existing change before
allocating, so the in-place update can't fail? If not, the kernel-doc
could say that an already pending entry only keeps its first DEL.
> +
> common->flags |= BATADV_TT_CLIENT_PENDING;
[ ... ]
> @@ -1911,11 +1936,18 @@ static void batadv_tt_local_purge_list(struct batadv_priv *bat_priv,
> common);
>
> scoped_guard(spinlock_bh, &tt_local_entry->common.flags_lock) {
> - if (tt_local_entry->common.flags & BATADV_TT_CLIENT_NOPURGE)
> + /* entry already marked for deletion */
> + if (tt_local_entry->common.flags & BATADV_TT_CLIENT_PENDING) {
> + /* but its removal must still be announced */
> + if (tt_local_entry->del_unqueued)
> + batadv_tt_local_set_pending(bat_priv,
> + tt_local_entry,
> + BATADV_TT_CLIENT_DEL,
> + "requeued");
[Severity: Low]
This is a pre-existing issue and wasn't introduced by this patch. This
requeue runs from the periodic work without tt.commit_lock.
Can it clear del_unqueued after the splice but before
batadv_tt_local_purge_pending_clients() runs in
batadv_tt_local_commit_changes_nolock()?
spin_lock_bh(&bat_priv->tt.changes_list_lock);
list_splice_init(&bat_priv->tt.changes_list, &changes_list);
...
batadv_tt_local_transition_new(bat_priv);
batadv_tt_local_purge_pending_clients(bat_priv);
If so, the entry is removed in the current TTVN, but its DEL is only
announced in the next one. The same window already existed for any
concurrent batadv_tt_local_set_pending() DEL. The worst case looks like
a CRC mismatch for one TTVN, which a full table request repairs.
A later patch in this series, "batman-adv: tt: commit only the announced
local changes", seems to close this. After it, only entries whose DEL is
in the spliced changes_list are unhashed. The only remaining caller of
batadv_tt_local_purge_pending_clients() is
batadv_tt_local_resize_to_mtu(), which runs under commit_lock before the
splice.
> break;
> + }
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123171827.3294525-2-sw%40simonwunderlich.de
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH net-next 12/15] batman-adv: tt: extract removal of pending local entry
2026-11-23 17:18 ` [PATCH net-next 12/15] batman-adv: tt: extract removal of pending local entry Simon Wunderlich
@ 2026-11-24 17:20 ` netdev-bot+sashiko
0 siblings, 0 replies; 31+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 17:20 UTC (permalink / raw)
To: sw; +Cc: netdev, davem, edumazet, kuba, pabeni, horms, b.a.t.m.a.n, sven
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The kernel-docs of batadv_tt_local_unhash() and
batadv_tt_local_unhash_pending() disagree about who checks that the…
--
batman-adv: tt: extract removal of pending local entry
This moves the removal of a single pending entry out of
batadv_tt_local_purge_pending_clients() into a new helper,
batadv_tt_local_unhash_pending(). The helper calls a lower level
batadv_tt_local_unhash(), which does the actual unhash steps. There is
no functional change.
> diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
> index 0c5e21f3ba756..2a7f50de70fc8 100644
> --- a/net/batman-adv/translation-table.c
> +++ b/net/batman-adv/translation-table.c
> @@ -1760,6 +1760,44 @@ int batadv_tt_local_dump(struct sk_buff *msg, struct netlink_callback *cb)
> return ret;
> }
>
> +/**
> + * batadv_tt_local_unhash() - remove an entry from the local table
> + * @bat_priv: the bat priv with all the mesh interface information
> + * @tt_local: the local TT entry to remove
> + * @message: message to append to the log on deletion
> + *
> + * The caller must hold the hash bucket list_lock and the flags_lock of the
> + * entry. It must have checked that the entry is still part of the local table
> + * and has to drop the reference of the hash after it released the flags_lock.
> + */
[ ... ]
> @@ -4550,6 +4588,43 @@ static void batadv_tt_local_transition_new(struct batadv_priv *bat_priv)
> }
> }
>
> +/**
> + * batadv_tt_local_unhash_pending() - remove a pending entry from the local table
> + * @bat_priv: the bat priv with all the mesh interface information
> + * @tt_local: the local TT entry to remove
> + *
> + * Only an entry which is marked as BATADV_TT_CLIENT_PENDING and whose DEL was
> + * queued is removed. An entry which still waits for its DEL (del_unqueued) must
> + * stay in the local table until batadv_tt_local_purge_list() was able to queue
> + * it.
> + *
> + * The caller must hold the hash bucket list_lock and the flags_lock of the
> + * entry.
> + *
> + * Return: true if the entry was unhashed and the caller has to drop the
> + * reference of the hash, false otherwise.
> + */
> +static bool
> +batadv_tt_local_unhash_pending(struct batadv_priv *bat_priv,
> + struct batadv_tt_local_entry *tt_local)
> + __must_hold(&tt_local->common.flags_lock)
> +{
> + struct batadv_tt_common_entry *tt_common = &tt_local->common;
> +
> + lockdep_assert_held(&tt_common->flags_lock);
> +
> + if (!(tt_common->flags & BATADV_TT_CLIENT_PENDING))
> + return false;
> +
> + /* the removal must be announced first */
> + if (tt_local->del_unqueued)
> + return false;
> +
> + batadv_tt_local_unhash(bat_priv, tt_local, "pending");
> +
> + return true;
> +}
[Severity: Low]
This isn't a bug, but the kernel-doc of batadv_tt_local_unhash_pending()
seems to leave out a requirement it inherits from batadv_tt_local_unhash().
The kernel-doc of batadv_tt_local_unhash() says the caller "must have
checked that the entry is still part of the local table". That function
does not check hlist_unhashed() itself. It always calls
hlist_del_init_rcu(), increments hash->generation and calls
batadv_tt_local_size_dec() for entries without BATADV_TT_CLIENT_NEW.
batadv_tt_local_unhash_pending() checks only BATADV_TT_CLIENT_PENDING and
del_unqueued before it calls batadv_tt_local_unhash(). Its kernel-doc asks
callers only to hold the bucket list_lock and the flags_lock. It still
says that a true return means the caller must drop the hash reference.
batadv_tt_local_unhash() does not clear the flags. So an entry that was
already unhashed can still have BATADV_TT_CLIENT_PENDING set with
del_unqueued false.
A caller that relied only on the documented contract of the wrapper could
pass such an entry and get true back. The per-VID size would then be
decremented twice and the hash reference put twice.
There is no such caller now. Both batadv_tt_local_purge_pending_clients()
and the batadv_tt_local_commit_change() caller added later in the series
find the entry by walking the bucket under list_lock.
Could the kernel-doc of batadv_tt_local_unhash_pending() state the same
membership requirement as batadv_tt_local_unhash()? Another option would
be an hlist_unhashed() check inside the wrapper.
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123171827.3294525-2-sw%40simonwunderlich.de
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH net-next 13/15] batman-adv: tt: commit only the announced local changes
2026-11-23 17:18 ` [PATCH net-next 13/15] batman-adv: tt: commit only the announced local changes Simon Wunderlich
@ 2026-11-24 17:20 ` netdev-bot+sashiko
0 siblings, 0 replies; 31+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 17:20 UTC (permalink / raw)
To: sw; +Cc: netdev, davem, edumazet, kuba, pabeni, horms, b.a.t.m.a.n, sven
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The change does not fully deliver the invariant it states.
- [Low] Two comments no longer match the code after this patch.
--
batman-adv: tt: commit only the announced local changes
batadv_tt_local_commit_changes_nolock() no longer scans the whole local
table when it commits. It now walks the change list it took for the new
TTVN and calls batadv_tt_local_commit_change() for each queued change: an
ADD ends the NEW state of an entry and a DEL removes the pending entry. An
entry whose client was detected again after its DEL was taken is put back
into the NEW state, so it stays out of the CRC until its ADD is committed.
> diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
> index 2a7f50de70fc8..b03d6c74732f4 100644
> --- a/net/batman-adv/translation-table.c
> +++ b/net/batman-adv/translation-table.c
[ ... ]
> @@ -1876,9 +1882,8 @@ batadv_tt_local_set_pending(struct batadv_priv *bat_priv,
> *
> * All checks and modifications happen under the hash bucket list_lock and the
> * flags_lock of the entry. This prevents a concurrent
> - * batadv_tt_local_purge_pending_clients() from removing the entry,
> - * batadv_tt_local_transition_new() from clearing BATADV_TT_CLIENT_NEW and
> - * batadv_tt_local_refresh() from modifying the entry after it was checked.
> + * batadv_tt_local_commit_change() from removing the entry and
> + * batadv_tt_local_refresh() from modifying it after it was checked.
> */
[Severity: Low]
Should batadv_tt_local_purge_pending_clients() still be listed here?
It is still called from batadv_tt_local_resize_to_mtu() with only
commit_lock held:
batadv_tt_local_purge(bat_priv, timeout);
batadv_tt_local_purge_pending_clients(bat_priv);
It unhashes PENDING entries through batadv_tt_local_unhash_pending()
under the same list_locks[i] and entry flags_lock. Because
batadv_tt_local_remove_entry() does not take commit_lock, the two can
still run concurrently.
On a related note, the comment in batadv_tt_local_unhash() is no longer
accurate:
/* An entry which still carries BATADV_TT_CLIENT_NEW was never counted
* and must not be uncounted here.
*/
if (!(tt_common->flags & BATADV_TT_CLIENT_NEW))
batadv_tt_local_size_dec(bat_priv, tt_common->key.vid);
batadv_tt_local_commit_change() can now set NEW again on an entry that
was already counted, and it uncounts that entry with
batadv_tt_local_size_dec(). The accounting is still correct, because NEW
means "not counted right now". But "was never counted" is wrong for such
entries. Could this comment be updated too? Later patches in the series
change neither comment.
[ ... ]
> +/**
> + * batadv_tt_local_commit_change() - apply a committed change to the local table
> + * @bat_priv: the bat priv with all the mesh interface information
> + * @change: the change which is announced with the new ttvn
> + *
> + * The CRC and the full table responses of a ttvn must reflect exactly the
> + * changes announced with it. Only the entry affected by a committed change is
> + * therefore modified. An entry which was added or marked for removal after the
> + * change set was taken stays in its current state until its own change is
> + * committed with a later ttvn.
[ ... ]
> + hlist_for_each_entry(tt_common, head, hash_entry) {
> + if (!batadv_compare_tt(&tt_common->hash_entry, &key))
> + continue;
> +
> + scoped_guard(spinlock_bh, &tt_common->flags_lock) {
> + if (!del_op) {
> + /* an ADD of an already committed entry only
> + * announces new flags or cancels its removal
> + */
> + if (!(tt_common->flags & BATADV_TT_CLIENT_NEW))
> + break;
[Severity: Medium]
Does this fully meet the invariant in the kernel-doc above ("must
reflect exactly the changes announced with it") when flags change?
The CRC-relevant flags BATADV_TT_CLIENT_WIFI and BATADV_TT_CLIENT_ISOLA
are in BATADV_TT_SYNC_MASK. They are still written to the live entry
when their ADD is queued, not when that ADD is committed. That happens
in batadv_tt_local_refresh_locked(), reached through
batadv_tt_local_add()->batadv_tt_local_refresh(). That path holds only
the bucket list_lock and the entry flags_lock, not tt.commit_lock:
if (announce &&
!__batadv_tt_local_event(bat_priv, common, flags))
return false;
common->flags = flags;
Consider this sequence:
CPU1 (commit_lock held)
batadv_tt_local_commit_changes_nolock()
list_splice_init(&bat_priv->tt.changes_list, &changes_list);
CPU2
batadv_tt_local_add()->batadv_tt_local_refresh()
WIFI or ISOLA of client X changes
ADD(X) is queued in the fresh tt.changes_list for N+1
common->flags = flags;
CPU1
batadv_tt_local_commit_change() for X: entry is not NEW, so break
batadv_tt_local_update_crc()
batadv_tt_local_crc() hashes the live flags of every entry that is not
NEW:
if (tt_flags & BATADV_TT_CLIENT_NEW)
continue;
flags = tt_flags & BATADV_TT_SYNC_MASK;
Doesn't CRC N then already include flags that are only announced with
N+1?
The same seems to apply when changeset N carries the initial ADD(X, F1)
and a refresh queues ADD(X, F2) for N+1 before the commit runs. This
function clears NEW, and CRC N is computed with F2, while the announced
changeset says F1.
Receivers that apply changeset N would then see a CRC mismatch and fall
back to a full-table TT_REQUEST. The commit message says this patch
removes that symptom. The window is small: one bucket lookup per queued
change between list_splice_init() and batadv_tt_local_update_crc().
The eager common->flags = flags write is still there at the end of the
series. The last patch ("drop ADD+DEL events of never announced
clients") also mentions this window: "An ADD queued by
batadv_tt_local_refresh() in this window (for example for a changed
BATADV_TT_CLIENT_WIFI flag)".
> +
> + tt_common->flags &= ~BATADV_TT_CLIENT_NEW;
> + committed = true;
> + break;
> + }
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123171827.3294525-2-sw%40simonwunderlich.de
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH net-next 15/15] batman-adv: tt: drop ADD+DEL events of never announced clients
2026-11-23 17:18 ` [PATCH net-next 15/15] batman-adv: tt: drop ADD+DEL events of never announced clients Simon Wunderlich
@ 2026-11-24 17:20 ` netdev-bot+sashiko
0 siblings, 0 replies; 31+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 17:20 UTC (permalink / raw)
To: sw; +Cc: netdev, davem, edumazet, kuba, pabeni, horms, b.a.t.m.a.n, sven
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] In net/batman-adv/translation-table.c, batadv_tt_local_event()
allocates the new change node with…
- [Low] The new cancel path in batadv_tt_local_set_pending() (lines
1957-1961) unhashes a NEW local entry as soon as a DEL cancels its…
- [Low] Some kernel-doc still describes removal of a local entry as
always deferred, but after this patch it can be immediate.
--
batman-adv: tt: drop ADD+DEL events of never announced clients
With this patch, a DEL event cancels the queued initial ADD of a local
TT client that was never announced, and the local entry is removed from
the table right away. Each queued change node now records whether it is
the initial ADD of its client. An ADD queued after the initial ADD was
committed therefore stays non-cancellable.
> diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
> index 998c7f285e1df..c17cfee6ff84d 100644
> --- a/net/batman-adv/translation-table.c
> +++ b/net/batman-adv/translation-table.c
> @@ -651,13 +651,20 @@ static u16 batadv_tt_flags_get(struct batadv_tt_common_entry *common)
[ ... ]
> * Only a single change per client is queued. It describes the latest state of
> - * the client and a new event therefore replaces an already queued one.
> + * the client and a new event therefore replaces an already queued one. The
> + * only exception is a DEL for a client whose initial ADD is still queued. The
> + * other nodes don't need to know anything about such a client and the ADD is
> + * cancelled instead.
[ ... ]
> @@ -669,12 +676,12 @@ static u16 batadv_tt_flags_get(struct batadv_tt_common_entry *common)
[ ... ]
> - * Return: true if the event was stored, false if the memory for it could not
> - * be allocated.
> + * Return: true if the event was stored (or cancelled a queued ADD), false if
> + * the memory for it could not be allocated.
[ ... ]
> @@ -685,6 +692,9 @@ static bool __batadv_tt_local_event(struct batadv_priv *bat_priv,
>
> lockdep_assert_held(&common->flags_lock);
>
> + if (cancelled)
> + *cancelled = false;
> +
> tt_change_node = kmem_cache_alloc(batadv_tt_change_cache, GFP_ATOMIC);
> if (!tt_change_node)
> return false;
[Severity: Low]
Can the cancellation be skipped under memory pressure? In
batadv_tt_local_event(), the new change node is allocated before
changes_list is searched for a queued initial ADD.
If this GFP_ATOMIC allocation fails while an initial_add entry for the
client is still queued, the function returns false and *cancelled stays
false. The cancel itself needs no memory. That branch only frees the
queued entry and the new node.
batadv_tt_local_set_pending() then takes the queued == false path. It
sets PENDING and del_unqueued and leaves the initial ADD in the list.
The next batadv_tt_local_commit_changes_nolock() announces the client as
an ADD. batadv_tt_local_purge_list() then requeues a DEL for the
following TTVN.
That matches the pre-patch behaviour, so the tables stay consistent.
However, the kernel-doc above describes the cancellation as
unconditional. The Return text also doesn't say that an allocation
failure skips it.
Would it make sense to search the list first and allocate only when
nothing matched? Alternatively, the kernel-doc could say that the
cancellation is best-effort.
[ ... ]
> @@ -1883,6 +1919,11 @@ static void batadv_tt_local_unhash(struct batadv_priv *bat_priv,
> * retry it. Such an entry is marked as del_unqueued instead. It stays in the
> * local table until batadv_tt_local_purge_list() was able to queue its DEL.
> *
> + * A client whose initial ADD is still queued was never announced to the other
> + * nodes. Its DEL cancels the ADD and the entry is removed from the local table
> + * right away. The caller has to drop the hash reference of the entry after it
> + * released the flags_lock.
> + *
[Severity: Low]
This isn't a bug, but the first paragraph of the
batadv_tt_local_set_pending() kernel-doc still reads:
* The entry is kept in the local table until the next TTVN increment
* so that a consistency-check response can still be answered.
That is no longer always true with the new cancel path. Only this later
paragraph mentions the exception.
The summary line of batadv_tt_local_remove() also still says "logically
remove an entry from the local table". Through
batadv_tt_local_remove()->batadv_tt_local_remove_entry()->
batadv_tt_local_set_pending(), the entry can now be unhashed and freed
before any TTVN increment.
Could both comments be updated? The callers of batadv_tt_local_remove()
in mesh-interface.c and multicast.c rely on that description.
[ ... ]
> @@ -1907,8 +1952,13 @@ batadv_tt_local_set_pending(struct batadv_priv *bat_priv,
> lockdep_assert_held(&hash->list_locks[i]);
> lockdep_assert_held(&common->flags_lock);
>
> - queued = __batadv_tt_local_event(bat_priv, common,
> - common->flags | flags);
> + queued = batadv_tt_local_event(bat_priv, common, common->flags | flags,
> + false, &cancelled);
> + if (cancelled) {
> + /* the entry was never announced */
> + batadv_tt_local_unhash(bat_priv, tt_local_entry, message);
> + return true;
> + }
[Severity: Low]
Does this hold when the DEL comes from a roaming event? The commit
message says:
The other nodes never heard about the client and don't need a DEL
for it.
When the entry was inserted, batadv_tt_local_add_roam() may already have
sent a ROAMING_ADV to the previous originator:
hlist_for_each_entry_rcu(orig_entry, head, list) {
batadv_send_roam_adv(bat_priv, tt_global->common.key.addr,
tt_global->common.key.vid,
orig_entry->orig_node);
}
The previous originator (call it C) then creates a ROAM-flagged global
entry that points to this node (A). It also marks its own local entry
ROAM|PENDING.
This also happens when a client roams back. When C's ROAMING_ADV is
merged, batadv_tt_global_merge_flags() clears ROAM on the global entry.
The early return in batadv_tt_local_add_roam() therefore doesn't prevent
A's ROAMING_ADV.
Just before this call, batadv_tt_local_remove_entry() marks the entry
for later rerouting:
net/batman-adv/translation-table.c:batadv_tt_local_remove_entry() {
...
/* 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)
common->flags |= BATADV_TT_CLIENT_ROAM;
...
}
With the cancel path, the entry is unhashed in the same flags_lock
section, so this ROAM mark is lost immediately.
First, the local roaming reroute seems to be lost. After the unhash,
batadv_tt_local_client_is_roaming() no longer finds the entry, so
batadv_check_unicast_ttvn() skips the reroute. Take a unicast packet for
the client that carries A's current TTVN, for example one that C
rerouted to A. It is now delivered locally instead of being sent back.
Before this patch it was rerouted until the next commit.
Second, C can keep stale state. Consider client X:
X roams C->A, A sends a ROAMING_ADV to C
C commits DEL|ROAM for X, A frees its global X on that DEL
X reappears at C as a new local entry
batadv_tt_local_add_roam() on C returns early, because C's global
X->A carries ROAM
C announces ADD X, which reaches A before A commits its initial ADD
on A: batadv_tt_global_add()->batadv_tt_global_purge_local()->
batadv_tt_local_remove(roaming=false) cancels A's initial ADD
A then sends nothing for X. Before this patch, the merged change went
out as DEL X, and batadv_tt_global_del() on C removed the stale entry.
Now C keeps the ROAM-flagged global entry X->A until
BATADV_TT_CLIENT_ROAM_TIMEOUT expires (600 seconds).
Should the cancel path be skipped for roaming DELs, or for clients that
already sent a ROAMING_ADV?
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123171827.3294525-2-sw%40simonwunderlich.de
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH net-next 04/15] batman-adv: bla: register own backbone gw when claiming for local node
2026-11-24 17:20 ` netdev-bot+sashiko
@ 2026-11-24 19:19 ` Sven Eckelmann
0 siblings, 0 replies; 31+ messages in thread
From: Sven Eckelmann @ 2026-11-24 19:19 UTC (permalink / raw)
To: sw, netdev-bot+sashiko
Cc: netdev, davem, edumazet, kuba, pabeni, horms, b.a.t.m.a.n
[-- Attachment #1: Type: text/plain, Size: 1628 bytes --]
On Tuesday, 24 November 2026 18:20:38 CET netdev-bot+sashiko@kernel.org wrote:
[...]
> > When no backbone gateway entry for the local node exists yet on this VLAN
> > (for example due to an earlier error), the entry is therefore created like
> > a foreign backbone gateway.
>
> [Severity: Low]
> Is "for example due to an earlier error" the usual way to reach this state?
I just gave an example. Sorry for not providing a full list of everything
which ever could happen under any circumstance.... will also not change the
commit for this.
>
> Could the commit message say that this is the normal startup path? Stable
> maintainers would then have an accurate picture of how often the bug
> occurs.
No stable maintainer involved here.
> > diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
> > index 68ff2f94cf49d..3da070a087da6 100644
> > --- a/net/batman-adv/bridge_loop_avoidance.c
> > +++ b/net/batman-adv/bridge_loop_avoidance.c
> > @@ -986,18 +986,22 @@ static bool batadv_handle_claim(struct batadv_priv *bat_priv,
> > unsigned short vid)
> > {
> > struct batadv_bla_backbone_gw *backbone_gw;
> > + bool own_backbone;
> > +
> > + own_backbone = batadv_compare_eth(backbone_addr,
> > + primary_if->net_dev->dev_addr);
> >
> > /* register the gateway if not yet available, and add the claim. */
> >
> > backbone_gw = batadv_bla_get_backbone_gw(bat_priv, backbone_addr, vid,
> > - false);
> > + own_backbone);
>
> [Severity: Low]
> Should this patch have a Fixes: tag?
No, Fixes: or Cc: stable@ are not allowed for net-next
Regards,
Sven
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH net-next 06/15] batman-adv: tt: refresh local entry in single flags_lock section
2026-11-24 17:20 ` netdev-bot+sashiko
@ 2026-11-24 19:22 ` Sven Eckelmann
0 siblings, 0 replies; 31+ messages in thread
From: Sven Eckelmann @ 2026-11-24 19:22 UTC (permalink / raw)
To: sw, netdev-bot+sashiko
Cc: netdev, davem, edumazet, kuba, pabeni, horms, b.a.t.m.a.n
[-- Attachment #1: Type: text/plain, Size: 1217 bytes --]
On Tuesday, 24 November 2026 18:20:40 CET netdev-bot+sashiko@kernel.org wrote:
[...]
> > This is a preparation for the validation of the entry under the hash bucket
> > list_lock, which then only needs to cover a single region.
> >
> > Reported-by: Sashiko <sashiko-bot@kernel.org>
> > Closes: https://sashiko.dev/#/bug/linux-7602d89e-b2cd-43ca-8aca-c165e5d674b2
>
> [Severity: Low]
> The Reported-by: and Closes: tags suggest this is a bug fix. The message
> calls it a preparation patch, though, and there is no Fixes: tag. Could the
> message describe the race being fixed and what users see as a result?
No, it gives here attribution to Sashiko and helps me to figure out what I've
handled and what not.
[...]
> Could the commit message state this consequence and add a Fixes: tag? The
> flag-update helpers being replaced seem to come from ec6edeb755ece6 and
> d72e16b1c5d527.
No, Fixes: or Cc: stable@ are not allowed for net-next
> Is this patch enough on its own to resolve the Closes: report? Or is the
> later "batman-adv: tt: don't queue local events for unhashed entries" patch
> also needed? Saying so in the message would help with backporting.
No stable maintainer involved here.
Regards,
Sven
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH net-next 07/15] batman-adv: tt: don't remove unhashed local entries
2026-11-24 17:20 ` netdev-bot+sashiko
@ 2026-11-24 19:24 ` Sven Eckelmann
0 siblings, 0 replies; 31+ messages in thread
From: Sven Eckelmann @ 2026-11-24 19:24 UTC (permalink / raw)
To: sw, netdev-bot+sashiko
Cc: netdev, davem, edumazet, kuba, pabeni, horms, b.a.t.m.a.n
[-- Attachment #1: Type: text/plain, Size: 1071 bytes --]
On Tuesday, 24 November 2026 18:20:41 CET netdev-bot+sashiko@kernel.org wrote:
[...]
> > batadv_tt_local_remove() looks up the local entry via RCU only.
> > batadv_tt_local_purge_pending_clients() can unhash it before
> > batadv_tt_local_mark_removed() acquired the hash bucket list_lock. The DEL
> > is then queued for a client which is no longer part of the local table (and
> > its CRC). And it might replace the queued ADD of a new entry which was
> > added for the same client in the meantime.
>
> [ ... ]
>
> > Reported-by: Sashiko <sashiko-bot@kernel.org>
> > Closes: https://sashiko.dev/#/bug/linux-c3e34735-5286-4ed0-9338-a77e64fef540
> > Signed-off-by: Sven Eckelmann <sven@narfation.org>
> > Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
>
> [Severity: Low]
> This isn't a bug, but should this commit have a Fixes: tag?
No, Fixes: or Cc: stable@ are not allowed for net-next
[...]
> Without a Fixes: tag, backporters and the stable tooling cannot tell which
> trees contain the broken logic.
No stable maintainer involved here.
Regards,
Sven
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH net-next 10/15] batman-adv: tt: keep local entry unchanged when ADD can't be queued
2026-11-24 17:20 ` netdev-bot+sashiko
@ 2026-11-24 19:30 ` Sven Eckelmann
0 siblings, 0 replies; 31+ messages in thread
From: Sven Eckelmann @ 2026-11-24 19:30 UTC (permalink / raw)
To: sw, netdev-bot+sashiko
Cc: netdev, davem, edumazet, kuba, pabeni, horms, b.a.t.m.a.n
[-- Attachment #1: Type: text/plain, Size: 1839 bytes --]
On Tuesday, 24 November 2026 18:20:43 CET netdev-bot+sashiko@kernel.org wrote:
> > diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
> > index 977f62c88da76..c94b292a1c4a8 100644
> > --- a/net/batman-adv/translation-table.c
> > +++ b/net/batman-adv/translation-table.c
> > @@ -653,10 +653,18 @@ static u16 batadv_tt_flags_get(struct batadv_tt_common_entry *common)
> > * Only a single change per client is queued. It describes the latest state of
> > * the client and a new event therefore replaces an already queued one.
> > *
> > + * The other nodes only learn about the modification of a local entry through
> > + * the queued change. The caller must therefore not modify the entry in a way
> > + * which depends on this change (e.g. hash it as BATADV_TT_CLIENT_NEW or mark it
> > + * as BATADV_TT_CLIENT_PENDING) when the event could not be stored.
> > + *
> > * The caller must hold the flags_lock of @common. The events of an entry are
> > * then queued in the same order in which its flags were modified.
> > + *
> > + * Return: true if the event was stored, false if the memory for it could not
> > + * be allocated.
> > */
> > -static void __batadv_tt_local_event(struct batadv_priv *bat_priv,
> > +static bool __batadv_tt_local_event(struct batadv_priv *bat_priv,
> > const struct batadv_tt_common_entry *common,
> > u8 flags)
> > __must_hold(&common->flags_lock)
>
> [Severity: Low]
> At this commit, batadv_tt_local_set_pending() in
> net/batman-adv/translation-table.c doesn't follow the new rule. It still
> ignores the return value and always sets the PENDING flag:
This prepares it for a later patch. I don't think it helps us here to discuss
in which patch this comment is added.
Regards,
Sven
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
end of thread, other threads:[~2026-11-24 19:30 UTC | newest]
Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 17:18 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-11-23 Simon Wunderlich
2026-11-23 17:18 ` [PATCH net-next 01/15] batman-adv: document refcount of returned objects Simon Wunderlich
2026-11-23 17:23 ` netdev-bot+sinfo
2026-11-23 18:13 ` Sven Eckelmann
2026-11-24 17:20 ` netdev-bot+sashiko
2026-11-23 17:18 ` [PATCH net-next 02/15] batman-adv: mcast: use mla_lock also during mcast_free Simon Wunderlich
2026-11-23 17:18 ` [PATCH net-next 03/15] batman-adv: mark functions inheriting critical sections Simon Wunderlich
2026-11-23 17:18 ` [PATCH net-next 04/15] batman-adv: bla: register own backbone gw when claiming for local node Simon Wunderlich
2026-11-24 17:20 ` netdev-bot+sashiko
2026-11-24 19:19 ` Sven Eckelmann
2026-11-23 17:18 ` [PATCH net-next 05/15] batman-adv: tt: unhash local entries with hlist_del_init_rcu() Simon Wunderlich
2026-11-23 17:18 ` [PATCH net-next 06/15] batman-adv: tt: refresh local entry in single flags_lock section Simon Wunderlich
2026-11-24 17:20 ` netdev-bot+sashiko
2026-11-24 19:22 ` Sven Eckelmann
2026-11-23 17:18 ` [PATCH net-next 07/15] batman-adv: tt: don't remove unhashed local entries Simon Wunderlich
2026-11-24 17:20 ` netdev-bot+sashiko
2026-11-24 19:24 ` Sven Eckelmann
2026-11-23 17:18 ` [PATCH net-next 08/15] batman-adv: tt: don't queue local events for unhashed entries Simon Wunderlich
2026-11-23 17:18 ` [PATCH net-next 09/15] batman-adv: tt: remove unannounced local entries via pending state Simon Wunderlich
2026-11-23 17:18 ` [PATCH net-next 10/15] batman-adv: tt: keep local entry unchanged when ADD can't be queued Simon Wunderlich
2026-11-24 17:20 ` netdev-bot+sashiko
2026-11-24 19:30 ` Sven Eckelmann
2026-11-23 17:18 ` [PATCH net-next 11/15] batman-adv: tt: requeue DEL of pending local entry after failed allocation Simon Wunderlich
2026-11-24 17:20 ` netdev-bot+sashiko
2026-11-23 17:18 ` [PATCH net-next 12/15] batman-adv: tt: extract removal of pending local entry Simon Wunderlich
2026-11-24 17:20 ` netdev-bot+sashiko
2026-11-23 17:18 ` [PATCH net-next 13/15] batman-adv: tt: commit only the announced local changes Simon Wunderlich
2026-11-24 17:20 ` netdev-bot+sashiko
2026-11-23 17:18 ` [PATCH net-next 14/15] batman-adv: tt: avoid list_lock for unchanged local clients Simon Wunderlich
2026-11-23 17:18 ` [PATCH net-next 15/15] batman-adv: tt: drop ADD+DEL events of never announced clients Simon Wunderlich
2026-11-24 17:20 ` netdev-bot+sashiko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox