Skip to contentSkip to conversation

tests: shell: add test case for netdev + dormant table

PATCH In review Florian Westphal 1 participant 2 messages Apr 26 – Apr 27 netfilter

lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 tests: shell: add test case for netdev + dormant table

both commit update and abort path need to release memory associated with netdev hooks. kfree gets skipped because it mixes registration and allocation.

---
 .../transactions/dormant_updchain_abort       | 23 +++++++++++++
 .../dumps/dormant_updchain_abort.json-nft     | 33 +++++++++++++++++++
 .../dumps/dormant_updchain_abort.nft          |  7 ++++
 3 files changed, 63 insertions(+)
 create mode 100755 tests/shell/testcases/transactions/dormant_updchain_abort
 create mode 100644 tests/shell/testcases/transactions/dumps/dormant_updchain_abort.json-nft
 create mode 100644 tests/shell/testcases/transactions/dumps/dormant_updchain_abort.nft
tests/shell/testcases/transactions/dormant_updchain_abort new file +23 -0
new file mode 100755
index 000000000000..56ad887d0d92
@@ -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
tests/shell/testcases/transactions/dumps/dormant_updchain_abort.json-nft new file +33 -0
new file mode 100644
index 000000000000..f6838c15e9f1
@@ -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"
+      }
+    }
+  ]
+}
tests/shell/testcases/transactions/dumps/dormant_updchain_abort.nft new file +7 -0
new file mode 100644
index 000000000000..95dcc59a3e46
@@ -0,0 +1,7 @@
+table netdev t {
+	flags dormant
+
+	chain c {
+		type filter hook ingress priority filter; policy accept;
+	}
+}
Signature · 1 line
2.53.0
author maintainer
#1 lore raw
Quoted 3 lines · Florian Westphal

both commit update and abort path need to release memory associated with netdev hooks. kfree gets skipped because it mixes registration and allocation.

I have a kernel fix for this bug but I am waiting for the pending PR to get merged before sending it, the fix depends on the new unlink+free helper and doesn't apply to main branch.