All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 0/3] netns_helper.sh: cleanup
@ 2021-07-16 10:04 Petr Vorel
  2021-07-16 10:04 ` [LTP] [PATCH 1/3] netns_helper.sh: Check for ping Petr Vorel
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Petr Vorel @ 2021-07-16 10:04 UTC (permalink / raw)
  To: ltp

Petr Vorel (3):
  netns_helper.sh: Check for ping
  netns_helper.sh: Check veth with TST_NEEDS_DRIVERS
  netns_helper.sh: Formatting and style cleanup

 .../kernel/containers/netns/netns_helper.sh   | 53 ++++++++-----------
 1 file changed, 23 insertions(+), 30 deletions(-)

-- 
2.32.0


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

* [LTP] [PATCH 1/3] netns_helper.sh: Check for ping
  2021-07-16 10:04 [LTP] [PATCH 0/3] netns_helper.sh: cleanup Petr Vorel
@ 2021-07-16 10:04 ` Petr Vorel
  2021-07-16 10:04 ` [LTP] [PATCH 2/3] netns_helper.sh: Check veth with TST_NEEDS_DRIVERS Petr Vorel
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Petr Vorel @ 2021-07-16 10:04 UTC (permalink / raw)
  To: ltp

to give more informative message than just:
netns_comm 1 TFAIL: ns_exec 48906 net ping -q -c2 -I veth0 192.168.0.3 failed unexpectedly
netns_comm 1 TFAIL: ns_exec 48908 net ping -q -c2 -I veth1 192.168.0.2 failed unexpectedly
netns_comm 1 TFAIL: ns_exec 48906 net ping -q -c2 -I lo 127.0.0.1 failed unexpectedly

Use the same approach implemented in d57ac0b7a for tst_net.sh: for IPv6
ping6 is preferred (but still require ping), but fallback with warning
if only ping is available (some distros may still miss ping6 symlink
required by upstream since iputils s20150815).

Reported-by: Martin Doucha <mdoucha@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Reported in https://github.com/linux-test-project/ltp/issues/840

 testcases/kernel/containers/netns/netns_helper.sh | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/containers/netns/netns_helper.sh b/testcases/kernel/containers/netns/netns_helper.sh
index 1f97ec4d4..218fcef8c 100755
--- a/testcases/kernel/containers/netns/netns_helper.sh
+++ b/testcases/kernel/containers/netns/netns_helper.sh
@@ -1,11 +1,11 @@
 #!/bin/sh
 # SPDX-License-Identifier: GPL-2.0-or-later
-# Copyright (c) Linux Test Project, 2014-2020
+# 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 modprobe"
+TST_NEEDS_CMDS="ip modprobe ping"
 . tst_test.sh
 
 # Set to 1 only for test cases using ifconfig (ioctl).
@@ -132,10 +132,12 @@ netns_setup()
 	ipv6)
 		IFCONF_IN6_ARG="inet6 add"
 		IP0=$6; IP1=$7;
-		if which ping6 >/dev/null 2>&1; then
+
+		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
 		;;
-- 
2.32.0


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

* [LTP] [PATCH 2/3] netns_helper.sh: Check veth with TST_NEEDS_DRIVERS
  2021-07-16 10:04 [LTP] [PATCH 0/3] netns_helper.sh: cleanup Petr Vorel
  2021-07-16 10:04 ` [LTP] [PATCH 1/3] netns_helper.sh: Check for ping Petr Vorel
