[PATCH nft 3/3] tests: shell: add flush set after expiration

Pablo Neira Ayuso <[email protected]> Wed, 5 Aug 2026 18:39:20 +0200
Newsgroups gmane.comp.security.firewalls.netfilter.devel
Message-ID <[email protected]>
Add a new test to cover for flush commands after elements have expired,
this allowed me to catch a bug in:

("netfilter: nf_tables: call set ops .commit when building new ruleset")

This tests works fine with <= 7.2-rc6, this is not specifically covering
any existing regression.

Signed-off-by: Pablo Neira Ayuso <[email protected]>
---
 .../sets/dumps/flush_after_expiration.nodump  |  0
 .../testcases/sets/flush_after_expiration     | 45 +++++++++++++++++++
 2 files changed, 45 insertions(+)
 create mode 100644 tests/shell/testcases/sets/dumps/flush_after_expiration.nodump
 create mode 100755 tests/shell/testcases/sets/flush_after_expiration

diff --git a/tests/shell/testcases/sets/dumps/flush_after_expiration.nodump b/tests/shell/testcases/sets/dumps/flush_after_expiration.nodump
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/tests/shell/testcases/sets/flush_after_expiration b/tests/shell/testcases/sets/flush_after_expiration
new file mode 100755
index 000000000000..eaf03a546ca0
--- /dev/null
+++ b/tests/shell/testcases/sets/flush_after_expiration
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+$NFT -f - <<EOF
+table ip x {
+        set s0 {
+                type inet_service
+                elements = { 20, 21, 22 }
+                flags interval
+                timeout 3s
+        }
+}
+EOF
+
+sleep 6
+
+$NFT flush set ip x s0
+
+$NFT -f - <<EOF
+table ip x {
+        set s1 {
+                type ipv4_addr . inet_service
+                elements = { 1.2.3.4 . 20, 1.2.3.5 . 21, 1.2.3.6 . 22 }
+                flags interval
+                timeout 3s
+        }
+}
+EOF
+
+sleep 6
+
+$NFT flush set ip x s1
+
+$NFT -f - <<EOF
+table ip x {
+        set s2 {
+                type ipv4_addr
+                elements = { 2.2.2.1, 2.2.2.2, 2.2.2.3 }
+                timeout 3s
+        }
+}
+EOF
+
+sleep 6
+
+$NFT flush set ip x s2
-- 
2.47.3