All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/2] test_net.sh: add tst_set_sysctl()
@ 2017-01-25 14:21 Alexey Kodanev
  2017-01-25 14:21 ` [LTP] [PATCH 2/2] net: dctcp01: apply tst_set_sysctl() Alexey Kodanev
  2017-01-31 10:07 ` [LTP] [PATCH 1/2] test_net.sh: add tst_set_sysctl() Cyril Hrubis
  0 siblings, 2 replies; 7+ messages in thread
From: Alexey Kodanev @ 2017-01-25 14:21 UTC (permalink / raw)
  To: ltp

It can handle the case when sysctl is not namespaceified.

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 testcases/lib/test_net.sh |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/testcases/lib/test_net.sh b/testcases/lib/test_net.sh
index 37cc939..43a1d59 100644
--- a/testcases/lib/test_net.sh
+++ b/testcases/lib/test_net.sh
@@ -390,6 +390,27 @@ tst_ping()
 	return $ret
 }
 
+# tst_set_sysctl NAME VALUE [safe]
+# It can handle netns case when sysctl not namespaceified.
+tst_set_sysctl()
+{
+	local name="$1"
+	local value="$2"
+	local safe=
+	[ "$3" = "safe" ] && safe="-s" || safe=""
+
+	local add_opt=
+	[ "$TST_USE_NETNS" = "yes" ] && add_opt="-e"
+
+	if [ "$safe" ]; then
+		ROD sysctl -qw $name=$value
+	else
+		sysctl -qw $name=$value
+	fi
+
+	tst_rhost_run $safe -c "sysctl -qw $add_opt $name=$value"
+}
+
 # Management Link
 [ -z "$RHOST" ] && TST_USE_NETNS="yes"
 export RHOST="$RHOST"
-- 
1.7.1


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

* [LTP] [PATCH 2/2] net: dctcp01: apply tst_set_sysctl()
  2017-01-25 14:21 [LTP] [PATCH 1/2] test_net.sh: add tst_set_sysctl() Alexey Kodanev
@ 2017-01-25 14:21 ` Alexey Kodanev
  2017-01-31 10:07 ` [LTP] [PATCH 1/2] test_net.sh: add tst_set_sysctl() Cyril Hrubis
  1 sibling, 0 replies; 7+ messages in thread
From: Alexey Kodanev @ 2017-01-25 14:21 UTC (permalink / raw)
  To: ltp

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 testcases/network/dctcp/dctcp01.sh |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/testcases/network/dctcp/dctcp01.sh b/testcases/network/dctcp/dctcp01.sh
index 5c401ce..ebb59f6 100755
--- a/testcases/network/dctcp/dctcp01.sh
+++ b/testcases/network/dctcp/dctcp01.sh
@@ -29,16 +29,13 @@ set_cong_alg()
 	local alg=$1
 	tst_resm TINFO "setting $alg"
 
-	ROD sysctl -q -w net.ipv4.tcp_congestion_control=$alg
-	tst_rhost_run -s -c "sysctl -q -w net.ipv4.tcp_congestion_control=$alg"
+	tst_set_sysctl net.ipv4.tcp_congestion_control $alg safe
 }
 
 cleanup()
 {
 	if [ "$prev_cong_ctl" ]; then
-		sysctl -q -w net.ipv4.tcp_congestion_control=$prev_alg
-		tst_rhost_run -c \
-			"sysctl -q -w net.ipv4.tcp_congestion_control=$prev_alg"
+		tst_set_sysctl net.ipv4.tcp_congestion_control $prev_alg
 	fi
 	tst_rmdir
 	tc qdisc del dev $(tst_iface) root netem loss 0.03% ecn
@@ -61,7 +58,7 @@ setup()
 
 	tst_tmpdir
 
-	prev_alg="$(cat /proc/sys/net/ipv4/tcp_congestion_control)"
+	prev_alg="$(sysctl -n net.ipv4.tcp_congestion_control)"
 }
 
 test_run()
-- 
1.7.1


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

