diff options
| -rw-r--r-- | net/core/dev.c | 28 | ||||
| -rw-r--r-- | net/core/net-sysfs.c | 16 | ||||
| -rw-r--r-- | net/core/net-sysfs.h | 1 |
3 files changed, 6 insertions, 39 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 | ||
| 1004 | rollback: | 1004 | rollback: |
| 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 */ |
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 6881e65944c8..99e7052d7323 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c | |||
| @@ -808,9 +808,6 @@ static int netdev_uevent(struct device *d, struct kobj_uevent_env *env) | |||
| 808 | struct net_device *dev = to_net_dev(d); | 808 | struct net_device *dev = to_net_dev(d); |
| 809 | int retval; | 809 | int retval; |
| 810 | 810 | ||
| 811 | if (!net_eq(dev_net(dev), &init_net)) | ||
| 812 | return 0; | ||
| 813 | |||
| 814 | /* pass interface to uevent. */ | 811 | /* pass interface to uevent. */ |
| 815 | retval = add_uevent_var(env, "INTERFACE=%s", dev->name); | 812 | retval = add_uevent_var(env, "INTERFACE=%s", dev->name); |
| 816 | if (retval) | 813 | if (retval) |
| @@ -869,9 +866,6 @@ void netdev_unregister_kobject(struct net_device * net) | |||
| 869 | 866 | ||
| 870 | kobject_get(&dev->kobj); | 867 | kobject_get(&dev->kobj); |
| 871 | 868 | ||
| 872 | if (!net_eq(dev_net(net), &init_net)) | ||
| 873 | return; | ||
| 874 | |||
| 875 | #ifdef CONFIG_RPS | 869 | #ifdef CONFIG_RPS |
| 876 | rx_queue_remove_kobjects(net); | 870 | rx_queue_remove_kobjects(net); |
| 877 | #endif | 871 | #endif |
| @@ -886,6 +880,7 @@ int netdev_register_kobject(struct net_device *net) | |||
| 886 | const struct attribute_group **groups = net->sysfs_groups; | 880 | const struct attribute_group **groups = net->sysfs_groups; |
| 887 | int error = 0; | 881 | int error = 0; |
| 888 | 882 | ||
| 883 | device_initialize(dev); | ||
| 889 | dev->class = &net_class; | 884 | dev->class = &net_class; |
| 890 | dev->platform_data = net; | 885 | dev->platform_data = net; |
| 891 | dev->groups = groups; | 886 | dev->groups = groups; |
| @@ -908,9 +903,6 @@ int netdev_register_kobject(struct net_device *net) | |||
| 908 | #endif | 903 | #endif |
| 909 | #endif /* CONFIG_SYSFS */ | 904 | #endif /* CONFIG_SYSFS */ |
| 910 | 905 | ||
| 911 | if (!net_eq(dev_net(net), &init_net)) | ||
| 912 | return 0; | ||
| 913 | |||
| 914 | error = device_add(dev); | 906 | error = device_add(dev); |
| 915 | if (error) | 907 | if (error) |
| 916 | return error; | 908 | return error; |
| @@ -939,12 +931,6 @@ void netdev_class_remove_file(struct class_attribute *class_attr) | |||
| 939 | EXPORT_SYMBOL(netdev_class_create_file); | 931 | EXPORT_SYMBOL(netdev_class_create_file); |
| 940 | EXPORT_SYMBOL(netdev_class_remove_file); | 932 | EXPORT_SYMBOL(netdev_class_remove_file); |
| 941 | 933 | ||
| 942 | void netdev_initialize_kobject(struct net_device *net) | ||
| 943 | { | ||
| 944 | struct device *device = &(net->dev); | ||
| 945 | device_initialize(device); | ||
| 946 | } | ||
| 947 | |||
| 948 | int netdev_kobject_init(void) | 934 | int netdev_kobject_init(void) |
| 949 | { | 935 | { |
| 950 | kobj_ns_type_register(&net_ns_type_operations); | 936 | kobj_ns_type_register(&net_ns_type_operations); |
diff --git a/net/core/net-sysfs.h b/net/core/net-sysfs.h index 14e7524260b3..805555e8b187 100644 --- a/net/core/net-sysfs.h +++ b/net/core/net-sysfs.h | |||
| @@ -4,5 +4,4 @@ | |||
| 4 | int netdev_kobject_init(void); | 4 | int netdev_kobject_init(void); |
| 5 | int netdev_register_kobject(struct net_device *); | 5 | int netdev_register_kobject(struct net_device *); |
| 6 | void netdev_unregister_kobject(struct net_device *); | 6 | void netdev_unregister_kobject(struct net_device *); |
| 7 | void netdev_initialize_kobject(struct net_device *); | ||
| 8 | #endif | 7 | #endif |
