* [LTP] [PATCH v2 0/3] shell: Fixes for disabled IPv6
@ 2022-02-04 19:46 Petr Vorel
2022-02-04 19:46 ` [LTP] [PATCH v2 1/3] tst_net.sh: Fix " Petr Vorel
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Petr Vorel @ 2022-02-04 19:46 UTC (permalink / raw)
To: ltp
Hi all,
changes v2->v3:
* Partly rewritten containers netns to use tst_net.sh. Further cleanup
will be done, but changes are already big and for sake of
working IPv6 is this enough.
TODO: Test should be further cleanup to use tst_rhost_run over different
LTP_NETNS and tst_ping instead of $tping.
* Use only $TST_NET_IPV6_ENABLED for both lhost and rhost. ATM when
use TST_NET_SKIP_VARIABLE_INIT=1 it detects only lhost. This is useful
for containers netns tests (and will be needed even after
NOTE: no other shell tests which use only tst_test.sh need this
(if any needs in the future, can be migrated the same way as
netns_helper.sh currently).
C tests are ok, because they can check EAFNOSUPPORT (as done for SCTP
tests: https://patchwork.ozlabs.org/project/ltp/list/?series=284336)
NOTE: this is really v3, because I forget to add v2 in previous version
https://patchwork.ozlabs.org/project/ltp/list/?series=282638
Kind regards,
Petr
Petr Vorel (3):
tst_net.sh: Fix for disabled IPv6
broken_ip-nexthdr.sh: Check IPv6 support before forcing it
netns: Rewrite to use tst_net.sh
runtest/containers | 32 +--
.../kernel/containers/netns/netns_breakns.sh | 29 +--
.../kernel/containers/netns/netns_comm.sh | 53 +----
.../kernel/containers/netns/netns_helper.sh | 225 +++++++-----------
testcases/lib/tst_net.sh | 71 +++++-
.../stress/broken_ip/broken_ip-nexthdr.sh | 1 +
6 files changed, 169 insertions(+), 242 deletions(-)
--
2.35.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 11+ messages in thread
* [LTP] [PATCH v2 1/3] tst_net.sh: Fix for disabled IPv6
2022-02-04 19:46 [LTP] [PATCH v2 0/3] shell: Fixes for disabled IPv6 Petr Vorel
@ 2022-02-04 19:46 ` Petr Vorel
2022-03-02 11:00 ` Cyril Hrubis
2022-02-04 19:46 ` [LTP] [PATCH v2 2/3] broken_ip-nexthdr.sh: Check IPv6 support before forcing it Petr Vorel
2022-02-04 19:46 ` [LTP] [PATCH v2 3/3] netns: Rewrite to use tst_net.sh Petr Vorel
2 siblings, 1 reply; 11+ messages in thread
From: Petr Vorel @ 2022-02-04 19:46 UTC (permalink / raw)
To: ltp
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>
---
testcases/lib/tst_net.sh | 71 +++++++++++++++++++++++++++++++++-------
1 file changed, 60 insertions(+), 11 deletions(-)
diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh
index 047686dc39..15fd595942 100644
--- a/testcases/lib/tst_net.sh
+++ b/testcases/lib/tst_net.sh
@@ -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,32 @@ 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
@@ -517,7 +545,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
@@ -529,7 +559,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"
}
@@ -606,7 +638,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
@@ -937,6 +971,9 @@ tst_default_max_pkt()
echo "$((mtu + mtu / 10))"
}
+# detect IPv6 support on lhost for tests which don't use test links
+tst_net_detect_ipv6
+
[ -n "$TST_PRINT_HELP" -o -n "$TST_NET_SKIP_VARIABLE_INIT" ] && return 0
# Management Link
@@ -971,8 +1008,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
@@ -981,19 +1023,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.35.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [LTP] [PATCH v2 2/3] broken_ip-nexthdr.sh: Check IPv6 support before forcing it
2022-02-04 19:46 [LTP] [PATCH v2 0/3] shell: Fixes for disabled IPv6 Petr Vorel
2022-02-04 19:46 ` [LTP] [PATCH v2 1/3] tst_net.sh: Fix " Petr Vorel
@ 2022-02-04 19:46 ` Petr Vorel
2022-03-02 14:18 ` Cyril Hrubis
2022-02-04 19:46 ` [LTP] [PATCH v2 3/3] netns: Rewrite to use tst_net.sh Petr Vorel
2 siblings, 1 reply; 11+ messages in thread
From: Petr Vorel @ 2022-02-04 19:46 UTC (permalink / raw)
To: ltp
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
testcases/network/stress/broken_ip/broken_ip-nexthdr.sh | 1 +
1 file changed, 1 insertion(+)
diff --git a/testcases/network/stress/broken_ip/broken_ip-nexthdr.sh b/testcases/network/stress/broken_ip/broken_ip-nexthdr.sh
index ec6643af66..cb4a3dd399 100755
--- a/testcases/network/stress/broken_ip/broken_ip-nexthdr.sh
+++ b/testcases/network/stress/broken_ip/broken_ip-nexthdr.sh
@@ -11,6 +11,7 @@ TST_TESTFUNC="do_test"
do_test()
{
# not supported on IPv4
+ tst_net_require_ipv6
TST_IPV6=6
TST_IPVER=6
--
2.35.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [LTP] [PATCH v2 3/3] netns: Rewrite to use tst_net.sh
2022-02-04 19:46 [LTP] [PATCH v2 0/3] shell: Fixes for disabled IPv6 Petr Vorel
2022-02-04 19:46 ` [LTP] [PATCH v2 1/3] tst_net.sh: Fix " Petr Vorel
2022-02-04 19:46 ` [LTP] [PATCH v2 2/3] broken_ip-nexthdr.sh: Check IPv6 support before forcing it Petr Vorel
@ 2022-02-04 19:46 ` Petr Vorel
2 siblings, 0 replies; 11+ messages in thread
From: Petr Vorel @ 2022-02-04 19:46 UTC (permalink / raw)
To: ltp
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).
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
runtest/containers | 32 +--
.../kernel/containers/netns/netns_breakns.sh | 29 +--
.../kernel/containers/netns/netns_comm.sh | 53 +----
.../kernel/containers/netns/netns_helper.sh | 225 +++++++-----------
4 files changed, 108 insertions(+), 231 deletions(-)
diff --git a/runtest/containers b/runtest/containers
index eea7bfadb7..ab0b94f51a 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 1ce5d37efd..64810b711e 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,21 +12,8 @@
# 1. using netlink (ip command).
# 2. using ioctl (ifconfig command).
-TST_POS_ARGS=3
-TST_SETUP=do_setup
-TST_TESTFUNC=do_test
. netns_helper.sh
-PROG=$1
-IP_VER=$2
-COM_TYPE=$3
-
-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"
-}
-
do_test()
{
EXPECT_FAIL $NS_EXEC $NS_HANDLE0 $NS_TYPE ip address add $IP1/$NETMASK dev veth1
diff --git a/testcases/kernel/containers/netns/netns_comm.sh b/testcases/kernel/containers/netns/netns_comm.sh
index ccb8b47b11..3fdbf13b59 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,41 +15,22 @@
# 3. communication over the lo (localhost) device in a separate
# network namespace
-TST_POS_ARGS=3
-TST_SETUP=do_setup
-TST_TESTFUNC=do_test
. netns_helper.sh
-PROG=$1
-IP_VER=$2
-COM_TYPE=$3
-
-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"
-}
-
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
}
diff --git a/testcases/kernel/containers/netns/netns_helper.sh b/testcases/kernel/containers/netns/netns_helper.sh
index d7d4d2c2de..4b6ad23009 100755
--- a/testcases/kernel/containers/netns/netns_helper.sh
+++ b/testcases/kernel/containers/netns/netns_helper.sh
@@ -1,37 +1,32 @@
#!/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"
-. tst_test.sh
-# 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=netns_setup
+TST_CLEANUP=netns_ns_exec_cleanup
+TST_TESTFUNC=do_test
-# 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"
+. tst_net.sh
# 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
@@ -46,107 +41,61 @@ 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"
+
+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
+ TST_CLEANUP=netns_ip_cleanup
+ 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"
}
# Sets up NS_EXEC to use 'ns_exec', creates two network namespaces and stores
@@ -198,23 +147,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
@@ -223,35 +167,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()
--
2.35.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH v2 1/3] tst_net.sh: Fix for disabled IPv6
2022-02-04 19:46 ` [LTP] [PATCH v2 1/3] tst_net.sh: Fix " Petr Vorel
@ 2022-03-02 11:00 ` Cyril Hrubis
2022-03-02 11:05 ` Petr Vorel
0 siblings, 1 reply; 11+ messages in thread
From: Cyril Hrubis @ 2022-03-02 11:00 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
Hi!
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> testcases/lib/tst_net.sh | 71 +++++++++++++++++++++++++++++++++-------
> 1 file changed, 60 insertions(+), 11 deletions(-)
>
> diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh
> index 047686dc39..15fd595942 100644
> --- a/testcases/lib/tst_net.sh
> +++ b/testcases/lib/tst_net.sh
> @@ -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,32 @@ 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"
> +}
Shouldn't we detect support for IPv6 on both lhost and rhost in the
tst_net_detect_ipv6() function? I would say that it's pretty obvious
that we need the support on both machines.
> init_ltp_netspace()
> {
> local pid
> @@ -517,7 +545,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
> @@ -529,7 +559,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"
> }
>
> @@ -606,7 +638,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
> @@ -937,6 +971,9 @@ tst_default_max_pkt()
> echo "$((mtu + mtu / 10))"
> }
>
> +# detect IPv6 support on lhost for tests which don't use test links
> +tst_net_detect_ipv6
> +
> [ -n "$TST_PRINT_HELP" -o -n "$TST_NET_SKIP_VARIABLE_INIT" ] && return 0
>
> # Management Link
> @@ -971,8 +1008,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
> @@ -981,19 +1023,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.35.1
>
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH v2 1/3] tst_net.sh: Fix for disabled IPv6
2022-03-02 11:00 ` Cyril Hrubis
@ 2022-03-02 11:05 ` Petr Vorel
0 siblings, 0 replies; 11+ messages in thread
From: Petr Vorel @ 2022-03-02 11:05 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp
Hi Cyril,
...
> > +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"
> > +}
> Shouldn't we detect support for IPv6 on both lhost and rhost in the
> tst_net_detect_ipv6() function? I would say that it's pretty obvious
> that we need the support on both machines.
Yes, that's done - see my explanations below. BTW in previous version I had 2
variables, but Alexey suggested to use just one variable
https://lore.kernel.org/ltp/29051e9c-f4c2-9840-7f84-8c9f49efba93@bell-sw.com/
> > init_ltp_netspace()
> > {
> > local pid
> > @@ -517,7 +545,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
> > @@ -529,7 +559,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"
> > }
> > @@ -606,7 +638,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
> > @@ -937,6 +971,9 @@ tst_default_max_pkt()
> > echo "$((mtu + mtu / 10))"
> > }
> > +# detect IPv6 support on lhost for tests which don't use test links
> > +tst_net_detect_ipv6
NOTE Here we detect on lhost - for netns based tests (third patch: https://lore.kernel.org/ltp/20220204194648.32165-4-pvorel@suse.cz/
Test uses TST_NET_SKIP_VARIABLE_INIT=1, because currently it does not use
tst_rhost_run (will be used in further cleanups - I wanted to do as minimal
changes as possible).
> > +
> > [ -n "$TST_PRINT_HELP" -o -n "$TST_NET_SKIP_VARIABLE_INIT" ] && return 0
> > # Management Link
> > @@ -971,8 +1008,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
And here we detect on rhost for all network tests
...
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH v2 2/3] broken_ip-nexthdr.sh: Check IPv6 support before forcing it
2022-02-04 19:46 ` [LTP] [PATCH v2 2/3] broken_ip-nexthdr.sh: Check IPv6 support before forcing it Petr Vorel
@ 2022-03-02 14:18 ` Cyril Hrubis
2022-03-02 20:44 ` Petr Vorel
2022-03-22 18:25 ` Petr Vorel
0 siblings, 2 replies; 11+ messages in thread
From: Cyril Hrubis @ 2022-03-02 14:18 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
Hi!
> diff --git a/testcases/network/stress/broken_ip/broken_ip-nexthdr.sh b/testcases/network/stress/broken_ip/broken_ip-nexthdr.sh
> index ec6643af66..cb4a3dd399 100755
> --- a/testcases/network/stress/broken_ip/broken_ip-nexthdr.sh
> +++ b/testcases/network/stress/broken_ip/broken_ip-nexthdr.sh
> @@ -11,6 +11,7 @@ TST_TESTFUNC="do_test"
> do_test()
> {
> # not supported on IPv4
> + tst_net_require_ipv6
> TST_IPV6=6
> TST_IPVER=6
I was looking at the code if we can simply instead do:
[ "$TST_IPVER" == 6 ] && tst_net_require_ipv6
in the test library, but it looks like the parameters are parsed in the
tst_test.sh in the tst_run() function. Which means that the TST_IPVER is
not actually set until the test starts and the library has no way of
knowing the variable value beforehand.
I guess that we can actually move the option parsing code in the
tst_test.sh so that it happens just right after the script is sourced,
which would make things much easier as the TST_IPVER would end up being
defined in the tst_network.sh and we coud simply use the statement above
without any further hacks like this patch adds.
As a side effect we could clean up the test option parsing code since we
do actually have two different getopts loop in the tst_test.sh library
and as far as I can tell we can do just with one.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH v2 2/3] broken_ip-nexthdr.sh: Check IPv6 support before forcing it
2022-03-02 14:18 ` Cyril Hrubis
@ 2022-03-02 20:44 ` Petr Vorel
2022-03-22 18:25 ` Petr Vorel
1 sibling, 0 replies; 11+ messages in thread
From: Petr Vorel @ 2022-03-02 20:44 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp
Hi Cyril,
first, thanks a lot for a review of network shell tests.
> Hi!
> > diff --git a/testcases/network/stress/broken_ip/broken_ip-nexthdr.sh b/testcases/network/stress/broken_ip/broken_ip-nexthdr.sh
> > index ec6643af66..cb4a3dd399 100755
> > --- a/testcases/network/stress/broken_ip/broken_ip-nexthdr.sh
> > +++ b/testcases/network/stress/broken_ip/broken_ip-nexthdr.sh
> > @@ -11,6 +11,7 @@ TST_TESTFUNC="do_test"
> > do_test()
> > {
> > # not supported on IPv4
> > + tst_net_require_ipv6
> > TST_IPV6=6
> > TST_IPVER=6
> I was looking at the code if we can simply instead do:
> [ "$TST_IPVER" == 6 ] && tst_net_require_ipv6
BTW this code was requested by Alexey, originally I suggested different way
to declare TST_NET_IPV{4,6}_ONLY=1 in the test:
https://lore.kernel.org/ltp/20210714140716.1568-3-pvorel@suse.cz/
> in the test library, but it looks like the parameters are parsed in the
> tst_test.sh in the tst_run() function. Which means that the TST_IPVER is
> not actually set until the test starts and the library has no way of
> knowing the variable value beforehand.
Yes.
> I guess that we can actually move the option parsing code in the
> tst_test.sh so that it happens just right after the script is sourced,
> which would make things much easier as the TST_IPVER would end up being
> defined in the tst_network.sh and we coud simply use the statement above
> without any further hacks like this patch adds.
Interesting. Originally I thought I'd need IPv6 check for netns_*.sh tests, but
in the end I realized that better will be if they use tst_net.sh with forcing
netns only.
Sure, I can have look into putting -6 handling into tst_test.sh. It's just a bit
strange to me that tst_test.sh parses it, but it's actually used elsewhere.
> As a side effect we could clean up the test option parsing code since we
> do actually have two different getopts loop in the tst_test.sh library
> and as far as I can tell we can do just with one.
When I looked last time into this and it looked to me that both are needed.
The second one (which is actually run the first - ":hi:$TST_OPTS" is for
ignoring errors when -h is set. But maybe these warnings ("Invalid number of
positional parameters:" and "Unexpected positional arguments" might be really
possible to handle inside of tst_run().
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH v2 2/3] broken_ip-nexthdr.sh: Check IPv6 support before forcing it
2022-03-02 14:18 ` Cyril Hrubis
2022-03-02 20:44 ` Petr Vorel
@ 2022-03-22 18:25 ` Petr Vorel
2022-03-30 9:15 ` Cyril Hrubis
1 sibling, 1 reply; 11+ messages in thread
From: Petr Vorel @ 2022-03-22 18:25 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp
Hi Cyril,
> Hi!
> > diff --git a/testcases/network/stress/broken_ip/broken_ip-nexthdr.sh b/testcases/network/stress/broken_ip/broken_ip-nexthdr.sh
> > index ec6643af66..cb4a3dd399 100755
> > --- a/testcases/network/stress/broken_ip/broken_ip-nexthdr.sh
> > +++ b/testcases/network/stress/broken_ip/broken_ip-nexthdr.sh
> > @@ -11,6 +11,7 @@ TST_TESTFUNC="do_test"
> > do_test()
> > {
> > # not supported on IPv4
> > + tst_net_require_ipv6
> > TST_IPV6=6
> > TST_IPVER=6
> I was looking at the code if we can simply instead do:
> [ "$TST_IPVER" == 6 ] && tst_net_require_ipv6
> in the test library, but it looks like the parameters are parsed in the
> tst_test.sh in the tst_run() function. Which means that the TST_IPVER is
> not actually set until the test starts and the library has no way of
> knowing the variable value beforehand.
> I guess that we can actually move the option parsing code in the
> tst_test.sh so that it happens just right after the script is sourced,
> which would make things much easier as the TST_IPVER would end up being
> defined in the tst_network.sh and we coud simply use the statement above
> without any further hacks like this patch adds.
> As a side effect we could clean up the test option parsing code since we
> do actually have two different getopts loop in the tst_test.sh library
> and as far as I can tell we can do just with one.
I tried to implement this [1] (or [2] if I force push), and using getopts the
end of the script only would require also to move loading '. tst_test.sh' at the
end of *all* the test scripts because setup functions needs to be loaded before
sourcing tst_test.sh. Do we want this?
Kind regards,
Petr
[1] https://github.com/pevik/ltp/commit/9d77e5d964751ea3f0c8d22c4265c0041e2ebbc9
[2] https://github.com/pevik/ltp/commits/tst_test.sh/cleanup-getopts
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH v2 2/3] broken_ip-nexthdr.sh: Check IPv6 support before forcing it
2022-03-22 18:25 ` Petr Vorel
@ 2022-03-30 9:15 ` Cyril Hrubis
2022-03-30 9:17 ` Petr Vorel
0 siblings, 1 reply; 11+ messages in thread
From: Cyril Hrubis @ 2022-03-30 9:15 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
Hi!
> I tried to implement this [1] (or [2] if I force push), and using getopts the
> end of the script only would require also to move loading '. tst_test.sh' at the
> end of *all* the test scripts because setup functions needs to be loaded before
> sourcing tst_test.sh. Do we want this?
Sounds reasonable. I would go even further and put the line that sources
the tst_test.sh to be last line in the test.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH v2 2/3] broken_ip-nexthdr.sh: Check IPv6 support before forcing it
2022-03-30 9:15 ` Cyril Hrubis
@ 2022-03-30 9:17 ` Petr Vorel
0 siblings, 0 replies; 11+ messages in thread
From: Petr Vorel @ 2022-03-30 9:17 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp
> Hi!
> > I tried to implement this [1] (or [2] if I force push), and using getopts the
> > end of the script only would require also to move loading '. tst_test.sh' at the
> > end of *all* the test scripts because setup functions needs to be loaded before
> > sourcing tst_test.sh. Do we want this?
> Sounds reasonable. I would go even further and put the line that sources
> the tst_test.sh to be last line in the test.
+1, I'll also update docs examples and mention it.
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2022-03-30 9:17 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-04 19:46 [LTP] [PATCH v2 0/3] shell: Fixes for disabled IPv6 Petr Vorel
2022-02-04 19:46 ` [LTP] [PATCH v2 1/3] tst_net.sh: Fix " Petr Vorel
2022-03-02 11:00 ` Cyril Hrubis
2022-03-02 11:05 ` Petr Vorel
2022-02-04 19:46 ` [LTP] [PATCH v2 2/3] broken_ip-nexthdr.sh: Check IPv6 support before forcing it Petr Vorel
2022-03-02 14:18 ` Cyril Hrubis
2022-03-02 20:44 ` Petr Vorel
2022-03-22 18:25 ` Petr Vorel
2022-03-30 9:15 ` Cyril Hrubis
2022-03-30 9:17 ` Petr Vorel
2022-02-04 19:46 ` [LTP] [PATCH v2 3/3] netns: Rewrite to use tst_net.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.