Skip to contentSkip to conversation

net: xdp: don't call notifiers during driver init

PATCH Applied Jakub Kicinski 2 participants 2 messages Mar 16, 2023 – Mar 17, 2023

Subsystems (4)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH v2 1/1 net: xdp: don't call notifiers during driver init

Drivers will commonly perform feature setting during init, if they use the xdp_set_features_flag() helper they'll likely run into an ASSERT_RTNL() inside call_netdevice_notifiers_info().

Don't call the notifier until the device is actually registered. Nothing should be tracking the device until its registered and after its unregistration has started.

Fixes 4d5ab0ad964d ("net/mlx5e: take into account device reconfiguration for xdp_features flag")

---
v2: only call for REGISTERED devices, not dead ones
v1: https://lore.kernel.org/all/[email protected]/

---
 net/core/xdp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/core/xdp.c +3 -1
index 87e654b7d06c..b5737e47ec41 100644
@@ -781,7 +781,9 @@ void xdp_set_features_flag(struct net_device *dev, xdp_features_t val)
 		return;
 
 	dev->xdp_features = val;
-	call_netdevice_notifiers(NETDEV_XDP_FEAT_CHANGE, dev);
+
+	if (dev->reg_state == NETREG_REGISTERED)
+		call_netdevice_notifiers(NETDEV_XDP_FEAT_CHANGE, dev);
 }
 EXPORT_SYMBOL_GPL(xdp_set_features_flag);
 
Signature · 1 line
2.39.2
#1 lore raw
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

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

Quoted 9 lines · On Thu, 16 Mar 2023 15:02:34 -0700 you wrote:

Drivers will commonly perform feature setting during init, if they use the xdp_set_features_flag() helper they'll likely run into an ASSERT_RTNL() inside call_netdevice_notifiers_info().

Don't call the notifier until the device is actually registered. Nothing should be tracking the device until its registered and after its unregistration has started.

[...]

Here is the summary with links:
- [net,v2] net: xdp: don't call notifiers during driver init

    https://git.kernel.org/netdev/net/c/769639c1fe8a

You are awesome, thank you!

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