From: Richard Palethorpe <rpalethorpe@suse.de>
To: Petr Vorel <pvorel@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2 2/2] tst_net.sh: Detect IPv6 disabled on interface via sysctl
Date: Tue, 07 Mar 2023 13:01:07 +0000 [thread overview]
Message-ID: <87lek87m1x.fsf@suse.de> (raw)
In-Reply-To: <20230217151036.10295-3-pvorel@suse.cz>
Petr Vorel <pvorel@suse.cz> writes:
> IPv6 on interface can be also disabled by sysctl
> net.ipv6.conf.$iface.disable_ipv6=1. This is better to be checked:
> * for all interfaces before run (can be disabled even for netns
> interface previously created).
> * before ip addr command tries to work with IPv6 (in tst_init_iface()
> and tst_add_ipaddr(), other functions should run these before)
>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
Acked-by: Richard Palethorpe <rpalethorpe@suse.com>
> ---
> testcases/lib/tst_net.sh | 46 ++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 46 insertions(+)
>
> diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh
> index 96eed50793..f414dd9359 100644
> --- a/testcases/lib/tst_net.sh
> +++ b/testcases/lib/tst_net.sh
> @@ -121,6 +121,47 @@ tst_net_detect_ipv6()
> TST_NET_IPV6_ENABLED=1
> }
>
> +# Detect IPv6 disabled on interface via sysctl
> +# net.ipv6.conf.$iface.disable_ipv6=1.
> +# $TST_NET_IPV6_ENABLED: 1 on IPv6 enabled, 0 on IPv6 disabled.
> +# return: 0 on IPv6 enabled, 1 on IPv6 disabled.
> +tst_net_detect_ipv6_iface()
> +{
> + [ "$TST_NET_IPV6_ENABLED" = 1 ] || return 1
> +
> + local iface="$1"
> + local type="${2:-lhost}"
> + local check="sysctl -n net.ipv6.conf.$iface.disable_ipv6"
> + local disabled
> +
> + if [ "$type" = "lhost" ]; then
> + disabled=$($check)
> + else
> + disabled=$(tst_rhost_run -c "$check")
> + fi
> + if [ $disabled = 1 ]; then
> + tst_res_ TINFO "IPv6 disabled on $type on $iface"
> + TST_NET_IPV6_ENABLED=0
> + return 1
> + fi
> +
> + return 0
> +}
> +
> +# Detect IPv6 disabled on used interfaces.
> +tst_net_check_ifaces_ipv6()
> +{
> + local iface
> +
> + for iface in $(tst_get_ifaces); do
> + tst_net_detect_ipv6_iface || return
> + done
> +
> + for iface in $(tst_get_ifaces rhost); do
> + tst_net_detect_ipv6_iface $iface rhost || return
> + done
> +}
> +
> tst_net_require_ipv6()
> {
> [ "$TST_NET_IPV6_ENABLED" = 1 ] || tst_brk_ TCONF "IPv6 disabled"
> @@ -531,7 +572,9 @@ tst_init_iface()
> local type="${1:-lhost}"
> local link_num="${2:-0}"
> local iface="$(tst_iface $type $link_num)"
> +
> tst_res_ TINFO "initialize '$type' '$iface' interface"
> + tst_net_detect_ipv6_iface $iface $type
>
> if [ "$type" = "lhost" ]; then
> if ip xfrm state 1>/dev/null 2>&1; then
> @@ -591,6 +634,8 @@ tst_add_ipaddr()
> local link_num="${2:-0}"
> local iface=$(tst_iface $type $link_num)
>
> + tst_net_detect_ipv6_iface $iface $type
> +
> if [ "$TST_IPV6" ]; then
> dad="nodad"
> [ "$type" = "lhost" ] && mask=$IPV6_LPREFIX || mask=$IPV6_RPREFIX
> @@ -1005,6 +1050,7 @@ tst_net_setup_network()
> $IPV4_RHOST/$IPV4_RPREFIX || echo "exit $?")
>
> if [ "$TST_NET_IPV6_ENABLED" = 1 ]; then
> + tst_net_check_ifaces_ipv6
> eval $(tst_net_iface_prefix $IPV6_LHOST || echo "exit $?")
> eval $(tst_rhost_run -c 'tst_net_iface_prefix -r '$IPV6_RHOST \
> || echo "exit $?")
> --
> 2.39.1
--
Thank you,
Richard.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2023-03-07 13:01 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
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 [this message]
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=87lek87m1x.fsf@suse.de \
--to=rpalethorpe@suse.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox