Skip to contentSkip to conversation

tst_net.sh: Add API function to check netns use

PATCH New Petr Vorel 2 participants 6 messages Feb 5, 2021 – Feb 9, 2021

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

PATCH 1/2 tst_net.sh: Add API function to check netns use

---
Hi Alexey,

or do we want to allow using TST_USE_NETNS?

Kind regards,
Petr

 testcases/lib/tst_net.sh | 6 ++++++
 1 file changed, 6 insertions(+)
testcases/lib/tst_net.sh +6 -0
index 1ddef2fea..d4633c509 100644
@@ -131,6 +131,12 @@ init_ltp_netspace()
 	tst_restore_ipaddr rhost
 }
 
+# return 0: use ssh, 1: use netns
+tst_net_use_netns()
+{
+	[ -n "$TST_USE_NETNS" ]
+}
+
 # Run command on remote host.
 # tst_rhost_run -c CMD [-b] [-s] [-u USER]
 # Options:
Signature · 1 line
2.30.0
author
#1 lore raw

PATCH 2/2 if-mtu-change.sh: Lower CHANGE_INTERVAL for netns

to make testing faster.

NOTE: the default sleep 5s is needed for ssh based testing to prevent link-flap errors on the switch. It can be lower down by user.

---
 .../network/stress/interface/if-mtu-change.sh      | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
testcases/network/stress/interface/if-mtu-change.sh +10 -4
index d2816606b..49ac5e3fc 100755
@@ -1,6 +1,6 @@
 #!/bin/sh
 # SPDX-License-Identifier: GPL-2.0-or-later
-# Copyright (c) 2017-2019 Petr Vorel <[email protected]>
+# Copyright (c) 2017-2021 Petr Vorel <[email protected]>
 # Copyright (c) 2015-2017 Oracle and/or its affiliates. All Rights Reserved.
 # Copyright (c) International Business Machines  Corp., 2005
 # Author: Mitsuru Chinen <[email protected]>
@@ -12,9 +12,13 @@ TST_CLEANUP="do_cleanup"
 
 # The interval of the mtu change [second]
 CHANGE_INTERVAL=${CHANGE_INTERVAL:-5}
-
 TST_TIMEOUT=$(((CHANGE_INTERVAL + 30) * MTU_CHANGE_TIMES))
 
+if tst_net_use_netns; then
+	CHANGE_INTERVAL="100ms"
+	TST_TIMEOUT=$((30 * MTU_CHANGE_TIMES))
+fi
+
 # The array of the value which MTU is changed into sequentially
 # 552 - net.ipv4.route.min_pmtu
 CHANGE_VALUES="784 1142 552 1500 552 1500 552 748 552 1142 1500"
@@ -65,6 +69,7 @@ find_ipv4_max_packet_size()
 
 do_setup()
 {
+
 	[ "$TST_IPV6" ] && CHANGE_VALUES=$CHANGE6_VALUES
 	if_setup
 	saved_mtu="$(cat /sys/class/net/$(tst_iface)/mtu)"
@@ -83,9 +88,10 @@ do_cleanup()
 test_body()
 {
 	local cmd="$CMD"
+	local msg="'$cmd' changes MTU $MTU_CHANGE_TIMES times every $CHANGE_INTERVAL"
 
-	tst_res TINFO "'$cmd' changes MTU $MTU_CHANGE_TIMES times" \
-	               "every $CHANGE_INTERVAL seconds"
+	tst_is_int $CHANGE_INTERVAL && msg="$msg seconds"
+	tst_res TINFO "$msg"
 
 	mtu_array_len=$(echo $CHANGE_VALUES | wc -w)
 	local cnt=0
Signature · 1 line
2.30.0
#2 lore raw

PATCH 2/2 if-mtu-change.sh: Lower CHANGE_INTERVAL for netns

Quoted 23 lines · Petr Vorel

to make testing faster.

NOTE: the default sleep 5s is needed for ssh based testing to prevent link-flap errors on the switch. It can be lower down by user.

---
 .../network/stress/interface/if-mtu-change.sh      | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
testcases/network/stress/interface/if-mtu-change.sh +1 -1
index d2816606b..49ac5e3fc 100755
@@ -1,6 +1,6 @@
 #!/bin/sh
 # SPDX-License-Identifier: GPL-2.0-or-later
-# Copyright (c) 2017-2019 Petr Vorel <[email protected]>
+# Copyright (c) 2017-2021 Petr Vorel <[email protected]>
 # Copyright (c) 2015-2017 Oracle and/or its affiliates. All Rights Reserved.
 # Copyright (c) International Business Machines  Corp., 2005
 # Author: Mitsuru Chinen <[email protected]>

testcases/network/stress/interface/if-mtu-change.sh TST_CLEANUP="do_cleanup" · line 18

Quoted 8 lines
testcases/network/stress/interface/if-mtu-change.sh +2 -1
@@ -12,9 +12,13 @@ TST_CLEANUP="do_cleanup"
 
 # The interval of the mtu change [second]
 CHANGE_INTERVAL=${CHANGE_INTERVAL:-5}
-
 TST_TIMEOUT=$(((CHANGE_INTERVAL + 30) * MTU_CHANGE_TIMES))
 
+if tst_net_use_netns; then
+	CHANGE_INTERVAL="100ms"

Hi Petr,

What about adding the option to change this value too for netns, for example like this:

TST_TIMEOUT=1
if tst_net_use_netns; then

    CHANGE_INTERVAL=${CHANGE_INTERVAL:-100ms}
else
    CHANGE_INTERVAL=${CHANGE_INTERVAL:-5}
    tst_is_int $CHANGE_INTERVAL && TST_TIMEOUT=$CHANGE_INTERVAL

fi

TST_TIMEOUT=$(((TST_TIMEOUT + 30) * MTU_CHANGE_TIMES))

testcases/network/stress/interface/if-mtu-change.sh find_ipv4_max_packet_size() · line 72

Quoted 11 lines
testcases/network/stress/interface/if-mtu-change.sh +4 -0
+	TST_TIMEOUT=$((30 * MTU_CHANGE_TIMES))
+fi
+
 # The array of the value which MTU is changed into sequentially
 # 552 - net.ipv4.route.min_pmtu
 CHANGE_VALUES="784 1142 552 1500 552 1500 552 748 552 1142 1500"
@@ -65,6 +69,7 @@ find_ipv4_max_packet_size()
 
 do_setup()
 {
+

empty new line?

Quoted 17 lines
testcases/network/stress/interface/if-mtu-change.sh +3 -2
 	[ "$TST_IPV6" ] && CHANGE_VALUES=$CHANGE6_VALUES
 	if_setup
 	saved_mtu="$(cat /sys/class/net/$(tst_iface)/mtu)"
@@ -83,9 +88,10 @@ do_cleanup()
 test_body()
 {
 	local cmd="$CMD"
+	local msg="'$cmd' changes MTU $MTU_CHANGE_TIMES times every $CHANGE_INTERVAL"
 
-	tst_res TINFO "'$cmd' changes MTU $MTU_CHANGE_TIMES times" \
-	               "every $CHANGE_INTERVAL seconds"
+	tst_is_int $CHANGE_INTERVAL && msg="$msg seconds"
+	tst_res TINFO "$msg"
 
 	mtu_array_len=$(echo $CHANGE_VALUES | wc -w)
 	local cnt=0
author
#3 lore raw

PATCH 2/2 if-mtu-change.sh: Lower CHANGE_INTERVAL for netns

Hi Alexey,

Quoted 15 lines

testcases/network/stress/interface/if-mtu-change.sh TST_CLEANUP="do_cleanup" · line 18

Quoted 7 lines

# The interval of the mtu change [second]
CHANGE_INTERVAL=${CHANGE_INTERVAL:-5}

testcases/network/stress/interface/if-mtu-change.sh +2 -1
-
 TST_TIMEOUT=$(((CHANGE_INTERVAL + 30) * MTU_CHANGE_TIMES))
 
+if tst_net_use_netns; then
+	CHANGE_INTERVAL="100ms"

Hi Petr,

What about adding the option to change this value too for netns, for example like this:

TST_TIMEOUT=1
if tst_net_use_netns; then

Quoted 7 lines
    CHANGE_INTERVAL=${CHANGE_INTERVAL:-100ms}
else
    CHANGE_INTERVAL=${CHANGE_INTERVAL:-5}
    tst_is_int $CHANGE_INTERVAL && TST_TIMEOUT=$CHANGE_INTERVAL

fi

TST_TIMEOUT=$(((TST_TIMEOUT + 30) * MTU_CHANGE_TIMES))

That's indeed much better!

How about allow to overwrite CHANGE_INTERVAL even for netns?
i.e move tst_is_int $CHANGE_INTERVAL && TST_TIMEOUT=$CHANGE_INTERVAL after the test (although it's unlikely anybody would use sec value for netns and ms value for ssh):

# CHANGE_INTERVAL: The interval of the mtu change
TST_TIMEOUT=1
if tst_net_use_netns; then

    CHANGE_INTERVAL=${CHANGE_INTERVAL:-100ms}
else
    CHANGE_INTERVAL=${CHANGE_INTERVAL:-5}

fi
tst_is_int $CHANGE_INTERVAL && TST_TIMEOUT=$CHANGE_INTERVAL TST_TIMEOUT=$(((TST_TIMEOUT + 30) * MTU_CHANGE_TIMES))

Quoted 8 lines
Quoted 7 lines
testcases/network/stress/interface/if-mtu-change.sh +3 -0
+	TST_TIMEOUT=$((30 * MTU_CHANGE_TIMES))
+fi
+
 # The array of the value which MTU is changed into sequentially
 # 552 - net.ipv4.route.min_pmtu
 CHANGE_VALUES="784 1142 552 1500 552 1500 552 748 552 1142 1500"
@@ -65,6 +69,7 @@ find_ipv4_max_packet_size()
Quoted 5 lines

testcases/network/stress/interface/if-mtu-change.sh find_ipv4_max_packet_size() · line 72

Quoted 3 lines
testcases/network/stress/interface/if-mtu-change.sh +1 -0
 do_setup()
 {
+

empty new line?

Thanks!

Kind regards,
Petr

#4 lore raw

PATCH 2/2 if-mtu-change.sh: Lower CHANGE_INTERVAL for netns

Quoted 8 lines · Petr Vorel

How about allow to overwrite CHANGE_INTERVAL even for netns?
i.e move tst_is_int $CHANGE_INTERVAL && TST_TIMEOUT=$CHANGE_INTERVAL after the test (although it's unlikely anybody would use sec value for netns and ms value for ssh):

# CHANGE_INTERVAL: The interval of the mtu change
TST_TIMEOUT=1
if tst_net_use_netns; then

Quoted 7 lines
    CHANGE_INTERVAL=${CHANGE_INTERVAL:-100ms}
else
    CHANGE_INTERVAL=${CHANGE_INTERVAL:-5}

fi
tst_is_int $CHANGE_INTERVAL && TST_TIMEOUT=$CHANGE_INTERVAL TST_TIMEOUT=$(((TST_TIMEOUT + 30) * MTU_CHANGE_TIMES))

Yeah, looks good.

author
#5 lore raw

PATCH 2/2 if-mtu-change.sh: Lower CHANGE_INTERVAL for netns

Hi Alexey,

Quoted 17 lines · Petr Vorel
Quoted 8 lines

How about allow to overwrite CHANGE_INTERVAL even for netns?
i.e move tst_is_int $CHANGE_INTERVAL && TST_TIMEOUT=$CHANGE_INTERVAL after the test (although it's unlikely anybody would use sec value for netns and ms value for ssh):

# CHANGE_INTERVAL: The interval of the mtu change
TST_TIMEOUT=1
if tst_net_use_netns; then

Quoted 6 lines
    CHANGE_INTERVAL=${CHANGE_INTERVAL:-100ms}
else
    CHANGE_INTERVAL=${CHANGE_INTERVAL:-5}

fi
tst_is_int $CHANGE_INTERVAL && TST_TIMEOUT=$CHANGE_INTERVAL TST_TIMEOUT=$(((TST_TIMEOUT + 30) * MTU_CHANGE_TIMES))

Quoted 1 line

Yeah, looks good.

Thanks for your ack, merged!

Kind regards,
Petr