netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: clear iflink when moving to a new netns
@ 2014-02-11 23:51 Cong Wang
  2014-02-11 23:51 ` [PATCH] macvlan: unregister net device when netdev_upper_dev_link() fails Cong Wang
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Cong Wang @ 2014-02-11 23:51 UTC (permalink / raw)
  To: netdev
  Cc: Cong Wang, David S. Miller, Eric W. Biederman, Eric Dumazet,
	Hannes Frederic Sowa, Cong Wang

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);
-- 
1.8.3.1

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

end of thread, other threads:[~2014-02-13 22:44 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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).