Message ID | 1416539426-20684-1-git-send-email-takayuki@midokura.com (mailing list archive) |
---|---|
State | Changes Requested, archived |
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id C0D4D7F44; Fri, 21 Nov 2014 04:00:03 +0100 (CET) Received: from mail-pa0-f45.google.com (mail-pa0-f45.google.com [209.85.220.45]) by dpdk.org (Postfix) with ESMTP id A3C937F0C for <dev@dpdk.org>; Fri, 21 Nov 2014 04:00:02 +0100 (CET) Received: by mail-pa0-f45.google.com with SMTP id lj1so3896041pab.32 for <dev@dpdk.org>; Thu, 20 Nov 2014 19:10:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=98biOOZhHfUtecsnOXpoAZ6CpajnfAevEg61TfmrYe4=; b=X9hWFmiT5OdJS1mD/pKb7t1KgUjZ8rOZWAvRvnR2iOLaFjhT9n3d+Hq7fizJDltZqk yWzeFJFMKxjuO149kEDLriQOoo6SjN2LPDh1rsM7LQO2420zwQiTp7JyvEMhxAi1XShN IgSGqEO5vYr9iT5LbgasX7G8MYkyJj6Ja6lsr1ymfPyfJ8i8qaQXTdCcVOXP8FW8O9DQ gwgNV1kskHy9sPe/HVMD66iF/QcFuYyg1LaS6dydywcFtsjxE8EISZuE63f1iW4iSkur HKLGliBRXfy5dWtJqGqNTzsROcYgnJ8vZs/R9IXs9RGDtablMRrKeNU23W2gfB3HJt7c O2GQ== X-Gm-Message-State: ALoCoQmaNz1mfrbOA29Pdy8qx69H2Y4q09StygjK7qXbQktNrmBKO+2jlmvBMM1uSWH8ejkThgNH X-Received: by 10.68.111.161 with SMTP id ij1mr3045306pbb.10.1416539433483; Thu, 20 Nov 2014 19:10:33 -0800 (PST) Received: from orifice.localdomain ([240b:10:25c0:200:178:126:4037:f352]) by mx.google.com with ESMTPSA id kj9sm3290431pbc.37.2014.11.20.19.10.32 for <dev@dpdk.org> (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Nov 2014 19:10:33 -0800 (PST) From: Takayuki Usui <takayuki@midokura.com> To: dev@dpdk.org Date: Fri, 21 Nov 2014 12:10:26 +0900 Message-Id: <1416539426-20684-1-git-send-email-takayuki@midokura.com> X-Mailer: git-send-email 2.1.3 Subject: [dpdk-dev] [PATCH] kni: create KNI interface in current network namespace X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK <dev.dpdk.org> List-Unsubscribe: <http://dpdk.org/ml/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://dpdk.org/ml/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <http://dpdk.org/ml/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org Sender: "dev" <dev-bounces@dpdk.org> |
Commit Message
Takayuki Usui
Nov. 21, 2014, 3:10 a.m. UTC
With this patch, KNI interface (e.g. vEth0) is created in the
network namespace where the DPDK application is running.
Otherwise, all interfaces are created in the default namespace
in the host.
Signed-off-by: Takayuki Usui <takayuki@midokura.com>
---
lib/librte_eal/linuxapp/kni/kni_misc.c | 2 ++
1 file changed, 2 insertions(+)
Comments
Anyone to review this KNI patch? 2014-11-21 12:10, Takayuki Usui: > With this patch, KNI interface (e.g. vEth0) is created in the > network namespace where the DPDK application is running. > Otherwise, all interfaces are created in the default namespace > in the host. > > Signed-off-by: Takayuki Usui <takayuki@midokura.com> > --- > lib/librte_eal/linuxapp/kni/kni_misc.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c > index ba77776..f4a9965 100644 > --- a/lib/librte_eal/linuxapp/kni/kni_misc.c > +++ b/lib/librte_eal/linuxapp/kni/kni_misc.c > @@ -354,6 +354,8 @@ kni_ioctl_create(unsigned int ioctl_num, unsigned long ioctl_param) > return -EBUSY; > } > > + dev_net_set(net_dev, get_net_ns_by_pid(current->pid)); > + > kni = netdev_priv(net_dev); > > kni->net_dev = net_dev;
Le 21/11/2014 04:10, Takayuki Usui a écrit : > With this patch, KNI interface (e.g. vEth0) is created in the > network namespace where the DPDK application is running. > Otherwise, all interfaces are created in the default namespace > in the host. > > Signed-off-by: Takayuki Usui <takayuki@midokura.com> > --- > lib/librte_eal/linuxapp/kni/kni_misc.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c > index ba77776..f4a9965 100644 > --- a/lib/librte_eal/linuxapp/kni/kni_misc.c > +++ b/lib/librte_eal/linuxapp/kni/kni_misc.c > @@ -354,6 +354,8 @@ kni_ioctl_create(unsigned int ioctl_num, unsigned long ioctl_param) > return -EBUSY; > } > > + dev_net_set(net_dev, get_net_ns_by_pid(current->pid)); You should test the returned value and release the refcnt. net = get_net_ns_by_pid(current->pid) if (IS_ERR(net)) ... put_net(net); > + > kni = netdev_priv(net_dev); > > kni->net_dev = net_dev; >
> 2014-11-21 12:10, Takayuki Usui: > > With this patch, KNI interface (e.g. vEth0) is created in the network > > namespace where the DPDK application is running. > > Otherwise, all interfaces are created in the default namespace in the > > host. > > > > Signed-off-by: Takayuki Usui <takayuki@midokura.com> > > --- > > lib/librte_eal/linuxapp/kni/kni_misc.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c > > b/lib/librte_eal/linuxapp/kni/kni_misc.c > > index ba77776..f4a9965 100644 > > --- a/lib/librte_eal/linuxapp/kni/kni_misc.c > > +++ b/lib/librte_eal/linuxapp/kni/kni_misc.c > > @@ -354,6 +354,8 @@ kni_ioctl_create(unsigned int ioctl_num, unsigned > long ioctl_param) > > return -EBUSY; > > } > > > > + dev_net_set(net_dev, get_net_ns_by_pid(current->pid)); > > + Another way to get it done is by the following. It will be init_net for the root container. #ifdef CONFIG_NET_NS net_dev->nd_net = current->nsproxy->net_ns; #endif > > kni = netdev_priv(net_dev); > > > > kni->net_dev = net_dev;
Le 01/12/2014 06:45, Hemant@freescale.com a écrit : >> 2014-11-21 12:10, Takayuki Usui: >>> With this patch, KNI interface (e.g. vEth0) is created in the network >>> namespace where the DPDK application is running. >>> Otherwise, all interfaces are created in the default namespace in the >>> host. >>> >>> Signed-off-by: Takayuki Usui <takayuki@midokura.com> >>> --- >>> lib/librte_eal/linuxapp/kni/kni_misc.c | 2 ++ >>> 1 file changed, 2 insertions(+) >>> >>> diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c >>> b/lib/librte_eal/linuxapp/kni/kni_misc.c >>> index ba77776..f4a9965 100644 >>> --- a/lib/librte_eal/linuxapp/kni/kni_misc.c >>> +++ b/lib/librte_eal/linuxapp/kni/kni_misc.c >>> @@ -354,6 +354,8 @@ kni_ioctl_create(unsigned int ioctl_num, unsigned >> long ioctl_param) >>> return -EBUSY; >>> } >>> >>> + dev_net_set(net_dev, get_net_ns_by_pid(current->pid)); >>> + > > Another way to get it done is by the following. It will be init_net for the root container. > > #ifdef CONFIG_NET_NS > net_dev->nd_net = current->nsproxy->net_ns; > #endif No. It's always better to use existing helpers, it hides this kind of ifdef and more importantly, it do the right things (call release_net()/hold_net())! Reimplemented helpers is error prone.
diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c index ba77776..f4a9965 100644 --- a/lib/librte_eal/linuxapp/kni/kni_misc.c +++ b/lib/librte_eal/linuxapp/kni/kni_misc.c @@ -354,6 +354,8 @@ kni_ioctl_create(unsigned int ioctl_num, unsigned long ioctl_param) return -EBUSY; } + dev_net_set(net_dev, get_net_ns_by_pid(current->pid)); + kni = netdev_priv(net_dev); kni->net_dev = net_dev;