@ 2021-07-16 10:04 ` Petr Vorel
  2021-07-16 10:04 ` [LTP] [PATCH 3/3] netns_helper.sh: Formatting and style cleanup Petr Vorel
  2021-08-02 17:41 ` [LTP] [PATCH 0/3] netns_helper.sh: cleanup Petr Vorel
  3 siblings, 0 replies; 5+ messages in thread
From: Petr Vorel @ 2021-07-16 10:04 UTC (permalink / raw)
  To: ltp

instead loading it with modprobe. ip link can load veth itself
(use the same approach as in tst_net.sh).

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/kernel/containers/netns/netns_helper.sh | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/testcases/kernel/containers/netns/netns_helper.sh b/testcases/kernel/containers/netns/netns_helper.sh
index 218fcef8c..c296b8726 100755
--- a/testcases/kernel/containers/netns/netns_helper.sh
+++ b/testcases/kernel/containers/netns/netns_helper.sh
@@ -5,7 +5,8 @@
 
 TST_CLEANUP=netns_ns_exec_cleanup
 TST_NEEDS_ROOT=1
-TST_NEEDS_CMDS="ip modprobe ping"
+TST_NEEDS_CMDS="ip ping"
+TST_NEEDS_DRIVERS="veth"
 . tst_test.sh
 
 # Set to 1 only for test cases using ifconfig (ioctl).
@@ -75,9 +76,6 @@ IFCONF_IN6_ARG=
 # On success function returns, on error tst_brk is called and TC is terminated.
 netns_setup()
 {
-
-	modprobe veth > /dev/null 2>&1
-
 	case "$1" in
 	ns_exec)
 		setns_check
-- 
2.32.0


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

* [LTP] [PATCH 3/3] netns_helper.sh: Formatting and style cleanup
  2021-07-16 10:04 [LTP] [PATCH 0/3] netns_helper.sh: cleanup Petr Vorel
  2021-07-16 10:04 ` [LTP] [PATCH 1/3] netns_helper.sh: Check for ping Petr Vorel
  2021-07-16 10:04 ` [LTP] [PATCH 2/3] netns_helper.sh: Check veth with TST_NEEDS_DRIVERS Petr Vorel
@ 2021-07-16 10:04 ` Petr Vorel
  2021-08-02 17:41 ` [LTP] [PATCH 0/3] netns_helper.sh: cleanup Petr Vorel
  3 siblings, 0 replies; 5+ messages in thread
From: Petr Vorel @ 2021-07-16 10:04 UTC (permalink / raw)
  To: ltp

Replace spaces with tabs, use shorter if clauses, add missing local.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 .../kernel/containers/netns/netns_helper.sh   | 41 ++++++++-----------
 1 file changed, 17 insertions(+), 24 deletions(-)

diff --git a/testcases/kernel/containers/netns/netns_helper.sh b/testcases/kernel/containers/netns/netns_helper.sh
index c296b8726..d7d4d2c2d 100755
--- a/testcases/kernel/containers/netns/netns_helper.sh
+++ b/testcases/kernel/containers/netns/netns_helper.sh
@@ -79,9 +79,8 @@ netns_setup()
 	case "$1" in
 	ns_exec)
 		setns_check
-		if [ $? -eq 32 ]; then
-			tst_brk TCONF "setns not supported"
-		fi
+		[ $? -eq 32 ] && tst_brk TCONF "setns not supported"
+
 		NS_TYPE="net"
 		netns_ns_exec_setup
 		TST_CLEANUP=netns_ns_exec_cleanup
@@ -124,17 +123,20 @@ netns_setup()
 
 	case "$2" in
 	ipv4)
-		IP0=$4; IP1=$5
-		tping="ping"; NETMASK=24
+		IP0=$4
+		IP1=$5
+		tping="ping"
+		NETMASK=24
 		;;
 	ipv6)
 		IFCONF_IN6_ARG="inet6 add"
-		IP0=$6; IP1=$7;
+		IP0=$6
+		IP1=$7
 
 		if tst_cmd_available ping6; then
-		    tping="ping6"
+			tping="ping6"
 		else
-		    tping="ping -6"
+			tping="ping -6"
 			tst_res_ TINFO "ping6 binary/symlink is missing, using workaround. Please, report missing ping6 to your distribution."
 		fi
 		NETMASK=64
@@ -153,6 +155,8 @@ netns_setup()
 # ethernet device is then created for each namespace.
 netns_ns_exec_setup()
 {
+	local ret
+
 	NS_EXEC="ns_exec"
 
 	NS_HANDLE0=$(ns_create $NS_TYPE)
@@ -172,13 +176,8 @@ netns_ns_exec_setup()
 
 	$NS_EXEC $NS_HANDLE0 $NS_TYPE ns_ifmove veth1 $NS_HANDLE1
 	ret=$?
-	if [ $ret -eq 0 ]; then
-		return;
-	fi
-
-	if [ $ret -eq 32 ]; then
-		tst_brk TCONF "IFLA_NET_NS_PID not supported"
-	fi
+	[ $ret -eq 0 ] && return
+	[ $ret -eq 32 ] && tst_brk TCONF "IFLA_NET_NS_PID not supported"
 
 	tst_brk TBROK "unable to add device veth1 to the separate network namespace"
 }
@@ -215,9 +214,7 @@ netns_ip_setup()
 # of them (IPv4/IPv6 variant is decided by netns_setup() function).
 netns_set_ip()
 {
-	if [ -z "$NS_EXEC" ]; then
-		tst_brk TBROK "netns_setup() function must be called first"
-	fi
+	[ "$NS_EXEC" ] || tst_brk TBROK "netns_setup() function must be called first"
 
 	# This applies only for ipv6 variant:
 	# Do not accept Router Advertisements (accept_ra) and do not use
@@ -259,9 +256,7 @@ netns_set_ip()
 
 netns_ns_exec_cleanup()
 {
-	if [ -z "$NS_EXEC" ]; then
-		return
-	fi
+	[ "$NS_EXEC" ] || return
 
 	# removes veth0 device (which also removes the paired veth1 device)
 	$NS_EXEC $NS_HANDLE0 $NS_TYPE ip link delete veth0
@@ -273,9 +268,7 @@ netns_ns_exec_cleanup()
 
 netns_ip_cleanup()
 {
-	if [ -z "$NS_EXEC" ]; then
-		return
-	fi
+	[ "$NS_EXEC" ] || return
 
 	# removes veth0 device (which also removes the paired veth1 device)
 	$NS_EXEC $NS_HANDLE0 ip link delete veth0
-- 
2.32.0


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

* [LTP] [PATCH 0/3] netns_helper.sh: cleanup
  2021-07-16 10:04 [LTP] [PATCH 0/3] netns_helper.sh: cleanup Petr Vorel
                   ` (2 preceding siblings ...)
  2021-07-16 10:04 ` [LTP] [PATCH 3/3] netns_helper.sh: Formatting and style cleanup Petr Vorel
@ 2021-08-02 17:41 ` Petr Vorel
  3 siblings, 0 replies; 5+ messages in thread
From: Petr Vorel @ 2021-08-02 17:41 UTC (permalink / raw)
  To: ltp

Hi,

> Petr Vorel (3):
>   netns_helper.sh: Check for ping
>   netns_helper.sh: Check veth with TST_NEEDS_DRIVERS
>   netns_helper.sh: Formatting and style cleanup

>  .../kernel/containers/netns/netns_helper.sh   | 53 ++++++++-----------
>  1 file changed, 23 insertions(+), 30 deletions(-)

whole patchset merged

Kind regards,
Petr

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

end of thread, other threads:[~2021-08-02 17:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-16 10:04 [LTP] [PATCH 0/3] netns_helper.sh: cleanup Petr Vorel
2021-07-16 10:04 ` [LTP] [PATCH 1/3] netns_helper.sh: Check for ping Petr Vorel
2021-07-16 10:04 ` [LTP] [PATCH 2/3] netns_helper.sh: Check veth with TST_NEEDS_DRIVERS Petr Vorel
2021-07-16 10:04 ` [LTP] [PATCH 3/3] netns_helper.sh: Formatting and style cleanup Petr Vorel
2021-08-02 17:41 ` [LTP] [PATCH 0/3] netns_helper.sh: cleanup 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.