Skip to content

Commit 91864f5

Browse files
avagindavem330
authored andcommitted
net: use net->count to check whether a netns is alive or not
The previous idea was to check whether a net namespace is in net_exit_list or not. It doesn't work, because net->exit_list is used in __register_pernet_operations and __unregister_pernet_operations where all namespaces are added to a temporary list to make cleanup in a error case, so list_empty(&net->exit_list) always returns false. Reported-by: Mantas Mikulėnas <[email protected]> Fixes: 002d8a1 ("net: skip genenerating uevents for network namespaces that are exiting") Signed-off-by: Andrei Vagin <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a13b208 commit 91864f5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

net/core/net-sysfs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ net_rx_queue_update_kobjects(struct net_device *dev, int old_num, int new_num)
953953
while (--i >= new_num) {
954954
struct kobject *kobj = &dev->_rx[i].kobj;
955955

956-
if (!list_empty(&dev_net(dev)->exit_list))
956+
if (!atomic_read(&dev_net(dev)->count))
957957
kobj->uevent_suppress = 1;
958958
if (dev->sysfs_rx_queue_group)
959959
sysfs_remove_group(kobj, dev->sysfs_rx_queue_group);
@@ -1371,7 +1371,7 @@ netdev_queue_update_kobjects(struct net_device *dev, int old_num, int new_num)
13711371
while (--i >= new_num) {
13721372
struct netdev_queue *queue = dev->_tx + i;
13731373

1374-
if (!list_empty(&dev_net(dev)->exit_list))
1374+
if (!atomic_read(&dev_net(dev)->count))
13751375
queue->kobj.uevent_suppress = 1;
13761376
#ifdef CONFIG_BQL
13771377
sysfs_remove_group(&queue->kobj, &dql_group);
@@ -1558,7 +1558,7 @@ void netdev_unregister_kobject(struct net_device *ndev)
15581558
{
15591559
struct device *dev = &(ndev->dev);
15601560

1561-
if (!list_empty(&dev_net(ndev)->exit_list))
1561+
if (!atomic_read(&dev_net(ndev)->count))
15621562
dev_set_uevent_suppress(dev, 1);
15631563

15641564
kobject_get(&dev->kobj);

0 commit comments

Comments
 (0)