aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/dev.c
diff options
context:
space:
mode:
authorDaniel Lezcano <dlezcano@fr.ibm.com>2008-05-02 20:00:58 -0400
committerDavid S. Miller <davem@davemloft.net>2008-05-02 20:00:58 -0400
commitaaf8cdc34ddba08122f02217d9d684e2f9f5d575 (patch)
tree40746e08bc9e6b590c9e7d1f7b54597539737c22 /net/core/dev.c
parent705d209168681b4408d10fca7257de3343be573d (diff)
netns: Fix device renaming for sysfs
When a netdev is moved across namespaces with the 'dev_change_net_namespace' function, the 'device_rename' function is used to fixup kobject and refresh the sysfs tree. The device_rename function will call kobject_rename and this one will check if there is an object with the same name and this is the case because we are renaming the object with the same name. The use of 'device_rename' seems for me wrong because we usually don't rename it but just move it across namespaces. As we just want to do a mini "netdev_[un]register", IMO the functions 'netdev_[un]register_kobject' should be used instead, like an usual network device [un]registering. This patch replace device_rename by netdev_unregister_kobject, followed by netdev_register_kobject. The netdev_register_kobject will call device_initialize and will raise a warning indicating the device was already initialized. In order to fix that, I split the device initialization into a separate function and use it together with 'netdev_register_kobject' into register_netdevice. So we can safely call 'netdev_register_kobject' in 'dev_change_net_namespace'. This fix will allow to properly use the sysfs per namespace which is coming from -mm tree. Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com> Acked-by: Benjamin Thery <benjamin.thery@bull.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/dev.c')
-rw-r--r--net/core/dev.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index a9500e6b3aa2..d334446a8eaf 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3776,6 +3776,7 @@ int register_netdevice(struct net_device *dev)
3776 } 3776 }
3777 } 3777 }
3778 3778
3779 netdev_initialize_kobject(dev);
3779 ret = netdev_register_kobject(dev); 3780 ret = netdev_register_kobject(dev);
3780 if (ret) 3781 if (ret)
3781 goto err_uninit; 3782 goto err_uninit;
@@ -4208,7 +4209,8 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char
4208 } 4209 }
4209 4210
4210 /* Fixup kobjects */ 4211 /* Fixup kobjects */
4211 err = device_rename(&dev->dev, dev->name); 4212 netdev_unregister_kobject(dev);
4213 err = netdev_register_kobject(dev);
4212 WARN_ON(err); 4214 WARN_ON(err);
4213 4215
4214 /* Add the device back in the hashes */ 4216 /* Add the device back in the hashes */