* [LTP] [PATCH] containers/netns/netns_sysfs.sh:load dummy module before collecting sysfs interface @ 2015-10-30 8:57 shuang.qiu 2015-11-04 12:49 ` Cyril Hrubis 2015-11-06 17:16 ` Jiri Jaburek 0 siblings, 2 replies; 10+ messages in thread From: shuang.qiu @ 2015-10-30 8:57 UTC (permalink / raw) To: ltp From: Shuang Qiu <shuang.qiu@oracle.com> 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. Signed-off-by: Shuang Qiu <shuang.qiu@oracle.com> --- testcases/kernel/containers/netns/netns_sysfs.sh | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/testcases/kernel/containers/netns/netns_sysfs.sh b/testcases/kernel/containers/netns/netns_sysfs.sh index 7dea52b..b5791bd 100755 --- a/testcases/kernel/containers/netns/netns_sysfs.sh +++ b/testcases/kernel/containers/netns/netns_sysfs.sh @@ -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 -- 1.7.7 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [LTP] [PATCH] containers/netns/netns_sysfs.sh:load dummy module before collecting sysfs interface 2015-10-30 8:57 [LTP] [PATCH] containers/netns/netns_sysfs.sh:load dummy module before collecting sysfs interface shuang.qiu @ 2015-11-04 12:49 ` Cyril Hrubis 2015-11-05 4:46 ` Shuang Qiu 2015-11-06 17:16 ` Jiri Jaburek 1 sibling, 1 reply; 10+ messages in thread From: Cyril Hrubis @ 2015-11-04 12:49 UTC (permalink / raw) To: ltp Hi! > diff --git a/testcases/kernel/containers/netns/netns_sysfs.sh b/testcases/kernel/containers/netns/netns_sysfs.sh > index 7dea52b..b5791bd 100755 > --- a/testcases/kernel/containers/netns/netns_sysfs.sh > +++ b/testcases/kernel/containers/netns/netns_sysfs.sh > @@ -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. -- Cyril Hrubis chrubis@suse.cz ^ permalink raw reply [flat|nested] 10+ messages in thread
* [LTP] [PATCH] containers/netns/netns_sysfs.sh:load dummy module before collecting sysfs interface 2015-11-04 12:49 ` Cyril Hrubis @ 2015-11-05 4:46 ` Shuang Qiu 2015-11-05 14:05 ` Cyril Hrubis 0 siblings, 1 reply; 10+ messages in thread From: Shuang Qiu @ 2015-11-05 4:46 UTC (permalink / raw) To: ltp Hi Cyril, Thanks for review. On 11/04/2015 08:49 PM, Cyril Hrubis wrote: > Hi! >> diff --git a/testcases/kernel/containers/netns/netns_sysfs.sh b/testcases/kernel/containers/netns/netns_sysfs.sh >> index 7dea52b..b5791bd 100755 >> --- a/testcases/kernel/containers/netns/netns_sysfs.sh >> +++ b/testcases/kernel/containers/netns/netns_sysfs.sh >> @@ -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=== > > 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 > ^ permalink raw reply [flat|nested] 10+ messages in thread
* [LTP] [PATCH] containers/netns/netns_sysfs.sh:load dummy module before collecting sysfs interface 2015-11-05 4:46 ` Shuang Qiu @ 2015-11-05 14:05 ` Cyril Hrubis 2015-11-06 10:28 ` Shuang Qiu 0 siblings, 1 reply; 10+ messages in thread From: Cyril Hrubis @ 2015-11-05 14:05 UTC (permalink / raw) To: ltp Hi! > >> diff --git a/testcases/kernel/containers/netns/netns_sysfs.sh b/testcases/kernel/containers/netns/netns_sysfs.sh > >> index 7dea52b..b5791bd 100755 > >> --- a/testcases/kernel/containers/netns/netns_sysfs.sh > >> +++ b/testcases/kernel/containers/netns/netns_sysfs.sh > >> @@ -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=== 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. > > 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. -- Cyril Hrubis chrubis@suse.cz ^ permalink raw reply [flat|nested] 10+ messages in thread
* [LTP] [PATCH] containers/netns/netns_sysfs.sh:load dummy module before collecting sysfs interface 2015-11-05 14:05 ` Cyril Hrubis @ 2015-11-06 10:28 ` Shuang Qiu 0 siblings, 0 replies; 10+ messages in thread From: Shuang Qiu @ 2015-11-06 10:28 UTC (permalink / raw) To: ltp On 11/05/2015 10:05 PM, Cyril Hrubis wrote: > Hi! >>>> diff --git a/testcases/kernel/containers/netns/netns_sysfs.sh b/testcases/kernel/containers/netns/netns_sysfs.sh >>>> index 7dea52b..b5791bd 100755 >>>> --- a/testcases/kernel/containers/netns/netns_sysfs.sh >>>> +++ b/testcases/kernel/containers/netns/netns_sysfs.sh >>>> @@ -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=== > 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. > >>> 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 > ^ permalink raw reply [flat|nested] 10+ messages in thread
* [LTP] [PATCH] containers/netns/netns_sysfs.sh:load dummy module before collecting sysfs interface 2015-10-30 8:57 [LTP] [PATCH] containers/netns/netns_sysfs.sh:load dummy module before collecting sysfs interface shuang.qiu 2015-11-04 12:49 ` Cyril Hrubis @ 2015-11-06 17:16 ` Jiri Jaburek 2015-11-09 14:14 ` Cyril Hrubis 2015-11-10 4:03 ` Shuang Qiu 1 sibling, 2 replies; 10+ messages in thread From: Jiri Jaburek @ 2015-11-06 17:16 UTC (permalink / raw) To: ltp On 10/30/2015 09:57 AM, shuang.qiu@oracle.com wrote: > From: Shuang Qiu <shuang.qiu@oracle.com> > > 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. 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 > Signed-off-by: Shuang Qiu <shuang.qiu@oracle.com> > --- > testcases/kernel/containers/netns/netns_sysfs.sh | 4 ++++ > 1 files changed, 4 insertions(+), 0 deletions(-) > > diff --git a/testcases/kernel/containers/netns/netns_sysfs.sh b/testcases/kernel/containers/netns/netns_sysfs.sh > index 7dea52b..b5791bd 100755 > --- a/testcases/kernel/containers/netns/netns_sysfs.sh > +++ b/testcases/kernel/containers/netns/netns_sysfs.sh > @@ -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 -------------- diff --git a/testcases/kernel/containers/netns/netns_sysfs.sh b/testcases/kernel/containers/netns/netns_sysfs.sh index 7dea52b..e725a50 100755 --- a/testcases/kernel/containers/netns/netns_sysfs.sh +++ b/testcases/kernel/containers/netns/netns_sysfs.sh @@ -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" ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [LTP] [PATCH] containers/netns/netns_sysfs.sh:load dummy module before collecting sysfs interface 2015-11-06 17:16 ` Jiri Jaburek @ 2015-11-09 14:14 ` Cyril Hrubis 2015-11-09 15:20 ` Jiri Jaburek 2015-11-10 4:03 ` Shuang Qiu 1 sibling, 1 reply; 10+ messages in thread From: Cyril Hrubis @ 2015-11-09 14:14 UTC (permalink / raw) To: ltp Hi! > 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. > diff --git a/testcases/kernel/containers/netns/netns_sysfs.sh b/testcases/kernel/containers/netns/netns_sysfs.sh > index 7dea52b..e725a50 100755 > --- a/testcases/kernel/containers/netns/netns_sysfs.sh > +++ b/testcases/kernel/containers/netns/netns_sysfs.sh > @@ -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. -- Cyril Hrubis chrubis@suse.cz ^ permalink raw reply [flat|nested] 10+ messages in thread
* [LTP] [PATCH] containers/netns/netns_sysfs.sh:load dummy module before collecting sysfs interface 2015-11-09 14:14 ` Cyril Hrubis @ 2015-11-09 15:20 ` Jiri Jaburek 2015-11-09 15:26 ` Cyril Hrubis 0 siblings, 1 reply; 10+ messages in thread From: Jiri Jaburek @ 2015-11-09 15:20 UTC (permalink / raw) To: ltp On 11/09/2015 03:14 PM, Cyril Hrubis wrote: > Hi! >> 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. :) > >> diff --git a/testcases/kernel/containers/netns/netns_sysfs.sh b/testcases/kernel/containers/netns/netns_sysfs.sh >> index 7dea52b..e725a50 100755 >> --- a/testcases/kernel/containers/netns/netns_sysfs.sh >> +++ b/testcases/kernel/containers/netns/netns_sysfs.sh >> @@ -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. > -------------- 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> ^ permalink raw reply [flat|nested] 10+ messages in thread
* [LTP] [PATCH] containers/netns/netns_sysfs.sh:load dummy module before collecting sysfs interface 2015-11-09 15:20 ` Jiri Jaburek @ 2015-11-09 15:26 ` Cyril Hrubis 0 siblings, 0 replies; 10+ messages in thread From: Cyril Hrubis @ 2015-11-09 15:26 UTC (permalink / raw) To: ltp Hi! > 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. -- Cyril Hrubis chrubis@suse.cz ^ permalink raw reply [flat|nested] 10+ messages in thread
* [LTP] [PATCH] containers/netns/netns_sysfs.sh:load dummy module before collecting sysfs interface 2015-11-06 17:16 ` Jiri Jaburek 2015-11-09 14:14 ` Cyril Hrubis @ 2015-11-10 4:03 ` Shuang Qiu 1 sibling, 0 replies; 10+ messages in thread From: Shuang Qiu @ 2015-11-10 4:03 UTC (permalink / raw) To: ltp Hi Jiri, On 11/07/2015 01:16 AM, Jiri Jaburek wrote: > On 10/30/2015 09:57 AM, shuang.qiu@oracle.com wrote: >> From: Shuang Qiu <shuang.qiu@oracle.com> >> >> 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. > 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.) 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 > > 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 > >> Signed-off-by: Shuang Qiu <shuang.qiu@oracle.com> >> --- >> testcases/kernel/containers/netns/netns_sysfs.sh | 4 ++++ >> 1 files changed, 4 insertions(+), 0 deletions(-) >> >> diff --git a/testcases/kernel/containers/netns/netns_sysfs.sh b/testcases/kernel/containers/netns/netns_sysfs.sh >> index 7dea52b..b5791bd 100755 >> --- a/testcases/kernel/containers/netns/netns_sysfs.sh >> +++ b/testcases/kernel/containers/netns/netns_sysfs.sh >> @@ -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 >> ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2015-11-10 4:03 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-10-30 8:57 [LTP] [PATCH] containers/netns/netns_sysfs.sh:load dummy module before collecting sysfs interface shuang.qiu 2015-11-04 12:49 ` Cyril Hrubis 2015-11-05 4:46 ` Shuang Qiu 2015-11-05 14:05 ` Cyril Hrubis 2015-11-06 10:28 ` Shuang Qiu 2015-11-06 17:16 ` Jiri Jaburek 2015-11-09 14:14 ` Cyril Hrubis 2015-11-09 15:20 ` Jiri Jaburek 2015-11-09 15:26 ` Cyril Hrubis 2015-11-10 4:03 ` Shuang Qiu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox