All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v3 0/3] shell: Fixes for disabled IPv6
@ 2022-05-10  6:51 Petr Vorel
  2022-05-10  6:51 ` [LTP] [PATCH v3 1/3] tst_net.sh: Fix " Petr Vorel
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Petr Vorel @ 2022-05-10  6:51 UTC (permalink / raw)
  To: ltp; +Cc: Martin Doucha

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

-- 
2.36.0


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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [LTP] [PATCH v3 1/3] tst_net.sh: Fix for disabled IPv6
  2022-05-10  6:51 [LTP] [PATCH v3 0/3] shell: Fixes for disabled IPv6 Petr Vorel
@ 2022-05-10  6:51 ` Petr Vorel
  2022-05-10 12:14   ` Cyril Hrubis
  2022-05-10  6:51 ` [LTP] [PATCH v3 2/3] netns: Rewrite to use tst_net.sh Petr Vorel
  2022-05-10  6:51 ` [LTP] [PATCH v3 3/3] netns: Rename netns_helper.sh -> netns_lib.sh Petr Vorel
  2 siblings, 1 reply; 10+ messages in thread
From: Petr Vorel @ 2022-05-10  6:51 UTC (permalink / raw)
  To: ltp; +Cc: Martin Doucha

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.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
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(-)

diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh
index b27b7e51c..29d80df89 100644
--- a/testcases/lib/tst_net.sh
+++ b/testcases/lib/tst_net.sh
@@ -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
 
-- 
2.36.0


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

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [LTP] [PATCH v3 2/3] netns: Rewrite to use tst_net.sh
  2022-05-10  6:51 [LTP] [PATCH v3 0/3] shell: Fixes for disabled IPv6 Petr Vorel
  2022-05-10  6:51 ` [LTP] [PATCH v3 1/3] tst_net.sh: Fix " Petr Vorel
