From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f179.google.com (mail-pd0-f179.google.com [209.85.192.179]) by dpdk.org (Postfix) with ESMTP id 847E37E75 for ; Wed, 3 Dec 2014 02:37:38 +0100 (CET) Received: by mail-pd0-f179.google.com with SMTP id w10so14426258pde.10 for ; Tue, 02 Dec 2014 17:37:37 -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:cc:subject:date:message-id:in-reply-to :references; bh=Wrc3UpofsQPYCQOkf1sUv7KMOUxWpoC6kTi4gJ4i308=; b=XbToRt32M3yo/HNmnEF1pPAh5iCtEeu1iTiah1sTR8R3n4LEt54RW6auY/PEfeR43o pT0S0u8kYezaZfFodDk2q6UrvW/LwW3UMCnT3/pAVBLBfSyvF3hYPlo10syvE296I3qM dz02Bh4lkzqXCMdrgM+9DAl1DgjOjmkwexFeOBwjhf5iqii/EfUE4bBNccakxlLFr8KX 9YrHbWXJh7SJEt/K9vkfle6SfXAb/Y+PVSyhSzndDH1GzxsOyeIkxThXmoU7Hldiz9B8 BRC7hKLPDzSz+HGna9eylYSZd8ECV5sfSxPOXmKS1i+XyhLSlnlGTzXU6HcnAFnS85eT urxw== X-Gm-Message-State: ALoCoQkYMAPIpPaAjZF03fIzcbKXjiLPKCUrFDGirNy+3bdlugLINyfwtIKv9ej1PpItewnKTDa5 X-Received: by 10.70.19.206 with SMTP id h14mr3818668pde.49.1417570657737; Tue, 02 Dec 2014 17:37:37 -0800 (PST) Received: from orifice.tyo.midokura.net (p2194-ipngn5201marunouchi.tokyo.ocn.ne.jp. [153.161.57.194]) by mx.google.com with ESMTPSA id ye3sm21305924pbb.93.2014.12.02.17.37.36 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Dec 2014 17:37:37 -0800 (PST) From: Takayuki Usui To: dev@dpdk.org Date: Wed, 3 Dec 2014 10:37:26 +0900 Message-Id: <1417570646-7724-1-git-send-email-takayuki@midokura.com> X-Mailer: git-send-email 2.1.3 In-Reply-To: <547D809E.8020607@6wind.com> References: <547D809E.8020607@6wind.com> Subject: [dpdk-dev] [PATCH v3] 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Dec 2014 01:37:38 -0000 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. put_net() is required, since get_net_ns_by_pid() increments the reference counter of the network namespace with get_net(). Signed-off-by: Takayuki Usui --- lib/librte_eal/linuxapp/kni/kni_misc.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c index ba77776..868b325 100644 --- a/lib/librte_eal/linuxapp/kni/kni_misc.c +++ b/lib/librte_eal/linuxapp/kni/kni_misc.c @@ -311,6 +311,7 @@ kni_ioctl_create(unsigned int ioctl_num, unsigned long ioctl_param) struct net_device *net_dev = NULL; struct net_device *lad_dev = NULL; struct kni_dev *kni, *dev, *n; + struct net *net; printk(KERN_INFO "KNI: Creating kni...\n"); /* Check the buffer size, to avoid warning */ @@ -354,6 +355,14 @@ kni_ioctl_create(unsigned int ioctl_num, unsigned long ioctl_param) return -EBUSY; } + net = get_net_ns_by_pid(current->pid); + if (IS_ERR(net)) { + free_netdev(net_dev); + return PTR_ERR(net); + } + dev_net_set(net_dev, net); + put_net(net); + kni = netdev_priv(net_dev); kni->net_dev = net_dev; -- 2.1.3