containers/netns/netns_sysfs.sh:load dummy module before collecting sysfs interface
PATCH 1/1 containers/netns/netns_sysfs.sh:load dummy module before collecting sysfs interface
From: Shuang Qiu <[email protected]>
If dummy is compiled as module in kernel,it is loaded dynamically when adding dummy device.And it will also create a default dummy interface.So the sysfs_after will have one more interface than sysfs_before which makes testcase #3 failed.Loading dummy module before collecting sysfs interface to workaround such issue.
--- testcases/kernel/containers/netns/netns_sysfs.sh | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
testcases/kernel/containers/netns/netns_sysfs.sh +4 -0
@@ -47,6 +47,10 @@ if [ $? -eq 1 ]; then tst_brkm TBROK "unable to create a new network namespace" fi TST_CLEANUP=cleanup + +#Load dummy module before collecting sysfs interface +lsmod | grep dummy || modprobe dummy +[ $? -eq 0 ] || tst_brkm TBROK "failed to load dummy module" ls /sys/class/net >sysfs_before ns_exec $NS_HANDLE $NS_TYPE mount --make-rprivate /sys
Signature · 1 line
1.7.7
PATCH 1/1 containers/netns/netns_sysfs.sh:load dummy module before collecting sysfs interface
Hi!
testcases/kernel/containers/netns/netns_sysfs.sh if [ $? -eq 1 ]; then · line 53
Quoted 12 lines
testcases/kernel/containers/netns/netns_sysfs.sh +4
-0@@ -47,6 +47,10 @@ if [ $? -eq 1 ]; then tst_brkm TBROK "unable to create a new network namespace" fi TST_CLEANUP=cleanup + +#Load dummy module before collecting sysfs interface +lsmod | grep dummy || modprobe dummy +[ $? -eq 0 ] || tst_brkm TBROK "failed to load dummy module"
But this will fail when dummy wasn't compiled in the kernel, right?
Since modprobe will exit with 1 when module couldn't be found. So we should either just call 'modprobe dummy' and ignore the return value or change the code to ignore the default dummy interface.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 containers/netns/netns_sysfs.sh:load dummy module before collecting sysfs interface
Hi Cyril,
Thanks for review.
Quoted 14 lines · Cyril Hrubis
Hi!
testcases/kernel/containers/netns/netns_sysfs.sh if [ $? -eq 1 ]; then · line 53
Quoted 12 lines
testcases/kernel/containers/netns/netns_sysfs.sh +4
-0@@ -47,6 +47,10 @@ if [ $? -eq 1 ]; then tst_brkm TBROK "unable to create a new network namespace" fi TST_CLEANUP=cleanup + +#Load dummy module before collecting sysfs interface +lsmod | grep dummy || modprobe dummy +[ $? -eq 0 ] || tst_brkm TBROK "failed to load dummy module"But this will fail when dummy wasn't compiled in the kernel, right?
Yes,if dummy wasn't compiled in the kernel,it will also fail when adding dummy device in the next step:
===cut===ns_exec $NS_HANDLE $NS_TYPE ip link add $DUMMYDEV type dummy || \
tst_brkm TBROK "failed to add a new dummy device"
===cut===
Quoted 4 lines
Since modprobe will exit with 1 when module couldn't be found. So we should either just call 'modprobe dummy' and ignore the return value or change the code to ignore the default dummy interface.
I prefer 'modprobe dummy' and ignore the return value,because I'm not sure whether there is any other default dummy interface name except "dummy0".
Thanks
Shuang
Quoted 1 line
PATCH 1/1 containers/netns/netns_sysfs.sh:load dummy module before collecting sysfs interface
Hi!
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
testcases/kernel/containers/netns/netns_sysfs.sh +0
-0@@ -47,6 +47,10 @@ if [ $? -eq 1 ]; thenQuoted 8 lines
testcases/kernel/containers/netns/netns_sysfs.sh if [ $? -eq 1 ]; then · line 53
Quoted 7 lines
testcases/kernel/containers/netns/netns_sysfs.sh +4
-0tst_brkm TBROK "unable to create a new network namespace" fi TST_CLEANUP=cleanup + +#Load dummy module before collecting sysfs interface +lsmod | grep dummy || modprobe dummy +[ $? -eq 0 ] || tst_brkm TBROK "failed to load dummy module"But this will fail when dummy wasn't compiled in the kernel, right?
Quoted 6 lines
Yes,if dummy wasn't compiled in the kernel,it will also fail when adding dummy device in the next step:
===cut===ns_exec$NS_HANDLE $NS_TYPE ip link add $DUMMYDEV type dummy || \
tst_brkmTBROK "failed to add a new dummy device"
===cut===
I meaned "wasn't compiled as module" i.e. compiled in kernel, sorry for the confusion. In that case this would work fine but the modprobe would fail.
Quoted 6 lines
Quoted 3 lines
Since modprobe will exit with 1 when module couldn't be found. So we should either just call 'modprobe dummy' and ignore the return value or change the code to ignore the default dummy interface.
I prefer 'modprobe dummy' and ignore the return value,because I'm not sure whether there is any other default dummy interface name except "dummy0".
Sounds good to me.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 containers/netns/netns_sysfs.sh:load dummy module before collecting sysfs interface
Quoted 20 lines · Cyril Hrubis
Hi!
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
testcases/kernel/containers/netns/netns_sysfs.sh +0
-0@@ -47,6 +47,10 @@ if [ $? -eq 1 ]; thenQuoted 8 lines
testcases/kernel/containers/netns/netns_sysfs.sh if [ $? -eq 1 ]; then · line 53
Quoted 7 lines
testcases/kernel/containers/netns/netns_sysfs.sh +4
-0tst_brkm TBROK "unable to create a new network namespace" fi TST_CLEANUP=cleanup + +#Load dummy module before collecting sysfs interface +lsmod | grep dummy || modprobe dummy +[ $? -eq 0 ] || tst_brkm TBROK "failed to load dummy module"But this will fail when dummy wasn't compiled in the kernel, right?
Quoted 6 lines
Yes,if dummy wasn't compiled in the kernel,it will also fail when adding dummy device in the next step:
===cut===ns_exec$NS_HANDLE $NS_TYPE ip link add $DUMMYDEV type dummy || \
tst_brkmTBROK "failed to add a new dummy device"
===cut===
Quoted 3 lines
I meaned "wasn't compiled as module" i.e. compiled in kernel, sorry for the confusion. In that case this would work fine but the modprobe would fail.
Aha,yes,thanks for clarification.
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
Since modprobe will exit with 1 when module couldn't be found. So we should either just call 'modprobe dummy' and ignore the return value or change the code to ignore the default dummy interface.
I prefer 'modprobe dummy' and ignore the return value,because I'm not sure whether there is any other default dummy interface name except "dummy0".
Sounds good to me.
ok,I will submit another patch.
Thanks
Shuang
Quoted 1 line
PATCH 1/1 containers/netns/netns_sysfs.sh:load dummy module before collecting sysfs interface
In reply to [email protected]Quoted 7 lines · On 10/30/2015 09:57 AM, [email protected] wrote:
From: Shuang Qiu <[email protected]>
If dummy is compiled as module in kernel,it is loaded dynamically when adding dummy device.And it will also create a default dummy interface.So the
sysfs_afterwill have one more interface thansysfs_beforewhich makes testcase #3 failed.Loading dummy module before collecting sysfs interface to workaround such issue.
I cannot reproduce this on any RHEL or Fedora system, but I can reproduce it on Debian (Jessie). If we accounted only for the module version of 'dummy', it could be countered by adding
options dummy numdummies=0
to any /etc/modprobe.d/* config (temporarily), however for the built-in version of the module, such option would need to be passed via kernel cmdline.
We could check [ -d /sys/module/dummy ] and if it exists, presume that no extra setup is necessary, because
1) if it's a module, our creation of additional dummy interface won't affect existing interfaces as dummy0 is created only on insmod (dummy_init_one() is called during __init with numdummies=1)
2) if it's built in, well .. see (1)
otherwise we can try modprobing it and if it fails, end with CONF.
However - wouldn't it be simply easier to add an exception for dummy0 during the comparison check? The test operates with iface names other than dummy0, so a possible namespace bug would be found anyway. (See attached diff.)
However the (quite possibly) best solution would be a one which cleans up after itself, so maybe the [ -d /sys/module/dummy ] solution with explicit modprobe / modprobe -r would work better.
Your choice. :)
Jiri
Quoted 11 lines
Signed-off-by Shuang Qiu <[email protected]>--- testcases/kernel/containers/netns/netns_sysfs.sh | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)testcases/kernel/containers/netns/netns_sysfs.sh +0
-0
testcases/kernel/containers/netns/netns_sysfs.sh if [ $? -eq 1 ]; then · line 56
Quoted 10 lines
testcases/kernel/containers/netns/netns_sysfs.sh +4
-0@@ -47,6 +47,10 @@ if [ $? -eq 1 ]; then tst_brkm TBROK "unable to create a new network namespace" fi TST_CLEANUP=cleanup + +#Load dummy module before collecting sysfs interface +lsmod | grep dummy || modprobe dummy +[ $? -eq 0 ] || tst_brkm TBROK "failed to load dummy module" ls /sys/class/net >sysfs_before ns_exec $NS_HANDLE $NS_TYPE mount --make-rprivate /sys
-------------- next part --------------
testcases/kernel/containers/netns/netns_sysfs.sh +5 -2
@@ -47,7 +47,10 @@ if [ $? -eq 1 ]; then tst_brkm TBROK "unable to create a new network namespace" fi TST_CLEANUP=cleanup -ls /sys/class/net >sysfs_before + +# exclude dummy0 from comparison as it gets automatically created by the +# dummy device driver upon insmod/modprobe (during ip link add) +ls /sys/class/net | grep -v dummy0 >sysfs_before ns_exec $NS_HANDLE $NS_TYPE mount --make-rprivate /sys ns_exec $NS_HANDLE $NS_TYPE ip link add $DUMMYDEV type dummy || \
@@ -84,7 +87,7 @@ fi # TEST CASE #3 -ls /sys/class/net >sysfs_after +ls /sys/class/net | grep -v dummy0 >sysfs_after diff sysfs_before sysfs_after if [ $? -eq 0 ]; then tst_resm TPASS "sysfs not affected by a separate namespace"
PATCH 1/1 containers/netns/netns_sysfs.sh:load dummy module before collecting sysfs interface
Hi!
Quoted 8 lines
However - wouldn't it be simply easier to add an exception for dummy0 during the comparison check? The test operates with iface names other than dummy0, so a possible namespace bug would be found anyway. (See attached diff.)
However the (quite possibly) best solution would be a one which cleans up after itself, so maybe the [ -d
/sys/module/dummy] solution with explicit modprobe / modprobe -r would work better.
Either one works for me.
testcases/kernel/containers/netns/netns_sysfs.sh if [ $? -eq 1 ]; then · line 53
Quoted 13 lines
testcases/kernel/containers/netns/netns_sysfs.sh +4
-1@@ -47,7 +47,10 @@ if [ $? -eq 1 ]; then tst_brkm TBROK "unable to create a new network namespace" fi TST_CLEANUP=cleanup -ls /sys/class/net >sysfs_before + +# exclude dummy0 from comparison as it gets automatically created by the +# dummy device driver upon insmod/modprobe (during ip link add) +ls /sys/class/net | grep -v dummy0 >sysfs_before
Maybe we should do grep -v dummy[0-9].* in order to skipp all dummy interfaces if someone changes the number of interfaces created. If we decide to go this way.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 containers/netns/netns_sysfs.sh:load dummy module before collecting sysfs interface
Quoted 11 lines · Cyril Hrubis
Hi!
Quoted 8 lines
However - wouldn't it be simply easier to add an exception for dummy0 during the comparison check? The test operates with iface names other than dummy0, so a possible namespace bug would be found anyway. (See attached diff.)
However the (quite possibly) best solution would be a one which cleans up after itself, so maybe the [ -d
/sys/module/dummy] solution with explicit modprobe / modprobe -r would work better.Either one works for me.
I would send a patch with the more "clean" solution, but I'm not sure how to modularize the cleanup function here as I need to add modprobe -r only if the modprobe was previously done.
Furthermore, doing it that way would make the test impossible to run multiple times in parallel.
So it boils down to either doing a preemptive modprobe 2>/dev/null or ignoring dummy[0-9]+, it's up to you. :)
Quoted 10 lines
Quoted 10 lines
testcases/kernel/containers/netns/netns_sysfs.sh +0
-1@@ -47,7 +47,10 @@ if [ $? -eq 1 ]; then tst_brkm TBROK "unable to create a new network namespace" fi TST_CLEANUP=cleanup -ls /sys/class/net >sysfs_before
Quoted 9 lines
testcases/kernel/containers/netns/netns_sysfs.sh if [ $? -eq 1 ]; then · line 53
Quoted 4 lines
testcases/kernel/containers/netns/netns_sysfs.sh +4
-0+ +# exclude dummy0 from comparison as it gets automatically created by the +# dummy device driver upon insmod/modprobe (during ip link add) +ls /sys/class/net | grep -v dummy0 >sysfs_beforeMaybe we should do grep -v dummy[0-9].* in order to skipp all dummy interfaces if someone changes the number of interfaces created. If we decide to go this way.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-containers-netns-exclude-dummy0-from-before-after-co.patch
Type: text/x-patch
Size: 1338 bytes
Desc: not available
URL: <http://lists.linux.it/pipermail/ltp/attachments/20151109/7f8a8c7c/attachment-0001.bin>
PATCH 1/1 containers/netns/netns_sysfs.sh:load dummy module before collecting sysfs interface
Hi!
Quoted 2 lines
So it boils down to either doing a preemptive modprobe 2>/dev/null or ignoring dummy[0-9]+, it's up to you. :)
I don't really care :), both are valid solutions. Maybe we should flip a coin and decide.
Well since you attached a patch to this email allready I will spare us from doubt and simply apply it, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 containers/netns/netns_sysfs.sh:load dummy module before collecting sysfs interface
In reply to Jiri JaburekHi Jiri,
Quoted 26 lines · Jiri Jaburek
Quoted 7 lines · On 10/30/2015 09:57 AM, [email protected] wrote:
From: Shuang Qiu <[email protected]>
If dummy is compiled as module in kernel,it is loaded dynamically when adding dummy device.And it will also create a default dummy interface.So the
sysfs_afterwill have one more interface thansysfs_beforewhich makes testcase #3 failed.Loading dummy module before collecting sysfs interface to workaround such issue.I cannot reproduce this on any RHEL or Fedora system, but I can reproduce it on Debian (Jessie). If we accounted only for the module version of 'dummy', it could be countered by adding
options dummy numdummies=0
to any
/etc/modprobe.d/*config (temporarily), however for the built-in version of the module, such option would need to be passed via kernel cmdline.We could check [ -d
/sys/module/dummy] and if it exists, presume that no extra setup is necessary, because1) if it's a module, our creation of additional dummy interface won't affect existing interfaces as dummy0 is created only on insmod (
dummy_init_one()is called during__initwith numdummies=1)
2) if it's built in, well .. see (1)
Quoted 6 lines
otherwise we can try modprobing it and if it fails, end with CONF.
However - wouldn't it be simply easier to add an exception for dummy0 during the comparison check? The test operates with iface names other than dummy0, so a possible namespace bug would be found anyway. (See attached diff.)
I did not learn dummy module much before and not sure if there is a specify iface name.
As you explained,we will have a expect name and may find a namespace bug,so I also prefer your way.
Thanks
Shuang
Quoted 30 lines
However the (quite possibly) best solution would be a one which cleans up after itself, so maybe the [ -d
/sys/module/dummy] solution with explicit modprobe / modprobe -r would work better.Your choice. :)
Jiri
Quoted 21 lines
Signed-off-by Shuang Qiu <[email protected]>--- testcases/kernel/containers/netns/netns_sysfs.sh | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)testcases/kernel/containers/netns/netns_sysfs.sh +4
-0@@ -47,6 +47,10 @@ if [ $? -eq 1 ]; then tst_brkm TBROK "unable to create a new network namespace" fi TST_CLEANUP=cleanup + +#Load dummy module before collecting sysfs interface +lsmod | grep dummy || modprobe dummy +[ $? -eq 0 ] || tst_brkm TBROK "failed to load dummy module" ls /sys/class/net >sysfs_before ns_exec $NS_HANDLE $NS_TYPE mount --make-rprivate /sys