netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Move interface across network namespaces
@ 2011-08-11  0:31 Renato Westphal
  2011-08-11  7:13 ` Eric W. Biederman
  0 siblings, 1 reply; 8+ messages in thread
From: Renato Westphal @ 2011-08-11  0:31 UTC (permalink / raw)
  To: netdev, Eric W. Biederman

Hello,

I have two questions regarding the process of moving a network
interface across different network namespaces:

* When I move an interface, all the virtual interfaces attached to it
are deleted. Is there any reason for such odd behavior? I would like
to move some network interfaces and keep the attached vlans untouched.

* The target network namespace sends a RTM_NEWLINK netlink message
when an interface is moved to it. In the other hand, the source
network namespace doesn't sends a RTM_DELLINK message when an
interface is moved from it. This is very annoying because user space
applications (such as zebra) can't detect some interface moving
operations and then get into an inconsistent state. Anyone knows if
there's a workaround for this?

Any help would be appreciated.

Best Regards,
Renato.

-- 
Renato Westphal

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Move interface across network namespaces
  2011-08-11  0:31 Move interface across network namespaces Renato Westphal
@ 2011-08-11  7:13 ` Eric W. Biederman
  2011-08-11 18:29   ` Renato Westphal
  0 siblings, 1 reply; 8+ messages in thread
From: Eric W. Biederman @ 2011-08-11  7:13 UTC (permalink / raw)
  To: Renato Westphal; +Cc: netdev

Renato Westphal <renatowestphal@gmail.com> writes:

> Hello,
>
> I have two questions regarding the process of moving a network
> interface across different network namespaces:
>
> * When I move an interface, all the virtual interfaces attached to it
> are deleted. Is there any reason for such odd behavior? I would like
> to move some network interfaces and keep the attached vlans untouched.

The defined semantics are that a network device is unregistered from
the networking stack in one network namespace and then registered
with the networking stack in another.  It is an unfortunate fact
that when vlan devices see their underlying device being unregistered
they decide to delete themselves.

A different vlan implementation might be able to have different
properties but I can't think of any obvious solution other than
don't do move the device that you have your vlans on top of.

> * The target network namespace sends a RTM_NEWLINK netlink message
> when an interface is moved to it. In the other hand, the source
> network namespace doesn't sends a RTM_DELLINK message when an
> interface is moved from it. This is very annoying because user space
> applications (such as zebra) can't detect some interface moving
> operations and then get into an inconsistent state. Anyone knows if
> there's a workaround for this?

Not getting RTM_DELLINK is a bug.  The device registration and
unregistration code has changed since dev_change_net_namespace was
written and apparently one of the changes failed to update
dev_change_net_namespace.

Eric


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Move interface across network namespaces
  2011-08-11  7:13 ` Eric W. Biederman
@ 2011-08-11 18:29   ` Renato Westphal
  2011-08-15 13:10     ` Renato Westphal
  0 siblings, 1 reply; 8+ messages in thread
From: Renato Westphal @ 2011-08-11 18:29 UTC (permalink / raw)
  To: Eric W. Biederman; +Cc: netdev

2011/8/11 Eric W. Biederman <ebiederm@xmission.com>:
> Renato Westphal <renatowestphal@gmail.com> writes:
>
>> Hello,
>>
>> I have two questions regarding the process of moving a network
>> interface across different network namespaces:
>>
>> * When I move an interface, all the virtual interfaces attached to it
>> are deleted. Is there any reason for such odd behavior? I would like
>> to move some network interfaces and keep the attached vlans untouched.
>
> The defined semantics are that a network device is unregistered from
> the networking stack in one network namespace and then registered
> with the networking stack in another.  It is an unfortunate fact
> that when vlan devices see their underlying device being unregistered
> they decide to delete themselves.
>
> A different vlan implementation might be able to have different
> properties but I can't think of any obvious solution other than
> don't do move the device that you have your vlans on top of.
>

Thanks for the info, I can handle with that by modifying my quagga-vrf patches.

>> * The target network namespace sends a RTM_NEWLINK netlink message
>> when an interface is moved to it. In the other hand, the source
>> network namespace doesn't sends a RTM_DELLINK message when an
>> interface is moved from it. This is very annoying because user space
>> applications (such as zebra) can't detect some interface moving
>> operations and then get into an inconsistent state. Anyone knows if
>> there's a workaround for this?
>
> Not getting RTM_DELLINK is a bug.  The device registration and
> unregistration code has changed since dev_change_net_namespace was
> written and apparently one of the changes failed to update
> dev_change_net_namespace.
>

Good, that makes a lot more sense. In the kernel 2.6.32.43 the
RTM_DELLINK netlink message is sent when a network interface is moved
from a network namespace. The same doesn't happens in the kernel
2.6.35.13. I'll try to isolate the problem some more.

Best Regards,
Renato.

-- 
Renato Westphal

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Move interface across network namespaces
  2011-08-11 18:29   ` Renato Westphal
@ 2011-08-15 13:10     ` Renato Westphal
  2011-08-18 23:12       ` Eric W. Biederman
  0 siblings, 1 reply; 8+ messages in thread
From: Renato Westphal @ 2011-08-15 13:10 UTC (permalink / raw)
  To: Eric W. Biederman; +Cc: netdev, kaber, David Lamparter

2011/8/11 Renato Westphal <renatowestphal@gmail.com>:
> 2011/8/11 Eric W. Biederman <ebiederm@xmission.com>:
>> Renato Westphal <renatowestphal@gmail.com> writes:
>>
>>> Hello,
>>>
>>> I have two questions regarding the process of moving a network
>>> interface across different network namespaces:
>>>
>>> * When I move an interface, all the virtual interfaces attached to it
>>> are deleted. Is there any reason for such odd behavior? I would like
>>> to move some network interfaces and keep the attached vlans untouched.
>>
>> The defined semantics are that a network device is unregistered from
>> the networking stack in one network namespace and then registered
>> with the networking stack in another.  It is an unfortunate fact
>> that when vlan devices see their underlying device being unregistered
>> they decide to delete themselves.
>>
>> A different vlan implementation might be able to have different
>> properties but I can't think of any obvious solution other than
>> don't do move the device that you have your vlans on top of.
>>
>
> Thanks for the info, I can handle with that by modifying my quagga-vrf patches.

I forgot to mention that I'm using kernel v2.6.35 (with a lot of
backports). For future reference, the commit 3b27e105550f7c4a ("netns:
keep vlan slaves on master netns move", merged into v2.6.37-rc1) fixes
this problem.

>>> * The target network namespace sends a RTM_NEWLINK netlink message
>>> when an interface is moved to it. In the other hand, the source
>>> network namespace doesn't sends a RTM_DELLINK message when an
>>> interface is moved from it. This is very annoying because user space
>>> applications (such as zebra) can't detect some interface moving
>>> operations and then get into an inconsistent state. Anyone knows if
>>> there's a workaround for this?
>>
>> Not getting RTM_DELLINK is a bug.  The device registration and
>> unregistration code has changed since dev_change_net_namespace was
>> written and apparently one of the changes failed to update
>> dev_change_net_namespace.
>>
>
> Good, that makes a lot more sense. In the kernel 2.6.32.43 the
> RTM_DELLINK netlink message is sent when a network interface is moved
> from a network namespace. The same doesn't happens in the kernel
> 2.6.35.13. I'll try to isolate the problem some more.

Well, this regression was introduced by commit a2835763e130c343ac,
which was merged into v2.6.34. Reverting parts of this commit makes
the problem go away but breaks the support of "specifying device flags
during device creation". I don't know the best way to fix this... any
ideas?

-- 
Renato Westphal

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Move interface across network namespaces
  2011-08-15 13:10     ` Renato Westphal
@ 2011-08-18 23:12       ` Eric W. Biederman
  2011-08-19 14:38         ` Renato Westphal
  0 siblings, 1 reply; 8+ messages in thread
From: Eric W. Biederman @ 2011-08-18 23:12 UTC (permalink / raw)
  To: Renato Westphal; +Cc: netdev, kaber, David Lamparter

Renato Westphal <renatowestphal@gmail.com> writes:

