]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests: shell: add test case for netdev + dormant table
authorFlorian Westphal <fw@strlen.de>
Sun, 26 Apr 2026 14:44:51 +0000 (16:44 +0200)
committerFlorian Westphal <fw@strlen.de>
Thu, 7 May 2026 22:07:04 +0000 (00:07 +0200)
both commit update and abort path need to release memory associated with
netdev hooks.  kfree gets skipped because it mixes registration and
allocation.

Signed-off-by: Florian Westphal <fw@strlen.de>
tests/shell/testcases/transactions/dormant_updchain_abort [new file with mode: 0755]
tests/shell/testcases/transactions/dumps/dormant_updchain_abort.json-nft [new file with mode: 0644]
tests/shell/testcases/transactions/dumps/dormant_updchain_abort.nft [new file with mode: 0644]

diff --git a/tests/shell/testcases/transactions/dormant_updchain_abort b/tests/shell/testcases/transactions/dormant_updchain_abort
new file mode 100755 (executable)
index 0000000..152b7fc
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+set -e
+
+$NFT -f - <<EOF
+table netdev t {
+       flags dormant
+
+       chain c {
+               type filter hook ingress priority 0
+       }
+}
+EOF
+
+# check abort path frees transaction
+$NFT --check -f - <<EOF
+table netdev t {
+       flags dormant
+       chain c {
+               type filter hook ingress device lo priority 0
+       }
+}
+EOF
diff --git a/tests/shell/testcases/transactions/dumps/dormant_updchain_abort.json-nft b/tests/shell/testcases/transactions/dumps/dormant_updchain_abort.json-nft
new file mode 100644 (file)
index 0000000..f6838c1
--- /dev/null
@@ -0,0 +1,33 @@
+{
+  "nftables": [
+    {
+      "metainfo": {
+        "version": "VERSION",
+        "release_name": "RELEASE_NAME",
+        "json_schema_version": 1
+      }
+    },
+    {
+      "table": {
+        "family": "netdev",
+        "name": "t",
+        "handle": 0,
+        "flags": [
+          "dormant"
+        ]
+      }
+    },
+    {
+      "chain": {
+        "family": "netdev",
+        "table": "t",
+        "name": "c",
+        "handle": 0,
+        "type": "filter",
+        "hook": "ingress",
+        "prio": 0,
+        "policy": "accept"
+      }
+    }
+  ]
+}
diff --git a/tests/shell/testcases/transactions/dumps/dormant_updchain_abort.nft b/tests/shell/testcases/transactions/dumps/dormant_updchain_abort.nft
new file mode 100644 (file)
index 0000000..95dcc59
--- /dev/null
@@ -0,0 +1,7 @@
+table netdev t {
+       flags dormant
+
+       chain c {
+               type filter hook ingress priority filter; policy accept;
+       }
+}