Skip to contentSkip to conversation

shell: Fixes for disabled IPv6

PATCH In review Petr Vorel 2 participants 10 messages May 10, 2022 Library code

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

v3 cover shell: Fixes for disabled IPv6

Hi,

changes v2->v3:
* removed commit "broken_ip-nexthdr.sh: Check IPv6 support before forcing it" (not needed after 04021637f ("tst_test.sh: Cleanup getopts usage")
* rebased "netns: Rewrite to use tst_net.sh"
* new commit "netns: Rename netns_helper.sh -> netns_lib.sh"

NOTE: network shell tests which use legacy API (i.e. TST_USE_LEGACY_API=1) are still broken. But I'd prefer to fix them by converting to new API (i.e. tcpdump01.sh, mc_*.sh). Some of them we might consider to delete instead of rewrite (telnet01.sh, ftp-{download,upload}-stress.sh, {dns,http}-stress.sh, ... rup01.sh and rusers01.sh has already been asked to delete [1]).

[1] https://patchwork.ozlabs.org/project/ltp/list/?series=297407

Petr Vorel (3):
tst_net.sh: Fix for disabled IPv6
netns: Rewrite to use tst_net.sh
netns: Rename netns_helper.sh -> netns_lib.sh

 runtest/containers                            |  32 +-
 .../kernel/containers/netns/netns_breakns.sh  |  33 +--
 .../kernel/containers/netns/netns_comm.sh     |  57 +---
 .../kernel/containers/netns/netns_helper.sh   | 279 ------------------
 .../kernel/containers/netns/netns_lib.sh      | 227 ++++++++++++++
 testcases/lib/tst_net.sh                      |  69 ++++-
 6 files changed, 317 insertions(+), 380 deletions(-)
 delete mode 100755 testcases/kernel/containers/netns/netns_helper.sh
 create mode 100755 testcases/kernel/containers/netns/netns_lib.sh
Signature · 5 lines
2.36.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#1 lore raw

PATCH v3 1/3 tst_net.sh: Fix for disabled IPv6

Tests failed in tst_init_iface even IPv4 only test was run. Allow to init interfaces at least for IPv4.

We need IPv6 enabled on both endpoints to be usable,
unless test use TST_NET_SKIP_VARIABLE_INIT=1, i.e. use network library functions but no test links (atm just library test tst_ipaddr_un.sh, but netns_helper.sh will also use it). In this case only IPv6 on lhost is tested.

Tests which use TST_IPV6=6 to force IPv6 (atm just broken_ip-nexthdr.sh) need to be fixed, unless they use just tst_ipaddr_un() (e.g. library test tst_ipaddr_un.sh).

Store result into $TST_NET_IPV6_ENABLED.

---
changes v2->v3:
Rebased. tst_net_require_ipv6 is now in tst_net_setup() instead in tst_net_parse_args().

 testcases/lib/tst_net.sh | 69 ++++++++++++++++++++++++++++++++++------
 1 file changed, 59 insertions(+), 10 deletions(-)
testcases/lib/tst_net.sh +59 -10
index b27b7e51c..29d80df89 100644
@@ -59,6 +59,8 @@ tst_net_remote_tmpdir()
 
 tst_net_setup()
 {
+	[ "$TST_IPVER" = 6 ] && tst_net_require_ipv6
+
 	tst_net_remote_tmpdir
 	[ -n "$TST_SETUP_CALLER" ] && $TST_SETUP_CALLER
 
@@ -98,6 +100,31 @@ 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 ]'
+	local ret
+
+	if [ "$type" = "lhost" ]; then
+		$cmd
+	else
+		tst_rhost_run -c "$cmd"
+	fi
+	ret=$?
+
+	if [ $ret -eq 0 ]; then
+		TST_NET_IPV6_ENABLED=1
+	else
+		tst_res TINFO "IPv6 disabled on $type"
+	fi
+}
+
+tst_net_require_ipv6()
+{
+	[ "$TST_NET_IPV6_ENABLED" = 1 ] || tst_brk_ TCONF "IPv6 disabled"
+}
+
 init_ltp_netspace()
 {
 	local pid
@@ -515,7 +542,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_IPV6_ENABLED" = 1 ]; then
+			sysctl -qw net.ipv6.conf.$iface.accept_dad=0 || return $?
+		fi
 		ip link set $iface up
 		return $?
 	fi
@@ -527,7 +556,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_IPV6_ENABLED" = 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"
 }
 
@@ -604,7 +635,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_IPV6_ENABLED" = 1 ]; then
+		TST_IPV6=6 tst_add_ipaddr $type $link_num || ret=$?
+	fi
 	TST_IPV6=$backup_tst_ipv6
 
 	return $ret
@@ -936,6 +969,10 @@ tst_default_max_pkt()
 }
 
 [ -n "$TST_USE_LEGACY_API" ] && . test.sh || . tst_test.sh
+
+# detect IPv6 support on lhost for tests which don't use test links
+tst_net_detect_ipv6
+
 [ -n "$TST_NET_SKIP_VARIABLE_INIT" ] && return 0
 
 # Management Link
@@ -970,8 +1007,13 @@ 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 rhost
+
+	if [ "$TST_NET_IPV6_ENABLED" = 1 ]; then
+		eval $(tst_net_ip_prefix $IPV6_LHOST || echo "exit $?")
+		eval $(tst_net_ip_prefix -r $IPV6_RHOST || echo "exit $?")
+	fi
 fi
 
 [ -n "$TST_USE_NETNS" -a "$TST_INIT_NETNS" != "no" ] && init_ltp_netspace
@@ -980,19 +1022,26 @@ 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_IPV6_ENABLED" = 1 ]; then
+		eval $(tst_net_iface_prefix $IPV6_LHOST || echo "exit $?")
+		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_IPV6_ENABLED" = 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.36.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

Re: [LTP] [PATCH v3 1/3] tst_net.sh: Fix for disabled IPv6

Hi!

Quoted 75 lines
testcases/lib/tst_net.sh +38 -3
+tst_net_detect_ipv6()
+{
+	local type="${1:-lhost}"
+	local cmd='[ -f /proc/net/if_inet6 ]'
+	local ret
+
+	if [ "$type" = "lhost" ]; then
+		$cmd
+	else
+		tst_rhost_run -c "$cmd"
+	fi
+	ret=$?
+
+	if [ $ret -eq 0 ]; then
+		TST_NET_IPV6_ENABLED=1
+	else
+		tst_res TINFO "IPv6 disabled on $type"
+	fi
+}
+
+tst_net_require_ipv6()
+{
+	[ "$TST_NET_IPV6_ENABLED" = 1 ] || tst_brk_ TCONF "IPv6 disabled"
+}
+
 init_ltp_netspace()
 {
 	local pid
@@ -515,7 +542,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_IPV6_ENABLED" = 1 ]; then
+			sysctl -qw net.ipv6.conf.$iface.accept_dad=0 || return $?
+		fi
 		ip link set $iface up
 		return $?
 	fi
@@ -527,7 +556,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_IPV6_ENABLED" = 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"
 }
 
@@ -604,7 +635,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_IPV6_ENABLED" = 1 ]; then
+		TST_IPV6=6 tst_add_ipaddr $type $link_num || ret=$?
+	fi
 	TST_IPV6=$backup_tst_ipv6
 
 	return $ret
@@ -936,6 +969,10 @@ tst_default_max_pkt()
 }
 
 [ -n "$TST_USE_LEGACY_API" ] && . test.sh || . tst_test.sh
+
+# detect IPv6 support on lhost for tests which don't use test links
+tst_net_detect_ipv6
+
 [ -n "$TST_NET_SKIP_VARIABLE_INIT" ] && return 0
 
 # Management Link
@@ -970,8 +1007,13 @@ 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 $?")

testcases/lib/tst_net.sh IPV6_RHOST="${IPV6_RHOST:-fd00:1:1:1::1/64}" · line 1016

Quoted 10 lines
testcases/lib/tst_net.sh +7 -2
 	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 rhost
+
+	if [ "$TST_NET_IPV6_ENABLED" = 1 ]; then
+		eval $(tst_net_ip_prefix $IPV6_LHOST || echo "exit $?")
+		eval $(tst_net_ip_prefix -r $IPV6_RHOST || echo "exit $?")
+	fi