> I forgot to mention that I'm using kernel v2.6.35 (with a lot of
> backports). For future reference, the commit 3b27e105550f7c4a ("netns:
> keep vlan slaves on master netns move", merged into v2.6.37-rc1) fixes
> this problem.

Which makes me silly as I now remember reviewing that patch.

>>>> * The target network namespace sends a RTM_NEWLINK netlink message
>>>> when an interface is moved to it. In the other hand, the source
>>>> network namespace doesn't sends a RTM_DELLINK message when an
>>>> interface is moved from it. This is very annoying because user space
>>>> applications (such as zebra) can't detect some interface moving
>>>> operations and then get into an inconsistent state. Anyone knows if
>>>> there's a workaround for this?
>>>
>>> Not getting RTM_DELLINK is a bug.  The device registration and
>>> unregistration code has changed since dev_change_net_namespace was
>>> written and apparently one of the changes failed to update
>>> dev_change_net_namespace.
>>>
>>
>> Good, that makes a lot more sense. In the kernel 2.6.32.43 the
>> RTM_DELLINK netlink message is sent when a network interface is moved
>> from a network namespace. The same doesn't happens in the kernel
>> 2.6.35.13. I'll try to isolate the problem some more.
>
> Well, this regression was introduced by commit a2835763e130c343ac,
> which was merged into v2.6.34. Reverting parts of this commit makes
> the problem go away but breaks the support of "specifying device flags
> during device creation". I don't know the best way to fix this... any
> ideas?

Everything going through dev_change_net_namespace already needs to be
in the initialized state.  So it looks like we just need to do:

Does the patch below work for you?

Eric

---

diff --git a/net/core/dev.c b/net/core/dev.c
index 17d67b5..bfbde69 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6108,6 +6108,8 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char
 	call_netdevice_notifiers(NETDEV_UNREGISTER, dev);
 	call_netdevice_notifiers(NETDEV_UNREGISTER_BATCH, dev);
 
+	rtmsg_ifinfo(RTM_DELLINK, dev, ~0U);
+
 	/*
 	 *	Flush the unicast and multicast chains
 	 */

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: Move interface across network namespaces
  2011-08-18 23:12       ` Eric W. Biederman
@ 2011-08-19 14:38         ` Renato Westphal
  2011-10-21 16:24           ` [PATCH] rtnetlink: Add missing manual netlink notification in dev_change_net_namespaces Eric W. Biederman
  0 siblings, 1 reply; 8+ messages in thread
From: Renato Westphal @ 2011-08-19 14:38 UTC (permalink / raw)
  To: Eric W. Biederman; +Cc: netdev, kaber, David Lamparter

>> Well, this regression was introduced by commit a2835763e130c343ac,
>> which was merged into v2.6.34. Reverting parts of this commit makes
>> the problem go away but breaks the support of "specifying device flags
>> during device creation". I don't know the best way to fix this... any
>> ideas?
>
> Everything going through dev_change_net_namespace already needs to be
> in the initialized state.  So it looks like we just need to do:
>
> Does the patch below work for you?
>
> Eric
>
> ---
>
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 17d67b5..bfbde69 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -6108,6 +6108,8 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char
>        call_netdevice_notifiers(NETDEV_UNREGISTER, dev);
>        call_netdevice_notifiers(NETDEV_UNREGISTER_BATCH, dev);
>
> +       rtmsg_ifinfo(RTM_DELLINK, dev, ~0U);
> +
>        /*
>         *      Flush the unicast and multicast chains
>         */
>

 This works pretty fine. Thanks! :)

-- 
Renato Westphal

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] rtnetlink: Add missing manual netlink notification in dev_change_net_namespaces
  2011-08-19 14:38         ` Renato Westphal
@ 2011-10-21 16:24           ` Eric W. Biederman
  2011-10-24  7:03             ` David Miller
  0 siblings, 1 reply; 8+ messages in thread
From: Eric W. Biederman @ 2011-10-21 16:24 UTC (permalink / raw)
  To: David Miller
  Cc: netdev, kaber, David Lamparter, Renato Westphal, Patrick McHardy


Renato Westphal noticed that since commit a2835763e130c343ace5320c20d33c281e7097b7
"rtnetlink: handle rtnl_link netlink notifications manually" was merged
we no longer send a netlink message when a networking device is moved
from one network namespace to another.

Fix this by adding the missing manual notification in dev_change_net_namespaces.

Since all network devices that are processed by dev_change_net_namspaces are
in the initialized state the complicated tests that guard the manual
rtmsg_ifinfo calls in rollback_registered and register_netdevice are
unnecessary and we can just perform a plain notification.

Cc: stable@kernel.org
Tested-by: Renato Westphal <renatowestphal@gmail.com>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
---
 net/core/dev.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index ad5d702..b7ba81a 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6266,6 +6266,7 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char
 	*/
 	call_netdevice_notifiers(NETDEV_UNREGISTER, dev);
 	call_netdevice_notifiers(NETDEV_UNREGISTER_BATCH, dev);
+	rtmsg_ifinfo(RTM_DELLINK, dev, ~0U);
 
 	/*
 	 *	Flush the unicast and multicast chains
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] rtnetlink: Add missing manual netlink notification in dev_change_net_namespaces
  2011-10-21 16:24           ` [PATCH] rtnetlink: Add missing manual netlink notification in dev_change_net_namespaces Eric W. Biederman
@ 2011-10-24  7:03             ` David Miller
  0 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2011-10-24  7:03 UTC (permalink / raw)
  To: ebiederm; +Cc: netdev, kaber, equinox, renatowestphal

From: ebiederm@xmission.com (Eric W. Biederman)
Date: Fri, 21 Oct 2011 09:24:20 -0700

> Renato Westphal noticed that since commit a2835763e130c343ace5320c20d33c281e7097b7
> "rtnetlink: handle rtnl_link netlink notifications manually" was merged
> we no longer send a netlink message when a networking device is moved
> from one network namespace to another.
> 
> Fix this by adding the missing manual notification in dev_change_net_namespaces.
> 
> Since all network devices that are processed by dev_change_net_namspaces are
> in the initialized state the complicated tests that guard the manual
> rtmsg_ifinfo calls in rollback_registered and register_netdevice are
> unnecessary and we can just perform a plain notification.
> 
> Cc: stable@kernel.org
> Tested-by: Renato Westphal <renatowestphal@gmail.com>
> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>

Applied, thanks Eric.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-10-24  7:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-11  0:31 Move interface across network namespaces Renato Westphal
2011-08-11  7:13 ` Eric W. Biederman
2011-08-11 18:29   ` Renato Westphal
2011-08-15 13:10     ` Renato Westphal
2011-08-18 23:12       ` Eric W. Biederman
2011-08-19 14:38         ` Renato Westphal
2011-10-21 16:24           ` [PATCH] rtnetlink: Add missing manual netlink notification in dev_change_net_namespaces Eric W. Biederman
2011-10-24  7:03             ` 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).