Create a helper file to: 1. create client <-> router <-> server topology 2. floodping from client to server 3. add a chain + set that contains both client and server addresses 4. a control counter that should never match 5. then, flush the set (not the ruleset) and re-add the addresses in one transaction Report failure when counter had a match. The test cases for the set types are done in separate files to take advantage of run-tests.sh parallelization. The expected behavior is that every ping packet is matched by the set. The packet path should either match the old state, right before flush, or the new state, after re-add. As the flushed addresses are re-added in the same transaction we must not observe in-limbo state where existing elements are deactivated but new elements are not found. Signed-off-by: Florian Westphal --- NB: This still fails on nf-next when AVX2 is available for the pipapo test case due to thinko, NFT_GENMASK_ANY has to be replaced with 0 to get the effect the (wrong) fix wanted. .../helpers/set_flush_add_atomic_helpers | 223 ++++++++++++++++++ .../dumps/set_flush_add_atomic_bitmap.nodump | 0 .../dumps/set_flush_add_atomic_hash.nodump | 0 .../set_flush_add_atomic_hash_fast.nodump | 0 .../dumps/set_flush_add_atomic_pipapo.nodump | 0 .../dumps/set_flush_add_atomic_rbtree.nodump | 0 .../dumps/set_flush_add_atomic_rhash.nodump | 0 .../packetpath/set_flush_add_atomic_bitmap | 18 ++ .../packetpath/set_flush_add_atomic_hash | 18 ++ .../packetpath/set_flush_add_atomic_hash_fast | 18 ++ .../packetpath/set_flush_add_atomic_pipapo | 20 ++ .../packetpath/set_flush_add_atomic_rbtree | 18 ++ .../packetpath/set_flush_add_atomic_rhash | 18 ++ 13 files changed, 333 insertions(+) create mode 100644 tests/shell/helpers/set_flush_add_atomic_helpers create mode 100644 tests/shell/testcases/packetpath/dumps/set_flush_add_atomic_bitmap.nodump create mode 100644 tests/shell/testcases/packetpath/dumps/set_flush_add_atomic_hash.nodump create mode 100644 tests/shell/testcases/packetpath/dumps/set_flush_add_atomic_hash_fast.nodump create mode 100644 tests/shell/testcases/packetpath/dumps/set_flush_add_atomic_pipapo.nodump create mode 100644 tests/shell/testcases/packetpath/dumps/set_flush_add_atomic_rbtree.nodump create mode 100644 tests/shell/testcases/packetpath/dumps/set_flush_add_atomic_rhash.nodump create mode 100755 tests/shell/testcases/packetpath/set_flush_add_atomic_bitmap create mode 100755 tests/shell/testcases/packetpath/set_flush_add_atomic_hash create mode 100755 tests/shell/testcases/packetpath/set_flush_add_atomic_hash_fast create mode 100755 tests/shell/testcases/packetpath/set_flush_add_atomic_pipapo create mode 100755 tests/shell/testcases/packetpath/set_flush_add_atomic_rbtree create mode 100755 tests/shell/testcases/packetpath/set_flush_add_atomic_rhash diff --git a/tests/shell/helpers/set_flush_add_atomic_helpers b/tests/shell/helpers/set_flush_add_atomic_helpers new file mode 100644 index 000000000000..fe895e98169b --- /dev/null +++ b/tests/shell/helpers/set_flush_add_atomic_helpers @@ -0,0 +1,223 @@ +# Test skeleton for kernel fixes: +# b2f742c846ca netfilter: nf_tables: restart set lookup on base_seq change +# a60f7bf4a152 netfilter: nft_set_rbtree: continue traversal if element is inactive +# .. and related patches. +# +# Generate traffic and then flush the set contents and replace +# them with the same matching entries. +# +# Fail when a packet gets through. + +# global variables: +# R, S, C (network namespaces). +# ip_s (server address) + +# helpers: +# set_flush_add_atomic_cleanup +# set_flush_add_create_topo +# set_flush_add_atomic_run_test + +[ -z "$TIMEOUT" ] && TIMEOUT=30 + +set_flush_add_atomic_cleanup() +{ + local tmp="$1" + local i + + rm -f "$tmp" + + ip netns exec $R $NFT --debug netlink list ruleset + + for i in $C $S $R;do + kill $(ip netns pid $i) 2>/dev/null + ip netns del $i + done +} + +check_counter() +{ + local tmp="$1" + local then="$2" + + if ip netns exec $R $NFT list chain ip filter block-spoofed | grep -q 'counter packets 0 bytes 0'; then + return 0 + fi + + local now=$(date +%s) + echo "$0 failed counter check after $((now-then))s" + + rm -f "$tmp" + kill $(ip netns pid $C) 2>/dev/null + return 1 +} + +load_ruleset() +{ + local type="$1" + local flags="$2" + local elements="$3" + local expr="$4" + +ip netns exec $R $NFT -f - <