If I'm looking right at this piece of code we do run the tst_net_detect_ipv6 twice once for lhost and once for rhost when the script is sourced and we only set the TST_NET_IPV6_ENABLED when the check succeeds, right?

Shouldn't we also unset it when the check fails because otherwise the check for rhost is basically no-op as long as the lhost supports ipv6?

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#3 lore raw

Re: [LTP] [PATCH v3 1/3] tst_net.sh: Fix for disabled IPv6

Hi Cyril,

...

Quoted 16 lines
Quoted 16 lines
(quoted diff) +7 -2
+# detect IPv6 support on lhost for tests which don't use test links
+tst_net_detect_ipv6
+
 [ -n "$TST_NET_SKIP_VARIABLE_INIT" ] && return 0
 
 # Management Link
@@ -970,8 +1007,13 @@ 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 rhost
+
+	if [ "$TST_NET_IPV6_ENABLED" = 1 ]; then
Quoted 8 lines

Review IPV6_RHOST="${IPV6_RHOST:-fd00:1:1:1::1/64}" · line 1016

Quoted 3 lines
(quoted diff) +3 -0
+		eval $(tst_net_ip_prefix $IPV6_LHOST || echo "exit $?")
+		eval $(tst_net_ip_prefix -r $IPV6_RHOST || echo "exit $?")
+	fi

If I'm looking right at this piece of code we do run the tst_net_detect_ipv6 twice once for lhost and once for rhost when the script is sourced and we only set the TST_NET_IPV6_ENABLED when the check succeeds, right?

Yes.

FYI 2 tests run only first run for lhost - these which use TST_NET_SKIP_VARIABLE_INIT=1:
* lib/newlib_tests/shell/net/tst_ipaddr_un.sh (which does not need this feature as test runs for both IPv4 and IPv6 and does not need IPv6 functionality)
* and with this patchset also for testcases/kernel/containers/netns/netns_lib.sh netns tests require IPv6 only for lhost, thus that's enough for TST_NET_SKIP_VARIABLE_INIT=1

Quoted 2 lines

Shouldn't we also unset it when the check fails because otherwise the check for rhost is basically no-op as long as the lhost supports ipv6?

Hm, that's right. Patch below would will fix it.
Anyway I'm not much happy with tst_net_detect_ipv6 setting global variable $TST_NET_IPV6_ENABLED. But I wanted to stay compatible with the rest of tst_net.sh, which becomes more an more messy (rewriting/deleting old tests will allow cleanup code for TST_USE_LEGACY_API=1). Anyway, feel free to suggest something better.

Kind regards,
Petr

lib/tst_net.sh +1 -1
index 29d80df89..48dd6e8eb 100644
@@ -1008,7 +1008,7 @@ 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 $?")
 
-       tst_net_detect_ipv6 rhost
+       [ "$TST_NET_IPV6_ENABLED" = 1 ] && tst_net_detect_ipv6 rhost
 
        if [ "$TST_NET_IPV6_ENABLED" = 1 ]; then
                eval $(tst_net_ip_prefix $IPV6_LHOST || echo "exit $?")
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw

Re: [LTP] [PATCH v3 1/3] tst_net.sh: Fix for disabled IPv6

Hi!

lib/tst_net.sh if [ -z "$_tst_net_parse_variables" ]; then · line 1011

Quoted 10 lines
lib/tst_net.sh +1 -1
index 29d80df89..48dd6e8eb 100644
@@ -1008,7 +1008,7 @@ 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 $?")
 
-       tst_net_detect_ipv6 rhost
+       [ "$TST_NET_IPV6_ENABLED" = 1 ] && tst_net_detect_ipv6 rhost

That solves the case where lhost does not support ipv6 but rhost does, but there is still case where lhost does support it but rhost does not, to fix that we have to clear TST_NET_IPV6_ENABLED in the tst_net_detect_ipv6() as well.

	if [ $ret -eq 0 ]; then
		TST_NET_IPV6_ENABLED=1
	else
		TST_NET_IPV6_ENABLED=0
		tst_res TINFO "IPv6 disabled on $type"
	fi
Quoted 4 lines
lib/tst_net.sh +0 -0
        if [ "$TST_NET_IPV6_ENABLED" = 1 ]; then
                eval $(tst_net_ip_prefix $IPV6_LHOST || echo "exit $?")
 
Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#5 lore raw

