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 07a48e2bf7db..1845b08c624e 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1006,15 +1006,10 @@ int dev_change_name(struct net_device *dev, const char *newname)
1006 return err; 1006 return err;
1007 1007
1008rollback: 1008rollback:
1009 /* For now only devices in the initial network namespace 1009 ret = device_rename(&dev->dev, dev->name);
1010 * are in sysfs. 1010 if (ret) {
1011 */ 1011 memcpy(dev->name, oldname, IFNAMSIZ);
1012 if (net_eq(net, &init_net)) { 1012 return ret;
1013 ret = device_rename(&dev->dev, dev->name);
1014 if (ret) {
1015 memcpy(dev->name, oldname, IFNAMSIZ);
1016 return ret;
1017 }
1018 } 1013 }
1019 1014
1020 write_lock_bh(&dev_base_lock); 1015 write_lock_bh(&dev_base_lock);
@@ -4998,8 +4993,6 @@ int register_netdevice(struct net_device *dev)
4998 if (dev->features & NETIF_F_SG) 4993 if (dev->features & NETIF_F_SG)
4999 dev->features |= NETIF_F_GSO; 4994 dev->features |= NETIF_F_GSO;
5000 4995
5001 netdev_initialize_kobject(dev);
5002
5003 ret = call_netdevice_notifiers(NETDEV_POST_INIT, dev); 4996 ret = call_netdevice_notifiers(NETDEV_POST_INIT, dev);
5004 ret = notifier_to_errno(ret); 4997 ret = notifier_to_errno(ret);
5005 if (ret) 4998 if (ret)
@@ -5551,15 +5544,6 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char
5551 if (dev->features & NETIF_F_NETNS_LOCAL) 5544 if (dev->features & NETIF_F_NETNS_LOCAL)
5552 goto out; 5545 goto out;
5553 5546
5554#ifdef CONFIG_SYSFS
5555 /* Don't allow real devices to be moved when sysfs
5556 * is enabled.
5557 */
5558 err = -EINVAL;
5559 if (dev->dev.parent)
5560 goto out;
5561#endif
5562
5563 /* Ensure the device has been registrered */ 5547 /* Ensure the device has been registrered */
5564 err = -EINVAL; 5548 err = -EINVAL;
5565 if (dev->reg_state != NETREG_REGISTERED) 5549 if (dev->reg_state != NETREG_REGISTERED)
@@ -5610,8 +5594,6 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char
5610 dev_uc_flush(dev); 5594 dev_uc_flush(dev);
5611 dev_mc_flush(dev); 5595 dev_mc_flush(dev);
5612 5596
5613 netdev_unregister_kobject(dev);
5614
5615 /* Actually switch the network namespace */ 5597 /* Actually switch the network namespace */
5616 dev_net_set(dev, net); 5598 dev_net_set(dev, net);
5617 5599
@@ -5624,7 +5606,7 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char
5624 } 5606 }
5625 5607
5626 /* Fixup kobjects */ 5608 /* Fixup kobjects */
5627 err = netdev_register_kobject(dev); 5609 err = device_rename(&dev->dev, dev->name);
5628 WARN_ON(err); 5610 WARN_ON(err);
5629 5611
5630 /* Add the device back in the hashes */ 5612 /* Add the device back in the hashes */