All of lore.kernel.org
 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

* [LTP] [PATCH] tst_net.sh: Fix root detection on netns on new shell API
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Alexey Kodanev @ 2019-08-27 12:22 UTC (permalink / raw)
  To: ltp

Hi Petr,
On 26.08.2019 17:11, Petr Vorel wrote:
> 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
> 

Agree

>  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

Can we fix tst_require_root_() instead?

>  
>  	local pid=
>  
> 


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

* [LTP] [PATCH] tst_net.sh: Fix root detection on netns on new shell API
  2019-08-27 12:22 ` Alexey Kodanev
@ 2019-08-29 19:21   ` Petr Vorel
  2019-08-29 19:35     ` Petr Vorel
  0 siblings, 1 reply; 4+ messages in thread
From: Petr Vorel @ 2019-08-29 19:21 UTC (permalink / raw)
  To: ltp

Hi Alexey,

> >  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?
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

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

* [LTP] [PATCH] tst_net.sh: Fix root detection on netns on new shell API
  2019-08-29 19:21   ` Petr Vorel
@ 2019-08-29 19:35     ` Petr Vorel
  0 siblings, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2019-08-29 19:35 UTC (permalink / raw)
  To: ltp

Hi Alexey,

> > >  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?
> 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.
Merged, with your ack and suggested-by tags.

Kind regards,
Petr

^ permalink raw reply	[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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.