[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250312223507.805719-9-kuba@kernel.org>
Date: Wed, 12 Mar 2025 23:35:04 +0100
From: Jakub Kicinski <kuba@...nel.org>
To: davem@...emloft.net
Cc: netdev@...r.kernel.org,
edumazet@...gle.com,
pabeni@...hat.com,
andrew+netdev@...n.ch,
horms@...nel.org,
sdf@...ichev.me,
Jakub Kicinski <kuba@...nel.org>
Subject: [PATCH net-next 08/11] net: make NETDEV_UNREGISTER and instance lock more consistent
The NETDEV_UNREGISTER notifier gets called under the ops lock
when device changes namespace but not during real unregistration.
Take it consistently, XSK tries to poke at netdev queue state
from this notifier.
Signed-off-by: Jakub Kicinski <kuba@...nel.org>
---
net/core/dev.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index ded6ffbda965..8296b4c159fe 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1856,7 +1856,9 @@ static void call_netdevice_unregister_notifiers(struct notifier_block *nb,
dev);
call_netdevice_notifier(nb, NETDEV_DOWN, dev);
}
+ netdev_lock_ops(dev);
call_netdevice_notifier(nb, NETDEV_UNREGISTER, dev);
+ netdev_unlock_ops(dev);
}
static int call_netdevice_register_net_notifiers(struct notifier_block *nb,
@@ -11155,8 +11157,11 @@ static struct net_device *netdev_wait_allrefs_any(struct list_head *list)
rtnl_lock();
/* Rebroadcast unregister notification */
- list_for_each_entry(dev, list, todo_list)
+ list_for_each_entry(dev, list, todo_list) {
+ netdev_lock_ops(dev);
call_netdevice_notifiers(NETDEV_UNREGISTER, dev);
+ netdev_unlock_ops(dev);
+ }
__rtnl_unlock();
rcu_barrier();
@@ -11947,7 +11952,9 @@ void unregister_netdevice_many_notify(struct list_head *head,
/* Notify protocols, that we are about to destroy
* this device. They should clean all the things.
*/
+ netdev_lock_ops(dev);
call_netdevice_notifiers(NETDEV_UNREGISTER, dev);
+ netdev_unlock_ops(dev);
if (!dev->rtnl_link_ops ||
dev->rtnl_link_state == RTNL_LINK_INITIALIZED)
--
2.48.1
Powered by blists - more mailing lists