* [LTP] [PATCH 1/2] test_net.sh: add tst_set_sysctl()
  2017-01-25 14:21 [LTP] [PATCH 1/2] test_net.sh: add tst_set_sysctl() Alexey Kodanev
  2017-01-25 14:21 ` [LTP] [PATCH 2/2] net: dctcp01: apply tst_set_sysctl() Alexey Kodanev
@ 2017-01-31 10:07 ` Cyril Hrubis
  2017-01-31 11:27   ` Alexey Kodanev
  1 sibling, 1 reply; 7+ messages in thread
From: Cyril Hrubis @ 2017-01-31 10:07 UTC (permalink / raw)
  To: ltp

Hi!
> +# tst_set_sysctl NAME VALUE [safe]
> +# It can handle netns case when sysctl not namespaceified.
> +tst_set_sysctl()
> +{
> +	local name="$1"
> +	local value="$2"
> +	local safe=
> +	[ "$3" = "safe" ] && safe="-s" || safe=""

Uh, this syntax is confusing, besides isn't safe set to empty string
anyway?

> +	local add_opt=
> +	[ "$TST_USE_NETNS" = "yes" ] && add_opt="-e"
> +
> +	if [ "$safe" ]; then
> +		ROD sysctl -qw $name=$value
> +	else
> +		sysctl -qw $name=$value
> +	fi
> +
> +	tst_rhost_run $safe -c "sysctl -qw $add_opt $name=$value"
> +}

And maybe the function name should say that we are changing the
parameter both on local and remote machine. Maybe just rename the
function to tst_set_sysctls().

>  # Management Link
>  [ -z "$RHOST" ] && TST_USE_NETNS="yes"
>  export RHOST="$RHOST"
> -- 
> 1.7.1
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH 1/2] test_net.sh: add tst_set_sysctl()
  2017-01-31 10:07 ` [LTP] [PATCH 1/2] test_net.sh: add tst_set_sysctl() Cyril Hrubis
@ 2017-01-31 11:27   ` Alexey Kodanev
  2017-01-31 12:41     ` Cyril Hrubis
  0 siblings, 1 reply; 7+ messages in thread
From: Alexey Kodanev @ 2017-01-31 11:27 UTC (permalink / raw)
  To: ltp

Hi,

On 01/31/2017 01:07 PM, Cyril Hrubis wrote:

> Hi!
>> +# tst_set_sysctl NAME VALUE [safe]
>> +# It can handle netns case when sysctl not namespaceified.
>> +tst_set_sysctl()
>> +{
>> +	local name="$1"
>> +	local value="$2"
>> +	local safe=
>> +	[ "$3" = "safe" ] && safe="-s" || safe=""
> Uh, this syntax is confusing, besides isn't safe set to empty string
> anyway?

What if we set TST_NO_CLEANUP just before calling cleanup()
or unset TST_CLEANUP... then we can use ROD, etc. in cleanup?


diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index c6a85f3..c1e75ec 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -35,6 +35,7 @@ tst_do_exit()

         if [ -n "$TST_SETUP_STARTED" -a -n "$TST_CLEANUP" -a \
              -z "$TST_NO_CLEANUP" ]; then
+               export TST_NO_CLEANUP="yes"
                 $TST_CLEANUP
         fi


>
>> +	local add_opt=
>> +	[ "$TST_USE_NETNS" = "yes" ] && add_opt="-e"
>> +
>> +	if [ "$safe" ]; then
>> +		ROD sysctl -qw $name=$value
>> +	else
>> +		sysctl -qw $name=$value
>> +	fi
>> +
>> +	tst_rhost_run $safe -c "sysctl -qw $add_opt $name=$value"
>> +}
> And maybe the function name should say that we are changing the
> parameter both on local and remote machine. Maybe just rename the
> function to tst_set_sysctls().

OK

Thanks,
Alexey


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

* [LTP] [PATCH 1/2] test_net.sh: add tst_set_sysctl()
  2017-01-31 11:27   ` Alexey Kodanev
@ 2017-01-31 12:41     ` Cyril Hrubis
  2017-01-31 13:38       ` Alexey Kodanev
  0 siblings, 1 reply; 7+ messages in thread
From: Cyril Hrubis @ 2017-01-31 12:41 UTC (permalink / raw)
  To: ltp

Hi!
> >> +# tst_set_sysctl NAME VALUE [safe]
> >> +# It can handle netns case when sysctl not namespaceified.
> >> +tst_set_sysctl()
> >> +{
> >> +	local name="$1"
> >> +	local value="$2"
> >> +	local safe=
> >> +	[ "$3" = "safe" ] && safe="-s" || safe=""
> > Uh, this syntax is confusing, besides isn't safe set to empty string
> > anyway?
> 
> What if we set TST_NO_CLEANUP just before calling cleanup()
> or unset TST_CLEANUP... then we can use ROD, etc. in cleanup?

You lost me here. How is this connected to the code I've commented?

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH 1/2] test_net.sh: add tst_set_sysctl()
  2017-01-31 12:41     ` Cyril Hrubis
