kni: Passing task_pid_vnr(current) to get_net_ns_by_pid() in kni_ioctl_create()
PATCH 1/1 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.
--- lib/librte_eal/linuxapp/kni/kni_misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/linuxapp/kni/kni_misc.c +1 -1
@@ -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);
Signature · 1 line
1.8.3.1
Quoted 26 lines
-----Original Message-----
From: Wenfeng Liu [mailto:[email protected]]
Sent: Monday, June 15, 2015 12:08 PM
To: Zhang, Helin; [email protected]
Subject: [PATCH] kni: Passingtask_pid_vnr(current)toget_net_ns_by_pid()inkni_ioctl_create()In containers like docker,
current->pidreturns current process's global PID instead of its own PID under containers's PID namespace, andget_net_ns_by_pid()suppose to accept a virtual PID under its own namespace, so we should usetask_pid_vnr(current)to get current process's virtual PID instead ofcurrent->pid.Signed-off-by Wenfeng Liu <[email protected]>--- lib/librte_eal/linuxapp/kni/kni_misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/librte_eal/linuxapp/kni/kni_misc.c +0
-0
lib/librte_eal/linuxapp/kni/kni_misc.c kni_ioctl_create(unsigned int ioctl_num, unsigned long · line 363
Quoted 6 lines
lib/librte_eal/linuxapp/kni/kni_misc.c +1
-1@@ -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
Quoted 5 lines
lib/librte_eal/linuxapp/kni/kni_misc.c +0
-0if (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:[email protected]]
发送时间: 2015年6月17日 11:59
收件人: Wenfeng Liu
抄送: [email protected]
主题: RE: [PATCH] kni: Passing task_pid_vnr(current) to get_net_ns_by_pid() in kni_ioctl_create()
Quoted 28 lines
-----Original Message-----
From: Wenfeng Liu [mailto:[email protected]]
Sent: Monday, June 15, 2015 12:08 PM
To: Zhang, Helin; [email protected]
Subject: [PATCH] kni: Passingtask_pid_vnr(current)toget_net_ns_by_pid()inkni_ioctl_create()In containers like docker,
current->pidreturns current process's global PID instead of its own PID under containers's PID namespace, andget_net_ns_by_pid()suppose to accept a virtual PID under its own namespace, so we should usetask_pid_vnr(current)to get current process's virtual PID instead ofcurrent->pid.Signed-off-by Wenfeng Liu <[email protected]>--- lib/librte_eal/linuxapp/kni/kni_misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/librte_eal/linuxapp/kni/kni_misc.c +0
-0@@ -359,7 +359,7 @@ kni_ioctl_create(unsigned int ioctl_num, unsignedlong
ioctl_param)
lib/librte_eal/linuxapp/kni/kni_misc.c kni_ioctl_create(unsigned int ioctl_num, unsigned long ioctl_param) · line 362
Quoted 5 lines
lib/librte_eal/linuxapp/kni/kni_misc.c +1
-1return -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
Quoted 5 lines
lib/librte_eal/linuxapp/kni/kni_misc.c +0
-1if (IS_ERR (net)) {free_netdev (net_dev);return PTR_ERR (net); --1.8.3.1
Quoted 10 lines
-----Original Message-----
From: Wenfeng Liu [mailto:[email protected]]
Sent: Wednesday, June 17, 2015 1:44 PM
To: Zhang, Helin
Cc: [email protected]
Subject: 答复: [PATCH] kni: Passingtask_pid_vnr(current)toget_net_ns_by_pid()inkni_ioctl_create()
Quoted 5 lines
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
Quoted 56 lines
Thanks,
liuwf-----邮件原件-----
发件人: Zhang, Helin [mailto:[email protected]]
发送时间: 2015年6月17日 11:59
收件人: Wenfeng Liu
抄送: [email protected]
主题: RE: [PATCH] kni: Passingtask_pid_vnr(current)toget_net_ns_by_pid()inkni_ioctl_create()Quoted 28 lines
-----Original Message-----
From: Wenfeng Liu [mailto:[email protected]]
Sent: Monday, June 15, 2015 12:08 PM
To: Zhang, Helin; [email protected]
Subject: [PATCH] kni: Passingtask_pid_vnr(current)toget_net_ns_by_pid()inkni_ioctl_create()In containers like docker,
current->pidreturns current process's global PID instead of its own PID under containers's PID namespace, andget_net_ns_by_pid()suppose to accept a virtual PID under its own namespace, so we should usetask_pid_vnr(current)to get current process's virtual PID instead ofcurrent->pid.Signed-off-by Wenfeng Liu <[email protected]>--- lib/librte_eal/linuxapp/kni/kni_misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/librte_eal/linuxapp/kni/kni_misc.c +0
-0@@ -359,7 +359,7 @@ kni_ioctl_create(unsigned int ioctl_num, unsignedlong
ioctl_param)lib/librte_eal/linuxapp/kni/kni_misc.c kni_ioctl_create(unsigned int ioctl_num, unsigned long ioctl_param) · line 362
Quoted 5 lines
lib/librte_eal/linuxapp/kni/kni_misc.c +1
-1return -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
Quoted 5 lines
lib/librte_eal/linuxapp/kni/kni_misc.c +0
-1if (IS_ERR (net)) {free_netdev (net_dev);return PTR_ERR (net); --1.8.3.1
Quoted 9 lines
-----Original Message-----
From: Wenfeng Liu [mailto:[email protected]]
Sent: Monday, June 15, 2015 12:08 PM
To: Zhang, Helin; [email protected]
Subject: [PATCH] kni: Passingtask_pid_vnr(current)toget_net_ns_by_pid()inkni_ioctl_create()
Quoted 7 lines
In containers like docker,
current->pidreturns current process's global PID instead of its own PID under containers's PID namespace, andget_net_ns_by_pid()suppose to accept a virtual PID under its own namespace, so we should usetask_pid_vnr(current)to get current process's virtual PID instead ofcurrent->pid.Signed-off-by Wenfeng Liu <[email protected]>
Thomas Monjalon
AppliedQuoted 8 lines
Quoted 7 lines
In containers like docker,
current->pidreturns current process's global PID instead of its own PID under containers's PID namespace, andget_net_ns_by_pid()suppose to accept a virtual PID under its own namespace, so we should usetask_pid_vnr(current)to get current process's virtual PID instead ofcurrent->pid.Signed-off-by Wenfeng Liu <[email protected]>Acked-by Helin Zhang <[email protected]>
Applied, thanks