From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Dichtel Subject: Re: [PATCH] kni: create KNI interface in current network namespace Date: Mon, 01 Dec 2014 11:42:29 +0100 Message-ID: <547C4615.7040701@6wind.com> References: <1416539426-20684-1-git-send-email-takayuki@midokura.com> <4920841.6YLj9k6iQh@xps13> Reply-To: nicolas.dichtel-pdR9zngts4EAvxtiuMwx3w@public.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: quoted-printable To: "Hemant-KZfg59tc24xl57MIdRCFDg@public.gmane.org" , "dev-VfR2kkLFssw@public.gmane.org" Return-path: In-Reply-To: List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" Le 01/12/2014 06:45, Hemant-KZfg59tc24xl57MIdRCFDg@public.gmane.org a =E9crit : >> 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 >>> --- >>> 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 =3D current->nsproxy->net_ns; > #endif No. It's always better to use existing helpers, it hides this kind of ifd= ef and more importantly, it do the right things (call release_net()/hold_net())! Reimplemented helpers is error prone.