|
1 | 1 | XDP_LOADER=${XDP_LOADER:-./xdp-loader}
|
2 | 2 | XDP_FORWARD=${XDP_FORWARD:-./xdp-forward}
|
3 |
| -ALL_TESTS="test_ping test_load test_fwd_full test_fwd_direct" |
| 3 | +ALL_TESTS="test_ping test_load test_fwd_full test_fwd_direct test_flowtable" |
4 | 4 |
|
5 | 5 |
|
6 | 6 | test_ping()
|
@@ -52,6 +52,61 @@ test_fwd_direct()
|
52 | 52 | check_run $XDP_FORWARD unload ${NS_NAMES[@]}
|
53 | 53 | }
|
54 | 54 |
|
| 55 | +test_flowtable() |
| 56 | +{ |
| 57 | + # veth NAPI GRO support added this symbol; forwarding won't work without it |
| 58 | + skip_if_missing_kernel_symbol veth_set_features |
| 59 | + # check if bpf flowtable lookup is available |
| 60 | + skip_if_missing_kernel_symbol bpf_xdp_flow_lookup |
| 61 | + |
| 62 | + # disable {tx,rx} checksum offload since it is not currently suported |
| 63 | + # by XDP_REDIRECT |
| 64 | + for n in ${NS_NAMES[@]}; do |
| 65 | + ip netns exec $n ethtool -K veth0 tx-checksumming off rx-checksumming off |
| 66 | + ethtool -K $n tx-checksumming off rx-checksumming off |
| 67 | + done |
| 68 | + |
| 69 | + # create data to send via tcp |
| 70 | + local infile="$(mktemp)" |
| 71 | + dd if=/dev/urandom of="${infile}" bs=8192 count=32 status=none |
| 72 | + |
| 73 | + # create flowtable configuration |
| 74 | + check_run nft -f /dev/stdin <<EOF |
| 75 | +table inet filter { |
| 76 | + flowtable ft { |
| 77 | + hook ingress priority filter |
| 78 | + devices = { ${NS_NAMES[0]}, ${NS_NAMES[-1]} } |
| 79 | + } |
| 80 | + chain forward { |
| 81 | + type filter hook forward priority filter |
| 82 | + meta l4proto { tcp } flow add @ft |
| 83 | + } |
| 84 | +} |
| 85 | +EOF |
| 86 | + # wait a bit to configure nft |
| 87 | + sleep 2 |
| 88 | + |
| 89 | + check_run $XDP_FORWARD load -f flowtable ${NS_NAMES[0]} |
| 90 | + |
| 91 | + PID=$(start_background_ns_devnull "nc -4 -l --no-shutdown 10000") |
| 92 | + check_run ip netns exec ${NS_NAMES[0]} nc -w 1 -4 ${ALL_INSIDE_IP4[-1]} 10000 < ${infile} |
| 93 | + stop_background $PID |
| 94 | + |
| 95 | + PID=$(start_background_ns_devnull "nc -6 -l --no-shutdown 10000") |
| 96 | + check_run ip netns exec ${NS_NAMES[0]} nc -w 1 -6 ${ALL_INSIDE_IP6[-1]} 10000 < ${infile} |
| 97 | + stop_background $PID |
| 98 | + |
| 99 | + check_run $XDP_FORWARD unload ${NS_NAMES[0]} |
| 100 | + check_run nft flush ruleset |
| 101 | + # enable {tx,rx} checksum offload |
| 102 | + for n in ${NS_NAMES[@]}; do |
| 103 | + ip netns exec $n ethtool -K veth0 tx-checksumming on rx-checksumming on |
| 104 | + ethtool -K $n tx-checksumming on rx-checksumming on |
| 105 | + done |
| 106 | + |
| 107 | + rm -f ${infile} |
| 108 | +} |
| 109 | + |
55 | 110 | cleanup_tests()
|
56 | 111 | {
|
57 | 112 | $XDP_FORWARD unload ${NS_NAMES[@]} >/dev/null 2>&1
|
|
0 commit comments