Linux Test Project
 help / color / mirror / Atom feed
* [LTP] [PATCH] tst_net.sh: Fix root detection on netns on new shell API
@ 2019-08-26 14:11 Petr Vorel
  2019-08-27 12:22 ` Alexey Kodanev
  0 siblings, 1 reply; 4+ messages in thread
From: Petr Vorel @ 2019-08-26 14:11 UTC (permalink / raw)
  To: ltp

When using LTP with netns ("Single Host Configuration"),
init_ltp_netspace before running test which performs checking for
TST_NEEDS_ROOT=1, therefore adding it is not enough.
It fails on adding netns:

RTNETLINK answers: Operation not permitted
sctp01 1 TBROK: ip li add name ltp_ns_veth1 type veth peer name ltp_ns_veth2 failed

NOTE: tst_restore_ipaddr is called before running tests only on netns,
in init_ltp_netspace, therefore tst_require_root_ as a check is enough.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Hi Alexey,

I also wanted to move variable setup (everything after
tst_default_max_pkt() definition) to separate function and call it
inside tst_net_setup() for new shell API, but all TST_* setup
(currently at least TST_TMPDIR_RHOST=1 and TST_NEEDS_ROOT=1)
would not work (we'd need to use tst_cleanup_rhost and _tst_require_root
directly, which is IMHO not good).

+ We might want to cleanup variables (prefix library internal variables
with _tst_net, use lower case), at least these two:
s/ping6_warn_printed/_tst_net_ping6_warn_printed/g
s/TST_PARSE_VARIABLES/_tst_net_parse_variables/g

 testcases/lib/tst_net.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh
index 1678bcfda..5a149530c 100644
--- a/testcases/lib/tst_net.sh
+++ b/testcases/lib/tst_net.sh
@@ -105,7 +105,7 @@ tst_require_root_()
 init_ltp_netspace()
 {
 	tst_test_cmds ip
-	tst_require_root_
+	[ -z "$TST_USE_LEGACY_API" ] && _tst_require_root || tst_require_root
 
 	local pid=
 
-- 
2.22.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-08-29 19:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-26 14:11 [LTP] [PATCH] tst_net.sh: Fix root detection on netns on new shell API Petr Vorel
2019-08-27 12:22 ` Alexey Kodanev
2019-08-29 19:21   ` Petr Vorel
2019-08-29 19:35     ` Petr Vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox