From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com [209.85.212.175]) by dpdk.org (Postfix) with ESMTP id 9CD488044 for ; Mon, 1 Dec 2014 11:42:31 +0100 (CET) Received: by mail-wi0-f175.google.com with SMTP id l15so24115870wiw.8 for ; Mon, 01 Dec 2014 02:42:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:reply-to:organization :user-agent:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=VWVPw1Y3BHVl6eJTW5uTzS787+lB9zXqZAEtrpD6UDs=; b=fJSMSQ6aj56n50l0zUNIqpOwaz3b4/CF29hXSuhcRP5SITkX1GvHK3IGJ++gzN8pTr h4rzo+O0ULM+U2Oi0iqcXF+HIAdzf4094Ud4ekuap3a+5ZdX4RpyR7Y9YkzYSo972GFq UfrUNiOGj06VPS2mD3kMziwKGYKrleZMfBirT+hfLghYqCwFyHQCJta4zgI6CDqGLGQ+ nCz+b7AsDFUX2Zs1uRTBHuGXWiWKw6d8pfIUrCahiTs23XAAwyCsfDd5o0kh7C78f2Rm OP8iwKg+U89/Yg3z+rBh9roAeJ12AcKw6utySoxzQrVGouUs8DuarQfbT5SVYNJmP7eD Atrw== X-Gm-Message-State: ALoCoQl+JQKX9WjSIyPxHE7E+0DHJ1Uq55RzAwDlpB7KUuIPuaIQ6Xg4apLUwMZ2h1NBkSMOswoI X-Received: by 10.194.90.244 with SMTP id bz20mr93386749wjb.125.1417430551456; Mon, 01 Dec 2014 02:42:31 -0800 (PST) Received: from ?IPv6:2a01:e35:8b63:dc30:ad57:3d91:4b53:154b? ([2a01:e35:8b63:dc30:ad57:3d91:4b53:154b]) by mx.google.com with ESMTPSA id pf4sm27015369wjb.36.2014.12.01.02.42.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Dec 2014 02:42:30 -0800 (PST) Message-ID: <547C4615.7040701@6wind.com> Date: Mon, 01 Dec 2014 11:42:29 +0100 From: Nicolas Dichtel Organization: 6WIND User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: "Hemant@freescale.com" , "dev@dpdk.org" References: <1416539426-20684-1-git-send-email-takayuki@midokura.com> <4920841.6YLj9k6iQh@xps13> In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH] kni: create KNI interface in current network namespace X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: nicolas.dichtel@6wind.com List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Dec 2014 10:42:31 -0000 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 >>> --- >>> 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.