Commit 4e8aaae7 authored by Andrey Vagin's avatar Andrey Vagin Committed by Thadeu Lima de Souza Cascardo

net: use net->count to check whether a netns is alive or not

BugLink: http://bugs.launchpad.net/bugs/1672144

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: default avatarMantas Mikulėnas <grawity@gmail.com>
Fixes: 002d8a1a ("net: skip genenerating uevents for network namespaces that are exiting")
Signed-off-by: default avatarAndrei Vagin <avagin@openvz.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
(back ported from commit 91864f58)
Signed-off-by: default avatarTim Gardner <tim.gardner@canonical.com>

Conflicts:
	net/core/net-sysfs.c
Acked-by: default avatarJoseph Salisbury <joseph.salisbury@canonical.com>
Acked-by: default avatarMarcelo Cerri <marcelo.cerri@canonical.com>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
parent fafbcec8
......@@ -931,6 +931,10 @@ net_rx_queue_update_kobjects(struct net_device *dev, int old_num, int new_num)
}
while (--i >= new_num) {
struct kobject *kobj = &dev->_rx[i].kobj;
if (!atomic_read(&dev_net(dev)->count))
kobj->uevent_suppress = 1;
if (dev->sysfs_rx_queue_group)
sysfs_remove_group(&dev->_rx[i].kobj,
dev->sysfs_rx_queue_group);
......@@ -1321,6 +1325,8 @@ netdev_queue_update_kobjects(struct net_device *dev, int old_num, int new_num)
while (--i >= new_num) {
struct netdev_queue *queue = dev->_tx + i;
if (!atomic_read(&dev_net(dev)->count))
queue->kobj.uevent_suppress = 1;
#ifdef CONFIG_BQL
sysfs_remove_group(&queue->kobj, &dql_group);
#endif
......@@ -1506,6 +1512,9 @@ void netdev_unregister_kobject(struct net_device *ndev)
{
struct device *dev = &(ndev->dev);
if (!atomic_read(&dev_net(ndev)->count))
dev_set_uevent_suppress(dev, 1);
kobject_get(&dev->kobj);
remove_queue_kobjects(ndev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment