All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [RFC PATCH 0/2] tst_net.sh: Fix for disabled IPv6
@ 2022-01-19 19:55 Petr Vorel
  2022-01-19 19:55 ` [LTP] [RFC PATCH 1/2] " Petr Vorel
  2022-01-19 19:55 ` [LTP] [RFC PATCH 2/2] broken_ip-nexthdr.sh: Check IPv6 support before forcing it Petr Vorel
  0 siblings, 2 replies; 5+ messages in thread
From: Petr Vorel @ 2022-01-19 19:55 UTC (permalink / raw)
  To: ltp

Hi,

not elegant, but working.
Meant to be merged after release.

We could allow user to disable IPv6 even supported with variable
(might be useful for debugging).

Kind regards,
Petr

Petr Vorel (2):
  tst_net.sh: Fix for disabled IPv6
  broken_ip-nexthdr.sh: Check IPv6 support before forcing it

 testcases/lib/tst_net.sh                      | 66 +++++++++++++++----
 .../stress/broken_ip/broken_ip-nexthdr.sh     |  1 +
 2 files changed, 56 insertions(+), 11 deletions(-)

-- 
2.34.1


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

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

* [LTP] [RFC PATCH 1/2] tst_net.sh: Fix for disabled IPv6
  2022-01-19 19:55 [LTP] [RFC PATCH 0/2] tst_net.sh: Fix for disabled IPv6 Petr Vorel
@ 2022-01-19 19:55 ` Petr Vorel
  2022-01-24 14:19   ` Martin Doucha
  2022-01-19 19:55 ` [LTP] [RFC PATCH 2/2] broken_ip-nexthdr.sh: Check IPv6 support before forcing it Petr Vorel
  1 sibling, 1 reply; 5+ messages in thread
From: Petr Vorel @ 2022-01-19 19:55 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.

Tests which use TST_IPV6=6 needs to be fixed (unless they use
just tst_ipaddr_un()).

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/lib/tst_net.sh | 66 +++++++++++++++++++++++++++++++++-------
 1 file changed, 55 insertions(+), 11 deletions(-)

diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh
index 4dc0fca926..df16e12a26 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,30 @@ tst_brk_()
 	[ -z "$TST_USE_LEGACY_API" ] && tst_brk $@ || tst_brkm $@
 }
 
+tst_net_detect_ipv6()
+{
+	local type="${1:-lhost}"
+	local cmd='[ -f /proc/net/if_inet6 ]'
+
+	if [ "$type" = "lhost" ]; then
+		$cmd
+		return $?
+	fi
+
+	tst_rhost_run -c "$cmd"
+	return $?
+}
+
+tst_net_require_ipv6()
+{
+	local err="IPv6 not supported on:"
+	local missing
+
+	tst_net_detect_ipv6 || missing=" lhost"
+	tst_net_detect_ipv6 rhost || missing="$missing rhost"
+	[ -z "$missing" ] || tst_brk_ TCONF "$err$missing"
+}
+
 init_ltp_netspace()
 {
 	local pid
@@ -517,7 +543,9 @@ tst_init_iface()
 		ip link set $iface down || return $?
 		ip route flush dev $iface || return $?
 		ip addr flush dev $iface || return $?
-		sysctl -qw net.ipv6.conf.$iface.accept_dad=0 || return $?
+		if tst_net_detect_ipv6; then
+			sysctl -qw net.ipv6.conf.$iface.accept_dad=0 || return $?
+		fi
 		ip link set $iface up
 		return $?
 	fi
@@ -529,7 +557,9 @@ tst_init_iface()
 	tst_rhost_run -c "ip link set $iface down" || return $?
 	tst_rhost_run -c "ip route flush dev $iface" || return $?
 	tst_rhost_run -c "ip addr flush dev $iface" || return $?
-	tst_rhost_run -c "sysctl -qw net.ipv6.conf.$iface.accept_dad=0" || return $?
+	if tst_net_detect_ipv6 rhost; then
+		tst_rhost_run -c "sysctl -qw net.ipv6.conf.$iface.accept_dad=0" || return $?
+	fi
 	tst_rhost_run -c "ip link set $iface up"
 }
 
@@ -606,7 +636,9 @@ tst_restore_ipaddr()
 	local ret=0
 	local backup_tst_ipv6=$TST_IPV6
 	TST_IPV6= tst_add_ipaddr $type $link_num || ret=$?
-	TST_IPV6=6 tst_add_ipaddr $type $link_num || ret=$?
+	if tst_net_detect_ipv6; then
+		TST_IPV6=6 tst_add_ipaddr $type $link_num || ret=$?
+	fi
 	TST_IPV6=$backup_tst_ipv6
 
 	return $ret
@@ -971,8 +1003,10 @@ 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 $?")
+	if tst_net_detect_ipv6; 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 +1015,29 @@ if [ -z "$_tst_net_parse_variables" ]; then
 	eval $(tst_net_iface_prefix $IPV4_LHOST || echo "exit $?")
 	eval $(tst_rhost_run -c 'tst_net_iface_prefix -r '$IPV4_RHOST \
 		|| echo "exit $?")
-	eval $(tst_net_iface_prefix $IPV6_LHOST || echo "exit $?")
-	eval $(tst_rhost_run -c 'tst_net_iface_prefix -r '$IPV6_RHOST \
-		|| echo "exit $?")
+
+	if tst_net_detect_ipv6; then
+		eval $(tst_net_iface_prefix $IPV6_LHOST || echo "exit $?")
+	fi
+
+	if tst_net_detect_ipv6 rhost; then
+		eval $(tst_rhost_run -c 'tst_net_iface_prefix -r '$IPV6_RHOST \
+			|| echo "exit $?")
+	fi
 
 	eval $(tst_net_vars $IPV4_LHOST/$IPV4_LPREFIX \
 		$IPV4_RHOST/$IPV4_RPREFIX || echo "exit $?")
-	eval $(tst_net_vars $IPV6_LHOST/$IPV6_LPREFIX \
-		$IPV6_RHOST/$IPV6_RPREFIX || echo "exit $?")
+
+	if tst_net_detect_ipv6; 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.34.1


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

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

* [LTP] [RFC PATCH 2/2] broken_ip-nexthdr.sh: Check IPv6 support before forcing it
  2022-01-19 19:55 [LTP] [RFC PATCH 0/2] tst_net.sh: Fix for disabled IPv6 Petr Vorel
  2022-01-19 19:55 ` [LTP] [RFC PATCH 1/2] " Petr Vorel
@ 2022-01-19 19:55 ` Petr Vorel
  1 sibling, 0 replies; 5+ messages in thread
From: Petr Vorel @ 2022-01-19 19:55 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.34.1


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

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

* Re: [LTP] [RFC PATCH 1/2] tst_net.sh: Fix for disabled IPv6
  2022-01-19 19:55 ` [LTP] [RFC PATCH 1/2] " Petr Vorel
@ 2022-01-24 14:19   ` Martin Doucha
  2022-01-24 15:19     ` Petr Vorel
  0 siblings, 1 reply; 5+ messages in thread
From: Martin Doucha @ 2022-01-24 14:19 UTC (permalink / raw)
  To: Petr Vorel, ltp

Hi,

On 19. 01. 22 20:55, Petr Vorel wrote:
> Tests failed in tst_init_iface even IPv4 only test was run.
> Allow to init interfaces at least for IPv4.
> 
> Tests which use TST_IPV6=6 needs to be fixed (unless they use
> just tst_ipaddr_un()).
> 
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
>  testcases/lib/tst_net.sh | 66 +++++++++++++++++++++++++++++++++-------
>  1 file changed, 55 insertions(+), 11 deletions(-)
> 
> diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh
> index 4dc0fca926..df16e12a26 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,30 @@ tst_brk_()
>  	[ -z "$TST_USE_LEGACY_API" ] && tst_brk $@ || tst_brkm $@
>  }
>  
> +tst_net_detect_ipv6()
> +{
> +	local type="${1:-lhost}"
> +	local cmd='[ -f /proc/net/if_inet6 ]'
> +
> +	if [ "$type" = "lhost" ]; then
> +		$cmd
> +		return $?
> +	fi
> +
> +	tst_rhost_run -c "$cmd"
> +	return $?
> +}

tst_net_detect_ipv6() should probably run each check only once and cache
the result. The function is called multiple times and tst_rhost_run()
could be quite slow if the remote side is on a different physical machine.

-- 
Martin Doucha   mdoucha@suse.cz
QA Engineer for Software Maintenance
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic

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

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

* Re: [LTP] [RFC PATCH 1/2] tst_net.sh: Fix for disabled IPv6
  2022-01-24 14:19   ` Martin Doucha
@ 2022-01-24 15:19     ` Petr Vorel
  0 siblings, 0 replies; 5+ messages in thread
From: Petr Vorel @ 2022-01-24 15:19 UTC (permalink / raw)
  To: Martin Doucha; +Cc: ltp

Hi Martin,

> tst_net_detect_ipv6() should probably run each check only once and cache
> the result. The function is called multiple times and tst_rhost_run()
> could be quite slow if the remote side is on a different physical machine.
You're right, ssh result needs to be cached. Thanks for a review!

Kind regards,
Petr

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

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

end of thread, other threads:[~2022-01-24 15:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-19 19:55 [LTP] [RFC PATCH 0/2] tst_net.sh: Fix for disabled IPv6 Petr Vorel
2022-01-19 19:55 ` [LTP] [RFC PATCH 1/2] " Petr Vorel
2022-01-24 14:19   ` Martin Doucha
2022-01-24 15:19     ` Petr Vorel
2022-01-19 19:55 ` [LTP] [RFC PATCH 2/2] broken_ip-nexthdr.sh: Check IPv6 support before forcing it 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.