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

Petr Vorel pvorel@suse.cz
Tue May 10 15:06:56 CEST 2022


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 $?")




More information about the ltp mailing list