@@ -27,8 +27,7 @@ ns2out=""
27
27
log_netns=$( sysctl -n net.netfilter.nf_log_all_netns)
28
28
29
29
checktool (){
30
- $1 > /dev/null 2>&1
31
- if [ $? -ne 0 ]; then
30
+ if ! $1 > /dev/null 2>&1 ; then
32
31
echo " SKIP: Could not $2 "
33
32
exit $ksft_skip
34
33
fi
@@ -187,15 +186,13 @@ if [ $? -ne 0 ]; then
187
186
fi
188
187
189
188
# 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
192
190
echo " ERROR: ns1 cannot reach ns2" 1>&2
193
191
bash
194
192
exit 1
195
193
fi
196
194
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
199
196
echo " ERROR: ns2 cannot reach ns1" 1>&2
200
197
exit 1
201
198
fi
@@ -230,8 +227,7 @@ check_transfer()
230
227
out=$2
231
228
what=$3
232
229
233
- cmp " $in " " $out " > /dev/null 2>&1
234
- if [ $? -ne 0 ] ; then
230
+ if ! cmp " $in " " $out " > /dev/null 2>&1 ; then
235
231
echo " FAIL: file mismatch for $what " 1>&2
236
232
ls -l " $in "
237
233
ls -l " $out "
@@ -268,13 +264,11 @@ test_tcp_forwarding_ip()
268
264
269
265
wait
270
266
271
- check_transfer " $ns1in " " $ns2out " " ns1 -> ns2"
272
- if [ $? -ne 0 ]; then
267
+ if ! check_transfer " $ns1in " " $ns2out " " ns1 -> ns2" ; then
273
268
lret=1
274
269
fi
275
270
276
- check_transfer " $ns2in " " $ns1out " " ns1 <- ns2"
277
- if [ $? -ne 0 ]; then
271
+ if ! check_transfer " $ns2in " " $ns1out " " ns1 <- ns2" ; then
278
272
lret=1
279
273
fi
280
274
@@ -308,8 +302,7 @@ make_file "$ns2in"
308
302
309
303
# First test:
310
304
# 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
313
306
echo " PASS: flow offloaded for ns1/ns2"
314
307
else
315
308
echo " FAIL: flow offload for ns1/ns2:" 1>&2
@@ -340,9 +333,7 @@ table ip nat {
340
333
}
341
334
EOF
342
335
343
- test_tcp_forwarding_nat ns1 ns2
344
-
345
- if [ $? -eq 0 ] ; then
336
+ if test_tcp_forwarding_nat ns1 ns2; then
346
337
echo " PASS: flow offloaded for ns1/ns2 with NAT"
347
338
else
348
339
echo " FAIL: flow offload for ns1/ns2 with NAT" 1>&2
354
345
# Same as second test, but with PMTU discovery enabled.
355
346
handle=$( ip netns exec nsr1 nft -a list table inet filter | grep something-to-grep-for | cut -d \# -f 2)
356
347
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
359
349
echo " FAIL: Could not delete large-packet accept rule"
360
350
exit 1
361
351
fi
362
352
363
353
ip netns exec ns1 sysctl net.ipv4.ip_no_pmtu_disc=0 > /dev/null
364
354
ip netns exec ns2 sysctl net.ipv4.ip_no_pmtu_disc=0 > /dev/null
365
355
366
- test_tcp_forwarding_nat ns1 ns2
367
- if [ $? -eq 0 ] ; then
356
+ if test_tcp_forwarding_nat ns1 ns2; then
368
357
echo " PASS: flow offloaded for ns1/ns2 with NAT and pmtu discovery"
369
358
else
370
359
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
410
399
ip -net ns2 route add default via 10.0.2.1
411
400
ip -net ns2 route add default via dead:2::1
412
401
413
- test_tcp_forwarding ns1 ns2
414
- if [ $? -eq 0 ] ; then
402
+ if test_tcp_forwarding ns1 ns2; then
415
403
echo " PASS: ipsec tunnel mode for ns1/ns2"
416
404
else
417
405
echo " FAIL: ipsec tunnel mode for ns1/ns2"
0 commit comments