Skip to contentSkip to conversation

lib/tst_net.sh: ignore errors on rhost with -i option in tst_net_run()

PATCH In review Alexey Kodanev 3 participants 7 messages Sep 13, 2021 – Nov 16, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 lib/tst_net.sh: ignore errors on rhost with -i option in tst_net_run()

Unfortanetly busysbox/sysctl with -e option only suppresses the warning about unknown keys and still returns exit code 1:
sysctl -h
...
-e don't warn about unknown keys

As a result busy_poll01 fails on this error:

    busy_poll01.sh
    busy_poll01 1 TINFO: initialize 'lhost' 'ltp_ns_veth2' interface
    ...
    busy_poll01 1 TINFO: set low latency busy poll to 50
    busy_poll01 1 TBROK: 'sysctl -q -w '-e' net.core.busy_read=50' failed on '': ''

So let's add a new option (-i) in tst_net_run() to ignore the error when running the command on "rhost".

---
 testcases/lib/tst_net.sh | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
testcases/lib/tst_net.sh +5 -3
index 958d71e3d..7f2a1bab3 100644
@@ -212,6 +212,7 @@ tst_rhost_run()
 # -l LPARAM: parameter passed to CMD in lhost
 # -r RPARAM: parameter passed to CMD in rhost
 # -q: quiet mode (suppress failure warnings)
+# -i: ignore errors on rhost
 # CMD: command to run (this must be binary, not shell builtin/function due
 # tst_rhost_run() limitation)
 # RETURN: 0 on success, 1 on missing CMD or exit code on lhost or rhost
@@ -227,12 +228,13 @@ tst_net_run()
 	local quiet
 
 	local OPTIND
-	while getopts l:qr:s opt; do
+	while getopts l:qr:si opt; do
 		case "$opt" in
 		l) lparams="$OPTARG" ;;
 		q) quiet=1 ;;
 		r) rparams="$OPTARG" ;;
 		s) lsafe="ROD"; rsafe="-s" ;;
+		i) rsafe="" ;;
 		*) tst_brk_ TBROK "tst_net_run: unknown option: $OPTARG" ;;
 		esac
 	done
@@ -916,9 +918,9 @@ tst_set_sysctl()
 	[ "$3" = "safe" ] && safe="-s"
 
 	local rparam=
-	[ "$TST_USE_NETNS" = "yes" ] && rparam="-r '-e'"
+	[ "$TST_USE_NETNS" = "yes" ] && rparam="-i -r '-e'"
 
-	tst_net_run $safe $rparam "sysctl" "-q -w $name=$value"
+	tst_net_run $safe -q $rparam "sysctl" "-q -w $name=$value"
 }
 
 tst_cleanup_rhost()
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/2 lib/tst_net.sh: disable ipv6_dad work on test interfaces

To fix intermittent issues with ping (in flood mode) [1] tests after initial test interfaces setup.

We're already adding IPv6 addresses with nodad option, but it should disable ipv6_dad for link-local addresses too, so that they are fully functional when tests start to use them.

It could also be tst_wait_ipv6_dad(), but it slows down a test setup.

[1]: https://github.com/iputils/iputils/issues/300

---
 testcases/lib/tst_net.sh | 2 ++
 1 file changed, 2 insertions(+)
testcases/lib/tst_net.sh +2 -0
index 7f2a1bab3..89d4c79ec 100644
@@ -517,6 +517,7 @@ 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 $?
 		ip link set $iface up
 		return $?
 	fi
@@ -528,6 +529,7 @@ 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 $?
 	tst_rhost_run -c "ip link set $iface up"
 }
 
Signature · 1 line
2.25.1
Tested-by on v1 2/2
#3 lore raw

Re: [LTP] [PATCH 2/2] lib/tst_net.sh: disable ipv6_dad work on test interfaces

In reply to Alexey Kodanev

Hi,
Obviously sysctl -qw net.ipv6.conf.$iface.accept_dad=0 would failed if ipv6 is off.
It caused failures of tests when ipv6 is off in our internal environment.
No mean to blame the commit, just report the issue : )

Thanks,
Su

________________________________________
From: Alexey Kodanev <[email protected]>
Sent: Monday, September 13, 2021 20:39
To: [email protected]
Cc: Alexey Kodanev; Su, Yue/苏 越
Subject: [PATCH 2/2] lib/tst_net.sh: disable ipv6_dad work on test interfaces

To fix intermittent issues with ping (in flood mode) [1] tests after initial test interfaces setup.

We're already adding IPv6 addresses with nodad option, but it should disable ipv6_dad for link-local addresses too, so that they are fully functional when tests start to use them.

It could also be tst_wait_ipv6_dad(), but it slows down a test setup.

[1]: https://github.com/iputils/iputils/issues/300

---
 testcases/lib/tst_net.sh | 2 ++
 1 file changed, 2 insertions(+)
testcases/lib/tst_net.sh +2 -0
index 7f2a1bab3..89d4c79ec 100644
@@ -517,6 +517,7 @@ 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 $?
                ip link set $iface up
                return $?
        fi
@@ -528,6 +529,7 @@ 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 $?
        tst_rhost_run -c "ip link set $iface up"
 }
 

--
2.25.1

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#5 lore raw

PATCH 1/2 lib/tst_net.sh: ignore errors on rhost with -i option in tst_net_run()

Hi Petr,

Quoted 6 lines · Petr Vorel

Hi Alexey,

good catch!

BTW are you going to send patch / report it to busybox? (I haven't find anything on ML)

Looking at busybox history, seems expected from the beginning there:

commit 64309f8669f08f2c3c16a3b5bf82d9cae84ec388

Author: Denis Vlasenko <[email protected]>
Date:   Thu Nov 29 06:40:28 2007 +0000

sysctl: add -e: supress warnings about invalid key (Jeremy Kerr <[email protected]>)

-e option unsets FLAG_SHOW_KEY_ERRORS.

busybox/sysctl: "-e Don't warn about unknown keys"
(Though, -q option can be used for that, which was added later, in 2012) vs
procps/sysctl: "-e, --ignore ignore unknown variables errors"

#6 lore raw

PATCH 1/2 lib/tst_net.sh: ignore errors on rhost with -i option in tst_net_run()

Hi Alexey,

Quoted 15 lines

Hi Petr,

Quoted 6 lines · Petr Vorel

Hi Alexey,

good catch!

BTW are you going to send patch / report it to busybox? (I haven't find anything on ML)

Looking at busybox history, seems expected from the beginning there:

commit 64309f8669f08f2c3c16a3b5bf82d9cae84ec388

Author: Denis Vlasenko <[email protected]>
Date:   Thu Nov 29 06:40:28 2007 +0000
Quoted 8 lines

sysctl: add -e: supress warnings about invalid key (Jeremy Kerr <[email protected]>)

-e option unsets FLAG_SHOW_KEY_ERRORS.

busybox/sysctl: "-e Don't warn about unknown keys"
(Though, -q option can be used for that, which was added later, in 2012) vs
procps/sysctl: "-e, --ignore ignore unknown variables errors"

Hm, IMHO it'd be good change to -e have 0 exit status. Because that's the behavior in procps-ng (tested on 3.3.17).

If you do it, please let me know and/or Cc me in your patch. Otherwise I'll do it.

Kind regards,
Petr