From: Stefano Brivio <sbrivio@redhat.com>
To: "David S . Miller" <davem@davemloft.net>
Cc: David Ahern <dsahern@gmail.com>,
Sabrina Dubroca <sd@queasysnail.net>,
Steffen Klassert <steffen.klassert@secunet.com>,
netdev@vger.kernel.org
Subject: [PATCH net-next 01/10 v2] selftests: pmtu: Reverse return codes of functions
Date: Sat, 17 Mar 2018 02:31:38 +0100 [thread overview]
Message-ID: <6152cc329a20f23cb38b7aa65393f0a5c7113c13.1521249420.git.sbrivio@redhat.com> (raw)
In-Reply-To: <cover.1521249420.git.sbrivio@redhat.com>
In-Reply-To: <cover.1521249420.git.sbrivio@redhat.com>
David suggests it's more intuitive to return non-zero on
failures, and zero on success.
No need to introduce tail 'return 0' in functions, they will
return the exit code of the last command anyway.
Suggested-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
v2: Introduced
tools/testing/selftests/net/pmtu.sh | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh
index 6c19c148cef8..65842a2afa55 100755
--- a/tools/testing/selftests/net/pmtu.sh
+++ b/tools/testing/selftests/net/pmtu.sh
@@ -26,14 +26,12 @@ vti6_b_addr="fd00:2::b"
vti6_mask="64"
setup_namespaces() {
- ip netns add ${NS_A} || return 0
+ ip netns add ${NS_A} || return 1
ip netns add ${NS_B}
-
- return 1
}
setup_veth() {
- ${ns_a} ip link add veth_a type veth peer name veth_b || return 0
+ ${ns_a} ip link add veth_a type veth peer name veth_b || return 1
${ns_a} ip link set veth_b netns ${NS_B}
${ns_a} ip addr add ${veth6_a_addr}/${veth6_mask} dev veth_a
@@ -41,12 +39,10 @@ setup_veth() {
${ns_a} ip link set veth_a up
${ns_b} ip link set veth_b up
-
- return 1
}
setup_vti6() {
- ${ns_a} ip link add vti_a type vti6 local ${veth6_a_addr} remote ${veth6_b_addr} key 10 || return 0
+ ${ns_a} ip link add vti_a type vti6 local ${veth6_a_addr} remote ${veth6_b_addr} key 10 || return 1
${ns_b} ip link add vti_b type vti6 local ${veth6_b_addr} remote ${veth6_a_addr} key 10
${ns_a} ip addr add ${vti6_a_addr}/${vti6_mask} dev vti_a
@@ -56,12 +52,10 @@ setup_vti6() {
${ns_b} ip link set vti_b up
sleep 1
-
- return 1
}
setup_xfrm() {
- ${ns_a} ip -6 xfrm state add src ${veth6_a_addr} dst ${veth6_b_addr} spi 0x1000 proto esp aead "rfc4106(gcm(aes))" 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel || return 0
+ ${ns_a} ip -6 xfrm state add src ${veth6_a_addr} dst ${veth6_b_addr} spi 0x1000 proto esp aead "rfc4106(gcm(aes))" 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel || return 1
${ns_a} ip -6 xfrm state add src ${veth6_b_addr} dst ${veth6_a_addr} spi 0x1001 proto esp aead "rfc4106(gcm(aes))" 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel
${ns_a} ip -6 xfrm policy add dir out mark 10 tmpl src ${veth6_a_addr} dst ${veth6_b_addr} proto esp mode tunnel
${ns_a} ip -6 xfrm policy add dir in mark 10 tmpl src ${veth6_b_addr} dst ${veth6_a_addr} proto esp mode tunnel
@@ -70,8 +64,6 @@ setup_xfrm() {
${ns_b} ip -6 xfrm state add src ${veth6_b_addr} dst ${veth6_a_addr} spi 0x1001 proto esp aead "rfc4106(gcm(aes))" 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel
${ns_b} ip -6 xfrm policy add dir out mark 10 tmpl src ${veth6_b_addr} dst ${veth6_a_addr} proto esp mode tunnel
${ns_b} ip -6 xfrm policy add dir in mark 10 tmpl src ${veth6_a_addr} dst ${veth6_b_addr} proto esp mode tunnel
-
- return 1
}
setup() {
@@ -79,13 +71,13 @@ setup() {
[ "$(id -u)" -ne 0 ] && echo "SKIP: need to run as root" && exit 0
- setup_namespaces && echo "SKIP: namespaces not supported" && exit 0
- setup_veth && echo "SKIP: veth not supported" && exit 0
+ setup_namespaces || { echo "SKIP: namespaces not supported"; exit 0; }
+ setup_veth || { echo "SKIP: veth not supported"; exit 0; }
case ${tunnel_type} in
"vti6")
- setup_vti6 && echo "SKIP: vti6 not supported" && exit 0
- setup_xfrm && echo "SKIP: xfrm not supported" && exit 0
+ setup_vti6 || { echo "SKIP: vti6 not supported"; exit 0; }
+ setup_xfrm || { echo "SKIP: xfrm not supported"; exit 0; }
;;
*)
;;
--
2.15.1
next prev parent reply other threads:[~2018-03-17 1:32 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-17 1:31 [PATCH net-next 00/10 v2] selftests: pmtu: Add further vti/vti6 MTU and PMTU tests Stefano Brivio
2018-03-17 1:31 ` Stefano Brivio [this message]
2018-03-17 1:31 ` [PATCH net-next 02/10 v2] selftests: pmtu: Use namespace command prefix to fetch route mtu Stefano Brivio
2018-03-17 1:31 ` [PATCH net-next 03/10 v2] selftests: pmtu: Factor out MTU parsing helper Stefano Brivio
2018-03-17 1:31 ` [PATCH net-next 04/10 v2] selftests: pmtu: Introduce support for multiple tests Stefano Brivio
2018-03-17 1:31 ` [PATCH net-next 05/10 v2] selftests: pmtu: Add pmtu_vti4_default_mtu test Stefano Brivio
2018-03-17 1:31 ` [PATCH net-next 06/10 v2] selftests: pmtu: Add pmtu_vti6_default_mtu test Stefano Brivio
2018-03-17 1:31 ` [PATCH net-next 07/10 v2] selftests: pmtu: Add test_pmtu_vti4_exception test Stefano Brivio
2018-03-17 1:31 ` [PATCH net-next 08/10 v2] selftests: pmtu: Add pmtu_vti4_link_add_mtu test Stefano Brivio
2018-03-17 1:31 ` [PATCH net-next 09/10 v2] selftests: pmtu: Add pmtu_vti6_link_add_mtu test Stefano Brivio
2018-03-17 1:31 ` [PATCH net-next 10/10 v2] selftests: pmtu: Add pmtu_vti6_link_change_mtu test Stefano Brivio
2018-03-18 0:15 ` [PATCH net-next 00/10 v2] selftests: pmtu: Add further vti/vti6 MTU and PMTU tests David Miller
2018-03-18 17:31 ` David Ahern
2018-03-18 17:42 ` Stefano Brivio
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6152cc329a20f23cb38b7aa65393f0a5c7113c13.1521249420.git.sbrivio@redhat.com \
--to=sbrivio@redhat.com \
--cc=davem@davemloft.net \
--cc=dsahern@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=sd@queasysnail.net \
--cc=steffen.klassert@secunet.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).