* [LTP] [PATCH v5 1/3] net: Add tst_net_run helper
@ 2018-11-30 20:37 Petr Vorel
2018-11-30 20:37 ` [LTP] [PATCH v5 2/3] net/ipsec: Add check for xfrm_user kernel module Petr Vorel
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Petr Vorel @ 2018-11-30 20:37 UTC (permalink / raw)
To: ltp
and use it in tst_set_sysctl
+ improve doc of tst_rhost_run()
Signed-off-by: Petr Vorel <pvorel@suse.cz>
Reviewed-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
Changes v4->v5:
* Add -q mode (default off) in tst_net_run()
* Fix in tst_set_sysctl() for rhost (passed everything as single command
to avoid processing -w in tst_net_run() as getopt.
---
testcases/lib/tst_net.sh | 70 ++++++++++++++++++++++++++++++++++------
1 file changed, 60 insertions(+), 10 deletions(-)
diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh
index d1206e285..953ae68ab 100644
--- a/testcases/lib/tst_net.sh
+++ b/testcases/lib/tst_net.sh
@@ -131,7 +131,8 @@ init_ltp_netspace()
# -b run in background
# -B run in background and save output to $TST_TMPDIR/bg.cmd
# -s safe option, if something goes wrong, will exit with TBROK
-# -c specify command to run
+# -c specify command to run (this must be binary, not shell buildin/function)
+# RETURN: 0 on success, 1 on failure
tst_rhost_run()
{
local pre_cmd=
@@ -191,6 +192,61 @@ tst_rhost_run()
return $ret
}
+# Run command on both lhost and rhost.
+# tst_net_run [-s] [-l LPARAM] [-r RPARAM] [ -q ] CMD [ARG [ARG2]]
+# Options:
+# -l LPARAM: parameter passed to CMD in lhost
+# -r RPARAM: parameter passed to CMD in rhost
+# -q: quiet mode (suppress failure warnings)
+# CMD: command to run (this must be binary, not shell buildin/function due
+# tst_rhost_run() limitation)
+# RETURN: 0 on success, 1 on missing CMD or exit code on lhost or rhost
+tst_net_run()
+{
+ local cmd
+ local lparams
+ local rparams
+ local lsafe
+ local rsafe
+ local lret
+ local rret
+ local quiet
+
+ local OPTIND
+ while getopts l:qr:s opt; do
+ case "$opt" in
+ l) lparams="$OPTARG" ;;
+ q) quiet=1 ;;
+ r) rparams="$OPTARG" ;;
+ s) lsafe="ROD"; rsafe="-s" ;;
+ *) tst_brk_ TBROK "tst_net_run: unknown option: $OPTARG" ;;
+ esac
+ done
+ shift $((OPTIND - 1))
+ cmd="$1"
+ shift
+
+ if [ -z "$cmd" ]; then
+ [ -n "$lsafe" ] && \
+ tst_brk_ TBROK "tst_net_run: command not defined"
+ tst_res_ TWARN "tst_net_run: command not defined"
+ return 1
+ fi
+
+ $lsafe $cmd $lparams $@
+ lret=$?
+ tst_rhost_run $rsafe -c "$cmd $rparams $@"
+ rret=$?
+
+ if [ -z "$quiet" ]; then
+ [ $lret -ne 0 ] && tst_res_ TWARN "tst_net_run: lhost command failed: $lret"
+ [ $rret -ne 0 ] && tst_res_ TWARN "tst_net_run: rhost command failed: $rret"
+ fi
+
+ [ $lret -ne 0 ] && return $lret
+ return $rret
+}
+
EXPECT_RHOST_PASS()
{
tst_rhost_run -c "$*" > /dev/null
@@ -642,16 +698,10 @@ tst_set_sysctl()
local safe=
[ "$3" = "safe" ] && safe="-s"
- local add_opt=
- [ "$TST_USE_NETNS" = "yes" ] && add_opt="-e"
-
- if [ "$safe" ]; then
- ROD sysctl -q -w $name=$value
- else
- sysctl -q -w $name=$value
- fi
+ local rparam=
+ [ "$TST_USE_NETNS" = "yes" ] && rparam="-e"
- tst_rhost_run $safe -c "sysctl -q -w $add_opt $name=$value"
+ tst_net_run $safe -r $rparam "sysctl -q -w $name=$value"
}
tst_cleanup_rhost()
--
2.19.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [LTP] [PATCH v5 2/3] net/ipsec: Add check for xfrm_user kernel module
2018-11-30 20:37 [LTP] [PATCH v5 1/3] net: Add tst_net_run helper Petr Vorel
@ 2018-11-30 20:37 ` Petr Vorel
2018-11-30 20:37 ` [LTP] [PATCH v5 3/3] network/mpls: Use tst_net_run() Petr Vorel
2018-12-18 1:07 ` [LTP] [PATCH v5 1/3] net: Add tst_net_run helper Petr Vorel
2 siblings, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2018-11-30 20:37 UTC (permalink / raw)
To: ltp
xfrm_user is required by ip xfrm command.
Check is performed only when needed.
Call in cleanup function could trigger infinite loop,
therefore check only once.
NOTE: we cannot use tst_test_drivers() due tst_rhost_run() limitation.
Signed-off-by: Petr Vorel <pvorel@suse.cz>
Suggested-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
testcases/network/stress/ipsec/ipsec_lib.sh | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/testcases/network/stress/ipsec/ipsec_lib.sh b/testcases/network/stress/ipsec/ipsec_lib.sh
index b099fdeaf..74d4fc0cb 100644
--- a/testcases/network/stress/ipsec/ipsec_lib.sh
+++ b/testcases/network/stress/ipsec/ipsec_lib.sh
@@ -81,6 +81,12 @@ ipsec_lib_setup()
cleanup_vti=
ALG=
ALGR=
+
+ if [ -n "$IPSEC_MODE" ]; then
+ tst_net_run "tst_check_drivers xfrm_user" || \
+ tst_brk TCONF "xfrm_user driver not available on lhost or rhost"
+ cleanup_xfrm=1
+ fi
}
TST_OPTS="l:m:p:s:S:k:A:e:a:c:r:"
@@ -110,6 +116,8 @@ tst_ipsec_setup()
# tst_ipsec_cleanup: flush ipsec state and policy rules
tst_ipsec_cleanup()
{
+ [ -z "$cleanup_xfrm" ] && return
+
ip xfrm state flush
ip xfrm policy flush
tst_rhost_run -c "ip xfrm state flush && ip xfrm policy flush"
--
2.19.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [LTP] [PATCH v5 3/3] network/mpls: Use tst_net_run()
2018-11-30 20:37 [LTP] [PATCH v5 1/3] net: Add tst_net_run helper Petr Vorel
2018-11-30 20:37 ` [LTP] [PATCH v5 2/3] net/ipsec: Add check for xfrm_user kernel module Petr Vorel
@ 2018-11-30 20:37 ` Petr Vorel
2018-12-18 1:07 ` [LTP] [PATCH v5 1/3] net: Add tst_net_run helper Petr Vorel
2 siblings, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2018-11-30 20:37 UTC (permalink / raw)
To: ltp
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
New commit.
---
testcases/network/mpls/mpls_lib.sh | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/testcases/network/mpls/mpls_lib.sh b/testcases/network/mpls/mpls_lib.sh
index 43ec16a6e..c64b46c9d 100755
--- a/testcases/network/mpls/mpls_lib.sh
+++ b/testcases/network/mpls/mpls_lib.sh
@@ -37,8 +37,7 @@ mpls_setup()
{
local label="$1"
- ROD modprobe -a $TST_NEEDS_DRIVERS
- tst_rhost_run -s -c "modprobe -a $TST_NEEDS_DRIVERS"
+ tst_net_run -s "modprobe -a $TST_NEEDS_DRIVERS"
ROD sysctl -q net.mpls.conf.$(tst_iface).input=1
tst_set_sysctl net.mpls.conf.lo.input 1 safe
--
2.19.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [LTP] [PATCH v5 1/3] net: Add tst_net_run helper
2018-11-30 20:37 [LTP] [PATCH v5 1/3] net: Add tst_net_run helper Petr Vorel
2018-11-30 20:37 ` [LTP] [PATCH v5 2/3] net/ipsec: Add check for xfrm_user kernel module Petr Vorel
2018-11-30 20:37 ` [LTP] [PATCH v5 3/3] network/mpls: Use tst_net_run() Petr Vorel
@ 2018-12-18 1:07 ` Petr Vorel
2 siblings, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2018-12-18 1:07 UTC (permalink / raw)
To: ltp
Hi,
> and use it in tst_set_sysctl
> + improve doc of tst_rhost_run()
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> Reviewed-by: Alexey Kodanev <alexey.kodanev@oracle.com>
> ---
> Changes v4->v5:
> * Add -q mode (default off) in tst_net_run()
> * Fix in tst_set_sysctl() for rhost (passed everything as single command
> to avoid processing -w in tst_net_run() as getopt.
FYI patchset merged.
Kind regards,
Petr
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-12-18 1:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-30 20:37 [LTP] [PATCH v5 1/3] net: Add tst_net_run helper Petr Vorel
2018-11-30 20:37 ` [LTP] [PATCH v5 2/3] net/ipsec: Add check for xfrm_user kernel module Petr Vorel
2018-11-30 20:37 ` [LTP] [PATCH v5 3/3] network/mpls: Use tst_net_run() Petr Vorel
2018-12-18 1:07 ` [LTP] [PATCH v5 1/3] net: Add tst_net_run helper Petr Vorel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox