[PATCH] selftests: test_vxlan_under_vrf: mute uncessary error message
The cleanup function in this script that tries to delete hv-1 / hv-2 vm-1 / vm-2 netns will generate some uncessary error messages: Cannot remove namespace file "/run/netns/hv-2": No such file or directory Cannot remove namespace file "/run/netns/vm-1": No such file or directory Cannot remove namespace file "/run/netns/vm-2": No such file or directory Redirect it to /dev/null like other commands in the cleanup function to reduce confusion. Signed-off-by: Po-Hsu Lin --- tools/testing/selftests/net/test_vxlan_under_vrf.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/test_vxlan_under_vrf.sh b/tools/testing/selftests/net/test_vxlan_under_vrf.sh index 09f9ed9..534c8b7 100755 --- a/tools/testing/selftests/net/test_vxlan_under_vrf.sh +++ b/tools/testing/selftests/net/test_vxlan_under_vrf.sh @@ -50,7 +50,7 @@ cleanup() { ip link del veth-tap 2>/dev/null || true for ns in hv-1 hv-2 vm-1 vm-2; do -ip netns del $ns || true +ip netns del $ns 2>/dev/null || true done } -- 2.7.4
[PATCHv2] selftests: test_vxlan_under_vrf: mute unnecessary error message
The cleanup function in this script that tries to delete hv-1 / hv-2 vm-1 / vm-2 netns will generate some uncessary error messages: Cannot remove namespace file "/run/netns/hv-2": No such file or directory Cannot remove namespace file "/run/netns/vm-1": No such file or directory Cannot remove namespace file "/run/netns/vm-2": No such file or directory Redirect it to /dev/null like other commands in the cleanup function to reduce confusion. Signed-off-by: Po-Hsu Lin --- tools/testing/selftests/net/test_vxlan_under_vrf.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/test_vxlan_under_vrf.sh b/tools/testing/selftests/net/test_vxlan_under_vrf.sh index 09f9ed9..534c8b7 100755 --- a/tools/testing/selftests/net/test_vxlan_under_vrf.sh +++ b/tools/testing/selftests/net/test_vxlan_under_vrf.sh @@ -50,7 +50,7 @@ cleanup() { ip link del veth-tap 2>/dev/null || true for ns in hv-1 hv-2 vm-1 vm-2; do -ip netns del $ns || true +ip netns del $ns 2>/dev/null || true done } -- 2.7.4
Re: [PATCH 2/2] selftests: pmtu.sh: improve the test result processing
On Tue, Nov 10, 2020 at 2:09 AM Jakub Kicinski wrote: > > On Mon, 9 Nov 2020 11:42:33 +0800 Po-Hsu Lin wrote: > > On Sun, Nov 8, 2020 at 7:02 AM Jakub Kicinski wrote: > > > > > > On Thu, 5 Nov 2020 18:50:51 +0800 Po-Hsu Lin wrote: > > > > This test will treat all non-zero return codes as failures, it will > > > > make the pmtu.sh test script being marked as FAILED when some > > > > sub-test got skipped. > > > > > > > > Improve the result processing by > > > > * Only mark the whole test script as SKIP when all of the > > > > sub-tests were skipped > > > > * If the sub-tests were either passed or skipped, the overall > > > > result will be PASS > > > > * If any of them has failed, the overall result will be FAIL > > > > * Treat other return codes (e.g. 127 for command not found) as FAIL > > > > > > > > Signed-off-by: Po-Hsu Lin > > > > > > Patch 1 looks like a cleanup while patch 2 is more of a fix, can we > > > separate the two and apply the former to -next and latter to 5.10? > > > They shouldn't conflict, right? > > > > > > > Hello Jakub, > > > > Yes the first patch is just changing return code to $ksft_skip, the > > real fix is the second one. However the second patch was based on the > > first one, if we want to apply them separately we might need to change > > this $ksft_skip handling part in the second patch. > > Ah, I misread the situation, ksft_skip is 4, not 2, so the patch is > more than just refactoring. > > > What should I do to deal with this? > > Resend the former for -next and rebase + resend the latter (plus the > > fix to remove case 1) for 5.10 without the former patch? > > Let's apply both of the patches to net-next if that's fine with you. > Indeed detangling them is may be more effort that it's worth. That would be great, but allow me to resend V2 to get rid of case 1 first. Thanks!
[PATCHv2 1/2] selftests: pmtu.sh: use $ksft_skip for skipped return code
This test uses return code 2 as a hard-coded skipped state, let's use the kselftest framework skip code variable $ksft_skip instead to make it more readable and easier to maintain. Signed-off-by: Po-Hsu Lin --- tools/testing/selftests/net/pmtu.sh | 64 ++--- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh index 6bbf69a..fb53987 100755 --- a/tools/testing/selftests/net/pmtu.sh +++ b/tools/testing/selftests/net/pmtu.sh @@ -355,7 +355,7 @@ setup_fou_or_gue() { encap="${3}" if [ "${outer}" = "4" ]; then - modprobe fou || return 2 + modprobe fou || return $ksft_skip a_addr="${prefix4}.${a_r1}.1" b_addr="${prefix4}.${b_r1}.1" if [ "${inner}" = "4" ]; then @@ -366,7 +366,7 @@ setup_fou_or_gue() { ipproto="41" fi else - modprobe fou6 || return 2 + modprobe fou6 || return $ksft_skip a_addr="${prefix6}:${a_r1}::1" b_addr="${prefix6}:${b_r1}::1" if [ "${inner}" = "4" ]; then @@ -380,8 +380,8 @@ setup_fou_or_gue() { fi fi - run_cmd ${ns_a} ip fou add port ipproto ${ipproto} || return 2 - run_cmd ${ns_a} ip link add ${encap}_a type ${type} ${mode} local ${a_addr} remote ${b_addr} encap ${encap} encap-sport auto encap-dport 5556 || return 2 + run_cmd ${ns_a} ip fou add port ipproto ${ipproto} || return $ksft_skip + run_cmd ${ns_a} ip link add ${encap}_a type ${type} ${mode} local ${a_addr} remote ${b_addr} encap ${encap} encap-sport auto encap-dport 5556 || return $ksft_skip run_cmd ${ns_b} ip fou add port 5556 ipproto ${ipproto} run_cmd ${ns_b} ip link add ${encap}_b type ${type} ${mode} local ${b_addr} remote ${a_addr} encap ${encap} encap-sport auto encap-dport @@ -455,7 +455,7 @@ setup_ipvX_over_ipvY() { fi fi - run_cmd ${ns_a} ip link add ip_a type ${type} local ${a_addr} remote ${b_addr} mode ${mode} || return 2 + run_cmd ${ns_a} ip link add ip_a type ${type} local ${a_addr} remote ${b_addr} mode ${mode} || return $ksft_skip run_cmd ${ns_b} ip link add ip_b type ${type} local ${b_addr} remote ${a_addr} mode ${mode} run_cmd ${ns_a} ip link set ip_a up @@ -713,7 +713,7 @@ setup_routing() { } setup_bridge() { - run_cmd ${ns_a} ip link add br0 type bridge || return 2 + run_cmd ${ns_a} ip link add br0 type bridge || return $ksft_skip run_cmd ${ns_a} ip link set br0 up run_cmd ${ns_c} ip link add veth_C-A type veth peer name veth_A-C @@ -765,7 +765,7 @@ setup_ovs_vxlan6() { } setup_ovs_bridge() { - run_cmd ovs-vsctl add-br ovs_br0 || return 2 + run_cmd ovs-vsctl add-br ovs_br0 || return $ksft_skip run_cmd ip link set ovs_br0 up run_cmd ${ns_c} ip link add veth_C-A type veth peer name veth_A-C @@ -887,7 +887,7 @@ check_pmtu_value() { test_pmtu_ipvX() { family=${1} - setup namespaces routing || return 2 + setup namespaces routing || return $ksft_skip trace "${ns_a}" veth_A-R1"${ns_r1}" veth_R1-A \ "${ns_r1}" veth_R1-B"${ns_b}" veth_B-R1 \ "${ns_a}" veth_A-R2"${ns_r2}" veth_R2-A \ @@ -985,11 +985,11 @@ test_pmtu_ipvX_over_vxlanY_or_geneveY_exception() { ll_mtu=4000 if [ ${outer_family} -eq 4 ]; then - setup namespaces routing ${type}4 || return 2 + setup namespaces routing ${type}4 || return $ksft_skip # IPv4 header UDP header VXLAN/GENEVE header Ethernet header exp_mtu=$((${ll_mtu} - 20 - 8 - 8 - 14)) else - setup namespaces routing ${type}6 || return 2 + setup namespaces routing ${type}6 || return $ksft_skip # IPv6 header UDP header VXLAN/GENEVE header Ethernet header exp_mtu=$((${ll_mtu} - 40 - 8 - 8 - 14)) fi @@ -1060,11 +1060,11 @@ test_pmtu_ipvX_over_bridged_vxlanY_or_geneveY_exception() { ll_mtu=4000 if [ ${outer_family} -eq 4 ]; then - setup namespaces routing bridge bridged_${type}4 || return 2 + setup namespaces routing bridge bridged_${type}4 || return $ksft_skip # IPv4 header UDP header VXLAN/GENEVE header Ethernet header exp_mtu=$((${ll_mtu} - 20 - 8 - 8
[PATCHv2 0/2] selftests: pmtu.sh: improve the test result processing
The pmtu.sh test script treats all non-zero return code as a failure, thus it will be marked as FAILED when some sub-test got skipped. This patchset will: 1. Use the kselftest framework skip code $ksft_skip to replace the hardcoded SKIP return code. 2. Improve the result processing, the test will be marked as PASSED if nothing goes wrong and not all the tests were skipped. Po-Hsu Lin (2): selftests: pmtu.sh: use $ksft_skip for skipped return code selftests: pmtu.sh: improve the test result processing tools/testing/selftests/net/pmtu.sh | 79 + 1 file changed, 46 insertions(+), 33 deletions(-) -- 2.7.4
[PATCHv2 2/2] selftests: pmtu.sh: improve the test result processing
This test will treat all non-zero return codes as failures, it will make the pmtu.sh test script being marked as FAILED when some sub-test got skipped. Improve the result processing by * Only mark the whole test script as SKIP when all of the sub-tests were skipped * If the sub-tests were either passed or skipped, the overall result will be PASS * If any of them has failed with return code 1 or anything bad happened (e.g. return code 127 for command not found), the overall result will be FAIL Signed-off-by: Po-Hsu Lin --- tools/testing/selftests/net/pmtu.sh | 15 ++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh index fb53987..464e31e 100755 --- a/tools/testing/selftests/net/pmtu.sh +++ b/tools/testing/selftests/net/pmtu.sh @@ -1652,7 +1652,19 @@ run_test() { return $ret ) ret=$? - [ $ret -ne 0 ] && exitcode=1 + case $ret in + 0) + all_skipped=false + [ $exitcode=$ksft_skip ] && exitcode=0 + ;; + $ksft_skip) + [ $all_skipped = true ] && exitcode=$ksft_skip + ;; + *) + all_skipped=false + exitcode=1 + ;; + esac return $ret } @@ -1786,6 +1798,7 @@ usage() { # exitcode=0 desc=0 +all_skipped=true while getopts :ptv o do -- 2.7.4
[PATCH] selftests: xfrm: fix test return value override issue in xfrm_policy.sh
When running this xfrm_policy.sh test script, even with some cases marked as FAIL, the overall test result will still be PASS: $ sudo ./xfrm_policy.sh PASS: policy before exception matches FAIL: expected ping to .254 to fail (exceptions) PASS: direct policy matches (exceptions) PASS: policy matches (exceptions) FAIL: expected ping to .254 to fail (exceptions and block policies) PASS: direct policy matches (exceptions and block policies) PASS: policy matches (exceptions and block policies) FAIL: expected ping to .254 to fail (exceptions and block policies after hresh changes) PASS: direct policy matches (exceptions and block policies after hresh changes) PASS: policy matches (exceptions and block policies after hresh changes) FAIL: expected ping to .254 to fail (exceptions and block policies after hthresh change in ns3) PASS: direct policy matches (exceptions and block policies after hthresh change in ns3) PASS: policy matches (exceptions and block policies after hthresh change in ns3) FAIL: expected ping to .254 to fail (exceptions and block policies after htresh change to normal) PASS: direct policy matches (exceptions and block policies after htresh change to normal) PASS: policy matches (exceptions and block policies after htresh change to normal) PASS: policies with repeated htresh change $ echo $? 0 This is because the $lret in check_xfrm() is not a local variable. Therefore when a test failed in check_exceptions(), the non-zero $lret will later get reset to 0 when the next test calls check_xfrm(). With this fix, the final return value will be 1. Make it easier for testers to spot this failure. Fixes: 39aa6928d462d0 ("xfrm: policy: fix netlink/pf_key policy lookups") Signed-off-by: Po-Hsu Lin --- tools/testing/selftests/net/xfrm_policy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/xfrm_policy.sh b/tools/testing/selftests/net/xfrm_policy.sh index 7a1bf94..5922941 100755 --- a/tools/testing/selftests/net/xfrm_policy.sh +++ b/tools/testing/selftests/net/xfrm_policy.sh @@ -202,7 +202,7 @@ check_xfrm() { # 1: iptables -m policy rule count != 0 rval=$1 ip=$2 - lret=0 + local lret=0 ip netns exec ns1 ping -q -c 1 10.0.2.$ip > /dev/null -- 2.7.4
[PATCH] selftests: fix the return value for UDP GRO test
The udpgro.sh will always return 0 (unless the bpf selftest was not build first) even if there are some failed sub test-cases. Therefore the kselftest framework will report this case is OK. Check and return the exit status of each test to make it easier to spot real failures. Signed-off-by: Po-Hsu Lin --- tools/testing/selftests/net/udpgro.sh | 34 ++ 1 file changed, 34 insertions(+) diff --git a/tools/testing/selftests/net/udpgro.sh b/tools/testing/selftests/net/udpgro.sh index ac2a30b..f8a19f5 100755 --- a/tools/testing/selftests/net/udpgro.sh +++ b/tools/testing/selftests/net/udpgro.sh @@ -5,6 +5,14 @@ readonly PEER_NS="ns-peer-$(mktemp -u XX)" +# set global exit status, but never reset nonzero one. +check_err() +{ + if [ $ret -eq 0 ]; then + ret=$1 + fi +} + cleanup() { local -r jobs="$(jobs -p)" local -r ns="$(ip netns list|grep $PEER_NS)" @@ -44,7 +52,9 @@ run_one() { # Hack: let bg programs complete the startup sleep 0.1 ./udpgso_bench_tx ${tx_args} + ret=$? wait $(jobs -p) + return $ret } run_test() { @@ -87,8 +97,10 @@ run_one_nat() { sleep 0.1 ./udpgso_bench_tx ${tx_args} + ret=$? kill -INT $pid wait $(jobs -p) + return $ret } run_one_2sock() { @@ -110,7 +122,9 @@ run_one_2sock() { sleep 0.1 # first UDP GSO socket should be closed at this point ./udpgso_bench_tx ${tx_args} + ret=$? wait $(jobs -p) + return $ret } run_nat_test() { @@ -131,36 +145,54 @@ run_all() { local -r core_args="-l 4" local -r ipv4_args="${core_args} -4 -D 192.168.1.1" local -r ipv6_args="${core_args} -6 -D 2001:db8::1" + ret=0 echo "ipv4" run_test "no GRO" "${ipv4_args} -M 10 -s 1400" "-4 -n 10 -l 1400" + check_err $? # explicitly check we are not receiving UDP_SEGMENT cmsg (-S -1) # when GRO does not take place run_test "no GRO chk cmsg" "${ipv4_args} -M 10 -s 1400" "-4 -n 10 -l 1400 -S -1" + check_err $? # the GSO packets are aggregated because: # * veth schedule napi after each xmit # * segmentation happens in BH context, veth napi poll is delayed after # the transmission of the last segment run_test "GRO" "${ipv4_args} -M 1 -s 14720 -S 0 " "-4 -n 1 -l 14720" + check_err $? run_test "GRO chk cmsg" "${ipv4_args} -M 1 -s 14720 -S 0 " "-4 -n 1 -l 14720 -S 1472" + check_err $? run_test "GRO with custom segment size" "${ipv4_args} -M 1 -s 14720 -S 500 " "-4 -n 1 -l 14720" + check_err $? run_test "GRO with custom segment size cmsg" "${ipv4_args} -M 1 -s 14720 -S 500 " "-4 -n 1 -l 14720 -S 500" + check_err $? run_nat_test "bad GRO lookup" "${ipv4_args} -M 1 -s 14720 -S 0" "-n 10 -l 1472" + check_err $? run_2sock_test "multiple GRO socks" "${ipv4_args} -M 1 -s 14720 -S 0 " "-4 -n 1 -l 14720 -S 1472" + check_err $? echo "ipv6" run_test "no GRO" "${ipv6_args} -M 10 -s 1400" "-n 10 -l 1400" + check_err $? run_test "no GRO chk cmsg" "${ipv6_args} -M 10 -s 1400" "-n 10 -l 1400 -S -1" + check_err $? run_test "GRO" "${ipv6_args} -M 1 -s 14520 -S 0" "-n 1 -l 14520" + check_err $? run_test "GRO chk cmsg" "${ipv6_args} -M 1 -s 14520 -S 0" "-n 1 -l 14520 -S 1452" + check_err $? run_test "GRO with custom segment size" "${ipv6_args} -M 1 -s 14520 -S 500" "-n 1 -l 14520" + check_err $? run_test "GRO with custom segment size cmsg" "${ipv6_args} -M 1 -s 14520 -S 500" "-n 1 -l 14520 -S 500" + check_err $? run_nat_test "bad GRO lookup" "${ipv6_args} -M 1 -s 14520 -S 0" "-n 10 -l 1452" + check_err $? run_2sock_test "multiple GRO socks" "${ipv6_args} -M 1 -s 14520 -S 0 " "-n 1 -l 14520 -S 1452" + check_err $? + return $ret } if [ ! -f ../bpf/xdp_dummy.o ]; then @@ -180,3 +212,5 @@ elif [[ $1 == "__subprocess_2sock" ]]; then shift run_one_2sock $@ fi + +exit $? -- 2.7.4
Re: [PATCHv4] selftests: rtnetlink: load fou module for kci_test_encap_fou() test
On Sat, Oct 17, 2020 at 7:32 AM Jakub Kicinski wrote: > > On Fri, 16 Oct 2020 12:12:11 +0800 Po-Hsu Lin wrote: > > The kci_test_encap_fou() test from kci_test_encap() in rtnetlink.sh > > needs the fou module to work. Otherwise it will fail with: > > > > $ ip netns exec "$testns" ip fou add port ipproto 47 > > RTNETLINK answers: No such file or directory > > Error talking to the kernel > > > > Add the CONFIG_NET_FOU into the config file as well. Which needs at > > least to be set as a loadable module. > > > > Signed-off-by: Po-Hsu Lin > > Doesn't apply :( Could you rebase on top of: > > https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/ Ah OK, I was using the next branch in kselftest, will resend another one. Thanks.
[PATCHv5] selftests: rtnetlink: load fou module for kci_test_encap_fou() test
The kci_test_encap_fou() test from kci_test_encap() in rtnetlink.sh needs the fou module to work. Otherwise it will fail with: $ ip netns exec "$testns" ip fou add port ipproto 47 RTNETLINK answers: No such file or directory Error talking to the kernel Add the CONFIG_NET_FOU into the config file as well. Which needs at least to be set as a loadable module. Signed-off-by: Po-Hsu Lin --- tools/testing/selftests/net/config | 1 + tools/testing/selftests/net/rtnetlink.sh | 5 + 2 files changed, 6 insertions(+) diff --git a/tools/testing/selftests/net/config b/tools/testing/selftests/net/config index 4364924..4d5df8e 100644 --- a/tools/testing/selftests/net/config +++ b/tools/testing/selftests/net/config @@ -33,3 +33,4 @@ CONFIG_KALLSYMS=y CONFIG_TRACEPOINTS=y CONFIG_NET_DROP_MONITOR=m CONFIG_NETDEVSIM=m +CONFIG_NET_FOU=m diff --git a/tools/testing/selftests/net/rtnetlink.sh b/tools/testing/selftests/net/rtnetlink.sh index 8a2fe6d..c9ce3df 100755 --- a/tools/testing/selftests/net/rtnetlink.sh +++ b/tools/testing/selftests/net/rtnetlink.sh @@ -520,6 +520,11 @@ kci_test_encap_fou() return $ksft_skip fi + if ! /sbin/modprobe -q -n fou; then + echo "SKIP: module fou is not found" + return $ksft_skip + fi + /sbin/modprobe -q fou ip -netns "$testns" fou add port ipproto 47 2>/dev/null if [ $? -ne 0 ];then echo "FAIL: can't add fou port , skipping test" -- 2.7.4
[PATCH 2/2] selftests: pmtu.sh: improve the test result processing
This test will treat all non-zero return codes as failures, it will make the pmtu.sh test script being marked as FAILED when some sub-test got skipped. Improve the result processing by * Only mark the whole test script as SKIP when all of the sub-tests were skipped * If the sub-tests were either passed or skipped, the overall result will be PASS * If any of them has failed, the overall result will be FAIL * Treat other return codes (e.g. 127 for command not found) as FAIL Signed-off-by: Po-Hsu Lin --- tools/testing/selftests/net/pmtu.sh | 19 ++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh index fb53987..5c86fb1 100755 --- a/tools/testing/selftests/net/pmtu.sh +++ b/tools/testing/selftests/net/pmtu.sh @@ -1652,7 +1652,23 @@ run_test() { return $ret ) ret=$? - [ $ret -ne 0 ] && exitcode=1 + case $ret in + 0) + all_skipped=false + [ $exitcode=$ksft_skip ] && exitcode=0 + ;; + 1) + all_skipped=false + exitcode=1 + ;; + $ksft_skip) + [ $all_skipped = true ] && exitcode=$ksft_skip + ;; + *) + all_skipped=false + exitcode=1 + ;; + esac return $ret } @@ -1786,6 +1802,7 @@ usage() { # exitcode=0 desc=0 +all_skipped=true while getopts :ptv o do -- 2.7.4
[PATCH 0/2] selftests: pmtu.sh: improve the test result processing
The pmtu.sh test script treats all non-zero return code as a failure, thus it will be marked as FAILED when some sub-test got skipped. This patchset will: 1. Use the kselftest framework skip code $ksft_skip to replace the hardcoded SKIP return code. 2. Improve the result processing, the test will be marked as PASSED if nothing goes wrong and not all the tests were skipped. Po-Hsu Lin (2): selftests: pmtu.sh: use $ksft_skip for skipped return code selftests: pmtu.sh: improve the test result processing tools/testing/selftests/net/pmtu.sh | 83 ++--- 1 file changed, 50 insertions(+), 33 deletions(-) -- 2.7.4
[PATCH 1/2] selftests: pmtu.sh: use $ksft_skip for skipped return code
This test uses return code 2 as a hard-coded skipped state, let's use the kselftest framework skip code variable $ksft_skip instead to make it more readable and easier to maintain. Signed-off-by: Po-Hsu Lin --- tools/testing/selftests/net/pmtu.sh | 64 ++--- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh index 6bbf69a..fb53987 100755 --- a/tools/testing/selftests/net/pmtu.sh +++ b/tools/testing/selftests/net/pmtu.sh @@ -355,7 +355,7 @@ setup_fou_or_gue() { encap="${3}" if [ "${outer}" = "4" ]; then - modprobe fou || return 2 + modprobe fou || return $ksft_skip a_addr="${prefix4}.${a_r1}.1" b_addr="${prefix4}.${b_r1}.1" if [ "${inner}" = "4" ]; then @@ -366,7 +366,7 @@ setup_fou_or_gue() { ipproto="41" fi else - modprobe fou6 || return 2 + modprobe fou6 || return $ksft_skip a_addr="${prefix6}:${a_r1}::1" b_addr="${prefix6}:${b_r1}::1" if [ "${inner}" = "4" ]; then @@ -380,8 +380,8 @@ setup_fou_or_gue() { fi fi - run_cmd ${ns_a} ip fou add port ipproto ${ipproto} || return 2 - run_cmd ${ns_a} ip link add ${encap}_a type ${type} ${mode} local ${a_addr} remote ${b_addr} encap ${encap} encap-sport auto encap-dport 5556 || return 2 + run_cmd ${ns_a} ip fou add port ipproto ${ipproto} || return $ksft_skip + run_cmd ${ns_a} ip link add ${encap}_a type ${type} ${mode} local ${a_addr} remote ${b_addr} encap ${encap} encap-sport auto encap-dport 5556 || return $ksft_skip run_cmd ${ns_b} ip fou add port 5556 ipproto ${ipproto} run_cmd ${ns_b} ip link add ${encap}_b type ${type} ${mode} local ${b_addr} remote ${a_addr} encap ${encap} encap-sport auto encap-dport @@ -455,7 +455,7 @@ setup_ipvX_over_ipvY() { fi fi - run_cmd ${ns_a} ip link add ip_a type ${type} local ${a_addr} remote ${b_addr} mode ${mode} || return 2 + run_cmd ${ns_a} ip link add ip_a type ${type} local ${a_addr} remote ${b_addr} mode ${mode} || return $ksft_skip run_cmd ${ns_b} ip link add ip_b type ${type} local ${b_addr} remote ${a_addr} mode ${mode} run_cmd ${ns_a} ip link set ip_a up @@ -713,7 +713,7 @@ setup_routing() { } setup_bridge() { - run_cmd ${ns_a} ip link add br0 type bridge || return 2 + run_cmd ${ns_a} ip link add br0 type bridge || return $ksft_skip run_cmd ${ns_a} ip link set br0 up run_cmd ${ns_c} ip link add veth_C-A type veth peer name veth_A-C @@ -765,7 +765,7 @@ setup_ovs_vxlan6() { } setup_ovs_bridge() { - run_cmd ovs-vsctl add-br ovs_br0 || return 2 + run_cmd ovs-vsctl add-br ovs_br0 || return $ksft_skip run_cmd ip link set ovs_br0 up run_cmd ${ns_c} ip link add veth_C-A type veth peer name veth_A-C @@ -887,7 +887,7 @@ check_pmtu_value() { test_pmtu_ipvX() { family=${1} - setup namespaces routing || return 2 + setup namespaces routing || return $ksft_skip trace "${ns_a}" veth_A-R1"${ns_r1}" veth_R1-A \ "${ns_r1}" veth_R1-B"${ns_b}" veth_B-R1 \ "${ns_a}" veth_A-R2"${ns_r2}" veth_R2-A \ @@ -985,11 +985,11 @@ test_pmtu_ipvX_over_vxlanY_or_geneveY_exception() { ll_mtu=4000 if [ ${outer_family} -eq 4 ]; then - setup namespaces routing ${type}4 || return 2 + setup namespaces routing ${type}4 || return $ksft_skip # IPv4 header UDP header VXLAN/GENEVE header Ethernet header exp_mtu=$((${ll_mtu} - 20 - 8 - 8 - 14)) else - setup namespaces routing ${type}6 || return 2 + setup namespaces routing ${type}6 || return $ksft_skip # IPv6 header UDP header VXLAN/GENEVE header Ethernet header exp_mtu=$((${ll_mtu} - 40 - 8 - 8 - 14)) fi @@ -1060,11 +1060,11 @@ test_pmtu_ipvX_over_bridged_vxlanY_or_geneveY_exception() { ll_mtu=4000 if [ ${outer_family} -eq 4 ]; then - setup namespaces routing bridge bridged_${type}4 || return 2 + setup namespaces routing bridge bridged_${type}4 || return $ksft_skip # IPv4 header UDP header VXLAN/GENEVE header Ethernet header exp_mtu=$((${ll_mtu} - 20 - 8 - 8
Re: [PATCH 2/2] selftests: pmtu.sh: improve the test result processing
On Sun, Nov 8, 2020 at 7:02 AM Jakub Kicinski wrote: > > On Thu, 5 Nov 2020 18:50:51 +0800 Po-Hsu Lin wrote: > > This test will treat all non-zero return codes as failures, it will > > make the pmtu.sh test script being marked as FAILED when some > > sub-test got skipped. > > > > Improve the result processing by > > * Only mark the whole test script as SKIP when all of the > > sub-tests were skipped > > * If the sub-tests were either passed or skipped, the overall > > result will be PASS > > * If any of them has failed, the overall result will be FAIL > > * Treat other return codes (e.g. 127 for command not found) as FAIL > > > > Signed-off-by: Po-Hsu Lin > > Patch 1 looks like a cleanup while patch 2 is more of a fix, can we > separate the two and apply the former to -next and latter to 5.10? > They shouldn't conflict, right? > Hello Jakub, Yes the first patch is just changing return code to $ksft_skip, the real fix is the second one. However the second patch was based on the first one, if we want to apply them separately we might need to change this $ksft_skip handling part in the second patch. What should I do to deal with this? Resend the former for -next and rebase + resend the latter (plus the fix to remove case 1) for 5.10 without the former patch? Thanks! > > diff --git a/tools/testing/selftests/net/pmtu.sh > > b/tools/testing/selftests/net/pmtu.sh > > index fb53987..5c86fb1 100755 > > --- a/tools/testing/selftests/net/pmtu.sh > > +++ b/tools/testing/selftests/net/pmtu.sh > > @@ -1652,7 +1652,23 @@ run_test() { > > return $ret > > ) > > ret=$? > > - [ $ret -ne 0 ] && exitcode=1 > > + case $ret in > > + 0) > > + all_skipped=false > > + [ $exitcode=$ksft_skip ] && exitcode=0 > > + ;; > > + 1) > > + all_skipped=false > > + exitcode=1 > > + ;; > > Does it make sense to remove this case? The handling is identical to > the default case *). > Yes you're right, we can remove this part. > > + $ksft_skip) > > + [ $all_skipped = true ] && exitcode=$ksft_skip > > + ;; > > + *) > > + all_skipped=false > > + exitcode=1 > > + ;; > > + esac > > > > return $ret > > } > > @@ -1786,6 +1802,7 @@ usage() { > > # > > exitcode=0 > > desc=0 > > +all_skipped=true > > > > while getopts :ptv o > > do >
[PATCH] selftests: xfrm: put cleanup code into a exit trap
If the xfrm_policy.sh script takes longer than the default kselftest framework 45 seconds timeout to run, it will be terminated and thus leave those netns namespace files created by the test alone. In this case a second attempt will fail with: # Cannot create namespace file "/run/netns/ns1": File exists It might affect the outcome of other tests as well. Move the netns cleanup code into an exit trap so that we can ensure these namespace files will be removed after the test. Signed-off-by: Po-Hsu Lin --- tools/testing/selftests/net/xfrm_policy.sh | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/net/xfrm_policy.sh b/tools/testing/selftests/net/xfrm_policy.sh index bdf450e..bb4632b 100755 --- a/tools/testing/selftests/net/xfrm_policy.sh +++ b/tools/testing/selftests/net/xfrm_policy.sh @@ -28,6 +28,11 @@ KEY_AES=0x0123456789abcdef0123456789012345 SPI1=0x1 SPI2=0x2 +cleanup() { +for i in 1 2 3 4;do ip netns del ns$i 2>/dev/null ;done +} +trap cleanup EXIT + do_esp_policy() { local ns=$1 local me=$2 @@ -481,6 +486,4 @@ check_hthresh_repeat "policies with repeated htresh change" check_random_order ns3 "policies inserted in random order" -for i in 1 2 3 4;do ip netns del ns$i;done - exit $ret -- 2.7.4
[PATCH] selftests: rtnetlink: load fou module for kci_test_encap_fou()
The kci_test_encap_fou() test from kci_test_encap() in rtnetlink.sh needs the fou module to work. Otherwise it will fail with: $ ip netns exec "$testns" ip fou add port ipproto 47 RTNETLINK answers: No such file or directory Error talking to the kernel Add the CONFIG_NET_FOU into the config file as well. Signed-off-by: Po-Hsu Lin --- tools/testing/selftests/net/config | 1 + tools/testing/selftests/net/rtnetlink.sh | 6 ++ 2 files changed, 7 insertions(+) diff --git a/tools/testing/selftests/net/config b/tools/testing/selftests/net/config index 3b42c06b..96d2763 100644 --- a/tools/testing/selftests/net/config +++ b/tools/testing/selftests/net/config @@ -31,3 +31,4 @@ CONFIG_NET_SCH_ETF=m CONFIG_NET_SCH_NETEM=y CONFIG_TEST_BLACKHOLE_DEV=m CONFIG_KALLSYMS=y +CONFIG_NET_FOU diff --git a/tools/testing/selftests/net/rtnetlink.sh b/tools/testing/selftests/net/rtnetlink.sh index bdbf4b3..7931b65 100755 --- a/tools/testing/selftests/net/rtnetlink.sh +++ b/tools/testing/selftests/net/rtnetlink.sh @@ -521,6 +521,11 @@ kci_test_encap_fou() return $ksft_skip fi + if ! /sbin/modprobe -q -n fou; then + echo "SKIP: module fou is not found" + return $ksft_skip + fi + /sbin/modprobe -q fou ip -netns "$testns" fou add port ipproto 47 2>/dev/null if [ $? -ne 0 ];then echo "FAIL: can't add fou port , skipping test" @@ -541,6 +546,7 @@ kci_test_encap_fou() return 1 fi + /sbin/modprobe -q -r fou echo "PASS: fou" } -- 2.7.4
Re: [PATCH] selftests: rtnetlink: load fou module for kci_test_encap_fou()
On Sat, Aug 15, 2020 at 7:43 AM David Miller wrote: > > From: Po-Hsu Lin > Date: Thu, 13 Aug 2020 12:44:22 +0800 > > > diff --git a/tools/testing/selftests/net/config > > b/tools/testing/selftests/net/config > > index 3b42c06b..96d2763 100644 > > --- a/tools/testing/selftests/net/config > > +++ b/tools/testing/selftests/net/config > > @@ -31,3 +31,4 @@ CONFIG_NET_SCH_ETF=m > > CONFIG_NET_SCH_NETEM=y > > CONFIG_TEST_BLACKHOLE_DEV=m > > CONFIG_KALLSYMS=y > > +CONFIG_NET_FOU > > You need to assign it a value, not just add it to the file by itself. Oops! Patch re-submitted. Thanks for catching this.
Re: [PATCHv3] selftests: rtnetlink: load fou module for kci_test_encap_fou() test
On Tue, Sep 8, 2020 at 4:12 AM Jakub Kicinski wrote: > > On Mon, 7 Sep 2020 11:50:10 +0800 Po-Hsu Lin wrote: > > The kci_test_encap_fou() test from kci_test_encap() in rtnetlink.sh > > needs the fou module to work. Otherwise it will fail with: > > > > $ ip netns exec "$testns" ip fou add port ipproto 47 > > RTNETLINK answers: No such file or directory > > Error talking to the kernel > > > > Add the CONFIG_NET_FOU into the config file as well. Which needs at > > least to be set as a loadable module. > > > > Signed-off-by: Po-Hsu Lin > > > diff --git a/tools/testing/selftests/net/rtnetlink.sh > > b/tools/testing/selftests/net/rtnetlink.sh > > index 7c38a90..a711b3e 100755 > > --- a/tools/testing/selftests/net/rtnetlink.sh > > +++ b/tools/testing/selftests/net/rtnetlink.sh > > @@ -520,6 +520,11 @@ kci_test_encap_fou() > > return $ksft_skip > > fi > > > > + if ! /sbin/modprobe -q -n fou; then > > + echo "SKIP: module fou is not found" > > + return $ksft_skip > > + fi > > + /sbin/modprobe -q fou > > ip -netns "$testns" fou add port ipproto 47 2>/dev/null > > if [ $? -ne 0 ];then > > echo "FAIL: can't add fou port , skipping test" > > @@ -540,6 +545,7 @@ kci_test_encap_fou() > > return 1 > > fi > > > > + /sbin/modprobe -q -r fou > > I think the common practice is to not remove the module at the end of > the test. It may be used by something else than the test itself. > Hello Jakub, Thanks for your feedback. For this case I think it's safe to remove the module here, as it was never loaded before and thus causing this test to fail. If other tests in this rtnetlink.sh need this fou module, we should be able to spot those failures too, however this is the only failure as I can see. (pmtu.sh will need fou module to run as well, but it will be loaded there.) Shouldn't we insert the required module whenever the test needs it? So that we can run the test itself directly, without depending on other tests. Also, I can see modules for tests were being unloaded in other tests as well. Thanks > > echo "PASS: fou" > > } > > >
Re: [PATCHv3] selftests: rtnetlink: load fou module for kci_test_encap_fou() test
Hello, Is there any update on this patch? Thanks! PHLin On Fri, Sep 18, 2020 at 6:39 PM Po-Hsu Lin wrote: > > Hello folks, > > any thoughts on this patch? > It can make the test pass and reduce the failure numbers in > kselftests, it will be great to have this applied. > > Thanks > PHLin > > > On Tue, Sep 8, 2020 at 2:57 PM Po-Hsu Lin wrote: > > > > On Tue, Sep 8, 2020 at 4:12 AM Jakub Kicinski wrote: > > > > > > On Mon, 7 Sep 2020 11:50:10 +0800 Po-Hsu Lin wrote: > > > > The kci_test_encap_fou() test from kci_test_encap() in rtnetlink.sh > > > > needs the fou module to work. Otherwise it will fail with: > > > > > > > > $ ip netns exec "$testns" ip fou add port ipproto 47 > > > > RTNETLINK answers: No such file or directory > > > > Error talking to the kernel > > > > > > > > Add the CONFIG_NET_FOU into the config file as well. Which needs at > > > > least to be set as a loadable module. > > > > > > > > Signed-off-by: Po-Hsu Lin > > > > > > > diff --git a/tools/testing/selftests/net/rtnetlink.sh > > > > b/tools/testing/selftests/net/rtnetlink.sh > > > > index 7c38a90..a711b3e 100755 > > > > --- a/tools/testing/selftests/net/rtnetlink.sh > > > > +++ b/tools/testing/selftests/net/rtnetlink.sh > > > > @@ -520,6 +520,11 @@ kci_test_encap_fou() > > > > return $ksft_skip > > > > fi > > > > > > > > + if ! /sbin/modprobe -q -n fou; then > > > > + echo "SKIP: module fou is not found" > > > > + return $ksft_skip > > > > + fi > > > > + /sbin/modprobe -q fou > > > > ip -netns "$testns" fou add port ipproto 47 2>/dev/null > > > > if [ $? -ne 0 ];then > > > > echo "FAIL: can't add fou port , skipping test" > > > > @@ -540,6 +545,7 @@ kci_test_encap_fou() > > > > return 1 > > > > fi > > > > > > > > + /sbin/modprobe -q -r fou > > > > > > I think the common practice is to not remove the module at the end of > > > the test. It may be used by something else than the test itself. > > > > > Hello Jakub, > > Thanks for your feedback. > > > > For this case I think it's safe to remove the module here, as it was > > never loaded before and thus causing this test to fail. > > If other tests in this rtnetlink.sh need this fou module, we should be > > able to spot those failures too, however this is the only failure as I > > can see. > > (pmtu.sh will need fou module to run as well, but it will be loaded there.) > > > > Shouldn't we insert the required module whenever the test needs it? So > > that we can run the test itself directly, without depending on other > > tests. > > Also, I can see modules for tests were being unloaded in other tests as > > well. > > > > Thanks > > > > > > echo "PASS: fou" > > > > } > > > > > > >
Re: [PATCHv3] selftests: rtnetlink: load fou module for kci_test_encap_fou() test
On Mon, Oct 12, 2020 at 11:28 PM Jakub Kicinski wrote: > > On Mon, 12 Oct 2020 13:56:15 +0800 Po-Hsu Lin wrote: > > Is there any update on this patch? > > You received feedback. Don't remove modules after tests, something else > could be using them. Hello Jakub, I have my feedback regarding your input [1], so I guess it's not persuasive enough? Thanks [1] https://marc.info/?l=linux-kernel&m=159954826414645&w=2
[PATCHv4] selftests: rtnetlink: load fou module for kci_test_encap_fou() test
The kci_test_encap_fou() test from kci_test_encap() in rtnetlink.sh needs the fou module to work. Otherwise it will fail with: $ ip netns exec "$testns" ip fou add port ipproto 47 RTNETLINK answers: No such file or directory Error talking to the kernel Add the CONFIG_NET_FOU into the config file as well. Which needs at least to be set as a loadable module. Signed-off-by: Po-Hsu Lin --- tools/testing/selftests/net/config | 1 + tools/testing/selftests/net/rtnetlink.sh | 5 + 2 files changed, 6 insertions(+) diff --git a/tools/testing/selftests/net/config b/tools/testing/selftests/net/config index 3b42c06b..c5e50ab 100644 --- a/tools/testing/selftests/net/config +++ b/tools/testing/selftests/net/config @@ -31,3 +31,4 @@ CONFIG_NET_SCH_ETF=m CONFIG_NET_SCH_NETEM=y CONFIG_TEST_BLACKHOLE_DEV=m CONFIG_KALLSYMS=y +CONFIG_NET_FOU=m diff --git a/tools/testing/selftests/net/rtnetlink.sh b/tools/testing/selftests/net/rtnetlink.sh index 7c38a90..6f8f159 100755 --- a/tools/testing/selftests/net/rtnetlink.sh +++ b/tools/testing/selftests/net/rtnetlink.sh @@ -520,6 +520,11 @@ kci_test_encap_fou() return $ksft_skip fi + if ! /sbin/modprobe -q -n fou; then + echo "SKIP: module fou is not found" + return $ksft_skip + fi + /sbin/modprobe -q fou ip -netns "$testns" fou add port ipproto 47 2>/dev/null if [ $? -ne 0 ];then echo "FAIL: can't add fou port , skipping test" -- 2.7.4
[PATCH 0/2] selftests: rtnetlink: Fix for false-negative return values
This patchset will address the false-negative return value issue caused by the following: 1. The return value "ret" in this script will be reset to 0 from the beginning of each sub-test in rtnetlink.sh, therefore this rtnetlink test will always pass if the last sub-test has passed. 2. The test result from two sub-tests in kci_test_encap() were not being processed, thus they will not affect the final test result of this test. Po-Hsu Lin (2): selftests: rtnetlink: correct the final return value for the test selftests: rtnetlink: make kci_test_encap() return sub-test result tools/testing/selftests/net/rtnetlink.sh | 68 +--- 1 file changed, 46 insertions(+), 22 deletions(-) -- 2.7.4
[PATCH 2/2] selftests: rtnetlink: make kci_test_encap() return sub-test result
kci_test_encap() is actually composed by two different sub-tests, kci_test_encap_vxlan() and kci_test_encap_fou() Therefore we should check the test result of these two in kci_test_encap() to let the script be aware of the pass / fail status. Otherwise it will generate false-negative result like below: $ sudo ./test.sh PASS: policy routing PASS: route get PASS: preferred_lft addresses have expired PASS: promote_secondaries complete PASS: tc htb hierarchy PASS: gre tunnel endpoint PASS: gretap PASS: ip6gretap PASS: erspan PASS: ip6erspan PASS: bridge setup PASS: ipv6 addrlabel PASS: set ifalias 5b193daf-0a08-46d7-af2c-e7aadd422ded for test-dummy0 PASS: vrf PASS: vxlan FAIL: can't add fou port , skipping test PASS: macsec PASS: bridge fdb get PASS: neigh get $ echo $? 0 Signed-off-by: Po-Hsu Lin --- tools/testing/selftests/net/rtnetlink.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/testing/selftests/net/rtnetlink.sh b/tools/testing/selftests/net/rtnetlink.sh index 9db66be..7c38a90 100755 --- a/tools/testing/selftests/net/rtnetlink.sh +++ b/tools/testing/selftests/net/rtnetlink.sh @@ -564,9 +564,12 @@ kci_test_encap() check_err $? kci_test_encap_vxlan "$testns" + check_err $? kci_test_encap_fou "$testns" + check_err $? ip netns del "$testns" + return $ret } kci_test_macsec() -- 2.7.4
[PATCH 1/2] selftests: rtnetlink: correct the final return value for the test
The return value "ret" will be reset to 0 from the beginning of each sub-test in rtnetlink.sh, therefore this test will always pass if the last sub-test has passed: $ sudo ./rtnetlink.sh PASS: policy routing PASS: route get PASS: preferred_lft addresses have expired PASS: promote_secondaries complete PASS: tc htb hierarchy PASS: gre tunnel endpoint PASS: gretap PASS: ip6gretap PASS: erspan PASS: ip6erspan PASS: bridge setup PASS: ipv6 addrlabel PASS: set ifalias a39ee707-e36b-41d3-802f-63179ed4d580 for test-dummy0 PASS: vrf PASS: vxlan FAIL: can't add fou port , skipping test PASS: macsec PASS: ipsec 3,7c3,7 < sa[0]spi=0x0009 proto=0x32 salt=0x64636261 crypt=1 < sa[0]key=0x31323334 35363738 39303132 33343536 < sa[1] rx ipaddr=0x c0a87b03 < sa[1]spi=0x0009 proto=0x32 salt=0x64636261 crypt=1 < sa[1]key=0x31323334 35363738 39303132 33343536 --- > sa[0]spi=0x0009 proto=0x32 salt=0x61626364 crypt=1 > sa[0]key=0x34333231 38373635 32313039 36353433 > sa[1] rx ipaddr=0x 037ba8c0 > sa[1]spi=0x0009 proto=0x32 salt=0x61626364 crypt=1 > sa[1]key=0x34333231 38373635 32313039 36353433 FAIL: ipsec_offload incorrect driver data FAIL: ipsec_offload PASS: bridge fdb get PASS: neigh get $ echo $? 0 Make "ret" become a local variable for all sub-tests. Also, check the sub-test results in kci_test_rtnl() and return the final result for this test. Signed-off-by: Po-Hsu Lin --- tools/testing/selftests/net/rtnetlink.sh | 65 +--- 1 file changed, 43 insertions(+), 22 deletions(-) diff --git a/tools/testing/selftests/net/rtnetlink.sh b/tools/testing/selftests/net/rtnetlink.sh index bdbf4b3..9db66be 100755 --- a/tools/testing/selftests/net/rtnetlink.sh +++ b/tools/testing/selftests/net/rtnetlink.sh @@ -5,7 +5,6 @@ # set -e devdummy="test-dummy0" -ret=0 # Kselftest framework requirement - SKIP code is 4. ksft_skip=4 @@ -66,7 +65,7 @@ kci_test_bridge() devbr="test-br0" vlandev="testbr-vlan1" - ret=0 + local ret=0 ip link add name "$devbr" type bridge check_err $? @@ -113,7 +112,7 @@ kci_test_gre() rem=10.42.42.1 loc=10.0.0.1 - ret=0 + local ret=0 ip tunnel add $gredev mode gre remote $rem local $loc ttl 1 check_err $? ip link set $gredev up @@ -149,7 +148,7 @@ kci_test_gre() kci_test_tc() { dev=lo - ret=0 + local ret=0 tc qdisc add dev "$dev" root handle 1: htb check_err $? @@ -184,7 +183,7 @@ kci_test_tc() kci_test_polrouting() { - ret=0 + local ret=0 ip rule add fwmark 1 lookup 100 check_err $? ip route add local 0.0.0.0/0 dev lo table 100 @@ -207,7 +206,7 @@ kci_test_route_get() { local hash_policy=$(sysctl -n net.ipv4.fib_multipath_hash_policy) - ret=0 + local ret=0 ip route get 127.0.0.1 > /dev/null check_err $? @@ -290,7 +289,7 @@ kci_test_promote_secondaries() kci_test_addrlabel() { - ret=0 + local ret=0 ip addrlabel add prefix dead::/64 dev lo label 1 check_err $? @@ -330,7 +329,7 @@ kci_test_addrlabel() kci_test_ifalias() { - ret=0 + local ret=0 namewant=$(uuidgen) syspathname="/sys/class/net/$devdummy/ifalias" @@ -385,7 +384,7 @@ kci_test_ifalias() kci_test_vrf() { vrfname="test-vrf" - ret=0 + local ret=0 ip link show type vrf 2>/dev/null if [ $? -ne 0 ]; then @@ -425,7 +424,7 @@ kci_test_vrf() kci_test_encap_vxlan() { - ret=0 + local ret=0 vxlan="test-vxlan0" vlan="test-vlan0" testns="$1" @@ -511,7 +510,7 @@ kci_test_encap_vxlan() kci_test_encap_fou() { - ret=0 + local ret=0 name="test-fou" testns="$1" @@ -548,7 +547,7 @@ kci_test_encap_fou() kci_test_encap() { testns="testns" - ret=0 + local ret=0 ip netns add "$testns" if [ $? -ne 0 ]; then @@ -573,7 +572,7 @@ kci_test_encap() kci_test_macsec() { msname="test_macsec0" - ret=0 + local ret=0 ip macsec help 2>&1 | grep -q "^Usage: ip macsec" if [ $? -ne 0 ]; then @@ -631,7 +630,7 @@ kci_test_macsec() #--- kci_test_ipsec() { - ret=0 + local ret=0 algo="aead rfc4106(gcm(aes)) 0x3132333435363738393031323334353664636261 128" srcip=192.168.123.1 dstip=192.168.123.2 @@ -731,7 +
Re: [PATCHv3] selftests: rtnetlink: load fou module for kci_test_encap_fou() test
Hello folks, any thoughts on this patch? It can make the test pass and reduce the failure numbers in kselftests, it will be great to have this applied. Thanks PHLin On Tue, Sep 8, 2020 at 2:57 PM Po-Hsu Lin wrote: > > On Tue, Sep 8, 2020 at 4:12 AM Jakub Kicinski wrote: > > > > On Mon, 7 Sep 2020 11:50:10 +0800 Po-Hsu Lin wrote: > > > The kci_test_encap_fou() test from kci_test_encap() in rtnetlink.sh > > > needs the fou module to work. Otherwise it will fail with: > > > > > > $ ip netns exec "$testns" ip fou add port ipproto 47 > > > RTNETLINK answers: No such file or directory > > > Error talking to the kernel > > > > > > Add the CONFIG_NET_FOU into the config file as well. Which needs at > > > least to be set as a loadable module. > > > > > > Signed-off-by: Po-Hsu Lin > > > > > diff --git a/tools/testing/selftests/net/rtnetlink.sh > > > b/tools/testing/selftests/net/rtnetlink.sh > > > index 7c38a90..a711b3e 100755 > > > --- a/tools/testing/selftests/net/rtnetlink.sh > > > +++ b/tools/testing/selftests/net/rtnetlink.sh > > > @@ -520,6 +520,11 @@ kci_test_encap_fou() > > > return $ksft_skip > > > fi > > > > > > + if ! /sbin/modprobe -q -n fou; then > > > + echo "SKIP: module fou is not found" > > > + return $ksft_skip > > > + fi > > > + /sbin/modprobe -q fou > > > ip -netns "$testns" fou add port ipproto 47 2>/dev/null > > > if [ $? -ne 0 ];then > > > echo "FAIL: can't add fou port , skipping test" > > > @@ -540,6 +545,7 @@ kci_test_encap_fou() > > > return 1 > > > fi > > > > > > + /sbin/modprobe -q -r fou > > > > I think the common practice is to not remove the module at the end of > > the test. It may be used by something else than the test itself. > > > Hello Jakub, > Thanks for your feedback. > > For this case I think it's safe to remove the module here, as it was > never loaded before and thus causing this test to fail. > If other tests in this rtnetlink.sh need this fou module, we should be > able to spot those failures too, however this is the only failure as I > can see. > (pmtu.sh will need fou module to run as well, but it will be loaded there.) > > Shouldn't we insert the required module whenever the test needs it? So > that we can run the test itself directly, without depending on other > tests. > Also, I can see modules for tests were being unloaded in other tests as well. > > Thanks > > > > echo "PASS: fou" > > > } > > > > >
[PATCH] selftests/net: improve descriptions for XFAIL cases in psock_snd.sh
Before changing this it's a bit confusing to read test output: raw csum_off with bad offset (fails) ./psock_snd: write: Invalid argument Change "fails" in the test case description to "expected to fail", so that the test output can be more understandable. Signed-off-by: Po-Hsu Lin --- tools/testing/selftests/net/psock_snd.sh | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/net/psock_snd.sh b/tools/testing/selftests/net/psock_snd.sh index 6331d91..170be65 100755 --- a/tools/testing/selftests/net/psock_snd.sh +++ b/tools/testing/selftests/net/psock_snd.sh @@ -45,7 +45,7 @@ echo "raw vnet hdr" echo "raw csum_off" ./in_netns.sh ./psock_snd -v -c -echo "raw csum_off with bad offset (fails)" +echo "raw csum_off with bad offset (expected to fail)" (! ./in_netns.sh ./psock_snd -v -c -C) @@ -57,7 +57,7 @@ echo "raw min size" echo "raw mtu size" ./in_netns.sh ./psock_snd -l "${mss}" -echo "raw mtu size + 1 (fails)" +echo "raw mtu size + 1 (expected to fail)" (! ./in_netns.sh ./psock_snd -l "${mss_exceeds}") # fails due to ARPHRD_ETHER check in packet_extra_vlan_len_allowed @@ -65,19 +65,19 @@ echo "raw mtu size + 1 (fails)" # echo "raw vlan mtu size" # ./in_netns.sh ./psock_snd -V -l "${mss}" -echo "raw vlan mtu size + 1 (fails)" +echo "raw vlan mtu size + 1 (expected to fail)" (! ./in_netns.sh ./psock_snd -V -l "${mss_exceeds}") echo "dgram mtu size" ./in_netns.sh ./psock_snd -d -l "${mss}" -echo "dgram mtu size + 1 (fails)" +echo "dgram mtu size + 1 (expected to fail)" (! ./in_netns.sh ./psock_snd -d -l "${mss_exceeds}") -echo "raw truncate hlen (fails: does not arrive)" +echo "raw truncate hlen (expected to fail: does not arrive)" (! ./in_netns.sh ./psock_snd -t "$((${vnet_hlen} + ${eth_hlen}))") -echo "raw truncate hlen - 1 (fails: EINVAL)" +echo "raw truncate hlen - 1 (expected to fail: EINVAL)" (! ./in_netns.sh ./psock_snd -t "$((${vnet_hlen} + ${eth_hlen} - 1))") @@ -86,13 +86,13 @@ echo "raw truncate hlen - 1 (fails: EINVAL)" echo "raw gso min size" ./in_netns.sh ./psock_snd -v -c -g -l "${mss_exceeds}" -echo "raw gso min size - 1 (fails)" +echo "raw gso min size - 1 (expected to fail)" (! ./in_netns.sh ./psock_snd -v -c -g -l "${mss}") echo "raw gso max size" ./in_netns.sh ./psock_snd -v -c -g -l "${max_mss}" -echo "raw gso max size + 1 (fails)" +echo "raw gso max size + 1 (expected to fail)" (! ./in_netns.sh ./psock_snd -v -c -g -l "${max_mss_exceeds}") echo "OK. All tests passed" -- 2.7.4
Re: [PATCHv2] selftests: rtnetlink: load fou module for kci_test_encap_fou()
Hello David, do you need more information for this V2 patch? Thank you PHLin On Mon, Aug 17, 2020 at 10:53 AM Po-Hsu Lin wrote: > > The kci_test_encap_fou() test from kci_test_encap() in rtnetlink.sh > needs the fou module to work. Otherwise it will fail with: > > $ ip netns exec "$testns" ip fou add port ipproto 47 > RTNETLINK answers: No such file or directory > Error talking to the kernel > > Add the CONFIG_NET_FOU into the config file as well. Which needs at > least to be set as a loadable module. > > Signed-off-by: Po-Hsu Lin > --- > tools/testing/selftests/net/config | 1 + > tools/testing/selftests/net/rtnetlink.sh | 6 ++ > 2 files changed, 7 insertions(+) > > diff --git a/tools/testing/selftests/net/config > b/tools/testing/selftests/net/config > index 3b42c06b..96d2763 100644 > --- a/tools/testing/selftests/net/config > +++ b/tools/testing/selftests/net/config > @@ -31,3 +31,4 @@ CONFIG_NET_SCH_ETF=m > CONFIG_NET_SCH_NETEM=y > CONFIG_TEST_BLACKHOLE_DEV=m > CONFIG_KALLSYMS=y > +CONFIG_NET_FOU=m > diff --git a/tools/testing/selftests/net/rtnetlink.sh > b/tools/testing/selftests/net/rtnetlink.sh > index bdbf4b3..7931b65 100755 > --- a/tools/testing/selftests/net/rtnetlink.sh > +++ b/tools/testing/selftests/net/rtnetlink.sh > @@ -521,6 +521,11 @@ kci_test_encap_fou() > return $ksft_skip > fi > > + if ! /sbin/modprobe -q -n fou; then > + echo "SKIP: module fou is not found" > + return $ksft_skip > + fi > + /sbin/modprobe -q fou > ip -netns "$testns" fou add port ipproto 47 2>/dev/null > if [ $? -ne 0 ];then > echo "FAIL: can't add fou port , skipping test" > @@ -541,6 +546,7 @@ kci_test_encap_fou() > return 1 > fi > > + /sbin/modprobe -q -r fou > echo "PASS: fou" > } > > -- > 2.7.4 >
[PATCHv3] selftests: rtnetlink: load fou module for kci_test_encap_fou() test
The kci_test_encap_fou() test from kci_test_encap() in rtnetlink.sh needs the fou module to work. Otherwise it will fail with: $ ip netns exec "$testns" ip fou add port ipproto 47 RTNETLINK answers: No such file or directory Error talking to the kernel Add the CONFIG_NET_FOU into the config file as well. Which needs at least to be set as a loadable module. Signed-off-by: Po-Hsu Lin --- tools/testing/selftests/net/config | 1 + tools/testing/selftests/net/rtnetlink.sh | 6 ++ 2 files changed, 7 insertions(+) diff --git a/tools/testing/selftests/net/config b/tools/testing/selftests/net/config index 3b42c06b..c5e50ab 100644 --- a/tools/testing/selftests/net/config +++ b/tools/testing/selftests/net/config @@ -31,3 +31,4 @@ CONFIG_NET_SCH_ETF=m CONFIG_NET_SCH_NETEM=y CONFIG_TEST_BLACKHOLE_DEV=m CONFIG_KALLSYMS=y +CONFIG_NET_FOU=m diff --git a/tools/testing/selftests/net/rtnetlink.sh b/tools/testing/selftests/net/rtnetlink.sh index 7c38a90..a711b3e 100755 --- a/tools/testing/selftests/net/rtnetlink.sh +++ b/tools/testing/selftests/net/rtnetlink.sh @@ -520,6 +520,11 @@ kci_test_encap_fou() return $ksft_skip fi + if ! /sbin/modprobe -q -n fou; then + echo "SKIP: module fou is not found" + return $ksft_skip + fi + /sbin/modprobe -q fou ip -netns "$testns" fou add port ipproto 47 2>/dev/null if [ $? -ne 0 ];then echo "FAIL: can't add fou port , skipping test" @@ -540,6 +545,7 @@ kci_test_encap_fou() return 1 fi + /sbin/modprobe -q -r fou echo "PASS: fou" } -- 2.7.4