tst_net.sh: Fix root detection on netns on new shell API
PATCH 1/1 tst_net.sh: Fix root detection on netns on new shell API
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.
---
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(-)
testcases/lib/tst_net.sh +1 -1
@@ -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=
Signature · 1 line
2.22.0
PATCH 1/1 tst_net.sh: Fix root detection on netns on new shell API
Hi Petr,
Quoted 15 lines · Petr Vorel
When using LTP with netns ("Single Host Configuration"),
init_ltp_netspacebefore 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 nameltp_ns_veth1type veth peer nameltp_ns_veth2failedNOTE:
tst_restore_ipaddris called before running tests only on netns, ininit_ltp_netspace, thereforetst_require_root_as a check is enough.Signed-off-by Petr Vorel <[email protected]>---
Hi Alexey,
Quoted 11 lines
I also wanted to move variable setup (everything after
tst_default_max_pkt()definition) to separate function and call it insidetst_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 usetst_cleanup_rhostand_tst_require_rootdirectly, 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
Agree
testcases/lib/tst_net.sh tst_require_root_() · line 108
Quoted 13 lines
testcases/lib/tst_net.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)testcases/lib/tst_net.sh +1
-1@@ -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
Can we fix tst_require_root_() instead?
Quoted 4 lines
testcases/lib/tst_net.sh +0
-0local pid=
PATCH 1/1 tst_net.sh: Fix root detection on netns on new shell API
Hi Alexey,
Quoted 7 lines
testcases/lib/tst_net.sh tst_require_root_() · line 108
Quoted 5 lines
init_ltp_netspace()
{testcases/lib/tst_net.sh +1
-1tst_test_cmds ip - tst_require_root_ + [ -z "$TST_USE_LEGACY_API" ] && _tst_require_root || tst_require_rootCan we fix
tst_require_root_()instead?
I'll do.
I wanted to use API variable than call internal function. It's not a big issue and this function is called in _tst_require_root anyway.
NOTE: I've posted a patch which move variable and link setup to separate function, but I'm going to reject it myself. It's not an improvement and does not solve this solution. Sorry for the noise.
Kind regards,
Petr
PATCH 1/1 tst_net.sh: Fix root detection on netns on new shell API
Hi Alexey,
Quoted 7 lines
Quoted 7 lines
testcases/lib/tst_net.sh tst_require_root_() · line 108
Quoted 5 lines
init_ltp_netspace()
{testcases/lib/tst_net.sh +1
-1tst_test_cmds ip - tst_require_root_ + [ -z "$TST_USE_LEGACY_API" ] && _tst_require_root || tst_require_rootCan we fix
tst_require_root_()instead?
Quoted 7 lines
I'll do.
I wanted to use API variable than call internal function. It's not a big issue and this function is called in_tst_require_rootanyway.NOTE: I've posted a patch which move variable and link setup to separate function, but I'm going to reject it myself. It's not an improvement and does not solve this solution. Sorry for the noise.
Merged, with your ack and suggested-by tags.
Kind regards,
Petr