summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2024-10-25 09:47:25 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2024-11-11 11:40:08 +0100
commit058246016188c8418cae1b3db70b16b935b1fe7c (patch)
tree6f4c6363aaeb88bb79c9a843b50166deda0138ea /tests
parent1e0b74fae4d5f15c48ccabfe2fe147a78a5341d6 (diff)
src: allow to map key to nfqueue number
Allow to specify a numeric queue id as part of a map. The parser side is easy, but the reverse direction (listing) is not. 'queue' is a statement, it doesn't have an expression. Add a generic 'queue_type' datatype as a shim to the real basetype with constant expressions, this is used only for udata build/parse, it stores the "key" (the parser token, here "queue") as udata in kernel and can then restore the original key. Add a dumpfile to validate parser & output. JSON support is missing because JSON allow typeof only since quite recently. Joint work with Pablo. Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1455 Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/shell/testcases/nft-f/dumps/nfqueue.nft11
-rwxr-xr-xtests/shell/testcases/nft-f/nfqueue6
2 files changed, 17 insertions, 0 deletions
diff --git a/tests/shell/testcases/nft-f/dumps/nfqueue.nft b/tests/shell/testcases/nft-f/dumps/nfqueue.nft
new file mode 100644
index 00000000..7fe3ca66
--- /dev/null
+++ b/tests/shell/testcases/nft-f/dumps/nfqueue.nft
@@ -0,0 +1,11 @@
+table inet t {
+ map get_queue_id {
+ typeof ip saddr . ip daddr . tcp dport : queue
+ elements = { 127.0.0.1 . 127.0.0.1 . 22 : 1,
+ 127.0.0.1 . 127.0.0.2 . 22 : 2 }
+ }
+
+ chain test {
+ queue flags bypass to ip saddr . ip daddr . tcp dport map @get_queue_id
+ }
+}
diff --git a/tests/shell/testcases/nft-f/nfqueue b/tests/shell/testcases/nft-f/nfqueue
new file mode 100755
index 00000000..07820b7c
--- /dev/null
+++ b/tests/shell/testcases/nft-f/nfqueue
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+set -e
+dumpfile=$(dirname $0)/dumps/$(basename $0).nft
+
+$NFT -f "$dumpfile"