[RFC PATCH net-next 2/9] net: split unlisting the net device from unlisting its node name

From
Antoine Tenart <atenart@kernel.org>
Date
2021-09-28 12:55:20
Reply to
Antoine Tenart, 2021-09-28
This (mostly [*]) cosmetic patch spits the unlisting of the net device
from the unlisting of its node name. The two unlisting are still done
for now at the same places in the code, keeping the logic.

[*] The two removals are now not done in a single dev_base_lock locking
    section. That is not an issue as insertion/deletion from both lists
    doesn't have to be atomic from the dev_base_lock point of view.

Signed-off-by: Antoine Tenart <atenart@kernel.org>
---
 net/core/dev.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index fa989ab63f29..2f28b70e5244 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -385,13 +385,21 @@ static void unlist_netdevice(struct net_device *dev)
 	/* Unlink dev from the device chain */
 	write_lock_bh(&dev_base_lock);
 	list_del_rcu(&dev->dev_list);
-	netdev_name_node_del(dev->name_node);
 	hlist_del_rcu(&dev->index_hlist);
 	write_unlock_bh(&dev_base_lock);
 
 	dev_base_seq_inc(dev_net(dev));
 }
 
+static void unlist_netdevice_name(struct net_device *dev)
+{
+	ASSERT_RTNL();
+
+	write_lock_bh(&dev_base_lock);
+	netdev_name_node_del(dev->name_node);
+	write_unlock_bh(&dev_base_lock);
+}
+
 /*
  *	Our notifier list
  */
@@ -11030,6 +11038,7 @@ void unregister_netdevice_many(struct list_head *head)
 	list_for_each_entry(dev, head, unreg_list) {
 		/* And unlink it from device chain. */
 		unlist_netdevice(dev);
+		unlist_netdevice_name(dev);
 
 		dev->reg_state = NETREG_UNREGISTERING;
 	}
@@ -11177,6 +11186,7 @@ int __dev_change_net_namespace(struct net_device *dev, struct net *net,
 
 	/* And unlink it from device chain */
 	unlist_netdevice(dev);
+	unlist_netdevice_name(dev);
 
 	synchronize_net();
 
-- 
2.31.1
Thread (25 messages) 25 messages, 4 authors, last reply 2021-10-29
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help