dev.dpdk.org archive mirror
 help / color / mirror / Atom feed
From: Nicolas Dichtel <nicolas.dichtel-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
To: Takayuki Usui <takayuki-SN072n759w5Wk0Htik3J/w@public.gmane.org>,
	dev-VfR2kkLFssw@public.gmane.org
Subject: Re: [PATCH v2] kni: create KNI interface in current network namespace
Date: Tue, 02 Dec 2014 10:04:30 +0100	[thread overview]
Message-ID: <547D809E.8020607@6wind.com> (raw)
In-Reply-To: <1417486763-12883-1-git-send-email-takayuki-SN072n759w5Wk0Htik3J/w@public.gmane.org>

Le 02/12/2014 03:19, 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.
>
> 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 <takayuki-SN072n759w5Wk0Htik3J/w@public.gmane.org>
> ---
>   lib/librte_eal/linuxapp/kni/kni_misc.c | 7 +++++++
>   1 file changed, 7 insertions(+)
>
> diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c
> index ba77776..33c7a48 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,12 @@ 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))
In case of error, you should call free_netdev(net_dev) to avoid a memory leak.

> +		return PTR_ERR(net);
> +	dev_net_set(net_dev, net);
> +	put_net(net);
> +
>   	kni = netdev_priv(net_dev);
>
>   	kni->net_dev = net_dev;
>

  parent reply	other threads:[~2014-12-02  9:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-21  3:10 [PATCH] kni: create KNI interface in current network namespace Takayuki Usui
     [not found] ` <1416539426-20684-1-git-send-email-takayuki-SN072n759w5Wk0Htik3J/w@public.gmane.org>
2014-11-26 21:26   ` Thomas Monjalon
2014-12-01  5:45     ` Hemant-KZfg59tc24xl57MIdRCFDg
     [not found]       ` <BY2PR0301MB0693EA8FA0BDAF0AE6B55F52C27D0-swgC6WJTr6E3qekZfdyv35wN6zqB+hSMnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2014-12-01 10:42         ` Nicolas Dichtel
2014-11-27  9:06   ` Nicolas Dichtel
     [not found]     ` <5476E97D.5040304-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2014-12-02  2:19       ` [PATCH v2] " Takayuki Usui
     [not found]         ` <1417486763-12883-1-git-send-email-takayuki-SN072n759w5Wk0Htik3J/w@public.gmane.org>
2014-12-02  9:04           ` Nicolas Dichtel [this message]
     [not found]             ` <547D809E.8020607-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2014-12-03  1:37               ` [PATCH v3] " Takayuki Usui
     [not found]                 ` <1417570646-7724-1-git-send-email-takayuki-SN072n759w5Wk0Htik3J/w@public.gmane.org>
2014-12-03 10:51                   ` Nicolas Dichtel
     [not found]                     ` <547EEB31.4070900-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2014-12-03 14:01                       ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=547D809E.8020607@6wind.com \
    --to=nicolas.dichtel-pdr9zngts4eavxtiumwx3w@public.gmane.org \
    --cc=dev-VfR2kkLFssw@public.gmane.org \
    --cc=takayuki-SN072n759w5Wk0Htik3J/w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).