tests: shell: Keep dumps with numeric protocol values
Phil Sutter
reviewercover tests: shell: Keep dumps with numeric protocol values
Adjust the test wrapper to create dumps with --numeric-protocol option (patch 1) and update all dumps (patch 2).
One could also set --stateless, py test suite does that, too. Though there are tests (in packetpath dir) which seem to rely upon counter or other stateful data to be matched in dump files, so keep state for now.
Phil Sutter (2):
tests: shell: Use --numeric-protocol for dumps
tests: shell: Convert dumps to numeric protocols
tests/shell/helpers/test-wrapper.sh | 9 ++-- .../cache/dumps/0003_cache_update_0.json-nft | 4 +- .../cache/dumps/0003_cache_update_0.nft | 4 +- .../chains/dumps/0041chain_binding_0.nft | 4 +- .../maps/dumps/0010concat_map_0.json-nft | 2 +- .../testcases/maps/dumps/0010concat_map_0.nft | 2 +- .../testcases/maps/dumps/0013map_0.json-nft | 2 +- .../shell/testcases/maps/dumps/0013map_0.nft | 2 +- .../maps/dumps/anon_objmap_concat.json-nft | 4 +- .../maps/dumps/anon_objmap_concat.nft | 2 +- .../maps/dumps/named_limits.json-nft | 14 ++--- .../testcases/maps/dumps/named_limits.nft | 14 ++--- .../maps/dumps/nat_addr_port.json-nft | 16 +++--- .../testcases/maps/dumps/nat_addr_port.nft | 16 +++--- .../maps/dumps/typeof_maps_0.json-nft | 6 +-- .../testcases/maps/dumps/typeof_maps_0.nft | 4 +- .../dumps/typeof_maps_add_delete.json-nft | 2 +- .../maps/dumps/typeof_maps_add_delete.nft | 2 +- .../dumps/0012different_defines_0.json-nft | 4 +- .../nft-f/dumps/0012different_defines_0.nft | 2 +- .../dumps/named_set_as_protocol_dep.json-nft | 4 +- .../nft-f/dumps/named_set_as_protocol_dep.nft | 2 +- .../testcases/nft-f/dumps/sample-ruleset.nft | 4 +- .../optimizations/dumps/merge_reject.json-nft | 12 ++--- .../optimizations/dumps/merge_reject.nft | 4 +- .../dumps/merge_stmts_concat.json-nft | 4 +- .../dumps/merge_stmts_concat.nft | 2 +- .../dumps/merge_vmap_raw.json-nft | 10 ++-- .../optimizations/dumps/merge_vmap_raw.nft | 10 ++-- .../optimizations/dumps/merge_vmaps.json-nft | 4 +- .../optimizations/dumps/merge_vmaps.nft | 2 +- .../dumps/exclusive_start_cond.json-nft | 52 +++++++++---------- .../parsing/dumps/exclusive_start_cond.nft | 42 +++++++-------- .../parsing/dumps/large_rule_pipe.json-nft | 24 ++++----- .../parsing/dumps/large_rule_pipe.nft | 12 ++--- .../0037_set_with_inet_service_0.json-nft | 10 ++-- .../dumps/0037_set_with_inet_service_0.nft | 10 ++-- .../shell/testcases/sets/dumps/0047nat_0.nft | 2 +- .../sets/dumps/0067nat_concat_interval_0.nft | 6 +-- .../sets/dumps/0067nat_interval_0.nft | 2 +- .../testcases/sets/dumps/set_eval_0.json-nft | 4 +- .../shell/testcases/sets/dumps/set_eval_0.nft | 2 +- .../sets/dumps/sets_with_ifnames.json-nft | 4 +- .../sets/dumps/sets_with_ifnames.nft | 4 +- .../transactions/dumps/0049huge_0.json-nft | 16 +++--- .../transactions/dumps/0049huge_0.nft | 8 +-- 46 files changed, 186 insertions(+), 185 deletions(-)
Signature · 1 line
2.54.0
Phil Sutter
reviewerPATCH 1/2 tests: shell: Use --numeric-protocol for dumps
The py test suite does this as well. Protocol names depend on contents of /etc/protocols which is not in control of nftables. Using numeric protocol values for dumps therefore prevents the host system from compromising test results.
--- tests/shell/helpers/test-wrapper.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
tests/shell/helpers/test-wrapper.sh +5 -4
@@ -152,21 +152,22 @@ fi rc_chkdump=0 rc=0 -$NFT list ruleset > "$NFT_TEST_TESTTMPDIR/ruleset-after" 2> "$NFT_TEST_TESTTMPDIR/chkdump" || rc=$? +chkdump_nft="$NFT --numeric-protocol" +$chkdump_nft list ruleset > "$NFT_TEST_TESTTMPDIR/ruleset-after" 2> "$NFT_TEST_TESTTMPDIR/chkdump" || rc=$? if [ "$rc" -ne 0 -o -s "$NFT_TEST_TESTTMPDIR/chkdump" ] ; then - show_file "$NFT_TEST_TESTTMPDIR/chkdump" "Command \`$NFT list ruleset\` failed" >> "$NFT_TEST_TESTTMPDIR/rc-failed-chkdump" + show_file "$NFT_TEST_TESTTMPDIR/chkdump" "Command \`$chkdump_nft list ruleset\` failed" >> "$NFT_TEST_TESTTMPDIR/rc-failed-chkdump" rc_chkdump=1 fi if [ "$NFT_TEST_HAVE_json" != n ] ; then rc=0 - $NFT -j list ruleset > "$NFT_TEST_TESTTMPDIR/ruleset-after.json" 2> "$NFT_TEST_TESTTMPDIR/chkdump" || rc=$? + $chkdump_nft -j list ruleset > "$NFT_TEST_TESTTMPDIR/ruleset-after.json" 2> "$NFT_TEST_TESTTMPDIR/chkdump" || rc=$? # Workaround known bug in stmt_print_json(), due to # "chain_stmt_ops.json" being NULL. This spams stderr. sed -i '/^warning: stmt ops chain have no json callback$/d' "$NFT_TEST_TESTTMPDIR/chkdump" if [ "$rc" -ne 0 -o -s "$NFT_TEST_TESTTMPDIR/chkdump" ] ; then - show_file "$NFT_TEST_TESTTMPDIR/chkdump" "Command \`$NFT -j list ruleset\` failed" >> "$NFT_TEST_TESTTMPDIR/rc-failed-chkdump" + show_file "$NFT_TEST_TESTTMPDIR/chkdump" "Command \`$chkdump_nft -j list ruleset\` failed" >> "$NFT_TEST_TESTTMPDIR/rc-failed-chkdump" rc_chkdump=1 fi # JSON output needs normalization/sanitization, otherwise it's not stable.
Signature · 1 line
2.54.0
Phil Sutter
reviewerPATCH 2/2 tests: shell: Convert dumps to numeric protocols
In reply to Phil SutterThese changes were caused by a test run with DUMPGEN=y.
--- .../cache/dumps/0003_cache_update_0.json-nft | 4 +- .../cache/dumps/0003_cache_update_0.nft | 4 +- .../chains/dumps/0041chain_binding_0.nft | 4 +- .../maps/dumps/0010concat_map_0.json-nft | 2 +- .../testcases/maps/dumps/0010concat_map_0.nft | 2 +- .../testcases/maps/dumps/0013map_0.json-nft | 2 +- .../shell/testcases/maps/dumps/0013map_0.nft | 2 +- .../maps/dumps/anon_objmap_concat.json-nft | 4 +- .../maps/dumps/anon_objmap_concat.nft | 2 +- .../maps/dumps/named_limits.json-nft | 14 ++--- .../testcases/maps/dumps/named_limits.nft | 14 ++--- .../maps/dumps/nat_addr_port.json-nft | 16 +++--- .../testcases/maps/dumps/nat_addr_port.nft | 16 +++--- .../maps/dumps/typeof_maps_0.json-nft | 6 +-- .../testcases/maps/dumps/typeof_maps_0.nft | 4 +- .../dumps/typeof_maps_add_delete.json-nft | 2 +- .../maps/dumps/typeof_maps_add_delete.nft | 2 +- .../dumps/0012different_defines_0.json-nft | 4 +- .../nft-f/dumps/0012different_defines_0.nft | 2 +- .../dumps/named_set_as_protocol_dep.json-nft | 4 +- .../nft-f/dumps/named_set_as_protocol_dep.nft | 2 +- .../testcases/nft-f/dumps/sample-ruleset.nft | 4 +- .../optimizations/dumps/merge_reject.json-nft | 12 ++--- .../optimizations/dumps/merge_reject.nft | 4 +- .../dumps/merge_stmts_concat.json-nft | 4 +- .../dumps/merge_stmts_concat.nft | 2 +- .../dumps/merge_vmap_raw.json-nft | 10 ++-- .../optimizations/dumps/merge_vmap_raw.nft | 10 ++-- .../optimizations/dumps/merge_vmaps.json-nft | 4 +- .../optimizations/dumps/merge_vmaps.nft | 2 +- .../dumps/exclusive_start_cond.json-nft | 52 +++++++++---------- .../parsing/dumps/exclusive_start_cond.nft | 42 +++++++-------- .../parsing/dumps/large_rule_pipe.json-nft | 24 ++++----- .../parsing/dumps/large_rule_pipe.nft | 12 ++--- .../0037_set_with_inet_service_0.json-nft | 10 ++-- .../dumps/0037_set_with_inet_service_0.nft | 10 ++-- .../shell/testcases/sets/dumps/0047nat_0.nft | 2 +- .../sets/dumps/0067nat_concat_interval_0.nft | 6 +-- .../sets/dumps/0067nat_interval_0.nft | 2 +- .../testcases/sets/dumps/set_eval_0.json-nft | 4 +- .../shell/testcases/sets/dumps/set_eval_0.nft | 2 +- .../sets/dumps/sets_with_ifnames.json-nft | 4 +- .../sets/dumps/sets_with_ifnames.nft | 4 +- .../transactions/dumps/0049huge_0.json-nft | 16 +++--- .../transactions/dumps/0049huge_0.nft | 8 +-- 45 files changed, 181 insertions(+), 181 deletions(-)
tests/shell/testcases/cache/dumps/0003_cache_update_0.json-nft +2 -2
@@ -74,7 +74,7 @@ "key": "l4proto" } }, - "right": "icmp" + "right": 1 } }, {
@@ -111,7 +111,7 @@ "key": "l4proto" } }, - "right": "igmp" + "right": 2 } }, {
tests/shell/testcases/cache/dumps/0003_cache_update_0.nft +2 -2
@@ -10,9 +10,9 @@ table ip t3 { } table ip t4 { chain c { - meta l4proto icmp accept + meta l4proto 1 accept drop - meta l4proto igmp accept + meta l4proto 2 accept drop } }
tests/shell/testcases/chains/dumps/0041chain_binding_0.nft +2 -2
@@ -1,11 +1,11 @@ table inet x { chain y { type filter hook input priority filter; policy accept; - meta l4proto { tcp, udp } th dport 53 jump { + meta l4proto { 6, 17 } th dport 53 jump { ip saddr { 127.0.0.0/8, 172.23.0.0/16, 192.168.13.0/24 } counter packets 0 bytes 0 accept ip6 saddr ::1 counter packets 0 bytes 0 accept } - meta l4proto ipv6-icmp jump { + meta l4proto 58 jump { counter packets 0 bytes 0 accept } }
tests/shell/testcases/maps/dumps/0010concat_map_0.json-nft +1 -1
@@ -46,7 +46,7 @@ { "concat": [ "1.1.1.1", - "tcp", + 6, 20 ] },
tests/shell/testcases/maps/dumps/0010concat_map_0.nft +1 -1
@@ -1,7 +1,7 @@ table inet x { map z { type ipv4_addr . inet_proto . inet_service : ipv4_addr . inet_service - elements = { 1.1.1.1 . tcp . 20 : 2.2.2.2 . 30 } + elements = { 1.1.1.1 . 6 . 20 : 2.2.2.2 . 30 } } chain y {
tests/shell/testcases/maps/dumps/0013map_0.json-nft +1 -1
@@ -48,7 +48,7 @@ "val": { "concat": [ "10.133.89.138", - "tcp", + 6, 8081 ] },
tests/shell/testcases/maps/dumps/0013map_0.nft +1 -1
@@ -3,7 +3,7 @@ table ip filter { type ipv4_addr . inet_proto . inet_service : verdict flags interval counter - elements = { 10.133.89.138 . tcp . 8081 counter packets 0 bytes 0 : accept } + elements = { 10.133.89.138 . 6 . 8081 counter packets 0 bytes 0 : accept } } chain FORWARD {
tests/shell/testcases/maps/dumps/anon_objmap_concat.json-nft +2 -2
@@ -79,7 +79,7 @@ [ { "concat": [ - "udp", + 17, { "range": [ 10000,
@@ -93,7 +93,7 @@ [ { "concat": [ - "tcp", + 6, { "range": [ 10000,
tests/shell/testcases/maps/dumps/anon_objmap_concat.nft +1 -1
@@ -11,6 +11,6 @@ table inet filter { chain input { type filter hook input priority filter; policy accept; - ct helper set ip protocol . th dport map { udp . 10000-20000 : "sip-5060u", tcp . 10000-20000 : "sip-5060t" } + ct helper set ip protocol . th dport map { 17 . 10000-20000 : "sip-5060u", 6 . 10000-20000 : "sip-5060t" } } }
tests/shell/testcases/maps/dumps/named_limits.json-nft +7 -7
@@ -151,7 +151,7 @@ [ { "concat": [ - "tcp", + 6, { "prefix": { "addr": "192.168.0.0",
@@ -171,7 +171,7 @@ [ { "concat": [ - "udp", + 17, { "prefix": { "addr": "192.168.0.0",
@@ -191,7 +191,7 @@ [ { "concat": [ - "tcp", + 6, { "range": [ "127.0.0.1",
@@ -211,7 +211,7 @@ [ { "concat": [ - "tcp", + 6, { "range": [ "10.0.0.1",
@@ -226,7 +226,7 @@ [ { "concat": [ - "tcp", + 6, { "range": [ "10.0.0.1",
@@ -241,7 +241,7 @@ [ { "concat": [ - "tcp", + 6, { "prefix": { "addr": "10.0.1.0",
@@ -261,7 +261,7 @@ [ { "concat": [ - "tcp", + 6, "10.0.2.1", 22 ]
tests/shell/testcases/maps/dumps/named_limits.nft +7 -7
@@ -32,13 +32,13 @@ table inet filter { map addr4limit { typeof meta l4proto . ip saddr . tcp sport : limit flags interval - elements = { tcp . 192.168.0.0/16 . 1-65535 : "tarpit-bps", - udp . 192.168.0.0/16 . 1-65535 : "tarpit-pps", - tcp . 127.0.0.1-127.1.2.3 . 1-1024 : "tarpit-pps", - tcp . 10.0.0.1-10.0.0.255 . 80 : "http-bulk-rl-1m", - tcp . 10.0.0.1-10.0.0.255 . 443 : "http-bulk-rl-1m", - tcp . 10.0.1.0/24 . 1024-65535 : "http-bulk-rl-10m", - tcp . 10.0.2.1 . 22 : "http-bulk-rl-10m" } + elements = { 6 . 192.168.0.0/16 . 1-65535 : "tarpit-bps", + 17 . 192.168.0.0/16 . 1-65535 : "tarpit-pps", + 6 . 127.0.0.1-127.1.2.3 . 1-1024 : "tarpit-pps", + 6 . 10.0.0.1-10.0.0.255 . 80 : "http-bulk-rl-1m", + 6 . 10.0.0.1-10.0.0.255 . 443 : "http-bulk-rl-1m", + 6 . 10.0.1.0/24 . 1024-65535 : "http-bulk-rl-10m", + 6 . 10.0.2.1 . 22 : "http-bulk-rl-10m" } } map saddr6limit {
tests/shell/testcases/maps/dumps/nat_addr_port.json-nft +8 -8
@@ -262,7 +262,7 @@ "key": "l4proto" } }, - "right": "tcp" + "right": 6 } }, {
@@ -361,7 +361,7 @@ "key": "l4proto" } }, - "right": "tcp" + "right": 6 } }, {
@@ -612,7 +612,7 @@ "key": "l4proto" } }, - "right": "tcp" + "right": 6 } }, {
@@ -711,7 +711,7 @@ "key": "l4proto" } }, - "right": "tcp" + "right": 6 } }, {
@@ -1059,7 +1059,7 @@ "key": "l4proto" } }, - "right": "tcp" + "right": 6 } }, {
@@ -1159,7 +1159,7 @@ "key": "l4proto" } }, - "right": "tcp" + "right": 6 } }, {
@@ -1292,7 +1292,7 @@ "key": "l4proto" } }, - "right": "tcp" + "right": 6 } }, {
@@ -1392,7 +1392,7 @@ "key": "l4proto" } }, - "right": "tcp" + "right": 6 } }, {
tests/shell/testcases/maps/dumps/nat_addr_port.nft +8 -8
@@ -27,10 +27,10 @@ table ip ipfoo { dnat to ip daddr map @x ip saddr 10.1.1.1 dnat to 10.2.3.4 ip saddr 10.1.1.2 tcp dport 42 dnat to 10.2.3.4:4242 - meta l4proto tcp dnat ip to ip saddr map @y + meta l4proto 6 dnat ip to ip saddr map @y dnat ip to ip saddr . tcp dport map @z dnat to numgen inc mod 2 map @t1 - meta l4proto tcp dnat ip to numgen inc mod 2 map @t2 + meta l4proto 6 dnat ip to numgen inc mod 2 map @t2 } } table ip6 ip6foo {
@@ -60,10 +60,10 @@ table ip6 ip6foo { dnat to ip6 daddr map @x ip6 saddr dead::1 dnat to feed::1 ip6 saddr dead::2 tcp dport 42 dnat to [c0::1a]:4242 - meta l4proto tcp dnat ip6 to ip6 saddr map @y + meta l4proto 6 dnat ip6 to ip6 saddr map @y dnat ip6 to ip6 saddr . tcp dport map @z dnat to numgen inc mod 2 map @t1 - meta l4proto tcp dnat ip6 to numgen inc mod 2 map @t2 + meta l4proto 6 dnat ip6 to numgen inc mod 2 map @t2 } } table inet inetfoo {
@@ -114,16 +114,16 @@ table inet inetfoo { dnat ip to ip daddr map @x4 ip saddr 10.1.1.1 dnat ip to 10.2.3.4 ip saddr 10.1.1.2 tcp dport 42 dnat ip to 10.2.3.4:4242 - meta l4proto tcp dnat ip to ip saddr map @y4 + meta l4proto 6 dnat ip to ip saddr map @y4 dnat ip to ip saddr . tcp dport map @z4 dnat ip to numgen inc mod 2 map @t1v4 - meta l4proto tcp dnat ip to numgen inc mod 2 map @t2v4 + meta l4proto 6 dnat ip to numgen inc mod 2 map @t2v4 dnat ip6 to ip6 daddr map @x6 ip6 saddr dead::1 dnat ip6 to feed::1 ip6 saddr dead::2 tcp dport 42 dnat ip6 to [c0::1a]:4242 - meta l4proto tcp dnat ip6 to ip6 saddr map @y6 + meta l4proto 6 dnat ip6 to ip6 saddr map @y6 dnat ip6 to ip6 saddr . tcp dport map @z6 dnat ip6 to numgen inc mod 2 map @t1v6 - meta l4proto tcp dnat ip6 to numgen inc mod 2 map @t2v6 + meta l4proto 6 dnat ip6 to numgen inc mod 2 map @t2v6 } }
tests/shell/testcases/maps/dumps/typeof_maps_0.json-nft +3 -3
@@ -153,7 +153,7 @@ { "concat": [ "eth0", - "tcp", + 6, 22 ] },
@@ -375,7 +375,7 @@ { "concat": [ "eth0", - "tcp", + 6, 22 ] },
@@ -387,7 +387,7 @@ { "concat": [ "eth1", - "udp", + 17, 67 ] },
tests/shell/testcases/maps/dumps/typeof_maps_0.nft +2 -2
@@ -18,7 +18,7 @@ table inet t { map m4 { typeof iifname . ip protocol . th dport : verdict - elements = { "eth0" . tcp . 22 : accept } + elements = { "eth0" . 6 . 22 : accept } } map m5 {
@@ -31,7 +31,7 @@ table inet t { meta mark set vlan id map @m2 meta mark set ip saddr . ip daddr map @m3 iifname . ip protocol . th dport vmap @m4 - iifname . ip protocol . th dport vmap { "eth0" . tcp . 22 : accept, "eth1" . udp . 67 : drop } + iifname . ip protocol . th dport vmap { "eth0" . 6 . 22 : accept, "eth1" . 17 . 67 : drop } ipsec in reqid . iifname vmap @m5 } }
tests/shell/testcases/maps/dumps/typeof_maps_add_delete.json-nft +1 -1
@@ -263,7 +263,7 @@ "key": "l4proto" } }, - "right": "icmp" + "right": 1 } }, {
tests/shell/testcases/maps/dumps/typeof_maps_add_delete.nft +1 -1
@@ -17,6 +17,6 @@ table ip dynset { chain input { type filter hook input priority filter; policy accept; add @dynmark { 10.2.3.4 timeout 2s : 0x00000002 } comment "also check timeout-gc" - meta l4proto icmp ip daddr 127.0.0.42 jump test_ping + meta l4proto 1 ip daddr 127.0.0.42 jump test_ping } }
tests/shell/testcases/nft-f/dumps/0012different_defines_0.json-nft +2 -2
@@ -362,13 +362,13 @@ { "concat": [ "fe0::1", - "udp" + 17 ] }, { "concat": [ "fe0::2", - "tcp" + 6 ] } ]
tests/shell/testcases/nft-f/dumps/0012different_defines_0.nft +1 -1
@@ -8,7 +8,7 @@ table inet t { ip6 daddr fe0::1 ip6 saddr fe0::2 ip saddr vmap { 10.0.0.0 : drop, 10.0.0.2 : accept } ip6 daddr vmap { fe0::1 : drop, fe0::2 : accept } - ip6 saddr . ip6 nexthdr { fe0::1 . udp, fe0::2 . tcp } + ip6 saddr . ip6 nexthdr { fe0::1 . 17, fe0::2 . 6 } ip daddr . iif vmap { 10.0.0.0 . "lo" : accept } tcp dport 100-222 udp dport vmap { 100-222 : accept }
tests/shell/testcases/nft-f/dumps/named_set_as_protocol_dep.json-nft +2 -2
@@ -40,8 +40,8 @@ }, "handle": 0, "elem": [ - "tcp", - "udp" + 6, + 17 ] } },
tests/shell/testcases/nft-f/dumps/named_set_as_protocol_dep.nft +1 -1
@@ -1,7 +1,7 @@ table inet test { set protos { typeof meta l4proto - elements = { tcp, udp } + elements = { 6, 17 } } chain prerouting {
tests/shell/testcases/nft-f/dumps/sample-ruleset.nft +2 -2
@@ -49,7 +49,7 @@ table inet filter { chain PREROUTING_RAW { type filter hook prerouting priority raw; policy accept; - meta l4proto != { icmp, tcp, udp, ipv6-icmp } counter packets 0 bytes 0 drop + meta l4proto != { 1, 6, 17, 58 } counter packets 0 bytes 0 drop tcp flags syn jump { tcp option maxseg size 1-500 counter packets 0 bytes 0 drop tcp sport 0 counter packets 0 bytes 0 drop
@@ -119,7 +119,7 @@ table inet filter { icmp type echo-request accept icmpv6 type echo-request accept tcp dport 22 iifname "eth1" accept - meta l4proto { tcp, udp } th dport 53 jump { + meta l4proto { 6, 17 } th dport 53 jump { ip6 saddr != { fd00::/8, fe80::/64 } counter packets 0 bytes 0 reject with icmpv6 port-unreachable accept }
tests/shell/testcases/optimizations/dumps/merge_reject.json-nft +6 -6
@@ -100,21 +100,21 @@ "set": [ { "concat": [ - "tcp", + 6, "172.30.33.71", 3306 ] }, { "concat": [ - "tcp", + 6, "172.30.238.117", 8080 ] }, { "concat": [ - "tcp", + 6, "172.30.254.251", 3306 ]
@@ -233,21 +233,21 @@ "set": [ { "concat": [ - "tcp", + 6, "aaaa::2", 3306 ] }, { "concat": [ - "tcp", + 6, "aaaa::3", 8080 ] }, { "concat": [ - "tcp", + 6, "aaaa::4", 3306 ]
tests/shell/testcases/optimizations/dumps/merge_reject.nft +2 -2
@@ -1,13 +1,13 @@ table ip x { chain y { ip daddr 172.30.33.70 tcp dport 3306 counter packets 0 bytes 0 drop - meta l4proto . ip daddr . tcp dport { tcp . 172.30.33.71 . 3306, tcp . 172.30.238.117 . 8080, tcp . 172.30.254.251 . 3306 } counter packets 0 bytes 0 reject + meta l4proto . ip daddr . tcp dport { 6 . 172.30.33.71 . 3306, 6 . 172.30.238.117 . 8080, 6 . 172.30.254.251 . 3306 } counter packets 0 bytes 0 reject ip daddr 172.30.254.252 tcp dport 3306 counter packets 0 bytes 0 reject with tcp reset } } table ip6 x { chain y { - meta l4proto . ip6 daddr . tcp dport { tcp . aaaa::2 . 3306, tcp . aaaa::3 . 8080, tcp . aaaa::4 . 3306 } counter packets 0 bytes 0 reject + meta l4proto . ip6 daddr . tcp dport { 6 . aaaa::2 . 3306, 6 . aaaa::3 . 8080, 6 . aaaa::4 . 3306 } counter packets 0 bytes 0 reject ip6 daddr aaaa::5 tcp dport 3306 counter packets 0 bytes 0 reject with tcp reset } }
tests/shell/testcases/optimizations/dumps/merge_stmts_concat.json-nft +2 -2
@@ -164,13 +164,13 @@ "set": [ { "concat": [ - "tcp", + 6, 22 ] }, { "concat": [ - "udp", + 17, 67 ] }
tests/shell/testcases/optimizations/dumps/merge_stmts_concat.nft +1 -1
@@ -1,7 +1,7 @@ table ip x { chain y { iifname . ip saddr . ip daddr { "eth1" . 1.1.1.1 . 2.2.2.3, "eth1" . 1.1.1.2 . 2.2.2.4, "eth1" . 1.1.1.2 . 2.2.3.0/24, "eth1" . 1.1.1.2 . 2.2.4.0-2.2.4.10, "eth2" . 1.1.1.3 . 2.2.2.5 } accept - ip protocol . th dport { tcp . 22, udp . 67 } + ip protocol . th dport { 6 . 22, 17 . 67 } udp dport . ct state { 137 . new, 137 . untracked, 138 . new, 138 . untracked } accept }
tests/shell/testcases/optimizations/dumps/merge_vmap_raw.json-nft +5 -5
@@ -77,7 +77,7 @@ "key": "l4proto" } }, - "right": "udp" + "right": 17 } }, {
@@ -116,7 +116,7 @@ "key": "l4proto" } }, - "right": "udp" + "right": 17 } }, {
@@ -166,7 +166,7 @@ "key": "l4proto" } }, - "right": "udp" + "right": 17 } }, {
@@ -218,7 +218,7 @@ "key": "l4proto" } }, - "right": "udp" + "right": 17 } }, {
@@ -270,7 +270,7 @@ "key": "l4proto" } }, - "right": "udp" + "right": 17 } }, {
tests/shell/testcases/optimizations/dumps/merge_vmap_raw.nft +5 -5
@@ -1,26 +1,26 @@ table inet x { chain nat_dns_dnstc { - meta l4proto udp redirect to :5300 + meta l4proto 17 redirect to :5300 drop } chain nat_dns_this_5301 { - meta l4proto udp redirect to :5301 + meta l4proto 17 redirect to :5301 drop } chain nat_dns_saturn_5301 { - meta nfproto ipv4 meta l4proto udp dnat ip to 240.0.1.2:5301 + meta nfproto ipv4 meta l4proto 17 dnat ip to 240.0.1.2:5301 drop } chain nat_dns_saturn_5302 { - meta nfproto ipv4 meta l4proto udp dnat ip to 240.0.1.2:5302 + meta nfproto ipv4 meta l4proto 17 dnat ip to 240.0.1.2:5302 drop } chain nat_dns_saturn_5303 { - meta nfproto ipv4 meta l4proto udp dnat ip to 240.0.1.2:5303 + meta nfproto ipv4 meta l4proto 17 dnat ip to 240.0.1.2:5303 drop }
tests/shell/testcases/optimizations/dumps/merge_vmaps.json-nft +2 -2
@@ -166,7 +166,7 @@ "data": { "set": [ [ - "tcp", + 6, { "goto": { "target": "filter_in_tcp"
@@ -174,7 +174,7 @@ } ], [ - "udp", + 17, { "goto": { "target": "filter_in_udp"
tests/shell/testcases/optimizations/dumps/merge_vmaps.nft +1 -1
@@ -14,7 +14,7 @@ table ip x { chain y { update @s { ip saddr limit rate 12/minute burst 30 packets } accept tcp dport vmap { 80 : accept, 81 : accept, 443 : accept, 8000-8100 : accept, 24000-25000 : accept } - meta l4proto vmap { tcp : goto filter_in_tcp, udp : goto filter_in_udp } + meta l4proto vmap { 6 : goto filter_in_tcp, 17 : goto filter_in_udp } log } }
tests/shell/testcases/parsing/dumps/exclusive_start_cond.json-nft +26 -26
208 lines not on this page · raw message
tests/shell/testcases/parsing/dumps/exclusive_start_cond.nft +21 -21
65 lines not on this page · raw message
tests/shell/testcases/parsing/dumps/large_rule_pipe.json-nft +12 -12
@@ -2669,8 +2669,8 @@ }, "right": { "set": [ - "icmp", - "ipv6-icmp" + 1, + 58 ] } }
@@ -2838,8 +2838,8 @@ }, "right": { "set": [ - "icmp", - "ipv6-icmp" + 1, + 58 ] } }
@@ -3080,8 +3080,8 @@ }, "right": { "set": [ - "icmp", - "ipv6-icmp" + 1, + 58 ] } }
@@ -3595,8 +3595,8 @@ }, "right": { "set": [ - "icmp", - "ipv6-icmp" + 1, + 58 ] } }
@@ -3804,8 +3804,8 @@ }, "right": { "set": [ - "icmp", - "ipv6-icmp" + 1, + 58 ] } }
@@ -3973,8 +3973,8 @@ }, "right": { "set": [ - "icmp", - "ipv6-icmp" + 1, + 58 ] } }
tests/shell/testcases/parsing/dumps/large_rule_pipe.nft +6 -6
@@ -332,7 +332,7 @@ table inet firewalld { jump filter_IN_public_log jump filter_IN_public_deny jump filter_IN_public_allow - meta l4proto { icmp, ipv6-icmp } accept + meta l4proto { 1, 58 } accept } chain filter_IN_public_log {
@@ -350,7 +350,7 @@ table inet firewalld { jump filter_FWDI_public_log jump filter_FWDI_public_deny jump filter_FWDI_public_allow - meta l4proto { icmp, ipv6-icmp } accept + meta l4proto { 1, 58 } accept } chain filter_FWDI_public_log {
@@ -412,7 +412,7 @@ table inet firewalld { jump filter_IN_home_log jump filter_IN_home_deny jump filter_IN_home_allow - meta l4proto { icmp, ipv6-icmp } accept + meta l4proto { 1, 58 } accept } chain filter_IN_home_log {
@@ -438,7 +438,7 @@ table inet firewalld { jump filter_FWDI_home_log jump filter_FWDI_home_deny jump filter_FWDI_home_allow - meta l4proto { icmp, ipv6-icmp } accept + meta l4proto { 1, 58 } accept } chain filter_FWDI_home_log {
@@ -499,7 +499,7 @@ table inet firewalld { jump filter_IN_work_log jump filter_IN_work_deny jump filter_IN_work_allow - meta l4proto { icmp, ipv6-icmp } accept + meta l4proto { 1, 58 } accept } chain filter_IN_work_log {
@@ -517,7 +517,7 @@ table inet firewalld { jump filter_FWDI_work_log jump filter_FWDI_work_deny jump filter_FWDI_work_allow - meta l4proto { icmp, ipv6-icmp } accept + meta l4proto { 1, 58 } accept } chain filter_FWDI_work_log {
tests/shell/testcases/sets/dumps/0037_set_with_inet_service_0.json-nft +5 -5
@@ -41,35 +41,35 @@ { "concat": [ "192.168.0.12", - "tcp", + 6, 53 ] }, { "concat": [ "192.168.0.12", - "tcp", + 6, 80 ] }, { "concat": [ "192.168.0.12", - "udp", + 17, 53 ] }, { "concat": [ "192.168.0.13", - "tcp", + 6, 80 ] }, { "concat": [ "192.168.0.113", - "tcp", + 6, 22 ] }
tests/shell/testcases/sets/dumps/0037_set_with_inet_service_0.nft +5 -5
@@ -1,11 +1,11 @@ table inet filter { set myset { type ipv4_addr . inet_proto . inet_service - elements = { 192.168.0.12 . tcp . 53, - 192.168.0.12 . tcp . 80, - 192.168.0.12 . udp . 53, - 192.168.0.13 . tcp . 80, - 192.168.0.113 . tcp . 22 } + elements = { 192.168.0.12 . 6 . 53, + 192.168.0.12 . 6 . 80, + 192.168.0.12 . 17 . 53, + 192.168.0.13 . 6 . 80, + 192.168.0.113 . 6 . 22 } } chain forward {
tests/shell/testcases/sets/dumps/0047nat_0.nft +1 -1
@@ -9,7 +9,7 @@ table ip x { chain x { type nat hook prerouting priority dstnat; policy accept; - meta l4proto tcp dnat ip to iifname . ip saddr map { "enp2s0" . 10.1.1.136 : 1.1.2.69 . 22, "enp2s0" . 10.1.1.1-10.1.1.135 : 1.1.2.66-1.84.236.78 . 22 } + meta l4proto 6 dnat ip to iifname . ip saddr map { "enp2s0" . 10.1.1.136 : 1.1.2.69 . 22, "enp2s0" . 10.1.1.1-10.1.1.135 : 1.1.2.66-1.84.236.78 . 22 } dnat ip to iifname . ip saddr map { "enp2s0" . 10.1.1.136 : 1.1.2.69/32, "enp2s0" . 10.1.1.1-10.1.1.135 : 1.1.2.66-1.84.236.78 } }
tests/shell/testcases/sets/dumps/0067nat_concat_interval_0.nft +3 -3
@@ -27,9 +27,9 @@ table ip nat { chain prerouting { type nat hook prerouting priority dstnat; policy accept; - ip protocol tcp dnat ip to ip saddr . ip daddr map @ipportmap2 - meta l4proto { tcp, udp } dnat ip to ip daddr . th dport map @fwdtoip_th + ip protocol 6 dnat ip to ip saddr . ip daddr map @ipportmap2 + meta l4proto { 6, 17 } dnat ip to ip daddr . th dport map @fwdtoip_th dnat ip to iifname . ip saddr map @ipportmap4 - meta l4proto tcp dnat ip to iifname . ip saddr map @ipportmap5 + meta l4proto 6 dnat ip to iifname . ip saddr map @ipportmap5 } }
tests/shell/testcases/sets/dumps/0067nat_interval_0.nft +1 -1
@@ -8,6 +8,6 @@ table ip nat { chain prerouting { type nat hook prerouting priority dstnat; policy accept; - ip protocol tcp dnat ip to ip saddr map @ipportmap + ip protocol 6 dnat ip to ip saddr map @ipportmap } }
tests/shell/testcases/sets/dumps/set_eval_0.json-nft +2 -2
@@ -55,8 +55,8 @@ }, "right": { "set": [ - "tcp", - "udp" + 6, + 17 ] } }
tests/shell/testcases/sets/dumps/set_eval_0.nft +1 -1
@@ -6,6 +6,6 @@ table ip nat { chain prerouting { type nat hook prerouting priority dstnat; policy accept; - meta l4proto { tcp, udp } th dport 443 dnat to 10.0.0.1 + meta l4proto { 6, 17 } th dport 443 dnat to 10.0.0.1 } }
tests/shell/testcases/sets/dumps/sets_with_ifnames.json-nft +2 -2
@@ -509,7 +509,7 @@ "field": "protocol" } }, - "right": "icmp" + "right": 1 } }, {
@@ -536,7 +536,7 @@ "field": "protocol" } }, - "right": "icmp" + "right": 1 } }, {
tests/shell/testcases/sets/dumps/sets_with_ifnames.nft +2 -2
@@ -53,8 +53,8 @@ table inet testifsets { chain input { type filter hook input priority filter; policy accept; - ip protocol icmp jump v4icmp - ip protocol icmp goto v4icmpc + ip protocol 1 jump v4icmp + ip protocol 1 goto v4icmpc } chain do_nothing {
tests/shell/testcases/transactions/dumps/0049huge_0.json-nft +8 -8
@@ -1908,8 +1908,8 @@ }, "right": { "set": [ - "icmp", - "ipv6-icmp" + 1, + 58 ] } }
@@ -2111,8 +2111,8 @@ }, "right": { "set": [ - "icmp", - "ipv6-icmp" + 1, + 58 ] } }
@@ -2854,8 +2854,8 @@ }, "right": { "set": [ - "icmp", - "ipv6-icmp" + 1, + 58 ] } }
@@ -3132,8 +3132,8 @@ }, "right": { "set": [ - "icmp", - "ipv6-icmp" + 1, + 58 ] } }
tests/shell/testcases/transactions/dumps/0049huge_0.nft +4 -4
@@ -98,7 +98,7 @@ table inet firewalld { jump filter_IN_public_deny jump filter_IN_public_allow jump filter_IN_public_post - meta l4proto { icmp, ipv6-icmp } accept + meta l4proto { 1, 58 } accept } chain filter_IN_public_pre {
@@ -124,7 +124,7 @@ table inet firewalld { jump filter_FWDI_public_deny jump filter_FWDI_public_allow jump filter_FWDI_public_post - meta l4proto { icmp, ipv6-icmp } accept + meta l4proto { 1, 58 } accept } chain filter_FWDI_public_pre {
@@ -335,7 +335,7 @@ table inet firewalld { jump filter_IN_work_deny jump filter_IN_work_allow jump filter_IN_work_post - meta l4proto { icmp, ipv6-icmp } accept + meta l4proto { 1, 58 } accept } chain filter_IN_work_pre {
@@ -384,7 +384,7 @@ table inet firewalld { jump filter_FWDI_work_deny jump filter_FWDI_work_allow jump filter_FWDI_work_post - meta l4proto { icmp, ipv6-icmp } accept + meta l4proto { 1, 58 } accept } chain filter_FWDI_work_pre {
Signature · 1 line
2.54.0
Pablo Neira Ayuso
maintainerHi Phil,
Quoted 2 lines · Phil Sutter
Adjust the test wrapper to create dumps with --numeric-protocol option (patch 1) and update all dumps (patch 2).
Is this to make it consistent through different distros due to different definitions in /etc/services?
Thanks!
Quoted 59 lines
One could also set --stateless, py test suite does that, too. Though there are tests (in packetpath dir) which seem to rely upon counter or other stateful data to be matched in dump files, so keep state for now.
Phil Sutter (2):
tests: shell: Use --numeric-protocol for dumps
tests: shell: Convert dumps to numeric protocolstests/shell/helpers/test-wrapper.sh | 9 ++-- .../cache/dumps/0003_cache_update_0.json-nft | 4 +- .../cache/dumps/0003_cache_update_0.nft | 4 +- .../chains/dumps/0041chain_binding_0.nft | 4 +- .../maps/dumps/0010concat_map_0.json-nft | 2 +- .../testcases/maps/dumps/0010concat_map_0.nft | 2 +- .../testcases/maps/dumps/0013map_0.json-nft | 2 +- .../shell/testcases/maps/dumps/0013map_0.nft | 2 +- .../maps/dumps/anon_objmap_concat.json-nft | 4 +- .../maps/dumps/anon_objmap_concat.nft | 2 +- .../maps/dumps/named_limits.json-nft | 14 ++--- .../testcases/maps/dumps/named_limits.nft | 14 ++--- .../maps/dumps/nat_addr_port.json-nft | 16 +++--- .../testcases/maps/dumps/nat_addr_port.nft | 16 +++--- .../maps/dumps/typeof_maps_0.json-nft | 6 +-- .../testcases/maps/dumps/typeof_maps_0.nft | 4 +- .../dumps/typeof_maps_add_delete.json-nft | 2 +- .../maps/dumps/typeof_maps_add_delete.nft | 2 +- .../dumps/0012different_defines_0.json-nft | 4 +- .../nft-f/dumps/0012different_defines_0.nft | 2 +- .../dumps/named_set_as_protocol_dep.json-nft | 4 +- .../nft-f/dumps/named_set_as_protocol_dep.nft | 2 +- .../testcases/nft-f/dumps/sample-ruleset.nft | 4 +- .../optimizations/dumps/merge_reject.json-nft | 12 ++--- .../optimizations/dumps/merge_reject.nft | 4 +- .../dumps/merge_stmts_concat.json-nft | 4 +- .../dumps/merge_stmts_concat.nft | 2 +- .../dumps/merge_vmap_raw.json-nft | 10 ++-- .../optimizations/dumps/merge_vmap_raw.nft | 10 ++-- .../optimizations/dumps/merge_vmaps.json-nft | 4 +- .../optimizations/dumps/merge_vmaps.nft | 2 +- .../dumps/exclusive_start_cond.json-nft | 52 +++++++++---------- .../parsing/dumps/exclusive_start_cond.nft | 42 +++++++-------- .../parsing/dumps/large_rule_pipe.json-nft | 24 ++++----- .../parsing/dumps/large_rule_pipe.nft | 12 ++--- .../0037_set_with_inet_service_0.json-nft | 10 ++-- .../dumps/0037_set_with_inet_service_0.nft | 10 ++-- .../shell/testcases/sets/dumps/0047nat_0.nft | 2 +- .../sets/dumps/0067nat_concat_interval_0.nft | 6 +-- .../sets/dumps/0067nat_interval_0.nft | 2 +- .../testcases/sets/dumps/set_eval_0.json-nft | 4 +- .../shell/testcases/sets/dumps/set_eval_0.nft | 2 +- .../sets/dumps/sets_with_ifnames.json-nft | 4 +- .../sets/dumps/sets_with_ifnames.nft | 4 +- .../transactions/dumps/0049huge_0.json-nft | 16 +++--- .../transactions/dumps/0049huge_0.nft | 8 +-- 46 files changed, 186 insertions(+), 185 deletions(-)Signature · 1 line
2.54.0
Phil Sutter
reviewerHi Pablo,
Quoted 6 lines · Pablo Neira Ayuso
Quoted 2 lines · Phil Sutter
Adjust the test wrapper to create dumps with --numeric-protocol option (patch 1) and update all dumps (patch 2).
Is this to make it consistent through different distros due to different definitions in
/etc/services?
Yes, but it's about /etc/protocols. See Avinash's attempt at eliminating an actual problem there (and my response to it):
https://lore.kernel.org/netfilter-devel/[email protected]/
Thanks, Phil
Pablo Neira Ayuso
maintainerQuoted 7 lines · Phil Sutter
Hi Pablo,
Quoted 4 lines · Pablo Neira Ayuso
Quoted 2 lines · Phil Sutter
Adjust the test wrapper to create dumps with --numeric-protocol option (patch 1) and update all dumps (patch 2).
Quoted 7 lines
Quoted 2 lines
Is this to make it consistent through different distros due to different definitions in
/etc/services?Yes, but it's about
/etc/protocols. See Avinash's attempt at eliminating an actual problem there (and my response to it):
Makes sense, thanks for explaining.
Florian Westphal
maintainerQuoted 6 lines · Phil Sutter
Adjust the test wrapper to create dumps with --numeric-protocol option (patch 1) and update all dumps (patch 2).
One could also set --stateless, py test suite does that, too. Though there are tests (in packetpath dir) which seem to rely upon counter or other stateful data to be matched in dump files, so keep state for now.
Yes, there are tests that rely on dump validation to catch non-matching/matching rules; those would have to be switched over to test for the counter values manually.
Patch LGTM, thanks for working on this.
Phil Sutter
reviewerQuoted 11 lines · Florian Westphal
Quoted 6 lines · Phil Sutter
Adjust the test wrapper to create dumps with --numeric-protocol option (patch 1) and update all dumps (patch 2).
One could also set --stateless, py test suite does that, too. Though there are tests (in packetpath dir) which seem to rely upon counter or other stateful data to be matched in dump files, so keep state for now.
Yes, there are tests that rely on dump validation to catch non-matching/matching rules; those would have to be switched over to test for the counter values manually.
I was looking into that at first but decided to drop the --stateless flag for now instead. I'd rather implement a way for test cases to specify they want the stateful output, similar to the feature requirement.
Or we just leave things as-is, the stateful output is harmless anyway.
Quoted 1 line
Patch LGTM, thanks for working on this.
Thanks for the review, I'll push it out.
Cheers, Phil