@ 2022-05-10  6:51 ` Petr Vorel
  2022-05-10 13:08   ` Cyril Hrubis
  2022-05-10  6:51 ` [LTP] [PATCH v3 3/3] netns: Rename netns_helper.sh -> netns_lib.sh Petr Vorel
  2 siblings, 1 reply; 10+ messages in thread
From: Petr Vorel @ 2022-05-10  6:51 UTC (permalink / raw)
  To: ltp; +Cc: Martin Doucha

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).

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
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(-)

diff --git a/runtest/containers b/runtest/containers
index eea7bfadb..ab0b94f51 100644
--- a/runtest/containers
+++ b/runtest/containers
@@ -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
diff --git a/testcases/kernel/containers/netns/netns_breakns.sh b/testcases/kernel/containers/netns/netns_breakns.sh
index b7f255cb8..0b2eb319c 100755
--- a/testcases/kernel/containers/netns/netns_breakns.sh
+++ b/testcases/kernel/containers/netns/netns_breakns.sh
@@ -1,23 +1,9 @@
 #!/bin/sh
 # SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2022 Petr Vorel <pvorel@suse.cz>
 # Copyright (c) Köry Maincent <kory.maincent@bootlin.com> 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
diff --git a/testcases/kernel/containers/netns/netns_comm.sh b/testcases/kernel/containers/netns/netns_comm.sh
index bee944802..6570f386e 100755
--- a/testcases/kernel/containers/netns/netns_comm.sh
+++ b/testcases/kernel/containers/netns/netns_comm.sh
@@ -1,23 +1,9 @@
 #!/bin/sh
 # SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2022 Petr Vorel <pvorel@suse.cz>
 # Copyright (c) Köry Maincent <kory.maincent@bootlin.com> 2020
 # Copyright (c) 2015 Red Hat, Inc.
 #
-# SYNOPSIS:
-# netns_comm.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 that a separate network namespace can configure and communicate
 # over the devices it sees. Tests are done using netlink(7) ('ip' command)
 # or ioctl(2) ('ifconfig' command) for controlling devices.
@@ -29,43 +15,24 @@
 #   3. communication over the lo (localhost) device in a separate
 #      network namespace
 
-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()
 {
-	EXPECT_PASS $NS_EXEC $NS_HANDLE0 $NS_TYPE $tping -q -c2 -I veth0 $IP1 1>/dev/null
+	local ip_lo="127.0.0.1"
+	[ "$TST_IPV6" ] && ip_lo="::1"
 
+	EXPECT_PASS $NS_EXEC $NS_HANDLE0 $NS_TYPE $tping -q -c2 -I veth0 $IP1 1>/dev/null
 	EXPECT_PASS $NS_EXEC $NS_HANDLE1 $NS_TYPE $tping -q -c2 -I veth1 $IP0 1>/dev/null
 
-	case "$IP_VER" in
-	ipv4) ip_lo="127.0.0.1" ;;
-	ipv6) ip_lo="::1" ;;
-	esac
-	case "$COM_TYPE" in
-	netlink)
-		$NS_EXEC $NS_HANDLE0 $NS_TYPE ip link set dev lo up || \
-			tst_brk TBROK "enabling lo device failed"
-		;;
-	ioctl)
-		$NS_EXEC $NS_HANDLE0 $NS_TYPE ifconfig lo up || \
-			tst_brk TBROK "enabling lo device failed"
-		;;
-	esac
+	if [ "$COMM_TYPE" = "netlink" ]; then
+		ROD $NS_EXEC $NS_HANDLE0 $NS_TYPE ip link set dev lo up
+	else
+		ROD $NS_EXEC $NS_HANDLE0 $NS_TYPE ifconfig lo up
+	fi
+
 	EXPECT_PASS $NS_EXEC $NS_HANDLE0 $NS_TYPE $tping -q -c2 -I lo $ip_lo 1>/dev/null
 }
 
 . netns_helper.sh
-
-PROG=$1
-IP_VER=$2
-COM_TYPE=$3
-
 tst_run
diff --git a/testcases/kernel/containers/netns/netns_helper.sh b/testcases/kernel/containers/netns/netns_helper.sh
index a74d923d1..e8a09347a 100755
--- a/testcases/kernel/containers/netns/netns_helper.sh
+++ b/testcases/kernel/containers/netns/netns_helper.sh
@@ -1,36 +1,30 @@
 #!/bin/sh
 # SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2022 Petr Vorel <pvorel@suse.cz>
 # Copyright (c) Linux Test Project, 2014-2021
 # Copyright (c) 2015 Red Hat, Inc.
 
-TST_CLEANUP=netns_ns_exec_cleanup
 TST_NEEDS_ROOT=1
 TST_NEEDS_CMDS="ip ping"
 TST_NEEDS_DRIVERS="veth"
 
-# Set to 1 only for test cases using ifconfig (ioctl).
-USE_IFCONFIG=0
+TST_OPTS="eI"
+TST_PARSE_ARGS="netns_parse_args"
+TST_USAGE="netns_usage"
+TST_SETUP="${TST_SETUP:-netns_setup}"
+TST_CLEANUP="${TST_CLEANUP:-netns_cleanup}"
 
-# Variables which can be used in test cases (set by netns_setup() function):
+TST_NET_SKIP_VARIABLE_INIT=1
 
-# Use in test cases to execute commands inside a namespace. Set to 'ns_exec' or
-# 'ip netns exec' command according to NS_EXEC_PROGRAM argument specified in
-# netns_setup() function call.
-NS_EXEC=
+# from tst_net_vars.c
+IPV4_NET16_UNUSED="10.23"
+IPV6_NET32_UNUSED="fd00:23"
 
 # Set to "net" for ns_create/ns_exec as their options requires
 # to specify a namespace type. Empty for ip command.
 NS_TYPE=
 
-# IP addresses of veth0 (IP0) and veth1 (IP1) devices (ipv4/ipv6 variant
-# is determined according to the IP_VERSION argument specified in netns_setup()
-# function call.
-IP0=
-IP1=
-NETMASK=
-
-# 'ping' or 'ping6' according to the IP_VERSION argument specified
-# in netns_setup() function call.
+# 'ping' or 'ping6'
 tping=
 
 # Network namespaces handles for manipulating and executing commands inside
@@ -45,107 +39,73 @@ NS_HANDLE1=
 # ifconfig <device> $IFCONF_IN6_ARG IP/NETMASK
 IFCONF_IN6_ARG=
 
-# Sets up global variables which can be used in test cases (documented above),
-# creates two network namespaces and a pair of virtual ethernet devices, each
-# device in one namespace. Each device is then enabled and assigned an IP
-# address according to the function parameters. IFCONF_IN6_ARG variable is set
-# only if ipv6 variant of test case is used (determined by IP_VERSION argument).
-#
-# SYNOPSIS:
-# netns_setup <NS_EXEC_PROGRAM> <IP_VERSION> <COMM_TYPE> <IP4_VETH0>
-#             <IP4_VETH1> <IP6_VETH0> <IP6_VETH1>
-#
-# 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 enabling and assigning IP addresses to the virtual
-#		ethernet devices. Uses 'ip' command for netlink and 'ifconfig'
-#		for ioctl. (If set to ioctl, function also checks the existance
-#		of the 'ifconfig' command.)
-#	* IP4_VETH0, IP4_VETH1
-#		IPv4 addresses for veth0 and veth1 devices.
-#	* IP6_VETH0, IP6_VETH1
-#		IPv6 addresses for veth0 and veth1 devices.
-#
-# On success function returns, on error tst_brk is called and TC is terminated.
+# Program which will be used to enter and run other commands inside a network namespace.
+# (ns_exec|ip)
+NS_EXEC="ip"
+
+# 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()
+{
+	case $1 in
+	e) NS_EXEC="ns_exec" ;;
+	I) COMM_TYPE="ioctl"; tst_require_cmds ifconfig ;;
+	esac
+}
+
+netns_usage()
+{
+	echo "usage: $0 [ -e ] [ -t ]"
+	echo "OPTIONS"
+	echo "-e use ns_exec instead of ip"
+	echo "-I test ioctl (with ifconfig) instead of netlink (with ip)"
+}
+
 netns_setup()
 {
-	case "$1" in
-	ns_exec)
+	if [ "$NS_EXEC" = "ip" ]; then
+		netns_ip_setup
+	else
 		setns_check
 		[ $? -eq 32 ] && tst_brk TCONF "setns not supported"
 
 		NS_TYPE="net"
 		netns_ns_exec_setup
-		TST_CLEANUP=netns_ns_exec_cleanup
-		;;
-	ip)
-		netns_ip_setup
-		TST_CLEANUP=netns_ip_cleanup
-		;;
-	*)
-		tst_brk TBROK \
-		"first argument must be a program used to enter a network namespace (ns_exec|ip)"
-		;;
-	esac
-
-	case "$3" in
-	netlink)
-		;;
-	ioctl)
-		USE_IFCONFIG=1
-		tst_require_cmds ifconfig
-		;;
-	*)
-		tst_brk TBROK \
-		"third argument must be a comm. type between kernel and user space (netlink|ioctl)"
-		;;
-	esac
-
-	if [ -z "$4" ]; then
-		tst_brk TBROK "fourth argument must be the IPv4 address for veth0"
-	fi
-	if [ -z "$5" ]; then
-		tst_brk TBROK "fifth argument must be the IPv4 address for veth1"
-	fi
-	if [ -z "$6" ]; then
-		tst_brk TBROK "sixth argument must be the IPv6 address for veth0"
-	fi
-	if [ -z "$7" ]; then
-		tst_brk TBROK "seventh argument must be the IPv6 address for veth1"
 	fi
 
-	case "$2" in
-	ipv4)
-		IP0=$4
-		IP1=$5
-		tping="ping"
-		NETMASK=24
-		;;
-	ipv6)
+	IP0=$(tst_ipaddr_un -c 1)
+	IP1=$(tst_ipaddr_un -c 2)
+
+	if [ "$TST_IPV6" ]; then
 		IFCONF_IN6_ARG="inet6 add"
-		IP0=$6
-		IP1=$7
-
-		if tst_cmd_available ping6; then
-			tping="ping6"
-		else
-			tping="ping -6"
-			tst_res_ TINFO "ping6 binary/symlink is missing, using workaround. Please, report missing ping6 to your distribution."
-		fi
 		NETMASK=64
-		;;
-	*)
-		tst_brk TBROK "second argument must be an ip version (ipv4|ipv6)"
-		;;
-	esac
+	else
+		NETMASK=24
+	fi
+
+	tping=ping$TST_IPV6
 
 	netns_set_ip
+
+	tst_res TINFO "testing netns over $COMM_TYPE with $NS_EXEC $PROG"
+	do_cleanup=1
+}
+
+netns_cleanup()
+{
+	[ "$do_cleanup" ] || return
+
+	if [ "$NS_EXEC" = "ip" ]; then
+		netns_ip_cleanup
+	else
+		netns_ns_exec_cleanup
+	fi
 }
 
 # Sets up NS_EXEC to use 'ns_exec', creates two network namespaces and stores
@@ -197,23 +157,18 @@ netns_ip_setup()
 	ip netns del $NS_HANDLE0 2>/dev/null
 	ip netns del $NS_HANDLE1 2>/dev/null
 
-	ip netns add $NS_HANDLE0 || \
-		tst_brk TBROK "unable to create a new network namespace"
-	ip netns add $NS_HANDLE1 || \
-		tst_brk TBROK "unable to create a new network namespace"
-
-	$NS_EXEC $NS_HANDLE0 ip link add veth0 type veth peer name veth1 || \
-		tst_brk TBROK "unable to create veth pair devices"
+	ROD ip netns add $NS_HANDLE0
+	ROD ip netns add $NS_HANDLE1
 
-	$NS_EXEC $NS_HANDLE0 ip link set veth1 netns $NS_HANDLE1 || \
-		tst_brk TBROK "unable to add device veth1 to the separate network namespace"
+	ROD $NS_EXEC $NS_HANDLE0 ip link add veth0 type veth peer name veth1
+	ROD $NS_EXEC $NS_HANDLE0 ip link set veth1 netns $NS_HANDLE1
 }
 
 # Enables virtual ethernet devices and assigns IP addresses for both
 # of them (IPv4/IPv6 variant is decided by netns_setup() function).
 netns_set_ip()
 {
-	[ "$NS_EXEC" ] || tst_brk TBROK "netns_setup() function must be called first"
+	local cmd="ip"
 
 	# This applies only for ipv6 variant:
 	# Do not accept Router Advertisements (accept_ra) and do not use
@@ -222,35 +177,28 @@ netns_set_ip()
 	# there is no other host with the same address, the address is
 	# considered to be "tentative" (attempts to bind() to the address fail
 	# with EADDRNOTAVAIL) which may cause problems for tests using ipv6.
-	echo 0 | $NS_EXEC $NS_HANDLE0 $NS_TYPE \
-		tee /proc/sys/net/ipv6/conf/veth0/accept_dad \
-		/proc/sys/net/ipv6/conf/veth0/accept_ra >/dev/null
-	echo 0 | $NS_EXEC $NS_HANDLE1 $NS_TYPE \
-		tee /proc/sys/net/ipv6/conf/veth1/accept_dad \
-		/proc/sys/net/ipv6/conf/veth1/accept_ra >/dev/null
-
-	case $USE_IFCONFIG in
-	1)
-		$NS_EXEC $NS_HANDLE0 $NS_TYPE ifconfig veth0 $IFCONF_IN6_ARG $IP0/$NETMASK ||
-			tst_brk TBROK "adding address to veth0 failed"
-		$NS_EXEC $NS_HANDLE1 $NS_TYPE ifconfig veth1 $IFCONF_IN6_ARG $IP1/$NETMASK ||
-			tst_brk TBROK "adding address to veth1 failed"
-		$NS_EXEC $NS_HANDLE0 $NS_TYPE ifconfig veth0 up ||
-			tst_brk TBROK "enabling veth0 device failed"
-		$NS_EXEC $NS_HANDLE1 $NS_TYPE ifconfig veth1 up ||
-			tst_brk TBROK "enabling veth1 device failed"
-		;;
-	*)
-		$NS_EXEC $NS_HANDLE0 $NS_TYPE ip address add $IP0/$NETMASK dev veth0 ||
-			tst_brk TBROK "adding address to veth0 failed"
-		$NS_EXEC $NS_HANDLE1 $NS_TYPE ip address add $IP1/$NETMASK dev veth1 ||
-			tst_brk TBROK "adding address to veth1 failed"
-		$NS_EXEC $NS_HANDLE0 $NS_TYPE ip link set veth0 up ||
-			tst_brk TBROK "enabling veth0 device failed"
-		$NS_EXEC $NS_HANDLE1 $NS_TYPE ip link set veth1 up ||
-			tst_brk TBROK "enabling veth1 device failed"
-		;;
-	esac
+	if [ "$TST_IPV6" ]; then
+		echo 0 | $NS_EXEC $NS_HANDLE0 $NS_TYPE \
+			tee /proc/sys/net/ipv6/conf/veth0/accept_dad \
+			/proc/sys/net/ipv6/conf/veth0/accept_ra >/dev/null
+		echo 0 | $NS_EXEC $NS_HANDLE1 $NS_TYPE \
+			tee /proc/sys/net/ipv6/conf/veth1/accept_dad \
+			/proc/sys/net/ipv6/conf/veth1/accept_ra >/dev/null
+	fi
+
+	[ "$COMM_TYPE" = "ioctl" ] && cmd="ifconfig"
+
+	if [ "$COMM_TYPE" = "netlink" ]; then
+		ROD $NS_EXEC $NS_HANDLE0 $NS_TYPE ip address add $IP0/$NETMASK dev veth0
+		ROD $NS_EXEC $NS_HANDLE1 $NS_TYPE ip address add $IP1/$NETMASK dev veth1
+		ROD $NS_EXEC $NS_HANDLE0 $NS_TYPE ip link set veth0 up
+		ROD $NS_EXEC $NS_HANDLE1 $NS_TYPE ip link set veth1 up
+	else
+		ROD $NS_EXEC $NS_HANDLE0 $NS_TYPE ifconfig veth0 $IFCONF_IN6_ARG $IP0/$NETMASK
+		ROD $NS_EXEC $NS_HANDLE1 $NS_TYPE ifconfig veth1 $IFCONF_IN6_ARG $IP1/$NETMASK
+		ROD $NS_EXEC $NS_HANDLE0 $NS_TYPE ifconfig veth0 up
+		ROD $NS_EXEC $NS_HANDLE1 $NS_TYPE ifconfig veth1 up
+	fi
 }
 
 netns_ns_exec_cleanup()
@@ -276,4 +224,4 @@ netns_ip_cleanup()
 	ip netns del $NS_HANDLE1 2>/dev/null
 }
 
-. tst_test.sh
+. tst_net.sh
-- 
2.36.0


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

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [LTP] [PATCH v3 3/3] netns: Rename netns_helper.sh -> netns_lib.sh
  2022-05-10  6:51 [LTP] [PATCH v3 0/3] shell: Fixes for disabled IPv6 Petr Vorel
  2022-05-10  6:51 ` [LTP] [PATCH v3 1/3] tst_net.sh: Fix " Petr Vorel
  2022-05-10  6:51 ` [LTP] [PATCH v3 2/3] netns: Rewrite to use tst_net.sh Petr Vorel
@ 2022-05-10  6:51 ` Petr Vorel
  2 siblings, 0 replies; 10+ messages in thread
