Skip to contentSkip to conversation

Revert "network/vxlan03: Fix getopts parameters passed to virt_lib.sh"

PATCH New Petr Vorel 2 participants 4 messages Apr 30, 2018 – May 3, 2018

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

PATCH v2 1/3 Revert "network/vxlan03: Fix getopts parameters passed to virt_lib.sh"

This reverts commit 06ee2b0273bd79a423b88b4488c71aebef0bb2ea.

With this patch vxlan03 ignores the '-6' option.

And tst_net.sh sourced two times there, in virt_lib.sh and in vxlan03.sh.

---
 testcases/network/virt/virt_lib.sh | 29 ++++++++++++-----------------
 testcases/network/virt/vxlan03.sh  |  3 +--
 2 files changed, 13 insertions(+), 19 deletions(-)
testcases/network/virt/virt_lib.sh +12 -17
index 2355ddfe9..c99004b85 100644
@@ -28,6 +28,18 @@
 #          them in cleanup function. See "start_vni" variable which can
 #          solve it.
 
+ip_local=$(tst_ipaddr)
+ip_virt_local="$(TST_IPV6= tst_ipaddr_un)"
+ip6_virt_local="$(TST_IPV6=6 tst_ipaddr_un)"
+
+ip_remote=$(tst_ipaddr rhost)
+ip_virt_remote="$(TST_IPV6= tst_ipaddr_un rhost)"
+ip6_virt_remote="$(TST_IPV6=6 tst_ipaddr_un rhost)"
+
+# Max performance loss (%) for virtual devices during network load
+VIRT_PERF_THRESHOLD=${VIRT_PERF_THRESHOLD:-80}
+vxlan_dstport=0
+
 while getopts :hi:d:6 opt; do
 	case "$opt" in
 	h)
@@ -48,23 +60,6 @@ while getopts :hi:d:6 opt; do
 	esac
 done
 
-shift $(($OPTIND - 1))
-
-TST_USE_LEGACY_API=1
-. tst_net.sh
-
-ip_local=$(tst_ipaddr)
-ip_virt_local="$(TST_IPV6= tst_ipaddr_un)"
-ip6_virt_local="$(TST_IPV6=6 tst_ipaddr_un)"
-
-ip_remote=$(tst_ipaddr rhost)
-ip_virt_remote="$(TST_IPV6= tst_ipaddr_un rhost)"
-ip6_virt_remote="$(TST_IPV6=6 tst_ipaddr_un rhost)"
-
-# Max performance loss (%) for virtual devices during network load
-VIRT_PERF_THRESHOLD=${VIRT_PERF_THRESHOLD:-80}
-vxlan_dstport=0
-
 cleanup_vifaces()
 {
 	tst_resm TINFO "cleanup virtual interfaces..."
testcases/network/virt/vxlan03.sh +1 -2
index 9587badb6..6d3792ab7 100755
@@ -33,10 +33,9 @@ start_id=16700000
 # Destination address, can be unicast or multicast address
 vxlan_dst_addr="uni"
 
-. virt_lib.sh
-
 TST_USE_LEGACY_API=1
 . tst_net.sh
+. virt_lib.sh
 
 # In average cases (with small packets less then 150 bytes) VxLAN slower
 # by 10-30%. If hosts are too close to each other, e.g. connected to the same
Signature · 1 line
2.16.3
author
#1 lore raw

PATCH v2 2/3 network/virt_lib.sh: Process getopts parameters with TST_OPTS and TST_PARSE_ARGS

+ Move loading tst_net.sh from vxlan03.sh and other virt_lib.sh users to virt_lib.sh itself.

vxlan03.sh pass getopts parameter to virt_lib.sh (other than -6 which is handled by tst_net.sh), which causes getopts error:

vxlan03.sh -d uni
/opt/ltp/testcases/bin/vxlan03.sh: illegal option -- d /opt/ltp/testcases/bin/tst_net.sh: line 37: ?: command not found

Fix processing parameters with TST_OPTS and TST_PARSE_ARGS (proper way of handling parameters by API).

Fixes ba53eb04e tst_net.sh: Support both new and legacy APIs + rename
---
 testcases/network/virt/geneve01.sh  |  2 --
 testcases/network/virt/gre01.sh     |  3 ---
 testcases/network/virt/ipvlan01.sh  |  2 --
 testcases/network/virt/macvlan01.sh |  2 --
 testcases/network/virt/macvtap01.sh |  2 --
 testcases/network/virt/virt_lib.sh  | 38 +++++++++++++++++++++----------------
 testcases/network/virt/vlan01.sh    |  2 --
 testcases/network/virt/vlan02.sh    |  2 --
 testcases/network/virt/vlan03.sh    |  2 --
 testcases/network/virt/vxlan01.sh   |  2 --
 testcases/network/virt/vxlan02.sh   |  2 --
 testcases/network/virt/vxlan03.sh   |  2 --
 12 files changed, 22 insertions(+), 39 deletions(-)
testcases/network/virt/geneve01.sh +0 -2
index 709201358..0cc117f3b 100755
@@ -27,8 +27,6 @@ start_id=16700000
 # that is why using here 'vxlan_*' library functions.
 vxlan_dst_addr="uni"
 
-TST_USE_LEGACY_API=1
-. tst_net.sh
 . virt_lib.sh
 
 VIRT_PERF_THRESHOLD=${VIRT_PERF_THRESHOLD:-160}
testcases/network/virt/gre01.sh +0 -3
index 74ecb4898..09a77a4d5 100755
@@ -24,9 +24,6 @@ TCID=gre01
 TST_TOTAL=1
 TST_NEEDS_TMPDIR=1
 
-TST_USE_LEGACY_API=1
-. tst_net.sh
-
 virt_type="gre"
 [ "$TST_IPV6" ] && virt_type="ip6gre"
 
testcases/network/virt/ipvlan01.sh +0 -2
index b69444644..36b07f027 100755
@@ -24,8 +24,6 @@ TST_TOTAL=2
 
 virt_type="ipvlan"
 
-TST_USE_LEGACY_API=1
-. tst_net.sh
 . virt_lib.sh
 
 options="mode l2,mode l3"
testcases/network/virt/macvlan01.sh +0 -2
index cf0462ec4..cafca75e2 100755
@@ -24,8 +24,6 @@ TST_TOTAL=4
 
 virt_type="macvlan"
 
-TST_USE_LEGACY_API=1
-. tst_net.sh
 . virt_lib.sh
 
 options="mode private,mode vepa,mode bridge,mode passthru"
testcases/network/virt/macvtap01.sh +0 -2
index e647f9009..7b90213a1 100755
@@ -24,8 +24,6 @@ TST_TOTAL=4
 
 virt_type="macvtap"
 
-TST_USE_LEGACY_API=1
-. tst_net.sh
 . virt_lib.sh
 
 options="mode private,mode vepa,mode bridge,mode passthru"
testcases/network/virt/virt_lib.sh +22 -16
index c99004b85..0f75bb030 100644
@@ -1,5 +1,6 @@
 #!/bin/sh
 # Copyright (c) 2014-2017 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) 2018 Petr Vorel <[email protected]>
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License as
@@ -28,19 +29,8 @@
 #          them in cleanup function. See "start_vni" variable which can
 #          solve it.
 
-ip_local=$(tst_ipaddr)
-ip_virt_local="$(TST_IPV6= tst_ipaddr_un)"
-ip6_virt_local="$(TST_IPV6=6 tst_ipaddr_un)"
-
-ip_remote=$(tst_ipaddr rhost)
-ip_virt_remote="$(TST_IPV6= tst_ipaddr_un rhost)"
-ip6_virt_remote="$(TST_IPV6=6 tst_ipaddr_un rhost)"
-
-# Max performance loss (%) for virtual devices during network load
-VIRT_PERF_THRESHOLD=${VIRT_PERF_THRESHOLD:-80}
-vxlan_dstport=0
-
-while getopts :hi:d:6 opt; do
+virt_lib_parse_args()
+{
 	case "$opt" in
 	h)
 		echo "Usage:"
@@ -52,13 +42,29 @@ while getopts :hi:d:6 opt; do
 	;;
 	i) start_id=$OPTARG ;;
 	d) vxlan_dst_addr=$OPTARG ;;
-	6) # skip, test_net library already processed it
-	;;
 	*)
 		tst_brkm TBROK "unknown option: $opt"
 	;;
 	esac
-done
+}
+
+TST_OPTS="hi:d:"
+TST_PARSE_ARGS=virt_lib_parse_args
+
+TST_USE_LEGACY_API=1
+. tst_net.sh
+
+ip_local=$(tst_ipaddr)
+ip_virt_local="$(TST_IPV6= tst_ipaddr_un)"
+ip6_virt_local="$(TST_IPV6=6 tst_ipaddr_un)"
+
+ip_remote=$(tst_ipaddr rhost)
+ip_virt_remote="$(TST_IPV6= tst_ipaddr_un rhost)"
+ip6_virt_remote="$(TST_IPV6=6 tst_ipaddr_un rhost)"
+
+# Max performance loss (%) for virtual devices during network load
+VIRT_PERF_THRESHOLD=${VIRT_PERF_THRESHOLD:-80}
+vxlan_dstport=0
 
 cleanup_vifaces()
 {
testcases/network/virt/vlan01.sh +0 -2
index 890848fee..5ac412b32 100755
@@ -24,8 +24,6 @@ TST_TOTAL=9
 
 virt_type="vlan"
 
-TST_USE_LEGACY_API=1
-. tst_net.sh
 . virt_lib.sh
 
 p0="protocol 802.1Q"
testcases/network/virt/vlan02.sh +0 -2
index 4cb4856ba..748f9c44c 100755
@@ -25,8 +25,6 @@ TST_TOTAL=1
 
 virt_type="vlan"
 
-TST_USE_LEGACY_API=1
-. tst_net.sh
 . virt_lib.sh
 
 virt_add_delete_test "id 4094"
testcases/network/virt/vlan03.sh +0 -2
index 63a9d517d..7a8f74295 100755
@@ -29,8 +29,6 @@ TST_NEEDS_TMPDIR=1
 
 virt_type="vlan"
 
-TST_USE_LEGACY_API=1
-. tst_net.sh
 . virt_lib.sh
 
 TST_CLEANUP="virt_cleanup"
testcases/network/virt/vxlan01.sh +0 -2
index 8d96db257..1a301e5cc 100755
@@ -25,8 +25,6 @@ TST_TOTAL=5
 virt_type="vxlan"
 start_id=16700000
 
-TST_USE_LEGACY_API=1
-. tst_net.sh
 . virt_lib.sh
 
 options="l2miss l3miss,norsc nolearning noproxy,\
testcases/network/virt/vxlan02.sh +0 -2
index db152afdf..66d48ba56 100755
@@ -26,8 +26,6 @@ TST_TOTAL=1
 virt_type="vxlan"
 start_id=16700000
 
-TST_USE_LEGACY_API=1
-. tst_net.sh
 . virt_lib.sh
 
 [ "$TST_IPV6" ] && mult_addr="ff02::abc" || mult_addr="239.1.1.1"
testcases/network/virt/vxlan03.sh +0 -2
index 6d3792ab7..94eee71a8 100755
@@ -33,8 +33,6 @@ start_id=16700000
 # Destination address, can be unicast or multicast address
 vxlan_dst_addr="uni"
 
-TST_USE_LEGACY_API=1
-. tst_net.sh
 . virt_lib.sh
 
 # In average cases (with small packets less then 150 bytes) VxLAN slower
Signature · 1 line
2.16.3
author
#3 lore raw

PATCH v2 3/3 net/ipsec_lib.sh: Process getopts parameters with TST_OPTS and TST_PARSE_ARGS

In reply to Petr Vorel

as this is a proper way of handling parameters by API.

---
 testcases/network/stress/ipsec/ipsec_lib.sh | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
testcases/network/stress/ipsec/ipsec_lib.sh +6 -4
index 1a2eef996..4b9b473cf 100644
@@ -1,6 +1,7 @@
 #!/bin/sh
 # Copyright (c) 2016 Red Hat Inc.,  All Rights Reserved.
 # Copyright (c) 2016 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) 2018 Petr Vorel <[email protected]>
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License as
@@ -31,7 +32,8 @@ CALGO="deflate"
 IPSEC_REQUESTS="500"
 IPSEC_SIZE_ARRAY="${IPSEC_SIZE_ARRAY:-10 100 1000 2000 10000 65000}"
 
-while getopts "hl:m:p:s:S:k:A:e:a:c:r:6" opt; do
+ipsec_lib_parse_args()
+{
 	case "$opt" in
 	h)
 		echo "Usage:"
@@ -61,12 +63,12 @@ while getopts "hl:m:p:s:S:k:A:e:a:c:r:6" opt; do
 	a) AALGO=$OPTARG ;;
 	c) CALGO=$OPTARG ;;
 	r) IPSEC_REQUESTS="$OPTARG" ;;
-	6) TST_IPV6=6 ;;
 	*) tst_brkm TBROK "unknown option: $opt" ;;
 	esac
-done
-shift $(($OPTIND - 1))
+}
 
+TST_OPTS="hl:m:p:s:S:k:A:e:a:c:r:"
+TST_PARSE_ARGS=ipsec_lib_parse_args
 TST_USE_LEGACY_API=1
 . tst_net.sh
 
Signature · 1 line
2.16.3
#2 lore raw

PATCH v2 2/3 network/virt_lib.sh: Process getopts parameters with TST_OPTS and TST_PARSE_ARGS

In reply to Petr Vorel

On 04/30/2018 09:23 AM, Petr Vorel wrote:
...

Quoted 7 lines
testcases/network/virt/virt_lib.sh +0 -6
-ip_local=$(tst_ipaddr)
-ip_virt_local="$(TST_IPV6= tst_ipaddr_un)"
-ip6_virt_local="$(TST_IPV6=6 tst_ipaddr_un)"
-
-ip_remote=$(tst_ipaddr rhost)
-ip_virt_remote="$(TST_IPV6= tst_ipaddr_un rhost)"

testcases/network/virt/virt_lib.sh line 34

Quoted 10 lines
testcases/network/virt/virt_lib.sh +2 -7
-ip6_virt_remote="$(TST_IPV6=6 tst_ipaddr_un rhost)"
-
-# Max performance loss (%) for virtual devices during network load
-VIRT_PERF_THRESHOLD=${VIRT_PERF_THRESHOLD:-80}
-vxlan_dstport=0
-
-while getopts :hi:d:6 opt; do
+virt_lib_parse_args()
+{
 	case "$opt" in

Hi Petr,

Here we should use the first argument instead of the global $opt, otherwise it depends on how the library function implemented.

And the same in ipsec_lib.sh library.

Other than that, the patch-set looks good.

Thanks,
Alexey