All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Petr Vorel <pvorel@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2 1/2] tst_net.sh: Detect IPv6 disabled via sysct
Date: Wed, 22 Mar 2023 14:08:15 +0100	[thread overview]
Message-ID: <ZBr9v2cz6/gmksAW@yuki> (raw)
In-Reply-To: <20230217151036.10295-2-pvorel@suse.cz>

Hi!
> net.ipv6.conf.all.disable_ipv6=1 disables IPv6 on all interfaces
> (including both already created and later created).
> 
> The check prevent failures on IPv6 tests, and error messages on both
> IPv4 and IPv4 tests:
> 
>     # sysctl -w net.ipv6.conf.all.disable_ipv6=1
>     # ./ping02.sh -6
>     ping02 1 TINFO: tst_rhost_run: cmd: [ -f /proc/net/if_inet6 ]
>     ping02 1 TINFO: NETNS: sh -c " [ -f /proc/net/if_inet6 ] || echo RTERR" 2>&1
>     ping02 1 TINFO: initialize 'lhost' 'ltp_ns_veth2' interface
>     ping02 1 TINFO: add local addr 10.0.0.2/24
>     ping02 1 TINFO: add local addr fd00:1:1:1::2/64
>     RTNETLINK answers: Permission denied
>     ping02 1 TINFO: initialize 'rhost' 'ltp_ns_veth1' interface
>     ...
>     ping02 1 TINFO: timeout per run is 0h 5m 0s
>     ping6: connect: Network is unreachable
>     ping02 1 TFAIL: ping6 -I ltp_ns_veth2 -c 3 -s 8 -f -p 000102030405060708090a0b0c0d0e0f fd00:1:1:1::1 >/dev/null failed unexpectedly
> 
> Suggested-by: Cyril Hrubis <chrubis@suse.cz>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
>  testcases/lib/tst_net.sh | 26 +++++++++++++++++++++-----
>  1 file changed, 21 insertions(+), 5 deletions(-)
> 
> diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh
> index fc64a588ae..96eed50793 100644
> --- a/testcases/lib/tst_net.sh
> +++ b/testcases/lib/tst_net.sh
> @@ -84,25 +84,41 @@ tst_brk_()
>  	[ -z "$TST_USE_LEGACY_API" ] && tst_brk $@ || tst_brkm $@
>  }
>  
> +# Detect IPv6 disabled via ipv6.disable=1 kernel cmdline parameter
> +# or sysctl net.ipv6.conf.all.disable_ipv6=1 (disables IPv6 on all
> +# interfaces (including both already created and later created).
> +# $TST_NET_IPV6_ENABLED: 1 on IPv6 enabled, 0 on IPv6 disabled.
>  tst_net_detect_ipv6()
>  {
>  	local type="${1:-lhost}"
>  	local cmd='[ -f /proc/net/if_inet6 ]'
> -	local ret
> +	local disabled iface ret
>  
>  	if [ "$type" = "lhost" ]; then
>  		$cmd
>  	else
>  		tst_rhost_run -c "$cmd"
>  	fi
> -	ret=$?
>  
> -	if [ $ret -eq 0 ]; then
> -		TST_NET_IPV6_ENABLED=1
> +	if [ $? -ne 0 ]; then
> +		TST_NET_IPV6_ENABLED=0
> +		tst_res_ TINFO "IPv6 disabled on $type via ipv6.disable=1"

Doesn't this happen also in the unlikely case that CONFIG_IPV6 is not
set?

So maybe "IPv6 disabled on kernel commandline or not compiled in"

> +		return
> +	fi
> +
> +	cmd='sysctl -n net.ipv6.conf.all.disable_ipv6'

I'm not sure why we should use sysctl when this the same as doing

cat /proc/sys/net/ipv6/conf/all/disable_ipv6

Or is there any added value from the sysctl command?

> +	if [ "$type" = "lhost" ]; then
> +		disabled=$($cmd)
>  	else
> +		disabled=$(tst_rhost_run -c "$cmd")
> +	fi
> +	if [ $disabled = 1 ]; then
> +		tst_res_ TINFO "IPv6 disabled on $type net.ipv6.conf.all.disable_ipv6=1"
>  		TST_NET_IPV6_ENABLED=0
> -		tst_res_ TINFO "IPv6 disabled on $type"
> +		return
>  	fi
> +
> +	TST_NET_IPV6_ENABLED=1
>  }
>  
>  tst_net_require_ipv6()
> -- 
> 2.39.1
> 

-- 
Cyril Hrubis
chrubis@suse.cz

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

  parent reply	other threads:[~2023-03-22 13:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-17 15:10 [LTP] [PATCH v2 0/2] tst_net.sh IPv6 sysctl fixes Petr Vorel
2023-02-17 15:10 ` [LTP] [PATCH v2 1/2] tst_net.sh: Detect IPv6 disabled via sysct Petr Vorel
2023-03-07 12:59   ` Richard Palethorpe
2023-03-22 13:08   ` Cyril Hrubis [this message]
2023-03-22 16:20     ` Petr Vorel
2023-03-22 16:35       ` Petr Vorel
2023-03-22 16:35       ` Cyril Hrubis
2023-03-23  5:17         ` Petr Vorel
2023-02-17 15:10 ` [LTP] [PATCH v2 2/2] tst_net.sh: Detect IPv6 disabled on interface via sysctl Petr Vorel
2023-03-07 13:01   ` Richard Palethorpe
2023-03-22 13:10   ` Cyril Hrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZBr9v2cz6/gmksAW@yuki \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    --cc=pvorel@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.