ieee802154: fix netns settings
authorNicolas Dichtel <nicolas.dichtel@6wind.com>
Thu, 5 Feb 2015 17:21:30 +0000 (18:21 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Sat, 14 Feb 2015 04:19:58 +0000 (05:19 +0100)
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.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Acked-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
net/ieee802154/6lowpan/core.c
net/ieee802154/core.c

index 055fbb71ba6f3fae7ff3740566c97306d97ebe3b..dfd3c6007f609b4dc8a0a7cbcab91a0b400b00bd 100644 (file)
@@ -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) {
index 18bc7e7385074c4b62e5e7c87c1d2bba3981e7a4..888d0991c7613653b7dd285213162ac38fdb1f84 100644 (file)
@@ -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++;
This page took 0.027441 seconds and 5 git commands to generate.