aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/dev.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/core/dev.c')
-rw-r--r--net/core/dev.c28
1 files changed, 5 insertions, 23 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index 6c820650b80f..d273e4e3ecdc 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1002,15 +1002,10 @@ int dev_change_name(struct net_device *dev, const char *newname)
1002 return err; 1002 return err;
1003 1003
1004rollback: 1004rollback:
1005 /* For now only devices in the initial network namespace 1005 ret = device_rename(&dev->dev, dev->name);
1006 * are in sysfs. 1006 if (ret) {
1007 */ 1007 memcpy(dev->name, oldname, IFNAMSIZ);
1008 if (net_eq(net, &init_net)) { 1008 return ret;
1009 ret = device_rename(&dev->dev, dev->name);
1010 if (ret) {
1011 memcpy(dev->name, oldname, IFNAMSIZ);
1012 return ret;
1013 }
1014 } 1009 }
1015 1010
1016 write_lock_bh(&dev_base_lock); 1011 write_lock_bh(&dev_base_lock);
@@ -4994,8 +4989,6 @@ int register_netdevice(struct net_device *dev)
4994 if (dev->features & NETIF_F_SG) 4989 if (dev->features & NETIF_F_SG)
4995 dev->features |= NETIF_F_GSO; 4990 dev->features |= NETIF_F_GSO;
4996 4991
4997 netdev_initialize_kobject(dev);
4998
4999 ret = call_netdevice_notifiers(NETDEV_POST_INIT, dev); 4992 ret = call_netdevice_notifiers(NETDEV_POST_INIT, dev);
5000 ret = notifier_to_errno(ret); 4993 ret = notifier_to_errno(ret);
5001 if (ret) 4994 if (ret)
@@ -5547,15 +5540,6 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char
5547 if (dev->features & NETIF_F_NETNS_LOCAL) 5540 if (dev->features & NETIF_F_NETNS_LOCAL)
5548 goto out; 5541 goto out;
5549 5542
5550#ifdef CONFIG_SYSFS
5551 /* Don't allow real devices to be moved when sysfs
5552 * is enabled.
5553 */
5554 err = -EINVAL;
5555 if (dev->dev.parent)
5556 goto out;
5557#endif
5558
5559 /* Ensure the device has been registrered */ 5543 /* Ensure the device has been registrered */
5560 err = -EINVAL; 5544 err = -EINVAL;
5561 if (dev->reg_state != NETREG_REGISTERED) 5545 if (dev->reg_state != NETREG_REGISTERED)
@@ -5606,8 +5590,6 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char
5606 dev_uc_flush(dev); 5590 dev_uc_flush(dev);
5607 dev_mc_flush(dev); 5591 dev_mc_flush(dev);
5608 5592
5609 netdev_unregister_kobject(dev);
5610
5611 /* Actually switch the network namespace */ 5593 /* Actually switch the network namespace */
5612 dev_net_set(dev, net); 5594 dev_net_set(dev, net);
5613 5595
@@ -5620,7 +5602,7 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char
5620 } 5602 }
5621 5603
5622 /* Fixup kobjects */ 5604 /* Fixup kobjects */
5623 err = netdev_register_kobject(dev); 5605 err = device_rename(&dev->dev, dev->name);
5624 WARN_ON(err); 5606 WARN_ON(err);
5625 5607
5626 /* Add the device back in the hashes */ 5608 /* Add the device back in the hashes */