Skip to contentSkip to conversation

ieee802154: fix netns settings

PATCH Superseded Nicolas Dichtel 3 participants 7 messages Jan 28, 2015 – Feb 12, 2015

Subsystems (3)
lore
Share & tools
lore
maintainer Acked-by on v2 1/1
#1 lore raw
In reply to Nicolas Dichtel
Quoted 9 lines · Nicolas Dichtel

6LoWPAN currently doesn't supports x-netns and works only in init_net.

With this patch, we ensure that:
- the wpan interface cannot be moved to another netns;
- the 6lowpan interface cannot be moved to another netns;
- the wpan interface is in the same netns than the 6lowpan interface;
- the 6lowpan interface is in init_net.

Marcel, can you please queue this for bluetooth-next?

Thanks.

- Alex

#0 lore raw

PATCH v2 1/1 ieee802154: fix netns settings

6LoWPAN currently doesn't supports x-netns and works only in init_net.

With this patch, we ensure that:
- the wpan interface cannot be moved to another netns;
- the 6lowpan interface cannot be moved to another netns;
- the wpan interface is in the same netns than the 6lowpan interface;
- the 6lowpan interface is in init_net.

---

Note: only compile tested.

v2: update patch title
rebase the patch on bluetooth-next
update flag features in cfg802154_netdev_notifier_call

 net/ieee802154/6lowpan/core.c | 6 ++++--
 net/ieee802154/core.c         | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)
net/ieee802154/6lowpan/core.c +4 -2
index 055fbb71ba6f..dfd3c6007f60 100644
@@ -126,6 +126,7 @@ static void lowpan_setup(struct net_device *dev)
 	dev->header_ops		= &lowpan_header_ops;
 	dev->ml_priv		= &lowpan_mlme;
 	dev->destructor		= free_netdev;
+	dev->features		|= NETIF_F_NETNS_LOCAL;
 }
 
 static int lowpan_validate(struct nlattr *tb[], struct nlattr *data[])
