From 6eef16896c87b33a1749f3f804665204c007d60a Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Sat, 14 Sep 2024 19:19:36 +0200 Subject: [PATCH] xdp-forward: Add selftest for flowtable mode Signed-off-by: Lorenzo Bianconi --- lib/testing/test_runner.sh | 2 +- xdp-forward/tests/test-xdp-forward.sh | 56 ++++++++++++++++++++++++++- 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/lib/testing/test_runner.sh b/lib/testing/test_runner.sh index 8805e38f..3fb2626d 100755 --- a/lib/testing/test_runner.sh +++ b/lib/testing/test_runner.sh @@ -25,7 +25,7 @@ ALL_TESTS="" VERBOSE_TESTS=${V:-0} NUM_NS=2 -NEEDED_TOOLS="capinfos ethtool ip ping sed tc tcpdump timeout nc tshark" +NEEDED_TOOLS="capinfos ethtool ip ping sed tc tcpdump timeout nc tshark nft" if [ -f "$TEST_CONFIG" ]; then source "$TEST_CONFIG" diff --git a/xdp-forward/tests/test-xdp-forward.sh b/xdp-forward/tests/test-xdp-forward.sh index 2a6988e8..f5a4dda9 100644 --- a/xdp-forward/tests/test-xdp-forward.sh +++ b/xdp-forward/tests/test-xdp-forward.sh @@ -1,6 +1,6 @@ XDP_LOADER=${XDP_LOADER:-./xdp-loader} XDP_FORWARD=${XDP_FORWARD:-./xdp-forward} -ALL_TESTS="test_ping test_load test_fwd_full test_fwd_direct" +ALL_TESTS="test_ping test_load test_fwd_full test_fwd_direct test_flowtable" test_ping() @@ -52,8 +52,62 @@ test_fwd_direct() check_run $XDP_FORWARD unload ${NS_NAMES[@]} } +test_flowtable() +{ + # veth NAPI GRO support added this symbol; forwarding won't work without it + skip_if_missing_kernel_symbol veth_set_features + # check if bpf flowtable lookup is available + skip_if_missing_kernel_symbol bpf_xdp_flow_lookup + + # disable {tx,rx} checksum offload since it is not currently suported + # by XDP_REDIRECT + for n in ${NS_NAMES[@]}; do + ip netns exec $n ethtool -K veth0 tx-checksumming off rx-checksumming off + ethtool -K $n tx-checksumming off rx-checksumming off + done + + # create data to send via tcp + local infile="$(mktemp)" + dd if=/dev/urandom of="${infile}" bs=8192 count=32 status=none + + # create flowtable configuration + check_run nft -f /dev/stdin </dev/null 2>&1 $XDP_LOADER unload $NS --all >/dev/null 2>&1 }