* [net-2.6 patch 0/2][NETNS] netns fixes
@ 2008-04-30 21:31 Daniel Lezcano
2008-04-30 21:31 ` [net-2.6 patch 1/2][NETNS] fix device renaming for sysfs Daniel Lezcano
2008-04-30 21:31 ` [net-2.6 patch 2/2][NETNS] Fix reassembly timer to use the right namespace Daniel Lezcano
0 siblings, 2 replies; 7+ messages in thread
From: Daniel Lezcano @ 2008-04-30 21:31 UTC (permalink / raw)
To: davem; +Cc: netdev
The two following patches fix bugs related to the network
namespace. The first one fixes a sysfs issue (when using the
sysfs per namespace), and the second one fixes the frag timer
for ipv6 to use the right network namespace.
--
^ permalink raw reply [flat|nested] 7+ messages in thread
* [net-2.6 patch 1/2][NETNS] fix device renaming for sysfs
2008-04-30 21:31 [net-2.6 patch 0/2][NETNS] netns fixes Daniel Lezcano
@ 2008-04-30 21:31 ` Daniel Lezcano
2008-05-03 0:01 ` David Miller
2008-06-04 11:59 ` Eric W. Biederman
2008-04-30 21:31 ` [net-2.6 patch 2/2][NETNS] Fix reassembly timer to use the right namespace Daniel Lezcano
1 sibling, 2 replies; 7+ messages in thread
From: Daniel Lezcano @ 2008-04-30 21:31 UTC (permalink / raw)
To: davem; +Cc: netdev
[-- Attachment #1: fix-kobject.patch --]
[-- Type: text/plain, Size: 3206 bytes --]
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>
---
net/core/dev.c | 4 +++-
net/core/net-sysfs.c | 7 ++++++-
net/core/net-sysfs.h | 2 +-
3 files changed, 10 insertions(+), 3 deletions(-)
Index: net-2.6/net/core/dev.c
===================================================================
--- net-2.6.orig/net/core/dev.c
+++ net-2.6/net/core/dev.c
@@ -3776,6 +3776,7 @@ int register_netdevice(struct net_device
}
}
+ netdev_initialize_kobject(dev);
ret = netdev_register_kobject(dev);
if (ret)
goto err_uninit;
@@ -4208,7 +4209,8 @@ int dev_change_net_namespace(struct net_
}
/* Fixup kobjects */
- err = device_rename(&dev->dev, dev->name);
+ netdev_unregister_kobject(dev);
+ err = netdev_register_kobject(dev);
WARN_ON(err);
/* Add the device back in the hashes */
Index: net-2.6/net/core/net-sysfs.c
===================================================================
--- net-2.6.orig/net/core/net-sysfs.c
+++ net-2.6/net/core/net-sysfs.c
@@ -449,7 +449,6 @@ int netdev_register_kobject(struct net_d
struct device *dev = &(net->dev);
struct attribute_group **groups = net->sysfs_groups;
- device_initialize(dev);
dev->class = &net_class;
dev->platform_data = net;
dev->groups = groups;
@@ -470,6 +469,12 @@ int netdev_register_kobject(struct net_d
return device_add(dev);
}
+void netdev_initialize_kobject(struct net_device *net)
+{
+ struct device *device = &(net->dev);
+ device_initialize(device);
+}
+
int netdev_kobject_init(void)
{
return class_register(&net_class);
Index: net-2.6/net/core/net-sysfs.h
===================================================================
--- net-2.6.orig/net/core/net-sysfs.h
+++ net-2.6/net/core/net-sysfs.h
@@ -4,5 +4,5 @@
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
--
^ permalink raw reply [flat|nested] 7+ messages in thread
* [net-2.6 patch 2/2][NETNS] Fix reassembly timer to use the right namespace
2008-04-30 21:31 [net-2.6 patch 0/2][NETNS] netns fixes Daniel Lezcano
2008-04-30 21:31 ` [net-2.6 patch 1/2][NETNS] fix device renaming for sysfs Daniel Lezcano
@ 2008-04-30 21:31 ` Daniel Lezcano
2008-05-03 0:02 ` David Miller
1 sibling, 1 reply; 7+ messages in thread
From: Daniel Lezcano @ 2008-04-30 21:31 UTC (permalink / raw)
To: davem; +Cc: netdev
[-- Attachment #1: fix-reassembly-timer.patch --]
[-- Type: text/plain, Size: 920 bytes --]
This trivial fix retrieves the network namespace from frag queue
and use it to get the network device in the right namespace.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
---
net/ipv6/reassembly.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Index: net-2.6/net/ipv6/reassembly.c
===================================================================
--- net-2.6.orig/net/ipv6/reassembly.c
+++ net-2.6/net/ipv6/reassembly.c
@@ -197,6 +197,7 @@ static void ip6_frag_expire(unsigned lon
{
struct frag_queue *fq;
struct net_device *dev = NULL;
+ struct net *net;
fq = container_of((struct inet_frag_queue *)data, struct frag_queue, q);
@@ -207,7 +208,8 @@ static void ip6_frag_expire(unsigned lon
fq_kill(fq);
- dev = dev_get_by_index(&init_net, fq->iif);
+ net = container_of(fq->q.net, struct net, ipv6.frags);
+ dev = dev_get_by_index(net, fq->iif);
if (!dev)
goto out;
--
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [net-2.6 patch 1/2][NETNS] fix device renaming for sysfs
2008-04-30 21:31 ` [net-2.6 patch 1/2][NETNS] fix device renaming for sysfs Daniel Lezcano
@ 2008-05-03 0:01 ` David Miller
2008-06-04 11:59 ` Eric W. Biederman
1 sibling, 0 replies; 7+ messages in thread
From: David Miller @ 2008-05-03 0:01 UTC (permalink / raw)
To: dlezcano; +Cc: netdev
From: Daniel Lezcano <dlezcano@fr.ibm.com>
Date: Wed, 30 Apr 2008 23:31:14 +0200
> 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>
Looks good, applied.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [net-2.6 patch 2/2][NETNS] Fix reassembly timer to use the right namespace
2008-04-30 21:31 ` [net-2.6 patch 2/2][NETNS] Fix reassembly timer to use the right namespace Daniel Lezcano
@ 2008-05-03 0:02 ` David Miller
0 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2008-05-03 0:02 UTC (permalink / raw)
To: dlezcano; +Cc: netdev
From: Daniel Lezcano <dlezcano@fr.ibm.com>
Date: Wed, 30 Apr 2008 23:31:15 +0200
> This trivial fix retrieves the network namespace from frag queue
> and use it to get the network device in the right namespace.
>
> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
The one area where ipv4 and ipv6 code didn't get fully
considated, and voila! ipv4 got it right and ipv6 had
the bug :-)
Patch applied, thanks!
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [net-2.6 patch 1/2][NETNS] fix device renaming for sysfs
2008-04-30 21:31 ` [net-2.6 patch 1/2][NETNS] fix device renaming for sysfs Daniel Lezcano
2008-05-03 0:01 ` David Miller
@ 2008-06-04 11:59 ` Eric W. Biederman
2008-06-04 13:50 ` Daniel Lezcano
1 sibling, 1 reply; 7+ messages in thread
From: Eric W. Biederman @ 2008-06-04 11:59 UTC (permalink / raw)
To: Daniel Lezcano; +Cc: davem, netdev
Daniel Lezcano <dlezcano@fr.ibm.com> writes:
> 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.
device_rename is correct. Because doing device_del; device_add removes
any driver specific sysfs attributes.
Causing your patch to introduce subtle driver breakage only when we
move a network device between namespaces. Ouch!
To support this operation we need something like device_rename that
can preserve driver specific attributes, and generally handle
movement between namespaces. Since device_rename already does 99% of
what we need it to do I found it easier to extend device_rename to
handle this case then to introduce yet another function into the
kobject layer.
> This patch replace device_rename by netdev_unregister_kobject, followed by
> netdev_register_kobject.
And sysfs comes a' tumblin' down.
My apologies for not replying sooner I just spotted this.
Eric
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [net-2.6 patch 1/2][NETNS] fix device renaming for sysfs
2008-06-04 11:59 ` Eric W. Biederman
@ 2008-06-04 13:50 ` Daniel Lezcano
0 siblings, 0 replies; 7+ messages in thread
From: Daniel Lezcano @ 2008-06-04 13:50 UTC (permalink / raw)
To: Eric W. Biederman; +Cc: davem, netdev
Eric W. Biederman wrote:
> Daniel Lezcano <dlezcano@fr.ibm.com> writes:
>
>> 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.
>
> device_rename is correct. Because doing device_del; device_add removes
> any driver specific sysfs attributes.
>
> Causing your patch to introduce subtle driver breakage only when we
> move a network device between namespaces. Ouch!
>
> To support this operation we need something like device_rename that
> can preserve driver specific attributes, and generally handle
> movement between namespaces. Since device_rename already does 99% of
> what we need it to do I found it easier to extend device_rename to
> handle this case then to introduce yet another function into the
> kobject layer.
>
>> This patch replace device_rename by netdev_unregister_kobject, followed by
>> netdev_register_kobject.
>
> And sysfs comes a' tumblin' down.
> My apologies for not replying sooner I just spotted this.
My fault, I should have Cc'ed you when sending the email :(
Thanks for looking at this patch.
-- Daniel
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-06-04 13:50 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-30 21:31 [net-2.6 patch 0/2][NETNS] netns fixes Daniel Lezcano
2008-04-30 21:31 ` [net-2.6 patch 1/2][NETNS] fix device renaming for sysfs Daniel Lezcano
2008-05-03 0:01 ` David Miller
2008-06-04 11:59 ` Eric W. Biederman
2008-06-04 13:50 ` Daniel Lezcano
2008-04-30 21:31 ` [net-2.6 patch 2/2][NETNS] Fix reassembly timer to use the right namespace Daniel Lezcano
2008-05-03 0:02 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).