[dpdk-dev] kni: Passing task_pid_vnr(current) to get_net_ns_by_pid() in kni_ioctl_create()
Message ID | 1434341253-3227-1-git-send-email-liuwf@arraynetworks.com.cn (mailing list archive) |
---|---|
State | Accepted, 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 175985A65; Mon, 15 Jun 2015 06:08:19 +0200 (CEST) Received: from mail01.arraynetworks.com.cn (mail.arraynetworks.com.cn [124.42.99.121]) by dpdk.org (Postfix) with ESMTP id 8A75C106B for <dev@dpdk.org>; Mon, 15 Jun 2015 06:08:17 +0200 (CEST) Received: from AN.ustack.array (10.8.3.129) by mail01.arraynetworks.com.cn (10.3.0.251) with Microsoft SMTP Server id 14.3.123.3; Mon, 15 Jun 2015 12:08:13 +0800 From: Wenfeng Liu <liuwf@arraynetworks.com.cn> To: <helin.zhang@intel.com>, <dev@dpdk.org> Date: Mon, 15 Jun 2015 00:07:33 -0400 Message-ID: <1434341253-3227-1-git-send-email-liuwf@arraynetworks.com.cn> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.8.3.129] Subject: [dpdk-dev] [PATCH] kni: Passing task_pid_vnr(current) to get_net_ns_by_pid() in kni_ioctl_create() 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
Wenfeng Liu
June 15, 2015, 4:07 a.m. UTC
In containers like docker, current->pid returns current process's global PID instead of its
own PID under containers's PID namespace, and get_net_ns_by_pid() suppose to accept a virtual
PID under its own namespace, so we should use task_pid_vnr(current) to get current process's
virtual PID instead of current->pid.
Signed-off-by: Wenfeng Liu <liuwf@arraynetworks.com.cn>
---
lib/librte_eal/linuxapp/kni/kni_misc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
> -----Original Message----- > From: Wenfeng Liu [mailto:liuwf@arraynetworks.com.cn] > Sent: Monday, June 15, 2015 12:08 PM > To: Zhang, Helin; dev@dpdk.org > Subject: [PATCH] kni: Passing task_pid_vnr(current) to get_net_ns_by_pid() in > kni_ioctl_create() > > In containers like docker, current->pid returns current process's global PID > instead of its own PID under containers's PID namespace, and > get_net_ns_by_pid() suppose to accept a virtual PID under its own namespace, > so we should use task_pid_vnr(current) to get current process's virtual PID > instead of current->pid. > > Signed-off-by: Wenfeng Liu <liuwf@arraynetworks.com.cn> > --- > lib/librte_eal/linuxapp/kni/kni_misc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c > b/lib/librte_eal/linuxapp/kni/kni_misc.c > index 1935d32..18fb677 100644 > --- a/lib/librte_eal/linuxapp/kni/kni_misc.c > +++ b/lib/librte_eal/linuxapp/kni/kni_misc.c > @@ -359,7 +359,7 @@ kni_ioctl_create(unsigned int ioctl_num, unsigned long > ioctl_param) > return -EBUSY; > } > > - net = get_net_ns_by_pid(current->pid); > + net = get_net_ns_by_pid(task_pid_vnr(current)); Have you tried it on a very old kernel versions? E.g. 2.6.33 Helin > if (IS_ERR(net)) { > free_netdev(net_dev); > return PTR_ERR(net); > -- > 1.8.3.1
Hi Helin, Since I don’t have any 2.6.33 machine on hand right now, I tried to compile this patch on 2.6.32, and it succeed. I can't verify this modification in docker since it only support Linux kernel >= 3.10. Thanks, liuwf -----邮件原件----- 发件人: Zhang, Helin [mailto:helin.zhang@intel.com] 发送时间: 2015年6月17日 11:59 收件人: Wenfeng Liu 抄送: dev@dpdk.org 主题: RE: [PATCH] kni: Passing task_pid_vnr(current) to get_net_ns_by_pid() in kni_ioctl_create() > -----Original Message----- > From: Wenfeng Liu [mailto:liuwf@arraynetworks.com.cn] > Sent: Monday, June 15, 2015 12:08 PM > To: Zhang, Helin; dev@dpdk.org > Subject: [PATCH] kni: Passing task_pid_vnr(current) to > get_net_ns_by_pid() in > kni_ioctl_create() > > In containers like docker, current->pid returns current process's > global PID instead of its own PID under containers's PID namespace, > and > get_net_ns_by_pid() suppose to accept a virtual PID under its own > namespace, so we should use task_pid_vnr(current) to get current > process's virtual PID instead of current->pid. > > Signed-off-by: Wenfeng Liu <liuwf@arraynetworks.com.cn> > --- > lib/librte_eal/linuxapp/kni/kni_misc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c > b/lib/librte_eal/linuxapp/kni/kni_misc.c > index 1935d32..18fb677 100644 > --- a/lib/librte_eal/linuxapp/kni/kni_misc.c > +++ b/lib/librte_eal/linuxapp/kni/kni_misc.c > @@ -359,7 +359,7 @@ kni_ioctl_create(unsigned int ioctl_num, unsigned > long > ioctl_param) > return -EBUSY; > } > > - net = get_net_ns_by_pid(current->pid); > + net = get_net_ns_by_pid(task_pid_vnr(current)); Have you tried it on a very old kernel versions? E.g. 2.6.33 Helin > if (IS_ERR(net)) { > free_netdev(net_dev); > return PTR_ERR(net); > -- > 1.8.3.1
> -----Original Message----- > From: Wenfeng Liu [mailto:liuwf@arraynetworks.com.cn] > Sent: Wednesday, June 17, 2015 1:44 PM > To: Zhang, Helin > Cc: dev@dpdk.org > Subject: 答复: [PATCH] kni: Passing task_pid_vnr(current) to > get_net_ns_by_pid() in kni_ioctl_create() > > Hi Helin, > > Since I don’t have any 2.6.33 machine on hand right now, I tried to compile this > patch on 2.6.32, and it succeed. > I can't verify this modification in docker since it only support Linux kernel >= 3.10. OK, I think it should be enough. Thanks! - Helin > > Thanks, > liuwf > > -----邮件原件----- > 发件人: Zhang, Helin [mailto:helin.zhang@intel.com] > 发送时间: 2015年6月17日 11:59 > 收件人: Wenfeng Liu > 抄送: dev@dpdk.org > 主题: RE: [PATCH] kni: Passing task_pid_vnr(current) to get_net_ns_by_pid() in > kni_ioctl_create() > > > > > -----Original Message----- > > From: Wenfeng Liu [mailto:liuwf@arraynetworks.com.cn] > > Sent: Monday, June 15, 2015 12:08 PM > > To: Zhang, Helin; dev@dpdk.org > > Subject: [PATCH] kni: Passing task_pid_vnr(current) to > > get_net_ns_by_pid() in > > kni_ioctl_create() > > > > In containers like docker, current->pid returns current process's > > global PID instead of its own PID under containers's PID namespace, > > and > > get_net_ns_by_pid() suppose to accept a virtual PID under its own > > namespace, so we should use task_pid_vnr(current) to get current > > process's virtual PID instead of current->pid. > > > > Signed-off-by: Wenfeng Liu <liuwf@arraynetworks.com.cn> > > --- > > lib/librte_eal/linuxapp/kni/kni_misc.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c > > b/lib/librte_eal/linuxapp/kni/kni_misc.c > > index 1935d32..18fb677 100644 > > --- a/lib/librte_eal/linuxapp/kni/kni_misc.c > > +++ b/lib/librte_eal/linuxapp/kni/kni_misc.c > > @@ -359,7 +359,7 @@ kni_ioctl_create(unsigned int ioctl_num, unsigned > > long > > ioctl_param) > > return -EBUSY; > > } > > > > - net = get_net_ns_by_pid(current->pid); > > + net = get_net_ns_by_pid(task_pid_vnr(current)); > Have you tried it on a very old kernel versions? E.g. 2.6.33 > > Helin > > > if (IS_ERR(net)) { > > free_netdev(net_dev); > > return PTR_ERR(net); > > -- > > 1.8.3.1
> -----Original Message----- > From: Wenfeng Liu [mailto:liuwf@arraynetworks.com.cn] > Sent: Monday, June 15, 2015 12:08 PM > To: Zhang, Helin; dev@dpdk.org > Subject: [PATCH] kni: Passing task_pid_vnr(current) to get_net_ns_by_pid() in > kni_ioctl_create() > > In containers like docker, current->pid returns current process's global PID > instead of its own PID under containers's PID namespace, and > get_net_ns_by_pid() suppose to accept a virtual PID under its own namespace, > so we should use task_pid_vnr(current) to get current process's virtual PID > instead of current->pid. > > Signed-off-by: Wenfeng Liu <liuwf@arraynetworks.com.cn> Acked-by: Helin Zhang <helin.zhang@intel.com>
> > In containers like docker, current->pid returns current process's global PID > > instead of its own PID under containers's PID namespace, and > > get_net_ns_by_pid() suppose to accept a virtual PID under its own namespace, > > so we should use task_pid_vnr(current) to get current process's virtual PID > > instead of current->pid. > > > > Signed-off-by: Wenfeng Liu <liuwf@arraynetworks.com.cn> > Acked-by: Helin Zhang <helin.zhang@intel.com> Applied, thanks
diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c index 1935d32..18fb677 100644 --- a/lib/librte_eal/linuxapp/kni/kni_misc.c +++ b/lib/librte_eal/linuxapp/kni/kni_misc.c @@ -359,7 +359,7 @@ kni_ioctl_create(unsigned int ioctl_num, unsigned long ioctl_param) return -EBUSY; } - net = get_net_ns_by_pid(current->pid); + net = get_net_ns_by_pid(task_pid_vnr(current)); if (IS_ERR(net)) { free_netdev(net_dev); return PTR_ERR(net);