From: Petr Vorel @ 2022-05-10  6:51 UTC (permalink / raw)
  To: ltp; +Cc: Martin Doucha

LTP shell libraries are called *_lib.sh.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
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%)

diff --git a/testcases/kernel/containers/netns/netns_breakns.sh b/testcases/kernel/containers/netns/netns_breakns.sh
index 0b2eb319c..a5cec0953 100755
--- a/testcases/kernel/containers/netns/netns_breakns.sh
+++ b/testcases/kernel/containers/netns/netns_breakns.sh
@@ -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
diff --git a/testcases/kernel/containers/netns/netns_comm.sh b/testcases/kernel/containers/netns/netns_comm.sh
index 6570f386e..c7c2ae07a 100755
--- a/testcases/kernel/containers/netns/netns_comm.sh
+++ b/testcases/kernel/containers/netns/netns_comm.sh
@@ -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
diff --git a/testcases/kernel/containers/netns/netns_helper.sh b/testcases/kernel/containers/netns/netns_lib.sh
similarity index 100%
rename from testcases/kernel/containers/netns/netns_helper.sh
rename to testcases/kernel/containers/netns/netns_lib.sh
-- 
2.36.0


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

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [LTP] [PATCH v3 1/3] tst_net.sh: Fix for disabled IPv6
  2022-05-10  6:51 ` [LTP] [PATCH v3 1/3] tst_net.sh: Fix " Petr Vorel
@ 2022-05-10 12:14   ` Cyril Hrubis
  2022-05-10 13:06     ` Petr Vorel
  0 siblings, 1 reply; 10+ messages in thread
From: Cyril Hrubis @ 2022-05-10 12:14 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Martin Doucha, ltp

Hi!
> +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

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?


-- 
Cyril Hrubis
chrubis@suse.cz

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [LTP] [PATCH v3 1/3] tst_net.sh: Fix for disabled IPv6
  2022-05-10 12:14   ` Cyril Hrubis
