Commit 732fa323 authored by Björn Töpel's avatar Björn Töpel Committed by Daniel Borkmann

selftests/bpf: Convert test_xdp_redirect.sh to bash

The test_xdp_redirect.sh script uses a bash feature, '&>'. On systems,
e.g. Debian, where '/bin/sh' is dash, this will not work as
expected. Use bash in the shebang to get the expected behavior.

Further, using 'set -e' means that the error of a command cannot be
captured without the command being executed with '&&' or '||'. Let us
restructure the ping-commands, and use them as an if-expression, so
that we can capture the return value.

v4: Added missing Fixes:, and removed local variables. (Andrii)
v3: Reintroduced /bin/bash, and kept 'set -e'. (Andrii)
v2: Kept /bin/sh and removed bashisms. (Randy)

Fixes: 996139e8 ("selftests: bpf: add a test for XDP redirect")
Signed-off-by: default avatarBjörn Töpel <bjorn.topel@intel.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20210211082029.1687666-1-bjorn.topel@gmail.com
parent 291009f6
#!/bin/sh #!/bin/bash
# Create 2 namespaces with two veth peers, and # Create 2 namespaces with two veth peers, and
# forward packets in-between using generic XDP # forward packets in-between using generic XDP
# #
...@@ -57,12 +57,8 @@ test_xdp_redirect() ...@@ -57,12 +57,8 @@ test_xdp_redirect()
ip link set dev veth1 $xdpmode obj test_xdp_redirect.o sec redirect_to_222 &> /dev/null ip link set dev veth1 $xdpmode obj test_xdp_redirect.o sec redirect_to_222 &> /dev/null
ip link set dev veth2 $xdpmode obj test_xdp_redirect.o sec redirect_to_111 &> /dev/null ip link set dev veth2 $xdpmode obj test_xdp_redirect.o sec redirect_to_111 &> /dev/null
ip netns exec ns1 ping -c 1 10.1.1.22 &> /dev/null if ip netns exec ns1 ping -c 1 10.1.1.22 &> /dev/null &&
local ret1=$? ip netns exec ns2 ping -c 1 10.1.1.11 &> /dev/null; then
ip netns exec ns2 ping -c 1 10.1.1.11 &> /dev/null
local ret2=$?
if [ $ret1 -eq 0 -a $ret2 -eq 0 ]; then
echo "selftests: test_xdp_redirect $xdpmode [PASS]"; echo "selftests: test_xdp_redirect $xdpmode [PASS]";
else else
ret=1 ret=1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment