From patchwork Tue Jan 27 12:51:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Aring X-Patchwork-Id: 433467 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id EAD9C140188 for ; Tue, 27 Jan 2015 23:51:43 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933155AbbA0Mvk (ORCPT ); Tue, 27 Jan 2015 07:51:40 -0500 Received: from mail-wi0-f180.google.com ([209.85.212.180]:57229 "EHLO mail-wi0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932328AbbA0Mvg (ORCPT ); Tue, 27 Jan 2015 07:51:36 -0500 Received: by mail-wi0-f180.google.com with SMTP id h11so4729357wiw.1; Tue, 27 Jan 2015 04:51:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=nb+gB9vSQ38SDq11xDXFPWoEwZv4qs61hk5sZoJW4MQ=; b=fe2eIqkLlFltVXZ114RNjbZdpXx5Cb4o9RfNeULf8tUpM4mLHcs/1acGKIt7ilqxXC r4fJT+fJxi/hTSIprkeMPmqHZAkyjRB/wPCi9+vLiD4bUp4yqnPGF4d9rliZP9zq27WM 7lh5wQhZwvCMrmzSDdD09VuLkShQoIrlfNipbUsX2Yhf+CRP9wIHNQQKUWrfn4aOMcwo Y94g/Pd3VIAmie+O1wjxZirBFZ+nxIAenL68GihAD4J2+es56ga5zcIpVyard1roqIrA iRcb62AbdlY2XnqFiWFBVo7nbtUYn0N/Tacp3n2CUCKIvczelhBEbsVz52c96SYW5B+5 dVmA== X-Received: by 10.180.160.194 with SMTP id xm2mr5594746wib.77.1422363095268; Tue, 27 Jan 2015 04:51:35 -0800 (PST) Received: from omega (p20030064A9498C80E2CB4EFFFE1BB546.dip0.t-ipconnect.de. [2003:64:a949:8c80:e2cb:4eff:fe1b:b546]) by mx.google.com with ESMTPSA id fp2sm18023726wib.8.2015.01.27.04.51.33 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Jan 2015 04:51:34 -0800 (PST) Date: Tue, 27 Jan 2015 13:51:31 +0100 From: Alexander Aring To: Nicolas Dichtel Cc: netdev@vger.kernel.org, davem@davemloft.net, arvid.brodin@alten.se, linux-wpan@vger.kernel.org Subject: Re: [PATCH net 0/2] netns: audit netdevice creation with IFLA_NET_NS_[PID|FD] Message-ID: <20150127125130.GB4338@omega> References: <1422307694-10079-1-git-send-email-nicolas.dichtel@6wind.com> <20150127093425.GA2698@omega> <54C7694C.2060709@6wind.com> <20150127122340.GA4338@omega> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20150127122340.GA4338@omega> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Tue, Jan 27, 2015 at 01:23:40PM +0100, Alexander Aring wrote: ... > Summarize: > > I would add the dev->features |= NETIF_F_NETNS_LOCAL; while wpan > interface generation and add only the !net_eq(src_net, &init_net) check > above. I suppose that src_net is the net namespace from "underlaying" > interface wpan by calling: > > $ ip link add link wpan0 name lowpan0 type lowpan > should look something like: --- In ieee802154/core.c we set (like wireless it also does) the dev->features |= NETIF_F_NETNS_LOCAL; for wpan interface. In net/ieee802154/6lowpan/core.c, we only check if the wpan interface belongs to !net_eq(src_net, &init_net). On 6LoWPAN 802.15.4 interfaces it should be still possible to change the net namespace. - Alex -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/ieee802154/6lowpan/core.c b/net/ieee802154/6lowpan/core.c index 055fbb7..a44963c 100644 --- a/net/ieee802154/6lowpan/core.c +++ b/net/ieee802154/6lowpan/core.c @@ -148,10 +148,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(src_net, &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(&init_net, nla_get_u32(tb[IFLA_LINK])); if (!real_dev) return -ENODEV; if (real_dev->type != ARPHRD_IEEE802154) { diff --git a/net/ieee802154/core.c b/net/ieee802154/core.c index 18bc7e7..161f0e5 100644 --- a/net/ieee802154/core.c +++ b/net/ieee802154/core.c @@ -229,6 +229,8 @@ static int cfg802154_netdev_notifier_call(struct notifier_block *nb, list_add_rcu(&wpan_dev->list, &rdev->wpan_dev_list); rdev->devlist_generation++; + /* can only change netns with wpan_phy */ + dev->features |= NETIF_F_NETNS_LOCAL; wpan_dev->netdev = dev; break; case NETDEV_DOWN: