From 624b034b83a66ec2263314db9dc62ac06b1ae7e7 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Thu, 8 Feb 2024 14:30:17 +0100 Subject: tests: shell: Pretty-print all *.json-nft dumps The problem with single line output as produced by 'nft -j list ruleset' is its incompatibility to unified diff format as any change in this single line will produce a diff which contains the old and new lines in total. This is not just unreadable but will blow up patches which may exceed mailinglists' mail size limits. Convert them all at once by feeding their contents to tests/shell/helpers/json-pretty.sh. Signed-off-by: Phil Sutter --- .../maps/dumps/typeof_maps_add_delete.json-nft | 284 ++++++++++++++++++++- 1 file changed, 283 insertions(+), 1 deletion(-) (limited to 'tests/shell/testcases/maps/dumps/typeof_maps_add_delete.json-nft') diff --git a/tests/shell/testcases/maps/dumps/typeof_maps_add_delete.json-nft b/tests/shell/testcases/maps/dumps/typeof_maps_add_delete.json-nft index 475a52e3..4a58602a 100644 --- a/tests/shell/testcases/maps/dumps/typeof_maps_add_delete.json-nft +++ b/tests/shell/testcases/maps/dumps/typeof_maps_add_delete.json-nft @@ -1 +1,283 @@ -{"nftables": [{"metainfo": {"version": "VERSION", "release_name": "RELEASE_NAME", "json_schema_version": 1}}, {"table": {"family": "ip", "name": "dynset", "handle": 0}}, {"map": {"family": "ip", "name": "dynmark", "table": "dynset", "type": "ipv4_addr", "handle": 0, "map": "mark", "size": 64, "flags": ["timeout"], "timeout": 300, "stmt": [{"counter": null}]}}, {"chain": {"family": "ip", "table": "dynset", "name": "test_ping", "handle": 0}}, {"chain": {"family": "ip", "table": "dynset", "name": "input", "handle": 0, "type": "filter", "hook": "input", "prio": 0, "policy": "accept"}}, {"rule": {"family": "ip", "table": "dynset", "chain": "test_ping", "handle": 0, "comment": "should not increment", "expr": [{"match": {"op": "==", "left": {"payload": {"protocol": "ip", "field": "saddr"}}, "right": "@dynmark"}}, {"counter": {"packets": 0, "bytes": 0}}]}}, {"rule": {"family": "ip", "table": "dynset", "chain": "test_ping", "handle": 0, "expr": [{"match": {"op": "!=", "left": {"payload": {"protocol": "ip", "field": "saddr"}}, "right": "@dynmark"}}, {"map": {"op": "add", "elem": {"payload": {"protocol": "ip", "field": "saddr"}}, "data": 1, "map": "@dynmark"}}, {"counter": {"packets": 1, "bytes": 84}}]}}, {"rule": {"family": "ip", "table": "dynset", "chain": "test_ping", "handle": 0, "comment": "should increment", "expr": [{"match": {"op": "==", "left": {"payload": {"protocol": "ip", "field": "saddr"}}, "right": "@dynmark"}}, {"counter": {"packets": 1, "bytes": 84}}]}}, {"rule": {"family": "ip", "table": "dynset", "chain": "test_ping", "handle": 0, "expr": [{"match": {"op": "==", "left": {"payload": {"protocol": "ip", "field": "saddr"}}, "right": "@dynmark"}}, {"map": {"op": "delete", "elem": {"payload": {"protocol": "ip", "field": "saddr"}}, "data": 1, "map": "@dynmark"}}]}}, {"rule": {"family": "ip", "table": "dynset", "chain": "test_ping", "handle": 0, "comment": "delete should be instant but might fail under memory pressure", "expr": [{"match": {"op": "==", "left": {"payload": {"protocol": "ip", "field": "saddr"}}, "right": "@dynmark"}}, {"counter": {"packets": 0, "bytes": 0}}]}}, {"rule": {"family": "ip", "table": "dynset", "chain": "input", "handle": 0, "comment": "also check timeout-gc", "expr": [{"map": {"op": "add", "elem": {"elem": {"val": "10.2.3.4", "timeout": 1}}, "data": 2, "map": "@dynmark"}}]}}, {"rule": {"family": "ip", "table": "dynset", "chain": "input", "handle": 0, "expr": [{"match": {"op": "==", "left": {"meta": {"key": "l4proto"}}, "right": "icmp"}}, {"match": {"op": "==", "left": {"payload": {"protocol": "ip", "field": "daddr"}}, "right": "127.0.0.42"}}, {"jump": {"target": "test_ping"}}]}}]} +{ + "nftables": [ + { + "metainfo": { + "version": "VERSION", + "release_name": "RELEASE_NAME", + "json_schema_version": 1 + } + }, + { + "table": { + "family": "ip", + "name": "dynset", + "handle": 0 + } + }, + { + "map": { + "family": "ip", + "name": "dynmark", + "table": "dynset", + "type": "ipv4_addr", + "handle": 0, + "map": "mark", + "size": 64, + "flags": [ + "timeout" + ], + "timeout": 300, + "stmt": [ + { + "counter": null + } + ] + } + }, + { + "chain": { + "family": "ip", + "table": "dynset", + "name": "test_ping", + "handle": 0 + } + }, + { + "chain": { + "family": "ip", + "table": "dynset", + "name": "input", + "handle": 0, + "type": "filter", + "hook": "input", + "prio": 0, + "policy": "accept" + } + }, + { + "rule": { + "family": "ip", + "table": "dynset", + "chain": "test_ping", + "handle": 0, + "comment": "should not increment", + "expr": [ + { + "match": { + "op": "==", + "left": { + "payload": { + "protocol": "ip", + "field": "saddr" + } + }, + "right": "@dynmark" + } + }, + { + "counter": { + "packets": 0, + "bytes": 0 + } + } + ] + } + }, + { + "rule": { + "family": "ip", + "table": "dynset", + "chain": "test_ping", + "handle": 0, + "expr": [ + { + "match": { + "op": "!=", + "left": { + "payload": { + "protocol": "ip", + "field": "saddr" + } + }, + "right": "@dynmark" + } + }, + { + "map": { + "op": "add", + "elem": { + "payload": { + "protocol": "ip", + "field": "saddr" + } + }, + "data": 1, + "map": "@dynmark" + } + }, + { + "counter": { + "packets": 1, + "bytes": 84 + } + } + ] + } + }, + { + "rule": { + "family": "ip", + "table": "dynset", + "chain": "test_ping", + "handle": 0, + "comment": "should increment", + "expr": [ + { + "match": { + "op": "==", + "left": { + "payload": { + "protocol": "ip", + "field": "saddr" + } + }, + "right": "@dynmark" + } + }, + { + "counter": { + "packets": 1, + "bytes": 84 + } + } + ] + } + }, + { + "rule": { + "family": "ip", + "table": "dynset", + "chain": "test_ping", + "handle": 0, + "expr": [ + { + "match": { + "op": "==", + "left": { + "payload": { + "protocol": "ip", + "field": "saddr" + } + }, + "right": "@dynmark" + } + }, + { + "map": { + "op": "delete", + "elem": { + "payload": { + "protocol": "ip", + "field": "saddr" + } + }, + "data": 1, + "map": "@dynmark" + } + } + ] + } + }, + { + "rule": { + "family": "ip", + "table": "dynset", + "chain": "test_ping", + "handle": 0, + "comment": "delete should be instant but might fail under memory pressure", + "expr": [ + { + "match": { + "op": "==", + "left": { + "payload": { + "protocol": "ip", + "field": "saddr" + } + }, + "right": "@dynmark" + } + }, + { + "counter": { + "packets": 0, + "bytes": 0 + } + } + ] + } + }, + { + "rule": { + "family": "ip", + "table": "dynset", + "chain": "input", + "handle": 0, + "comment": "also check timeout-gc", + "expr": [ + { + "map": { + "op": "add", + "elem": { + "elem": { + "val": "10.2.3.4", + "timeout": 1 + } + }, + "data": 2, + "map": "@dynmark" + } + } + ] + } + }, + { + "rule": { + "family": "ip", + "table": "dynset", + "chain": "input", + "handle": 0, + "expr": [ + { + "match": { + "op": "==", + "left": { + "meta": { + "key": "l4proto" + } + }, + "right": "icmp" + } + }, + { + "match": { + "op": "==", + "left": { + "payload": { + "protocol": "ip", + "field": "daddr" + } + }, + "right": "127.0.0.42" + } + }, + { + "jump": { + "target": "test_ping" + } + } + ] + } + } + ] +} -- cgit v1.2.3