[PATCH net v2] net: xdp: don't call notifiers during driver init

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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")
Signed-off-by: Jakub Kicinski <kuba@xxxxxxxxxx>
---
v2: only call for REGISTERED devices, not dead ones
v1: https://lore.kernel.org/all/20230316002903.492497-1-kuba@xxxxxxxxxx/

CC: ast@xxxxxxxxxx
CC: daniel@xxxxxxxxxxxxx
CC: hawk@xxxxxxxxxx
CC: john.fastabend@xxxxxxxxx
CC: lorenzo@xxxxxxxxxx
CC: tariqt@xxxxxxxxxx
CC: bpf@xxxxxxxxxxxxxxx
---
 net/core/xdp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/core/xdp.c b/net/core/xdp.c
index 87e654b7d06c..b5737e47ec41 100644
--- a/net/core/xdp.c
+++ b/net/core/xdp.c
@@ -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);
 
-- 
2.39.2




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux