public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber•org>
To: Cong Wang <xiyou.wangcong@gmail•com>
Cc: netdev@vger•kernel.org, "David S. Miller" <davem@davemloft•net>,
	"Eric W. Biederman" <ebiederm@xmission•com>,
	Eric Dumazet <eric.dumazet@gmail•com>,
	Hannes Frederic Sowa <hannes@stressinduktion•org>,
	Cong Wang <cwang@twopensource•com>
Subject: Re: [PATCH] net: clear iflink when moving to a new netns
Date: Wed, 12 Feb 2014 08:33:22 -0800	[thread overview]
Message-ID: <20140212083322.1559f441@nehalam.linuxnetplumber.net> (raw)
In-Reply-To: <1392162690-6647-1-git-send-email-xiyou.wangcong@gmail.com>

On Tue, 11 Feb 2014 15:51:28 -0800
Cong Wang <xiyou.wangcong@gmail•com> wrote:

> From: Cong Wang <cwang@twopensource•com>
> 
> BZ: https://bugzilla.kernel.org/show_bug.cgi?id=66691
> 
> macvlan and vlan both use iflink to identify its lower device,
> however, after such device is moved to the new netns, its iflink
> would become meaningless as ifindex is per netns. So, instead of
> forbid them moving to another netns, just clear this field so that
> it will not be dumped at least.
> 
> Cc: David S. Miller <davem@davemloft•net>
> Cc: Eric W. Biederman <ebiederm@xmission•com>
> Cc: Eric Dumazet <eric.dumazet@gmail•com>
> Cc: Hannes Frederic Sowa <hannes@stressinduktion•org>,
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail•com>
> Signed-off-by: Cong Wang <cwang@twopensource•com>
> ---
>  net/core/dev.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 4ad1b78..5e88b0c2 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -6608,12 +6608,11 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char
>  	dev_net_set(dev, net);
>  
>  	/* If there is an ifindex conflict assign a new one */
> -	if (__dev_get_by_index(net, dev->ifindex)) {
> -		int iflink = (dev->iflink == dev->ifindex);
> +	if (__dev_get_by_index(net, dev->ifindex))
>  		dev->ifindex = dev_new_index(net);
> -		if (iflink)
> -			dev->iflink = dev->ifindex;
> -	}
> +
> +	/* Old iflink is meaningless in the new namespace */
> +	dev->iflink = dev->ifindex;
>  
>  	/* Send a netdev-add uevent to the new namespace */
>  	kobject_uevent(&dev->dev.kobj, KOBJ_ADD);

This also breaks propogation of state changes from lower device
to upper device. Things like carrier and up/down.

  parent reply	other threads:[~2014-02-12 16:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-11 23:51 [PATCH] net: clear iflink when moving to a new netns Cong Wang
2014-02-11 23:51 ` [PATCH] macvlan: unregister net device when netdev_upper_dev_link() fails Cong Wang
2014-02-13 22:13   ` David Miller
2014-02-11 23:51 ` [PATCH] net: correct error path in rtnl_newlink() Cong Wang
2014-02-13 22:13   ` David Miller
2014-02-12 15:43 ` [PATCH] net: clear iflink when moving to a new netns Nicolas Dichtel
2014-02-13  1:18   ` Cong Wang
2014-02-13  2:00     ` Eric W. Biederman
2014-02-13 22:44       ` Cong Wang
2014-02-12 16:33 ` Stephen Hemminger [this message]
2014-02-13  1:20   ` Cong Wang
2014-02-13  2:01     ` Eric W. Biederman
2014-02-12 23:18 ` Ben Hutchings
2014-02-13  1:34   ` Cong Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140212083322.1559f441@nehalam.linuxnetplumber.net \
    --to=stephen@networkplumber$(echo .)org \
    --cc=cwang@twopensource$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=ebiederm@xmission$(echo .)com \
    --cc=eric.dumazet@gmail$(echo .)com \
    --cc=hannes@stressinduktion$(echo .)org \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=xiyou.wangcong@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox