From patchwork Thu May 20 18:10:38 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gregkh@suse.de X-Patchwork-Id: 53098 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 930A9B7D2D for ; Fri, 21 May 2010 04:11:00 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757018Ab0ETSK6 (ORCPT ); Thu, 20 May 2010 14:10:58 -0400 Received: from kroah.org ([198.145.64.141]:43238 "EHLO coco.kroah.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757003Ab0ETSKx (ORCPT ); Thu, 20 May 2010 14:10:53 -0400 Received: from localhost (c-24-16-163-131.hsd1.wa.comcast.net [24.16.163.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by coco.kroah.org (Postfix) with ESMTPSA id 55F60484B4; Thu, 20 May 2010 11:10:53 -0700 (PDT) Subject: patch net-expose-all-network-devices-in-a-namespaces-in-sysfs.patch added to gregkh-2.6 tree To: ebiederm@xmission.com, bcrl@lhnet.ca, cornelia.huck@de.ibm.com, davem@davemloft.net, eric.dumazet@gmail.com, gregkh@suse.de, kay.sievers@vrfy.org, netdev@vger.kernel.org, serue@us.ibm.com, tj@kernel.org From: Date: Thu, 20 May 2010 11:10:38 -0700 In-Reply-To: <1273019809-16472-6-git-send-email-ebiederm@xmission.com> Message-ID: <12743790383043@kroah.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This is a note to let you know that I've just added the patch titled Subject: net: Expose all network devices in a namespaces in sysfs to my gregkh-2.6 tree. Its filename is net-expose-all-network-devices-in-a-namespaces-in-sysfs.patch This tree can be found at http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/ From ebiederm@xmission.com Thu May 20 10:46:13 2010 From: "Eric W. Biederman" Date: Tue, 4 May 2010 17:36:49 -0700 Subject: net: Expose all network devices in a namespaces in sysfs To: Greg Kroah-Hartman Cc: Kay Sievers , linux-kernel@vger.kernel.org, Tejun Heo , Cornelia Huck , Eric Dumazet , Benjamin LaHaise , Serge Hallyn , , David Miller , "Eric W. Biederman" Message-ID: <1273019809-16472-6-git-send-email-ebiederm@xmission.com> From: Eric W. Biederman This reverts commit aaf8cdc34ddba08122f02217d9d684e2f9f5d575. Drivers like the ipw2100 call device_create_group when they are initialized and device_remove_group when they are shutdown. Moving them between namespaces deletes their sysfs groups early. In particular the following call chain results. netdev_unregister_kobject -> device_del -> kobject_del -> sysfs_remove_dir With sysfs_remove_dir recursively deleting all of it's subdirectories, and nothing adding them back. Ouch! Therefore we need to call something that ultimate calls sysfs_mv_dir as that sysfs function can move sysfs directories between namespaces without deleting their subdirectories or their contents. Allowing us to avoid placing extra boiler plate into every driver that does something interesting with sysfs. Currently the function that provides that capability is device_rename. That is the code works without nasty side effects as originally written. So remove the misguided fix for moving devices between namespaces. The bug in the kobject layer that inspired it has now been recognized and fixed. Signed-off-by: Eric W. Biederman Acked-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/core/dev.c | 28 +++++----------------------- net/core/net-sysfs.c | 16 +--------------- net/core/net-sysfs.h | 1 - 3 files changed, 6 insertions(+), 39 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/net/core/dev.c +++ b/net/core/dev.c @@ -984,15 +984,10 @@ int dev_change_name(struct net_device *d return err; rollback: - /* For now only devices in the initial network namespace - * are in sysfs. - */ - if (net_eq(net, &init_net)) { - ret = device_rename(&dev->dev, dev->name); - if (ret) { - memcpy(dev->name, oldname, IFNAMSIZ); - return ret; - } + ret = device_rename(&dev->dev, dev->name); + if (ret) { + memcpy(dev->name, oldname, IFNAMSIZ); + return ret; } write_lock_bh(&dev_base_lock); @@ -5112,8 +5107,6 @@ int register_netdevice(struct net_device if (dev->features & NETIF_F_SG) dev->features |= NETIF_F_GSO; - netdev_initialize_kobject(dev); - ret = call_netdevice_notifiers(NETDEV_POST_INIT, dev); ret = notifier_to_errno(ret); if (ret) @@ -5634,15 +5627,6 @@ int dev_change_net_namespace(struct net_ if (dev->features & NETIF_F_NETNS_LOCAL) goto out; -#ifdef CONFIG_SYSFS - /* Don't allow real devices to be moved when sysfs - * is enabled. - */ - err = -EINVAL; - if (dev->dev.parent) - goto out; -#endif - /* Ensure the device has been registrered */ err = -EINVAL; if (dev->reg_state != NETREG_REGISTERED) @@ -5693,8 +5677,6 @@ int dev_change_net_namespace(struct net_ dev_unicast_flush(dev); dev_addr_discard(dev); - netdev_unregister_kobject(dev); - /* Actually switch the network namespace */ dev_net_set(dev, net); @@ -5707,7 +5689,7 @@ int dev_change_net_namespace(struct net_ } /* Fixup kobjects */ - err = netdev_register_kobject(dev); + err = device_rename(&dev->dev, dev->name); WARN_ON(err); /* Add the device back in the hashes */ --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -508,9 +508,6 @@ static int netdev_uevent(struct device * struct net_device *dev = to_net_dev(d); int retval; - if (!net_eq(dev_net(dev), &init_net)) - return 0; - /* pass interface to uevent. */ retval = add_uevent_var(env, "INTERFACE=%s", dev->name); if (retval) @@ -569,9 +566,6 @@ void netdev_unregister_kobject(struct ne kobject_get(&dev->kobj); - if (!net_eq(dev_net(net), &init_net)) - return; - device_del(dev); } @@ -581,6 +575,7 @@ int netdev_register_kobject(struct net_d struct device *dev = &(net->dev); const struct attribute_group **groups = net->sysfs_groups; + device_initialize(dev); dev->class = &net_class; dev->platform_data = net; dev->groups = groups; @@ -603,9 +598,6 @@ int netdev_register_kobject(struct net_d #endif #endif /* CONFIG_SYSFS */ - if (!net_eq(dev_net(net), &init_net)) - return 0; - return device_add(dev); } @@ -622,12 +614,6 @@ void netdev_class_remove_file(struct cla EXPORT_SYMBOL(netdev_class_create_file); EXPORT_SYMBOL(netdev_class_remove_file); -void netdev_initialize_kobject(struct net_device *net) -{ - struct device *device = &(net->dev); - device_initialize(device); -} - int netdev_kobject_init(void) { kobj_ns_type_register(&net_ns_type_operations); --- a/net/core/net-sysfs.h +++ b/net/core/net-sysfs.h @@ -4,5 +4,4 @@ int netdev_kobject_init(void); int netdev_register_kobject(struct net_device *); void netdev_unregister_kobject(struct net_device *); -void netdev_initialize_kobject(struct net_device *); #endif