@@ -148,10 +149,11 @@ static int lowpan_newlink(struct net *src_net, struct net_device *dev,
 
 	pr_debug("adding new link\n");
 
-	if (!tb[IFLA_LINK])
+	if (!tb[IFLA_LINK] ||
+	    !net_eq(dev_net(dev), &init_net))
 		return -EINVAL;
 	/* find and hold real wpan device */
-	real_dev = dev_get_by_index(src_net, nla_get_u32(tb[IFLA_LINK]));
+	real_dev = dev_get_by_index(dev_net(dev), nla_get_u32(tb[IFLA_LINK]));
 	if (!real_dev)
 		return -ENODEV;
 	if (real_dev->type != ARPHRD_IEEE802154) {
net/ieee802154/core.c +1 -0
index 18bc7e738507..888d0991c761 100644
@@ -225,6 +225,7 @@ static int cfg802154_netdev_notifier_call(struct notifier_block *nb,
 	switch (state) {
 		/* TODO NETDEV_DEVTYPE */
 	case NETDEV_REGISTER:
+		dev->features |= NETIF_F_NETNS_LOCAL;
 		wpan_dev->identifier = ++rdev->wpan_dev_id;
 		list_add_rcu(&wpan_dev->list, &rdev->wpan_dev_list);
 		rdev->devlist_generation++;
Signature · 1 line
2.2.2
maintainer
#2 lore raw
In reply to Alexander Aring
Quoted 9 lines · Alexander Aring
Quoted 8 lines · Nicolas Dichtel

6LoWPAN currently doesn't supports x-netns and works only in init_net.

With this patch, we ensure that:
- the wpan interface cannot be moved to another netns;
- the 6lowpan interface cannot be moved to another netns;
- the wpan interface is in the same netns than the 6lowpan interface;
- the 6lowpan interface is in init_net.

Quoted 6 lines
Quoted 1 line

Marcel, can you please queue this for bluetooth-next?

ping.

- Alex

#3 lore raw

Hi Alex,

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

6LoWPAN currently doesn't supports x-netns and works only in init_net.

With this patch, we ensure that:
- the wpan interface cannot be moved to another netns;
- the 6lowpan interface cannot be moved to another netns;
- the wpan interface is in the same netns than the 6lowpan interface;
- the 6lowpan interface is in init_net.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Marcel, can you please queue this for bluetooth-next?

ping.

I completely missed this one and it is not even showing up in my local archive. Care to resend it with your ack attached to it.

Regards

Marcel

#4 lore raw

PATCH v3 1/1 ieee802154: fix netns settings

6LoWPAN currently doesn't supports x-netns and works only in init_net.

With this patch, we ensure that:
- the wpan interface cannot be moved to another netns;
- the 6lowpan interface cannot be moved to another netns;
- the wpan interface is in the same netns than the 6lowpan interface;
- the 6lowpan interface is in init_net.

---

Note: only compile tested.

v3: rebase on head of bluetooth-next
add the Acked-by line

v2: update patch title
rebase the patch on bluetooth-next
update flag features in cfg802154_netdev_notifier_call

 net/ieee802154/6lowpan/core.c | 6 ++++--
 net/ieee802154/core.c         | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)
net/ieee802154/6lowpan/core.c +4 -2
index 055fbb71ba6f..dfd3c6007f60 100644
@@ -126,6 +126,7 @@ static void lowpan_setup(struct net_device *dev)
 	dev->header_ops		= &lowpan_header_ops;
 	dev->ml_priv		= &lowpan_mlme;
 	dev->destructor		= free_netdev;
+	dev->features		|= NETIF_F_NETNS_LOCAL;
 }
 
 static int lowpan_validate(struct nlattr *tb[], struct nlattr *data[])
@@ -148,10 +149,11 @@ static int lowpan_newlink(struct net *src_net, struct net_device *dev,
 
 	pr_debug("adding new link\n");
 
-	if (!tb[IFLA_LINK])
+	if (!tb[IFLA_LINK] ||
+	    !net_eq(dev_net(dev), &init_net))
 		return -EINVAL;
 	/* find and hold real wpan device */
-	real_dev = dev_get_by_index(src_net, nla_get_u32(tb[IFLA_LINK]));
+	real_dev = dev_get_by_index(dev_net(dev), nla_get_u32(tb[IFLA_LINK]));
 	if (!real_dev)
 		return -ENODEV;
 	if (real_dev->type != ARPHRD_IEEE802154) {
net/ieee802154/core.c +1 -0
index 18bc7e738507..888d0991c761 100644
@@ -225,6 +225,7 @@ static int cfg802154_netdev_notifier_call(struct notifier_block *nb,
 	switch (state) {
 		/* TODO NETDEV_DEVTYPE */
 	case NETDEV_REGISTER:
+		dev->features |= NETIF_F_NETNS_LOCAL;
 		wpan_dev->identifier = ++rdev->wpan_dev_id;
 		list_add_rcu(&wpan_dev->list, &rdev->wpan_dev_list);
 		rdev->devlist_generation++;
Signature · 1 line
2.2.2
maintainer
#5 lore raw

Hi Nicolas,

Quoted 10 lines · Nicolas Dichtel

6LoWPAN currently doesn't supports x-netns and works only in init_net.

With this patch, we ensure that:
- the wpan interface cannot be moved to another netns;
- the 6lowpan interface cannot be moved to another netns;
- the wpan interface is in the same netns than the 6lowpan interface;
- the 6lowpan interface is in init_net.

thanks for resend this patch and added my ack, thanks.

- Alex

#6 lore raw
In reply to Nicolas Dichtel

Hi Nicolas,

Quoted 17 lines

6LoWPAN currently doesn't supports x-netns and works only in init_net.

With this patch, we ensure that:
- the wpan interface cannot be moved to another netns;
- the 6lowpan interface cannot be moved to another netns;
- the wpan interface is in the same netns than the 6lowpan interface;
- the 6lowpan interface is in init_net.

---

Note: only compile tested.

v3: rebase on head of bluetooth-next
add the Acked-by line

Quoted 7 lines

v2: update patch title
rebase the patch on bluetooth-next
update flag features in cfg802154_netdev_notifier_call

net/ieee802154/6lowpan/core.c | 6 ++++--
net/ieee802154/core.c | 1 +

2 files changed, 5 insertions(+), 2 deletions(-)

patch has been applied bluetooth-next tree.

Regards

Marcel