diff options
author | Thomas Haller <thaller@redhat.com> | 2023-11-14 17:08:28 +0100 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2023-11-15 13:12:06 +0100 |
commit | 3d24b16b9ac132d26869953f54ef7c69f1c1d58f (patch) | |
tree | c9432f7716f192c913b1aefc353bd7f220340376 /tests/shell/testcases/optimizations/dumps/merge_nat.json-nft | |
parent | c9caa99c52752907509584b7165ad6180764d87d (diff) |
tests/shell: add JSON dump files
Generate and add ".json-nft" files. These files contain the output of
`nft -j list ruleset` after the test. Also, "test-wrapper.sh" will
compare the current ruleset against the ".json-nft" files and test them
with "nft -j --check -f $FILE`. These are useful extra tests, that we
almost get for free.
Note that for some JSON dumps, `nft -f --check` fails (or prints
something). For those tests no *.json-nft file is added. The bugs needs
to be fixed first.
An example of such an issue is:
$ DUMPGEN=all ./tests/shell/run-tests.sh tests/shell/testcases/maps/nat_addr_port
which gives a file "rc-failed-chkdump" with
Command `./tests/shell/../../src/nft -j --check -f "tests/shell/testcases/maps/dumps/nat_addr_port.json-nft"` failed
>>>>
internal:0:0-0: Error: Invalid map type 'ipv4_addr . inet_service'.
internal:0:0-0: Error: Parsing command array at index 3 failed.
internal:0:0-0: Error: unqualified type integer specified in map definition. Try "typeof expression" instead of "type datatype".
<<<<
Tests like "tests/shell/testcases/nft-f/0012different_defines_0" and
"tests/shell/testcases/nft-f/0024priority_0" also don't get a .json-nft
dump yet, because their output is not stable. That needs fixing too.
Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Florian Westphal <fw@strlen.de>
Signed-off-by: Thomas Haller <thaller@redhat.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'tests/shell/testcases/optimizations/dumps/merge_nat.json-nft')
-rw-r--r-- | tests/shell/testcases/optimizations/dumps/merge_nat.json-nft | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/tests/shell/testcases/optimizations/dumps/merge_nat.json-nft b/tests/shell/testcases/optimizations/dumps/merge_nat.json-nft new file mode 100644 index 00000000..675ad48e --- /dev/null +++ b/tests/shell/testcases/optimizations/dumps/merge_nat.json-nft @@ -0,0 +1 @@ +{"nftables": [{"metainfo": {"version": "VERSION", "release_name": "RELEASE_NAME", "json_schema_version": 1}}, {"table": {"family": "ip", "name": "test1", "handle": 2}}, {"chain": {"family": "ip", "table": "test1", "name": "y", "handle": 1}}, {"rule": {"family": "ip", "table": "test1", "chain": "y", "handle": 2, "expr": [{"match": {"op": "==", "left": {"meta": {"key": "oif"}}, "right": "lo"}}, {"accept": null}]}}, {"rule": {"family": "ip", "table": "test1", "chain": "y", "handle": 4, "expr": [{"dnat": {"addr": {"map": {"key": {"payload": {"protocol": "ip", "field": "saddr"}}, "data": {"set": [["4.4.4.4", "1.1.1.1"], ["5.5.5.5", "2.2.2.2"]]}}}}}]}}, {"table": {"family": "ip", "name": "test2", "handle": 4}}, {"chain": {"family": "ip", "table": "test2", "name": "y", "handle": 1}}, {"rule": {"family": "ip", "table": "test2", "chain": "y", "handle": 2, "expr": [{"match": {"op": "==", "left": {"meta": {"key": "oif"}}, "right": "lo"}}, {"accept": null}]}}, {"rule": {"family": "ip", "table": "test2", "chain": "y", "handle": 4, "expr": [{"dnat": {"family": "ip", "addr": {"map": {"key": {"payload": {"protocol": "tcp", "field": "dport"}}, "data": {"set": [[80, {"concat": ["1.1.1.1", 8001]}], [81, {"concat": ["2.2.2.2", 9001]}]]}}}}}]}}, {"rule": {"family": "ip", "table": "test2", "chain": "y", "handle": 6, "expr": [{"match": {"op": "==", "left": {"payload": {"protocol": "ip", "field": "saddr"}}, "right": {"set": [{"prefix": {"addr": "10.141.11.0", "len": 24}}, {"prefix": {"addr": "10.141.13.0", "len": 24}}]}}}, {"masquerade": null}]}}, {"table": {"family": "ip", "name": "test4", "handle": 6}}, {"chain": {"family": "ip", "table": "test4", "name": "y", "handle": 1}}, {"rule": {"family": "ip", "table": "test4", "chain": "y", "handle": 2, "expr": [{"match": {"op": "==", "left": {"meta": {"key": "oif"}}, "right": "lo"}}, {"accept": null}]}}, {"rule": {"family": "ip", "table": "test4", "chain": "y", "handle": 4, "expr": [{"dnat": {"family": "ip", "addr": {"map": {"key": {"concat": [{"payload": {"protocol": "ip", "field": "daddr"}}, {"payload": {"protocol": "tcp", "field": "dport"}}]}, "data": {"set": [[{"concat": ["1.1.1.1", 80]}, {"concat": ["4.4.4.4", 8000]}], [{"concat": ["2.2.2.2", 81]}, {"concat": ["3.3.3.3", 9000]}]]}}}}}]}}, {"rule": {"family": "ip", "table": "test4", "chain": "y", "handle": 6, "expr": [{"redirect": {"port": {"map": {"key": {"payload": {"protocol": "tcp", "field": "dport"}}, "data": {"set": [[83, 8083], [84, 8084]]}}}}}]}}, {"rule": {"family": "ip", "table": "test4", "chain": "y", "handle": 7, "expr": [{"match": {"op": "==", "left": {"payload": {"protocol": "tcp", "field": "dport"}}, "right": 85}}, {"redirect": null}]}}, {"table": {"family": "inet", "name": "nat", "handle": 8}}, {"chain": {"family": "inet", "table": "nat", "name": "prerouting", "handle": 1}}, {"chain": {"family": "inet", "table": "nat", "name": "postrouting", "handle": 2}}, {"rule": {"family": "inet", "table": "nat", "chain": "prerouting", "handle": 3, "expr": [{"match": {"op": "==", "left": {"meta": {"key": "oif"}}, "right": "lo"}}, {"accept": null}]}}, {"rule": {"family": "inet", "table": "nat", "chain": "prerouting", "handle": 5, "expr": [{"dnat": {"family": "ip", "addr": {"map": {"key": {"concat": [{"meta": {"key": "iifname"}}, {"payload": {"protocol": "ip", "field": "daddr"}}, {"payload": {"protocol": "tcp", "field": "dport"}}]}, "data": {"set": [[{"concat": ["enp2s0", "72.2.3.70", 80]}, {"concat": ["10.1.1.52", 80]}], [{"concat": ["enp2s0", "72.2.3.66", 53122]}, {"concat": ["10.1.1.10", 22]}], [{"concat": ["enp2s0", "72.2.3.66", 443]}, {"concat": ["10.1.1.52", 443]}]]}}}}}]}}, {"rule": {"family": "inet", "table": "nat", "chain": "postrouting", "handle": 6, "expr": [{"match": {"op": "==", "left": {"meta": {"key": "oif"}}, "right": "lo"}}, {"accept": null}]}}, {"rule": {"family": "inet", "table": "nat", "chain": "postrouting", "handle": 8, "expr": [{"snat": {"family": "ip", "addr": {"map": {"key": {"payload": {"protocol": "ip", "field": "daddr"}}, "data": {"set": [["72.2.3.66", "10.2.2.2"], ["72.2.3.67", "10.2.3.3"]]}}}}}]}}]} |