tst_net.sh: Fix for disabled IPv6
PATCH 1/2 tst_net.sh: Fix for disabled IPv6
From: Petr Vorel <[email protected]>
Tests failed in tst_init_iface even IPv4 only test was run. Allow to init interfaces at least for IPv4.
Tests which use TST_IPV6=6 needs to be fixed (unless they use just tst_ipaddr_un()).
Store result into TST_NET_{L,R}HOST_IPV6 in order to cache the result.
---
Changes v1->v2:
* cache variables with $TST_NET_{L,R}HOST_IPV6 (mdoucha)
NOTE: although I'd prefer to cache the result internally and use function for detection, tst_net.sh uses variables for most of the things, thus keep it this way.
Kind regards,
Petr
testcases/lib/tst_net.sh | 72 ++++++++++++++++++++++++++++++++++------ 1 file changed, 61 insertions(+), 11 deletions(-)
testcases/lib/tst_net.sh +61 -11
@@ -24,7 +24,9 @@ TST_IPV6_FLAG=${TST_IPV6_FLAG:-} tst_net_parse_args() { case $1 in - 6) TST_IPV6=6 TST_IPVER=6 TST_IPV6_FLAG="-6";; + 6) tst_net_require_ipv6 + TST_IPV6=6 TST_IPVER=6 TST_IPV6_FLAG="-6" + ;; *) [ "$TST_PARSE_ARGS_CALLER" ] && $TST_PARSE_ARGS_CALLER "$1" "$2";; esac }
@@ -100,6 +102,30 @@ tst_brk_() [ -z "$TST_USE_LEGACY_API" ] && tst_brk $@ || tst_brkm $@ } +tst_net_detect_ipv6() +{ + local type="${1:-lhost}" + local cmd='[ -f /proc/net/if_inet6 ]' + + if [ "$type" = "lhost" ]; then + $cmd + return $? + fi + + tst_rhost_run -c "$cmd" + return $? +} + +tst_net_require_ipv6() +{ + local err="IPv6 not supported on:" + local missing + + [ "$TST_NET_LHOST_IPV6" = 1 ] || missing=" lhost" + [ "$TST_NET_RHOST_IPV6" = 1 ] || missing="$missing rhost" + [ -z "$missing" ] || tst_brk_ TCONF "$err$missing" +} + init_ltp_netspace() { local pid
@@ -517,7 +543,9 @@ tst_init_iface() ip link set $iface down || return $? ip route flush dev $iface || return $? ip addr flush dev $iface || return $? - sysctl -qw net.ipv6.conf.$iface.accept_dad=0 || return $? + if [ "$TST_NET_LHOST_IPV6" = 1 ]; then + sysctl -qw net.ipv6.conf.$iface.accept_dad=0 || return $? + fi ip link set $iface up return $? fi
@@ -529,7 +557,9 @@ tst_init_iface() tst_rhost_run -c "ip link set $iface down" || return $? tst_rhost_run -c "ip route flush dev $iface" || return $? tst_rhost_run -c "ip addr flush dev $iface" || return $? - tst_rhost_run -c "sysctl -qw net.ipv6.conf.$iface.accept_dad=0" || return $? + if [ "$TST_NET_RHOST_IPV6" = 1 ]; then + tst_rhost_run -c "sysctl -qw net.ipv6.conf.$iface.accept_dad=0" || return $? + fi tst_rhost_run -c "ip link set $iface up" }
@@ -606,7 +636,9 @@ tst_restore_ipaddr() local ret=0 local backup_tst_ipv6=$TST_IPV6 TST_IPV6= tst_add_ipaddr $type $link_num || ret=$? - TST_IPV6=6 tst_add_ipaddr $type $link_num || ret=$? + if [ "$TST_NET_LHOST_IPV6" = 1 ]; then + TST_IPV6=6 tst_add_ipaddr $type $link_num || ret=$? + fi TST_IPV6=$backup_tst_ipv6 return $ret
@@ -971,8 +1003,16 @@ IPV6_RHOST="${IPV6_RHOST:-fd00:1:1:1::1/64}" if [ -z "$_tst_net_parse_variables" ]; then eval $(tst_net_ip_prefix $IPV4_LHOST || echo "exit $?") eval $(tst_net_ip_prefix -r $IPV4_RHOST || echo "exit $?") - eval $(tst_net_ip_prefix $IPV6_LHOST || echo "exit $?") - eval $(tst_net_ip_prefix -r $IPV6_RHOST || echo "exit $?") + + tst_net_detect_ipv6 && TST_NET_LHOST_IPV6=1 + tst_net_detect_ipv6 rhost && TST_NET_RHOST_IPV6=1 + + if [ "$TST_NET_LHOST_IPV6" = 1 ]; then + eval $(tst_net_ip_prefix $IPV6_LHOST || echo "exit $?") + fi + if [ "$TST_NET_RHOST_IPV6" = 1 ]; then + eval $(tst_net_ip_prefix -r $IPV6_RHOST || echo "exit $?") + fi fi [ -n "$TST_USE_NETNS" -a "$TST_INIT_NETNS" != "no" ] && init_ltp_netspace
@@ -981,19 +1021,29 @@ if [ -z "$_tst_net_parse_variables" ]; then eval $(tst_net_iface_prefix $IPV4_LHOST || echo "exit $?") eval $(tst_rhost_run -c 'tst_net_iface_prefix -r '$IPV4_RHOST \ || echo "exit $?") - eval $(tst_net_iface_prefix $IPV6_LHOST || echo "exit $?") - eval $(tst_rhost_run -c 'tst_net_iface_prefix -r '$IPV6_RHOST \ - || echo "exit $?") + + if [ "$TST_NET_LHOST_IPV6" = 1 ]; then + eval $(tst_net_iface_prefix $IPV6_LHOST || echo "exit $?") + fi + + if [ "$TST_NET_RHOST_IPV6" = 1 ]; then + eval $(tst_rhost_run -c 'tst_net_iface_prefix -r '$IPV6_RHOST \ + || echo "exit $?") + fi eval $(tst_net_vars $IPV4_LHOST/$IPV4_LPREFIX \ $IPV4_RHOST/$IPV4_RPREFIX || echo "exit $?") - eval $(tst_net_vars $IPV6_LHOST/$IPV6_LPREFIX \ - $IPV6_RHOST/$IPV6_RPREFIX || echo "exit $?") + + if [ "$TST_NET_LHOST_IPV6" = 1 ]; then + eval $(tst_net_vars $IPV6_LHOST/$IPV6_LPREFIX \ + $IPV6_RHOST/$IPV6_RPREFIX || echo "exit $?") + fi tst_res_ TINFO "Network config (local -- remote):" tst_res_ TINFO "$LHOST_IFACES -- $RHOST_IFACES" tst_res_ TINFO "$IPV4_LHOST/$IPV4_LPREFIX -- $IPV4_RHOST/$IPV4_RPREFIX" tst_res_ TINFO "$IPV6_LHOST/$IPV6_LPREFIX -- $IPV6_RHOST/$IPV6_RPREFIX" + export _tst_net_parse_variables="yes" fi
Signature · 5 lines
2.34.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 2/2 broken_ip-nexthdr.sh: Check IPv6 support before forcing it
From: Petr Vorel <[email protected]>
--- testcases/network/stress/broken_ip/broken_ip-nexthdr.sh | 1 + 1 file changed, 1 insertion(+)
testcases/network/stress/broken_ip/broken_ip-nexthdr.sh +1 -0
@@ -11,6 +11,7 @@ TST_TESTFUNC="do_test" do_test() { # not supported on IPv4 + tst_net_require_ipv6 TST_IPV6=6 TST_IPVER=6
Signature · 5 lines
2.34.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi,
I forget to add v2.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Petr,
Quoted 109 lines · Petr Vorel
From: Petr Vorel <[email protected]>
Tests failed in
tst_init_ifaceeven IPv4 only test was run. Allow to init interfaces at least for IPv4.Tests which use TST_IPV6=6 needs to be fixed (unless they use just
tst_ipaddr_un()).Store result into TST_NET_{L,R}HOST_IPV6 in order to cache the result.
Signed-off-by Petr Vorel <[email protected]>---
Changesv1->v2:
* cache variables with $TST_NET_{L,R}HOST_IPV6 (mdoucha)
NOTE: although I'd prefer to cache the result internally and use function for detection,tst_net.shuses variables for most of the things, thus keep it this way.Kind regards,
Petrtestcases/lib/tst_net.sh | 72 ++++++++++++++++++++++++++++++++++------ 1 file changed, 61 insertions(+), 11 deletions(-)testcases/lib/tst_net.sh +36
-6@@ -24,7 +24,9 @@ TST_IPV6_FLAG=${TST_IPV6_FLAG:-} tst_net_parse_args() { case $1 in - 6) TST_IPV6=6 TST_IPVER=6 TST_IPV6_FLAG="-6";; + 6) tst_net_require_ipv6 + TST_IPV6=6 TST_IPVER=6 TST_IPV6_FLAG="-6" + ;; *) [ "$TST_PARSE_ARGS_CALLER" ] && $TST_PARSE_ARGS_CALLER "$1" "$2";; esac }@@ -100,6 +102,30 @@ tst_brk_() [ -z "$TST_USE_LEGACY_API" ] && tst_brk $@ || tst_brkm $@ } +tst_net_detect_ipv6() +{ + local type="${1:-lhost}" + local cmd='[ -f /proc/net/if_inet6 ]' + + if [ "$type" = "lhost" ]; then + $cmd + return $? + fi + + tst_rhost_run -c "$cmd" + return $? +} + +tst_net_require_ipv6() +{ + local err="IPv6 not supported on:" + local missing + + [ "$TST_NET_LHOST_IPV6" = 1 ] || missing=" lhost" + [ "$TST_NET_RHOST_IPV6" = 1 ] || missing="$missing rhost" + [ -z "$missing" ] || tst_brk_ TCONF "$err$missing" +} + init_ltp_netspace() { local pid@@ -517,7 +543,9 @@ tst_init_iface() ip link set $iface down || return $? ip route flush dev $iface || return $? ip addr flush dev $iface || return $? - sysctl -qw net.ipv6.conf.$iface.accept_dad=0 || return $? + if [ "$TST_NET_LHOST_IPV6" = 1 ]; then + sysctl -qw net.ipv6.conf.$iface.accept_dad=0 || return $? + fi ip link set $iface up return $? fi@@ -529,7 +557,9 @@ tst_init_iface() tst_rhost_run -c "ip link set $iface down" || return $? tst_rhost_run -c "ip route flush dev $iface" || return $? tst_rhost_run -c "ip addr flush dev $iface" || return $? - tst_rhost_run -c "sysctl -qw net.ipv6.conf.$iface.accept_dad=0" || return $? + if [ "$TST_NET_RHOST_IPV6" = 1 ]; then + tst_rhost_run -c "sysctl -qw net.ipv6.conf.$iface.accept_dad=0" || return $? + fi tst_rhost_run -c "ip link set $iface up" }@@ -606,7 +636,9 @@ tst_restore_ipaddr() local ret=0 local backup_tst_ipv6=$TST_IPV6 TST_IPV6= tst_add_ipaddr $type $link_num || ret=$? - TST_IPV6=6 tst_add_ipaddr $type $link_num || ret=$? + if [ "$TST_NET_LHOST_IPV6" = 1 ]; then + TST_IPV6=6 tst_add_ipaddr $type $link_num || ret=$? + fi TST_IPV6=$backup_tst_ipv6 return $ret@@ -971,8 +1003,16 @@ IPV6_RHOST="${IPV6_RHOST:-fd00:1:1:1::1/64}" if [ -z "$_tst_net_parse_variables" ]; then eval $(tst_net_ip_prefix $IPV4_LHOST || echo "exit $?") eval $(tst_net_ip_prefix -r $IPV4_RHOST || echo "exit $?") - eval $(tst_net_ip_prefix $IPV6_LHOST || echo "exit $?") - eval $(tst_net_ip_prefix -r $IPV6_RHOST || echo "exit $?")
testcases/lib/tst_net.sh IPV6_RHOST="${IPV6_RHOST:-fd00:1:1:1::1/64}" · line 1015
Quoted 10 lines
testcases/lib/tst_net.sh +10
-0+ + tst_net_detect_ipv6 && TST_NET_LHOST_IPV6=1 + tst_net_detect_ipv6 rhost && TST_NET_RHOST_IPV6=1 + + if [ "$TST_NET_LHOST_IPV6" = 1 ]; then + eval $(tst_net_ip_prefix $IPV6_LHOST || echo "exit $?") + fi + if [ "$TST_NET_RHOST_IPV6" = 1 ]; then + eval $(tst_net_ip_prefix -r $IPV6_RHOST || echo "exit $?") + fi
Do we really need to keep around and check two variables? If at least one machine doesn't have IPv6, it's not longer necessary to setup the other.
Quoted 38 lines
testcases/lib/tst_net.sh +15
-5fi [ -n "$TST_USE_NETNS" -a "$TST_INIT_NETNS" != "no" ] && init_ltp_netspace@@ -981,19 +1021,29 @@ if [ -z "$_tst_net_parse_variables" ]; then eval $(tst_net_iface_prefix $IPV4_LHOST || echo "exit $?") eval $(tst_rhost_run -c 'tst_net_iface_prefix -r '$IPV4_RHOST \ || echo "exit $?") - eval $(tst_net_iface_prefix $IPV6_LHOST || echo "exit $?") - eval $(tst_rhost_run -c 'tst_net_iface_prefix -r '$IPV6_RHOST \ - || echo "exit $?") + + if [ "$TST_NET_LHOST_IPV6" = 1 ]; then + eval $(tst_net_iface_prefix $IPV6_LHOST || echo "exit $?") + fi + + if [ "$TST_NET_RHOST_IPV6" = 1 ]; then + eval $(tst_rhost_run -c 'tst_net_iface_prefix -r '$IPV6_RHOST \ + || echo "exit $?") + fi eval $(tst_net_vars $IPV4_LHOST/$IPV4_LPREFIX \ $IPV4_RHOST/$IPV4_RPREFIX || echo "exit $?") - eval $(tst_net_vars $IPV6_LHOST/$IPV6_LPREFIX \ - $IPV6_RHOST/$IPV6_RPREFIX || echo "exit $?") + + if [ "$TST_NET_LHOST_IPV6" = 1 ]; then + eval $(tst_net_vars $IPV6_LHOST/$IPV6_LPREFIX \ + $IPV6_RHOST/$IPV6_RPREFIX || echo "exit $?") + fi tst_res_ TINFO "Network config (local -- remote):" tst_res_ TINFO "$LHOST_IFACES -- $RHOST_IFACES" tst_res_ TINFO "$IPV4_LHOST/$IPV4_LPREFIX -- $IPV4_RHOST/$IPV4_RPREFIX" tst_res_ TINFO "$IPV6_LHOST/$IPV6_LPREFIX -- $IPV6_RHOST/$IPV6_RPREFIX" + export _tst_net_parse_variables="yes" fi
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Alexey, all,
...
Quoted 12 lines
Quoted 12 lines
testcases/lib/tst_net.sh +6
-2@@ -971,8 +1003,16 @@ IPV6_RHOST="${IPV6_RHOST:-fd00:1:1:1::1/64}" if [ -z "$_tst_net_parse_variables" ]; then eval $(tst_net_ip_prefix $IPV4_LHOST || echo "exit $?") eval $(tst_net_ip_prefix -r $IPV4_RHOST || echo "exit $?") - eval $(tst_net_ip_prefix $IPV6_LHOST || echo "exit $?") - eval $(tst_net_ip_prefix -r $IPV6_RHOST || echo "exit $?") + + tst_net_detect_ipv6 && TST_NET_LHOST_IPV6=1 + tst_net_detect_ipv6 rhost && TST_NET_RHOST_IPV6=1 + + if [ "$TST_NET_LHOST_IPV6" = 1 ]; then + eval $(tst_net_ip_prefix $IPV6_LHOST || echo "exit $?")
Quoted 8 lines
testcases/lib/tst_net.sh IPV6_RHOST="${IPV6_RHOST:-fd00:1:1:1::1/64}" · line 1015
Quoted 4 lines
testcases/lib/tst_net.sh +4
-0+ fi + if [ "$TST_NET_RHOST_IPV6" = 1 ]; then + eval $(tst_net_ip_prefix -r $IPV6_RHOST || echo "exit $?") + fiDo we really need to keep around and check two variables? If at least one machine doesn't have IPv6, it's not longer necessary to setup the other.
OK, just one variable is enough, e.g. TST_NET_REQUIRE_IPV6.
@all: But netns_helper.sh, which does not use tst_net.sh also requires IPv6 (and there are probably more), thus how about adding flag TST_REQUIRE_IPV6 into tst_test.sh (would help also for documentation - docparse). And tst_net.sh would just on check also IPv6 on rhost.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi all,
Quoted 24 lines
Hi Alexey, all,
...
Quoted 12 lines
Quoted 12 lines
testcases/lib/tst_net.sh +6
-2@@ -971,8 +1003,16 @@ IPV6_RHOST="${IPV6_RHOST:-fd00:1:1:1::1/64}" if [ -z "$_tst_net_parse_variables" ]; then eval $(tst_net_ip_prefix $IPV4_LHOST || echo "exit $?") eval $(tst_net_ip_prefix -r $IPV4_RHOST || echo "exit $?") - eval $(tst_net_ip_prefix $IPV6_LHOST || echo "exit $?") - eval $(tst_net_ip_prefix -r $IPV6_RHOST || echo "exit $?") + + tst_net_detect_ipv6 && TST_NET_LHOST_IPV6=1 + tst_net_detect_ipv6 rhost && TST_NET_RHOST_IPV6=1 + + if [ "$TST_NET_LHOST_IPV6" = 1 ]; then + eval $(tst_net_ip_prefix $IPV6_LHOST || echo "exit $?")Quoted 8 lines
testcases/lib/tst_net.sh IPV6_RHOST="${IPV6_RHOST:-fd00:1:1:1::1/64}" · line 1015
Quoted 4 lines
testcases/lib/tst_net.sh +4
-0+ fi + if [ "$TST_NET_RHOST_IPV6" = 1 ]; then + eval $(tst_net_ip_prefix -r $IPV6_RHOST || echo "exit $?") + fiDo we really need to keep around and check two variables? If at least one machine doesn't have IPv6, it's not longer necessary to setup the other.
Quoted 5 lines
OK, just one variable is enough, e.g.
TST_NET_REQUIRE_IPV6.@all: But
netns_helper.sh, which does not usetst_net.shalso requires IPv6 (and there are probably more), thus how about adding flagTST_REQUIRE_IPV6intotst_test.sh(would help also for documentation - docparse).
Going to add it to v3.
Quoted 1 line
And
tst_net.shwould just on check also IPv6 on rhost.
I found that no C test needs a special flag for handling IPv6 because we can filter it with errno EAFNOSUPPORT. We should just remember tests first use IPv4 (e.g. in bind05.c), because functions behind SAFE_* macros use tst_brk.
@Cyril: I suppose we don't want to have kind of info flag "uses_ipv6" in C API (for docparse), right?
Kind regards,
Petr
Quoted 2 lines
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp