@@ -27,8 +27,7 @@ ns2out=""
2727log_netns=$( sysctl -n net.netfilter.nf_log_all_netns)
2828
2929checktool (){
30- $1 > /dev/null 2>&1
31- if [ $? -ne 0 ]; then
30+ if ! $1 > /dev/null 2>&1 ; then
3231 echo " SKIP: Could not $2 "
3332 exit $ksft_skip
3433 fi
@@ -187,15 +186,13 @@ if [ $? -ne 0 ]; then
187186fi
188187
189188# test basic connectivity
190- ip netns exec ns1 ping -c 1 -q 10.0.2.99 > /dev/null
191- if [ $? -ne 0 ]; then
189+ if ! ip netns exec ns1 ping -c 1 -q 10.0.2.99 > /dev/null; then
192190 echo " ERROR: ns1 cannot reach ns2" 1>&2
193191 bash
194192 exit 1
195193fi
196194
197- ip netns exec ns2 ping -c 1 -q 10.0.1.99 > /dev/null
198- if [ $? -ne 0 ]; then
195+ if ! ip netns exec ns2 ping -c 1 -q 10.0.1.99 > /dev/null; then
199196 echo " ERROR: ns2 cannot reach ns1" 1>&2
200197 exit 1
201198fi
@@ -230,8 +227,7 @@ check_transfer()
230227 out=$2
231228 what=$3
232229
233- cmp " $in " " $out " > /dev/null 2>&1
234- if [ $? -ne 0 ] ; then
230+ if ! cmp " $in " " $out " > /dev/null 2>&1 ; then
235231 echo " FAIL: file mismatch for $what " 1>&2
236232 ls -l " $in "
237233 ls -l " $out "
@@ -268,13 +264,11 @@ test_tcp_forwarding_ip()
268264
269265 wait
270266
271- check_transfer " $ns1in " " $ns2out " " ns1 -> ns2"
272- if [ $? -ne 0 ]; then
267+ if ! check_transfer " $ns1in " " $ns2out " " ns1 -> ns2" ; then
273268 lret=1
274269 fi
275270
276- check_transfer " $ns2in " " $ns1out " " ns1 <- ns2"
277- if [ $? -ne 0 ]; then
271+ if ! check_transfer " $ns2in " " $ns1out " " ns1 <- ns2" ; then
278272 lret=1
279273 fi
280274
@@ -308,8 +302,7 @@ make_file "$ns2in"
308302
309303# First test:
310304# No PMTU discovery, nsr1 is expected to fragment packets from ns1 to ns2 as needed.
311- test_tcp_forwarding ns1 ns2
312- if [ $? -eq 0 ] ; then
305+ if test_tcp_forwarding ns1 ns2; then
313306 echo " PASS: flow offloaded for ns1/ns2"
314307else
315308 echo " FAIL: flow offload for ns1/ns2:" 1>&2
@@ -340,9 +333,7 @@ table ip nat {
340333}
341334EOF
342335
343- test_tcp_forwarding_nat ns1 ns2
344-
345- if [ $? -eq 0 ] ; then
336+ if test_tcp_forwarding_nat ns1 ns2; then
346337 echo " PASS: flow offloaded for ns1/ns2 with NAT"
347338else
348339 echo " FAIL: flow offload for ns1/ns2 with NAT" 1>&2
354345# Same as second test, but with PMTU discovery enabled.
355346handle=$( ip netns exec nsr1 nft -a list table inet filter | grep something-to-grep-for | cut -d \# -f 2)
356347
357- ip netns exec nsr1 nft delete rule inet filter forward $handle
358- if [ $? -ne 0 ] ; then
348+ if ! ip netns exec nsr1 nft delete rule inet filter forward $handle ; then
359349 echo " FAIL: Could not delete large-packet accept rule"
360350 exit 1
361351fi
362352
363353ip netns exec ns1 sysctl net.ipv4.ip_no_pmtu_disc=0 > /dev/null
364354ip netns exec ns2 sysctl net.ipv4.ip_no_pmtu_disc=0 > /dev/null
365355
366- test_tcp_forwarding_nat ns1 ns2
367- if [ $? -eq 0 ] ; then
356+ if test_tcp_forwarding_nat ns1 ns2; then
368357 echo " PASS: flow offloaded for ns1/ns2 with NAT and pmtu discovery"
369358else
370359 echo " FAIL: flow offload for ns1/ns2 with NAT and pmtu discovery" 1>&2
@@ -410,8 +399,7 @@ ip -net ns2 route del 192.168.10.1 via 10.0.2.1
410399ip -net ns2 route add default via 10.0.2.1
411400ip -net ns2 route add default via dead:2::1
412401
413- test_tcp_forwarding ns1 ns2
414- if [ $? -eq 0 ] ; then
402+ if test_tcp_forwarding ns1 ns2; then
415403 echo " PASS: ipsec tunnel mode for ns1/ns2"
416404else
417405 echo " FAIL: ipsec tunnel mode for ns1/ns2"
0 commit comments