Skip to contentSkip to conversation

pull request: batman-adv 2025-05-09

PATCH Applied Simon Wunderlich 2 participants 3 messages Feb 25 – Feb 27

Subsystems (4)
lore
Share & tools
lore

Simon Wunderlich

author maintainer
#0 lore raw

cover pull request: batman-adv 2025-05-09

Hi David, hi Jakub,

here is a bugfix for batman-adv which we would like to have integrated into net.

Please pull or let me know of any problem!

Thank you,
Simon

The following changes since commit 8f7aa3d3c7323f4ca2768a9e74ebbe359c4f8f88:

Merge tag 'net-next-6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next (2025-12-03 17:24:33 -0800)

are available in the Git repository at:

https://git.open-mesh.org/linux-merge.git tags/batadv-net-pullrequest-20260225

for you to fetch changes up to cfc83a3c71517b59c1047db57da31e26a9dc2f33:

batman-adv: Avoid double-rtnl_lock ELP metric worker (2026-02-21 13:01:55 +0100)

----------------------------------------------------------------
Here is a batman-adv bugfix:

- Avoid double-rtnl_lock ELP metric worker, by Sven Eckelmann

----------------------------------------------------------------
Sven Eckelmann (1):
batman-adv: Avoid double-rtnl_lock ELP metric worker

 net/batman-adv/bat_v_elp.c      | 10 +++++++++-
 net/batman-adv/hard-interface.c |  8 ++++----
 net/batman-adv/hard-interface.h |  1 +
 3 files changed, 14 insertions(+), 5 deletions(-)
author maintainer
#1 lore raw

PATCH 1/1 batman-adv: Avoid double-rtnl_lock ELP metric worker

From: Sven Eckelmann <[email protected]>

batadv_v_elp_get_throughput() might be called when the RTNL lock is already held. This could be problematic when the work queue item is cancelled via cancel_delayed_work_sync() in batadv_v_elp_iface_disable(). In this case, an rtnl_lock() would cause a deadlock.

To avoid this, rtnl_trylock() was used in this function to skip the retrieval of the ethtool information in case the RTNL lock was already held.

But for cfg80211 interfaces, batadv_get_real_netdev() was called - which also uses rtnl_lock(). The approach for __ethtool_get_link_ksettings() must also be used instead and the lockless version __batadv_get_real_netdev() has to be called.

Fixes 8c8ecc98f5c6 ("batman-adv: Drop unmanaged ELP metric worker")
---
 net/batman-adv/bat_v_elp.c      | 10 +++++++++-
 net/batman-adv/hard-interface.c |  8 ++++----
 net/batman-adv/hard-interface.h |  1 +
 3 files changed, 14 insertions(+), 5 deletions(-)
net/batman-adv/bat_v_elp.c +9 -1
index cb16c1ed2a58f..fe832093d421f 100644
@@ -111,7 +111,15 @@ static bool batadv_v_elp_get_throughput(struct batadv_hardif_neigh_node *neigh,
 			/* unsupported WiFi driver version */
 			goto default_throughput;
 
-		real_netdev = batadv_get_real_netdev(hard_iface->net_dev);
+		/* only use rtnl_trylock because the elp worker will be cancelled while
+		 * the rntl_lock is held. the cancel_delayed_work_sync() would otherwise
+		 * wait forever when the elp work_item was started and it is then also
+		 * trying to rtnl_lock
+		 */
+		if (!rtnl_trylock())
+			return false;
+		real_netdev = __batadv_get_real_netdev(hard_iface->net_dev);
+		rtnl_unlock();
 		if (!real_netdev)
 			goto default_throughput;
 
net/batman-adv/hard-interface.c +4 -4
index 5113f879736b5..1c488049d5546 100644
@@ -204,7 +204,7 @@ static bool batadv_is_valid_iface(const struct net_device *net_dev)
 }
 
 /**
- * batadv_get_real_netdevice() - check if the given netdev struct is a virtual
+ * __batadv_get_real_netdev() - check if the given netdev struct is a virtual
  *  interface on top of another 'real' interface
  * @netdev: the device to check
  *
@@ -214,7 +214,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.
  */
-static struct net_device *batadv_get_real_netdevice(struct net_device *netdev)
+struct net_device *__batadv_get_real_netdev(struct net_device *netdev)
 {
 	struct batadv_hard_iface *hard_iface = NULL;
 	struct net_device *real_netdev = NULL;
@@ -267,7 +267,7 @@ struct net_device *batadv_get_real_netdev(struct net_device *net_device)
 	struct net_device *real_netdev;
 
 	rtnl_lock();
-	real_netdev = batadv_get_real_netdevice(net_device);
+	real_netdev = __batadv_get_real_netdev(net_device);
 	rtnl_unlock();
 
 	return real_netdev;
@@ -336,7 +336,7 @@ static u32 batadv_wifi_flags_evaluate(struct net_device *net_device)
 	if (batadv_is_cfg80211_netdev(net_device))
 		wifi_flags |= BATADV_HARDIF_WIFI_CFG80211_DIRECT;
 
-	real_netdev = batadv_get_real_netdevice(net_device);
+	real_netdev = __batadv_get_real_netdev(net_device);
 	if (!real_netdev)
 		return wifi_flags;
 
net/batman-adv/hard-interface.h +1 -0
index 9db8a310961ea..9ba8fb2bdceb4 100644
@@ -67,6 +67,7 @@ enum batadv_hard_if_bcast {
 
 extern struct notifier_block batadv_hard_if_notifier;
 
+struct net_device *__batadv_get_real_netdev(struct net_device *net_device);
 struct net_device *batadv_get_real_netdev(struct net_device *net_device);
 bool batadv_is_cfg80211_hardif(struct batadv_hard_iface *hard_iface);
 bool batadv_is_wifi_hardif(struct batadv_hard_iface *hard_iface);
Signature · 1 line
2.47.3
#2 lore raw

Re: [PATCH net 1/1] batman-adv: Avoid double-rtnl_lock ELP metric worker

This patch was applied to netdev/net.git (main) by Simon Wunderlich <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Simon Wunderlich <[email protected]>:

Quoted 8 lines · On Wed, 25 Feb 2026 09:46:14 +0100 you wrote:

From: Sven Eckelmann <[email protected]>

batadv_v_elp_get_throughput() might be called when the RTNL lock is already held. This could be problematic when the work queue item is cancelled via cancel_delayed_work_sync() in batadv_v_elp_iface_disable(). In this case, an rtnl_lock() would cause a deadlock.

[...]

Here is the summary with links:
- [net,1/1] batman-adv: Avoid double-rtnl_lock ELP metric worker

    https://git.kernel.org/netdev/net/c/cfc83a3c7151

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html