@ 2022-05-10 13:06     ` Petr Vorel
  2022-05-10 13:21       ` Cyril Hrubis
  0 siblings, 1 reply; 10+ messages in thread
From: Petr Vorel @ 2022-05-10 13:06 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Martin Doucha, ltp

Hi Cyril,

...
> > +# 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

> 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

> 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

diff --git testcases/lib/tst_net.sh testcases/lib/tst_net.sh
index 29d80df89..48dd6e8eb 100644
--- testcases/lib/tst_net.sh
+++ testcases/lib/tst_net.sh
@@ -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 $?")



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

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [LTP] [PATCH v3 2/3] netns: Rewrite to use tst_net.sh
  2022-05-10  6:51 ` [LTP] [PATCH v3 2/3] netns: Rewrite to use tst_net.sh Petr Vorel
@ 2022-05-10 13:08   ` Cyril Hrubis
  2022-05-10 14:00     ` Petr Vorel
  0 siblings, 1 reply; 10+ messages in thread
From: Cyril Hrubis @ 2022-05-10 13:08 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Martin Doucha, ltp

Hi!
> +# 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()
> +{
> +	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
> +	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.

-- 
Cyril Hrubis
chrubis@suse.cz

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [LTP] [PATCH v3 1/3] tst_net.sh: Fix for disabled IPv6
  2022-05-10 13:06     ` Petr Vorel
@ 2022-05-10 13:21       ` Cyril Hrubis
  2022-05-10 14:04         ` Petr Vorel
  0 siblings, 1 reply; 10+ messages in thread
From: Cyril Hrubis @ 2022-05-10 13:21 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Martin Doucha, ltp

Hi!
> diff --git testcases/lib/tst_net.sh testcases/lib/tst_net.sh
> index 29d80df89..48dd6e8eb 100644
> --- testcases/lib/tst_net.sh
> +++ testcases/lib/tst_net.sh
> @@ -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

>         if [ "$TST_NET_IPV6_ENABLED" = 1 ]; then
>                 eval $(tst_net_ip_prefix $IPV6_LHOST || echo "exit $?")
> 
> 

-- 
Cyril Hrubis
chrubis@suse.cz

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [LTP] [PATCH v3 2/3] netns: Rewrite to use tst_net.sh
  2022-05-10 13:08   ` Cyril Hrubis
@ 2022-05-10 14:00     ` Petr Vorel
  0 siblings, 0 replies; 10+ messages in thread
From: Petr Vorel @ 2022-05-10 14:00 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Martin Doucha, ltp

Hi Cyril,

...
> > +netns_usage()
> > +{
> > +	echo "usage: $0 [ -e ] [ -t ]"
>                                   ^
> 				  -I
> > +	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

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [LTP] [PATCH v3 1/3] tst_net.sh: Fix for disabled IPv6
  2022-05-10 13:21       ` Cyril Hrubis
@ 2022-05-10 14:04         ` Petr Vorel
  0 siblings, 0 replies; 10+ messages in thread
From: Petr Vorel @ 2022-05-10 14:04 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Martin Doucha, ltp

Hi Cyril,

> > -       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!

> 	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=
> 		tst_res TINFO "IPv6 disabled on $type"
> 	fi

Kind regards,
Petr

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-05-10 14:05 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-10  6:51 [LTP] [PATCH v3 0/3] shell: Fixes for disabled IPv6 Petr Vorel
2022-05-10  6:51 ` [LTP] [PATCH v3 1/3] tst_net.sh: Fix " Petr Vorel
2022-05-10 12:14   ` Cyril Hrubis
2022-05-10 13:06     ` Petr Vorel
2022-05-10 13:21       ` Cyril Hrubis
2022-05-10 14:04         ` Petr Vorel
2022-05-10  6:51 ` [LTP] [PATCH v3 2/3] netns: Rewrite to use tst_net.sh Petr Vorel
2022-05-10 13:08   ` Cyril Hrubis
2022-05-10 14:00     ` Petr Vorel
2022-05-10  6:51 ` [LTP] [PATCH v3 3/3] netns: Rename netns_helper.sh -> netns_lib.sh Petr Vorel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.