Skip to contentSkip to conversation

tests: packetpath: add check for drop policy

PATCH New Florian Westphal 1 participant 1 message Apr 3, 2024 netfilter

lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 tests: packetpath: add check for drop policy

check that policy can be changed from accept to drop and that the kernel acts on this.

---
 .../packetpath/dumps/policy.json-nft          | 121 ++++++++++++++++++
 .../testcases/packetpath/dumps/policy.nft     |  11 ++
 tests/shell/testcases/packetpath/policy       |  42 ++++++
 3 files changed, 174 insertions(+)
 create mode 100644 tests/shell/testcases/packetpath/dumps/policy.json-nft
 create mode 100644 tests/shell/testcases/packetpath/dumps/policy.nft
 create mode 100755 tests/shell/testcases/packetpath/policy
tests/shell/testcases/packetpath/dumps/policy.json-nft new file +121 -0
new file mode 100644
index 000000000000..26e8a0525f2b
@@ -0,0 +1,121 @@
+{
+  "nftables": [
+    {
+      "metainfo": {
+        "version": "VERSION",
+        "release_name": "RELEASE_NAME",
+        "json_schema_version": 1
+      }
+    },
+    {
+      "table": {
+        "family": "inet",
+        "name": "filter",
+        "handle": 0
+      }
+    },
+    {
+      "chain": {
+        "family": "inet",
+        "table": "filter",
+        "name": "underflow",
+        "handle": 0
+      }
+    },
+    {
+      "chain": {
+        "family": "inet",
+        "table": "filter",
+        "name": "input",
+        "handle": 0,
+        "type": "filter",
+        "hook": "input",
+        "prio": 0,
+        "policy": "drop"
+      }
+    },
+    {
+      "rule": {
+        "family": "inet",
+        "table": "filter",
+        "chain": "input",
+        "handle": 0,
+        "expr": [
+          {
+            "match": {
+              "op": "==",
+              "left": {
+                "payload": {
+                  "protocol": "icmp",
+                  "field": "type"
+                }
+              },
+              "right": "echo-reply"
+            }
+          },
+          {
+            "accept": null
+          }
+        ]
+      }
+    },
+    {
+      "rule": {
+        "family": "inet",
+        "table": "filter",
+        "chain": "input",
+        "handle": 0,
+        "expr": [
+          {
+            "match": {
+              "op": "==",
+              "left": {
+                "payload": {
+                  "protocol": "ip",
+                  "field": "saddr"
+                }
+              },
+              "right": "127.0.0.1"
+            }
+          },
+          {
+            "match": {
+              "op": "==",
+              "left": {
+                "payload": {
+                  "protocol": "ip",
+                  "field": "daddr"
+                }
+              },
+              "right": "127.0.0.2"
+            }
+          },
+          {
+            "counter": {
+              "packets": 3,
+              "bytes": 252
+            }
+          },
+          {
+            "accept": null
+          }
+        ]
+      }
+    },
+    {
+      "rule": {
+        "family": "inet",
+        "table": "filter",
+        "chain": "input",
+        "handle": 0,
+        "expr": [
+          {
+            "goto": {
+              "target": "underflow"
+            }
+          }
+        ]
+      }
+    }
+  ]
+}
tests/shell/testcases/packetpath/dumps/policy.nft new file +11 -0
new file mode 100644
index 000000000000..e625ea6c82be
@@ -0,0 +1,11 @@
+table inet filter {
+	chain underflow {
+	}
+
+	chain input {
+		type filter hook input priority filter; policy drop;
+		icmp type echo-reply accept
+		ip saddr 127.0.0.1 ip daddr 127.0.0.2 counter packets 3 bytes 252 accept
+		goto underflow
+	}
+}
tests/shell/testcases/packetpath/policy new file +42 -0

42 lines not on this page · raw message

Signature · 1 line
2.43.2