Re: [LTP] [PATCH v3 1/3] tst_net.sh: Fix for disabled IPv6

Hi Cyril,

Quoted 7 lines

lib/tst_net.sh if [ -z "$_tst_net_parse_variables" ]; then · line 1011

Quoted 2 lines
lib/tst_net.sh +1 -1
-       tst_net_detect_ipv6 rhost
+       [ "$TST_NET_IPV6_ENABLED" = 1 ] && tst_net_detect_ipv6 rhost

That solves the case where lhost does not support ipv6 but rhost does, but there is still case where lhost does support it but rhost does not, to fix that we have to clear TST_NET_IPV6_ENABLED in the tst_net_detect_ipv6() as well.

Ah, correct, thanks!

Quoted 4 lines
	if [ $ret -eq 0 ]; then
		TST_NET_IPV6_ENABLED=1
	else
		TST_NET_IPV6_ENABLED=0

nit: I'd slightly prefer to use TST_NET_IPV6_ENABLED=

Quoted 2 lines

tst_res TINFO "IPv6 disabled on $type"
fi

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#6 lore raw

PATCH v3 2/3 netns: Rewrite to use tst_net.sh

In reply to Petr Vorel

Use TST_NET_SKIP_VARIABLE_INIT=1 thus we get network library functionality but use it's own test links.

Using tst_net.sh provides:
* detection of disabled IPv6
* -6 support instead of specifying ipv4/ipv6
* ping6 detection
* use tst_ipaddr_un() to get unused addresses instead of basic ranges 192.168.0.x / fd00::x

Also
* cleanup other parameter handling - instead of passing 7 parameters to the setup use as the default the modern variants (ip and netlink), use switches for other variants (ns_exec and ifconfig)
* use ROD to shorten code
* cleanup duplicate doc

TODO: Test should be further cleanup to use tst_rhost_run over different LTP_NETNS and tst_ping instead of $tping (changes already big enough).

---
changes v2->v3:
* Rebased. $do_cleanup is now required. There could be a variable in tst_net.sh or even tst_test.sh to signal that setup function passed, but let's postpone it for now.
* Moved TST_TESTFUNC="do_test" into test files, rest of the variables in netns_helper.sh.
* Use conditional expansion for TST_{SETUP,CLEANUP}.

 runtest/containers                            |  32 +--
 .../kernel/containers/netns/netns_breakns.sh  |  31 +--
 .../kernel/containers/netns/netns_comm.sh     |  55 +---
 .../kernel/containers/netns/netns_helper.sh   | 238 +++++++-----------
 4 files changed, 122 insertions(+), 234 deletions(-)
runtest/containers +16 -16
index eea7bfadb..ab0b94f51 100644
@@ -25,22 +25,22 @@ mqns_04 mqns_04
 mqns_04_clone mqns_04 -clone
 
 netns_netlink netns_netlink