@ 2017-01-31 13:38       ` Alexey Kodanev
  2017-01-31 15:23         ` Cyril Hrubis
  0 siblings, 1 reply; 7+ messages in thread
From: Alexey Kodanev @ 2017-01-31 13:38 UTC (permalink / raw)
  To: ltp

On 01/31/2017 03:41 PM, Cyril Hrubis wrote:
> Hi!
>>>> +# tst_set_sysctl NAME VALUE [safe]
>>>> +# It can handle netns case when sysctl not namespaceified.
>>>> +tst_set_sysctl()
>>>> +{
>>>> +	local name="$1"
>>>> +	local value="$2"
>>>> +	local safe=
>>>> +	[ "$3" = "safe" ] && safe="-s" || safe=""
>>> Uh, this syntax is confusing, besides isn't safe set to empty string
>>> anyway?
>> What if we set TST_NO_CLEANUP just before calling cleanup()
>> or unset TST_CLEANUP... then we can use ROD, etc. in cleanup?
> You lost me here. How is this connected to the code I've commented?

In the 2nd patch, 'safe' option is used like this:

do_cleanup()
{
    tst_set_sysctl net.ipv4.tcp_cong...
}

do_test()
{
    tst_set_sysctl net.ipv4.tcp_cong... safe
}

So, the main reason for splitting the code with 'safe' option is to be
able to call this function inside cleanup. But if we handle cleanup
recursion inside the shell library, we can get rid of 'safe' option
and simplify tst_set_sysctls().

Thanks,
Alexey

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

* [LTP] [PATCH 1/2] test_net.sh: add tst_set_sysctl()
  2017-01-31 13:38       ` Alexey Kodanev
@ 2017-01-31 15:23         ` Cyril Hrubis
  0 siblings, 0 replies; 7+ messages in thread
From: Cyril Hrubis @ 2017-01-31 15:23 UTC (permalink / raw)
  To: ltp

Hi!
> >>>> +# tst_set_sysctl NAME VALUE [safe]
> >>>> +# It can handle netns case when sysctl not namespaceified.
> >>>> +tst_set_sysctl()
> >>>> +{
> >>>> +	local name="$1"
> >>>> +	local value="$2"
> >>>> +	local safe=
> >>>> +	[ "$3" = "safe" ] && safe="-s" || safe=""
> >>> Uh, this syntax is confusing, besides isn't safe set to empty string
> >>> anyway?
> >> What if we set TST_NO_CLEANUP just before calling cleanup()
> >> or unset TST_CLEANUP... then we can use ROD, etc. in cleanup?
> > You lost me here. How is this connected to the code I've commented?
> 
> In the 2nd patch, 'safe' option is used like this:
> 
> do_cleanup()
> {
>     tst_set_sysctl net.ipv4.tcp_cong...
> }
> 
> do_test()
> {
>     tst_set_sysctl net.ipv4.tcp_cong... safe
> }
> 
> So, the main reason for splitting the code with 'safe' option is to be
> able to call this function inside cleanup. But if we handle cleanup
> recursion inside the shell library, we can get rid of 'safe' option
> and simplify tst_set_sysctls().

Ah, I wasn't clear enough. I only meant that setting safe to empty
string, i.e. || safe="" does not seem to have any effect at all, since
it's empty anyway, or isn't it?

Also we may be able to handle recursion in the shell library, but the
main reason I avoided doing that is to keep the C library and shell
library consistent. And the C library cannot be fixed until we get rid
of last testcase using the old library (tst_res.c). Or at least I did
not figured out how to do that. But maybe converting all oldlib
testcases that use pthreads and getting rid of locking in tst_res.c
would suffice...

-- 
Cyril Hrubis
chrubis@suse.cz

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

end of thread, other threads:[~2017-01-31 15:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-25 14:21 [LTP] [PATCH 1/2] test_net.sh: add tst_set_sysctl() Alexey Kodanev
2017-01-25 14:21 ` [LTP] [PATCH 2/2] net: dctcp01: apply tst_set_sysctl() Alexey Kodanev
2017-01-31 10:07 ` [LTP] [PATCH 1/2] test_net.sh: add tst_set_sysctl() Cyril Hrubis
2017-01-31 11:27   ` Alexey Kodanev
2017-01-31 12:41     ` Cyril Hrubis
2017-01-31 13:38       ` Alexey Kodanev
2017-01-31 15:23         ` Cyril Hrubis

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.