-netns_breakns_ns_exec_ipv4_netlink netns_breakns.sh ns_exec ipv4 netlink
-netns_breakns_ns_exec_ipv6_netlink netns_breakns.sh ns_exec ipv6 netlink
-netns_breakns_ns_exec_ipv4_ioctl netns_breakns.sh ns_exec ipv4 ioctl
-netns_breakns_ns_exec_ipv6_ioctl netns_breakns.sh ns_exec ipv6 ioctl
-netns_breakns_ip_ipv4_netlink netns_breakns.sh ip ipv4 netlink
-netns_breakns_ip_ipv6_netlink netns_breakns.sh ip ipv6 netlink
-netns_breakns_ip_ipv4_ioctl netns_breakns.sh ip ipv4 ioctl
-netns_breakns_ip_ipv6_ioctl netns_breakns.sh ip ipv6 ioctl
-netns_comm_ns_exec_ipv4_netlink netns_comm.sh ns_exec ipv4 netlink
-netns_comm_ns_exec_ipv6_netlink netns_comm.sh ns_exec ipv6 netlink
-netns_comm_ns_exec_ipv4_ioctl netns_comm.sh ns_exec ipv4 ioctl
-netns_comm_ns_exec_ipv6_ioctl netns_comm.sh ns_exec ipv6 ioctl
-netns_comm_ip_ipv4_netlink netns_comm.sh ip ipv4 netlink
-netns_comm_ip_ipv6_netlink netns_comm.sh ip ipv6 netlink
-netns_comm_ip_ipv4_ioctl netns_comm.sh ip ipv4 ioctl
-netns_comm_ip_ipv6_ioctl netns_comm.sh ip ipv6 ioctl
+netns_breakns_ip_ipv4_netlink netns_breakns.sh
+netns_breakns_ip_ipv6_netlink netns_breakns.sh -6
+netns_breakns_ip_ipv4_ioctl netns_breakns.sh -I
+netns_breakns_ip_ipv6_ioctl netns_breakns.sh -6I
+netns_breakns_ns_exec_ipv4_netlink netns_breakns.sh -e
+netns_breakns_ns_exec_ipv6_netlink netns_breakns.sh -6e
+netns_breakns_ns_exec_ipv4_ioctl netns_breakns.sh -eI
+netns_breakns_ns_exec_ipv6_ioctl netns_breakns.sh -6eI
+netns_comm_ip_ipv4_netlink netns_comm.sh
+netns_comm_ip_ipv6_netlink netns_comm.sh -6
+netns_comm_ip_ipv4_ioctl netns_comm.sh -I
+netns_comm_ip_ipv6_ioctl netns_comm.sh -6I
+netns_comm_ns_exec_ipv4_netlink netns_comm.sh -e
+netns_comm_ns_exec_ipv6_netlink netns_comm.sh -6e
+netns_comm_ns_exec_ipv4_ioctl netns_comm.sh -eI
+netns_comm_ns_exec_ipv6_ioctl netns_comm.sh -6eI
 netns_sysfs netns_sysfs.sh
 
 shmnstest_none shmnstest none
testcases/kernel/containers/netns/netns_breakns.sh +2 -29
index b7f255cb8..0b2eb319c 100755
@@ -1,23 +1,9 @@
 #!/bin/sh
 # SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2022 Petr Vorel <[email protected]>
 # Copyright (c) Köry Maincent <[email protected]> 2020
 # Copyright (c) 2015 Red Hat, Inc.
 #
-# SYNOPSIS:
-# netns_breakns.sh <NS_EXEC_PROGRAM> <IP_VERSION> <COMM_TYPE>
-#
-# OPTIONS:
-#	* NS_EXEC_PROGRAM (ns_exec|ip)
-#		Program which will be used to enter and run other commands
-#		inside a network namespace.
-#	* IP_VERSION (ipv4|ipv6)
-#		Version of IP. (ipv4|ipv6)
-#	* COMM_TYPE (netlink|ioctl)
-#		Communication type between kernel and user space
-#		for basic setup: enabling and assigning IP addresses
-#		to the virtual ethernet devices. (Uses 'ip' command for netlink
-#		and 'ifconfig' for ioctl.)
-#
 # Tests communication with ip (uses netlink) and ifconfig (uses ioctl)
 # over a device which is not visible from the current network namespace.
 #
@@ -26,15 +12,7 @@
 # 1. using netlink (ip command).
 # 2. using ioctl (ifconfig command).
 
-TST_POS_ARGS=3
-TST_SETUP=do_setup
-TST_TESTFUNC=do_test
-
-do_setup()
-{
-	netns_setup $PROG $IP_VER $COM_TYPE "192.168.0.2" "192.168.0.3" "fd00::2" "fd00::3"
-	tst_res TINFO "NS interaction: $PROG | devices setup: $COM_TYPE"
-}
+TST_TESTFUNC="do_test"
 
 do_test()
 {
@@ -45,9 +23,4 @@ do_test()
 }
 
 . netns_helper.sh
-
-PROG=$1
-IP_VER=$2
-COM_TYPE=$3
-
 tst_run
testcases/kernel/containers/netns/netns_comm.sh +11 -44

77 lines not on this page · raw message

testcases/kernel/containers/netns/netns_helper.sh +93 -145

298 lines not on this page · raw message

Signature · 5 lines
2.36.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#7 lore raw

Re: [LTP] [PATCH v3 2/3] netns: Rewrite to use tst_net.sh

Hi!

Quoted 9 lines
testcases/kernel/containers/netns/netns_helper.sh +9 -0
+# Communication type between kernel and user space for basic setup: enabling and
+# assigning IP addresses to the virtual ethernet devices. (Uses 'ip' command for
+# netlink and 'ifconfig' for ioctl.)
+# (netlink|ioctl)
+COMM_TYPE="netlink"
+
+do_cleanup=
+
+netns_parse_args()

testcases/kernel/containers/netns/netns_helper.sh NS_HANDLE1= · line 64

Quoted 10 lines
testcases/kernel/containers/netns/netns_helper.sh +10 -0
+{
+	case $1 in
+	e) NS_EXEC="ns_exec" ;;
+	I) COMM_TYPE="ioctl"; tst_require_cmds ifconfig ;;
+	esac
+}
+
+netns_usage()
+{
+	echo "usage: $0 [ -e ] [ -t ]"
                                  ^
				  -I

testcases/kernel/containers/netns/netns_helper.sh NS_HANDLE1= · line 68

Quoted 4 lines
testcases/kernel/containers/netns/netns_helper.sh +4 -0
+	echo "OPTIONS"
+	echo "-e use ns_exec instead of ip"
+	echo "-I test ioctl (with ifconfig) instead of netlink (with ip)"
+}

Otherwise it looks like a nice cleanup.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#8 lore raw

Re: [LTP] [PATCH v3 2/3] netns: Rewrite to use tst_net.sh

Hi Cyril,

...

Quoted 11 lines

testcases/kernel/containers/netns/netns_helper.sh NS_HANDLE1= · line 64

Quoted 3 lines
testcases/kernel/containers/netns/netns_helper.sh +3 -0
+netns_usage()
+{
+	echo "usage: $0 [ -e ] [ -t ]"
                                  ^
				  -I

testcases/kernel/containers/netns/netns_helper.sh NS_HANDLE1= · line 68

Quoted 4 lines
testcases/kernel/containers/netns/netns_helper.sh +4 -0
+	echo "OPTIONS"
+	echo "-e use ns_exec instead of ip"
+	echo "-I test ioctl (with ifconfig) instead of netlink (with ip)"
+}

Otherwise it looks like a nice cleanup.

Good catch, thanks!
FYI I have more plans, i.e. use tst_rhost_run(), but that will come after the release.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#9 lore raw

PATCH v3 3/3 netns: Rename netns_helper.sh -> netns_lib.sh

In reply to Petr Vorel

LTP shell libraries are called *_lib.sh.

---
New in v3

 testcases/kernel/containers/netns/netns_breakns.sh              | 2 +-
 testcases/kernel/containers/netns/netns_comm.sh                 | 2 +-
 .../kernel/containers/netns/{netns_helper.sh => netns_lib.sh}   | 0
 3 files changed, 2 insertions(+), 2 deletions(-)
 rename testcases/kernel/containers/netns/{netns_helper.sh => netns_lib.sh} (100%)
testcases/kernel/containers/netns/netns_breakns.sh +1 -1
index 0b2eb319c..a5cec0953 100755
@@ -22,5 +22,5 @@ do_test()
 	EXPECT_FAIL $NS_EXEC $NS_HANDLE0 $NS_TYPE ifconfig veth1 $IFCONF_IN6_ARG $IP1/$NETMASK
 }
 
-. netns_helper.sh
+. netns_lib.sh
 tst_run
testcases/kernel/containers/netns/netns_comm.sh +1 -1
index 6570f386e..c7c2ae07a 100755
@@ -34,5 +34,5 @@ do_test()
 	EXPECT_PASS $NS_EXEC $NS_HANDLE0 $NS_TYPE $tping -q -c2 -I lo $ip_lo 1>/dev/null
 }
 
-. netns_helper.sh
+. netns_lib.sh
 tst_run
testcases/kernel/containers/netns/netns_lib.sh renamed from testcases/kernel/containers/netns/netns_helper.sh +0 -0
similarity index 100%
rename from testcases/kernel/containers/netns/netns_helper.sh
rename to testcases/kernel/containers/netns/netns_lib.sh
Signature · 5 lines
2.36.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp