tests: shell: skip pipapo tests if kernel lacks support
Pablo Neira Ayuso
maintainerPATCH v2 1/11 tests: shell: skip pipapo tests if kernel lacks support
Skip tests that require net/netfilter/nft_set_pipapo support.
---
v2: use git describe --contains, requested by Florian.
tests/shell/features/pipapo.nft | 9 +++++++++ tests/shell/testcases/maps/0013map_0 | 2 ++ tests/shell/testcases/maps/anon_objmap_concat | 2 ++ tests/shell/testcases/maps/typeof_integer_0 | 2 ++ .../shell/testcases/optimizations/merge_stmts_concat | 2 ++ tests/shell/testcases/optimizations/merge_vmap_raw | 2 ++ tests/shell/testcases/sets/0034get_element_0 | 2 ++ tests/shell/testcases/sets/0043concatenated_ranges_0 | 1 + tests/shell/testcases/sets/0043concatenated_ranges_1 | 2 ++ tests/shell/testcases/sets/0044interval_overlap_0 | 12 ++++++++++-- tests/shell/testcases/sets/0047nat_0 | 2 ++ tests/shell/testcases/sets/concat_interval_0 | 2 ++ 12 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 tests/shell/features/pipapo.nft
tests/shell/features/pipapo.nft new file +9 -0
@@ -0,0 +1,9 @@ +# 3c4287f62044 ("nf_tables: Add set type for arbitrary concatenation of ranges") +# v5.6-rc1~151^2~28^2~1 +table t { + set s { + type ipv4_addr . inet_service + flags interval + elements = { 1.1.1.1-2.2.2.2 . 80-90 } + } +}
tests/shell/testcases/maps/0013map_0 +2 -0
@@ -1,5 +1,7 @@ #!/bin/bash +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_pipapo) + set -e RULESET="
tests/shell/testcases/maps/anon_objmap_concat +2 -0
@@ -1,5 +1,7 @@ #!/bin/bash +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_pipapo) + set -e dumpfile=$(dirname $0)/dumps/$(basename $0).nft
tests/shell/testcases/maps/typeof_integer_0 +2 -0
@@ -1,5 +1,7 @@ #!/bin/bash +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_pipapo) + EXPECTED="table inet t { map m1 { typeof udp length . @ih,32,32 : verdict
tests/shell/testcases/optimizations/merge_stmts_concat +2 -0
@@ -1,5 +1,7 @@ #!/bin/bash +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_pipapo) + set -e RULESET="table ip x {
tests/shell/testcases/optimizations/merge_vmap_raw +2 -0
@@ -1,5 +1,7 @@ #!/bin/bash +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_pipapo) + set -e RULESET="table inet x {
tests/shell/testcases/sets/0034get_element_0 +2 -0
@@ -1,5 +1,7 @@ #!/bin/bash +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_pipapo) + RC=0 check() { # (set, elems, expected)
tests/shell/testcases/sets/0043concatenated_ranges_0 +1 -0
@@ -1,5 +1,6 @@ #!/bin/bash -e # +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_pipapo) # NFT_TEST_SKIP(NFT_TEST_SKIP_slow) # # 0043concatenated_ranges_0 - Add, get, list, timeout for concatenated ranges
tests/shell/testcases/sets/0043concatenated_ranges_1 +2 -0
@@ -2,6 +2,8 @@ # # 0043concatenated_ranges_1 - Insert and list subnets of different sizes +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_pipapo) + check() { $NFT add element "${1}" t s "{ ${2} . ${3} }" [ "$( $NFT list set "${1}" t s | grep -c "${2} . ${3}" )" = 1 ]
tests/shell/testcases/sets/0044interval_overlap_0 +10 -2
@@ -117,7 +117,11 @@ add_elements() { IFS=' ' for t in ${intervals_simple} switch ${intervals_concat}; do +if [ "$NFT_TEST_HAVE_pipapo" = y ] ; then [ "${t}" = "switch" ] && set="c" && continue +else + break +fi [ -z "${pass}" ] && pass="${t}" && continue [ -z "${interval}" ] && interval="${t}" && continue unset IFS
@@ -148,7 +152,9 @@ add_elements() { $NFT add table t $NFT add set t s '{ type inet_service ; flags interval ; }' -$NFT add set t c '{ type inet_service . inet_service ; flags interval ; }' +if [ "$NFT_TEST_HAVE_pipapo" = y ] ; then + $NFT add set t c '{ type inet_service . inet_service ; flags interval ; }' +fi add_elements $NFT flush ruleset
@@ -157,7 +163,9 @@ estimate_timeout $NFT flush ruleset $NFT add table t $NFT add set t s "{ type inet_service ; flags interval,timeout; timeout ${timeout}s; gc-interval ${timeout}s; }" -$NFT add set t c "{ type inet_service . inet_service ; flags interval,timeout ; timeout ${timeout}s; gc-interval ${timeout}s; }" +if [ "$NFT_TEST_HAVE_pipapo" = y ] ; then + $NFT add set t c "{ type inet_service . inet_service ; flags interval,timeout ; timeout ${timeout}s; gc-interval ${timeout}s; }" +fi add_elements sleep $((timeout * 3 / 2))
tests/shell/testcases/sets/0047nat_0 +2 -0
@@ -1,5 +1,7 @@ #!/bin/bash +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_pipapo) + EXPECTED="table ip x { map y { type ipv4_addr : interval ipv4_addr
tests/shell/testcases/sets/concat_interval_0 +2 -0
@@ -1,5 +1,7 @@ #!/bin/bash +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_pipapo) + set -e RULESET="table ip t {
Signature · 1 line
2.30.2
Pablo Neira Ayuso
maintainerPATCH v2 2/11 tests: shell: skip prerouting reject tests if kernel lacks support
Skip tests that require reject at prerouting hook.
---
v2: use git describe --contains, requested by Florian.
tests/shell/features/prerouting_reject.nft | 8 ++++++++ tests/shell/testcases/optimizations/ruleset | 2 ++ 2 files changed, 10 insertions(+) create mode 100644 tests/shell/features/prerouting_reject.nft
tests/shell/features/prerouting_reject.nft new file +8 -0
@@ -0,0 +1,8 @@ +# f53b9b0bdc59 netfilter: introduce support for reject at prerouting stage +# v5.9-rc1~133^2~302^2~11 +table inet t { + chain nat_filter { + type filter hook prerouting priority 0; policy accept; + reject with icmpx type host-unreachable + } +}
tests/shell/testcases/optimizations/ruleset +2 -0
@@ -1,5 +1,7 @@ #!/bin/bash +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_prerouting_reject) + RULESET="table inet uni { chain gtfo { reject with icmpx type host-unreachable
Signature · 1 line
2.30.2
Pablo Neira Ayuso
maintainerPATCH v2 3/11 tests: shell: skip stateful expression in sets tests if kernel lacks support
In reply to Pablo Neira AyusoSkip tests that require stateful expressions in sets.
---
v2: use git describe --contains and use diff instead of $DIFF, requested by Florian
tests/shell/features/set_expr.sh | 19 +++++++++++++++++++ tests/shell/testcases/json/0002table_map_0 | 1 + tests/shell/testcases/maps/0009vmap_0 | 2 ++ .../testcases/optimizations/merge_stmts_vmap | 2 ++ tests/shell/testcases/sets/0048set_counters_0 | 2 ++ .../testcases/sets/0051set_interval_counter_0 | 2 ++ tests/shell/testcases/sets/elem_opts_compat_0 | 2 ++ 7 files changed, 30 insertions(+) create mode 100755 tests/shell/features/set_expr.sh
tests/shell/features/set_expr.sh new file +19 -0
@@ -0,0 +1,19 @@ +#!/bin/bash + +# 65038428b2c6 ("netfilter: nf_tables: allow to specify stateful expression in set definition") +# v5.7-rc1~146^2~12^2~25 + +# NFT_SET_EXPR to detect kernel feature only available since +# b4e70d8dd9ea ("netfilter: nftables: add set expression flags") +# v5.11-rc3~39^2^2 + +EXPECTED="table ip x { + set y { + typeof ip saddr + counter + } +}" + +$NFT -f - <<< $EXPECTED + +diff -u <($NFT list ruleset) - <<<"$EXPECTED"
tests/shell/testcases/json/0002table_map_0 +1 -0
@@ -1,6 +1,7 @@ #!/bin/bash # NFT_TEST_REQUIRES(NFT_TEST_HAVE_json) +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_set_expr) set -e
tests/shell/testcases/maps/0009vmap_0 +2 -0
@@ -1,5 +1,7 @@ #!/bin/bash +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_set_expr) + set -e EXPECTED="table inet filter {
tests/shell/testcases/optimizations/merge_stmts_vmap +2 -0
@@ -1,5 +1,7 @@ #!/bin/bash +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_set_expr) + set -e RULESET="table ip x {
tests/shell/testcases/sets/0048set_counters_0 +2 -0
@@ -1,5 +1,7 @@ #!/bin/bash +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_set_expr) + set -e EXPECTED="table ip x {
tests/shell/testcases/sets/0051set_interval_counter_0 +2 -0
@@ -1,5 +1,7 @@ #!/bin/bash +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_set_expr) + set -e EXPECTED="table ip x {
tests/shell/testcases/sets/elem_opts_compat_0 +2 -0
@@ -1,5 +1,7 @@ #!/bin/bash +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_set_expr) + # ordering of element options and expressions has changed, make sure parser # accepts both ways
Signature · 1 line
2.30.2
Pablo Neira Ayuso
maintainerPATCH v2 4/11 tests: shell: skip NAT netmap tests if kernel lacks support
In reply to Pablo Neira AyusoSkip tests that require NAT netmap support
---
v2: use git describe --contains, requested by Florian.
tests/shell/features/netmap.nft | 8 ++++++++ tests/shell/testcases/sets/0046netmap_0 | 2 ++ 2 files changed, 10 insertions(+) create mode 100644 tests/shell/features/netmap.nft
tests/shell/features/netmap.nft new file +8 -0
@@ -0,0 +1,8 @@ +# 3ff7ddb1353d ("netfilter: nft_nat: add netmap support") +# v5.8-rc1~165^2~393^2 +table ip x { + chain y { + type nat hook postrouting priority srcnat; policy accept; + snat ip prefix to ip saddr map { 10.141.11.0/24 : 192.168.2.0/24 } + } +}
tests/shell/testcases/sets/0046netmap_0 +2 -0
@@ -1,5 +1,7 @@ #!/bin/bash +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_netmap) + EXPECTED="table ip x { chain y { type nat hook postrouting priority srcnat; policy accept;
Signature · 1 line
2.30.2
Pablo Neira Ayuso
maintainerPATCH v2 5/11 tests: shell: skip comment tests if kernel lacks support
In reply to Pablo Neira AyusoSkip tests that require comment support
---
v2: use git describe --contains, requested by Florian.
tests/shell/features/comment.sh | 14 ++++++++++++++ tests/shell/testcases/json/0006obj_comment_0 | 1 + tests/shell/testcases/optionals/comments_chain_0 | 2 ++ tests/shell/testcases/optionals/comments_objects_0 | 2 ++ tests/shell/testcases/optionals/comments_table_0 | 2 ++ tests/shell/testcases/sets/0020comments_0 | 2 ++ 6 files changed, 23 insertions(+) create mode 100755 tests/shell/features/comment.sh
tests/shell/features/comment.sh new file +14 -0
@@ -0,0 +1,14 @@ +#!/bin/bash + +# 002f21765320 ("netfilter: nf_tables: add userdata attributes to nft_chain") +# v5.10-rc1~107^2~60^2~5 + +EXPECTED="table ip x { + chain y { + comment \"test\" + } +}" + +$NFT -f - <<< $EXPECTED + +diff -u <($NFT list ruleset) - <<<"$EXPECTED"
tests/shell/testcases/json/0006obj_comment_0 +1 -0
@@ -1,6 +1,7 @@ #!/bin/bash # NFT_TEST_REQUIRES(NFT_TEST_HAVE_json) +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_comment) set -e
tests/shell/testcases/optionals/comments_chain_0 +2 -0
@@ -1,5 +1,7 @@ #!/bin/bash +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_comment) + EXPECTED='table ip test_table { chain test_chain { comment "test"
tests/shell/testcases/optionals/comments_objects_0 +2 -0
@@ -1,5 +1,7 @@ #!/bin/bash +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_comment) + set -e COMMENT128="12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678"
tests/shell/testcases/optionals/comments_table_0 +2 -0
@@ -1,5 +1,7 @@ #!/bin/bash +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_comment) + # comments are shown $NFT add table test { comment \"test_comment\"\; }
tests/shell/testcases/sets/0020comments_0 +2 -0
@@ -1,5 +1,7 @@ #!/bin/bash +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_comment) + # Test that comments are added to set elements in standard sets. # Explicitly test bitmap backend set implementation.
Signature · 1 line
2.30.2
Pablo Neira Ayuso
maintainerPATCH v2 6/11 tests: shell: skip multidevice chain tests if kernel lacks support
In reply to Pablo Neira Ayuso---
v2: use git describe --contains, requested by Florian.
.../shell/features/netdev_chain_multidevice.sh | 17 +++++++++++++++++ .../shell/testcases/chains/0042chain_variable_0 | 2 ++ 2 files changed, 19 insertions(+) create mode 100755 tests/shell/features/netdev_chain_multidevice.sh
tests/shell/features/netdev_chain_multidevice.sh new file +17 -0
@@ -0,0 +1,17 @@ +#!/bin/bash + +# d54725cd11a5 ("netfilter: nf_tables: support for multiple devices per netdev hook") +# v5.5-rc1~174^2~312^2~4 + +trap "ip link del d0; ip link del d1" EXIT + +ip link add d0 type dummy +ip link add d1 type dummy + +EXPECTED="table netdev filter2 { + chain Main_Ingress2 { + type filter hook ingress devices = { \"d0\", \"d1\" } priority -500; policy accept; + } +}" + +$NFT -f - <<< $EXPECTED
tests/shell/testcases/chains/0042chain_variable_0 +2 -0
@@ -1,5 +1,7 @@ #!/bin/bash +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_netdev_chain_multidevice) + set -e ip link add name d23456789012345 type dummy
Signature · 1 line
2.30.2
Pablo Neira Ayuso
maintainerPATCH v2 7/11 tests: shell: skip if kernel does not support bitshift
In reply to Pablo Neira AyusoA few tests are missing bitshift checks that has been added to 885845468408 ("tests/shell: skip bitshift tests if kernel lacks support").
---
v2: no changes
.../shell/testcases/maps/vmap_mark_bitwise_0 | 2 + tests/shell/testcases/sets/typeof_sets_0 | 86 +++++++++---------- 2 files changed, 45 insertions(+), 43 deletions(-)
tests/shell/testcases/maps/vmap_mark_bitwise_0 +2 -0
@@ -1,5 +1,7 @@ #!/bin/bash +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_bitshift) + set -e RULESET="table ip x {
tests/shell/testcases/sets/typeof_sets_0 +43 -43
162 lines not on this page · raw message
Signature · 1 line
2.30.2
Pablo Neira Ayuso
maintainerPATCH v2 8/11 tests: shell: split set NAT interval test
In reply to Pablo Neira AyusoSplit test in two, one for interval sets and another with concatenation
+ intervals, so at least intervals are tested in older kernels with no pipapo support.
---
v2: no changes
.../testcases/sets/0067nat_concat_interval_0 | 17 ++--------------- tests/shell/testcases/sets/0067nat_interval_0 | 18 ++++++++++++++++++ .../sets/dumps/0067nat_concat_interval_0.nft | 7 ------- .../sets/dumps/0067nat_interval_0.nft | 12 ++++++++++++ 4 files changed, 32 insertions(+), 22 deletions(-) create mode 100755 tests/shell/testcases/sets/0067nat_interval_0 create mode 100644 tests/shell/testcases/sets/dumps/0067nat_interval_0.nft
tests/shell/testcases/sets/0067nat_concat_interval_0 +2 -15
@@ -1,21 +1,8 @@ #!/bin/bash -set -e - -EXPECTED="table ip nat { - map ipportmap { - type ipv4_addr : interval ipv4_addr . inet_service - flags interval - elements = { 192.168.1.2 : 10.141.10.1-10.141.10.3 . 8888-8999 } - } - chain prerouting { - type nat hook prerouting priority dstnat; policy accept; - ip protocol tcp dnat ip to ip saddr map @ipportmap - } -}" +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_pipapo) -$NFT -f - <<< $EXPECTED -$NFT add element ip nat ipportmap { 192.168.2.0/24 : 10.141.11.5-10.141.11.20 . 8888-8999 } +set -e EXPECTED="table ip nat { map ipportmap2 {
tests/shell/testcases/sets/0067nat_interval_0 new file +18 -0
@@ -0,0 +1,18 @@ +#!/bin/bash + +set -e + +EXPECTED="table ip nat { + map ipportmap { + type ipv4_addr : interval ipv4_addr . inet_service + flags interval + elements = { 192.168.1.2 : 10.141.10.1-10.141.10.3 . 8888-8999 } + } + chain prerouting { + type nat hook prerouting priority dstnat; policy accept; + ip protocol tcp dnat ip to ip saddr map @ipportmap + } +}" + +$NFT -f - <<< $EXPECTED +$NFT add element ip nat ipportmap { 192.168.2.0/24 : 10.141.11.5-10.141.11.20 . 8888-8999 }
tests/shell/testcases/sets/dumps/0067nat_concat_interval_0.nft +0 -7
@@ -1,10 +1,4 @@ table ip nat { - map ipportmap { - type ipv4_addr : interval ipv4_addr . inet_service - flags interval - elements = { 192.168.1.2 : 10.141.10.1-10.141.10.3 . 8888-8999, 192.168.2.0/24 : 10.141.11.5-10.141.11.20 . 8888-8999 } - } - map ipportmap2 { type ipv4_addr . ipv4_addr : interval ipv4_addr . inet_service flags interval
@@ -33,7 +27,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 tcp dnat ip to ip saddr . ip daddr map @ipportmap2 meta l4proto { tcp, udp } dnat ip to ip daddr . th dport map @fwdtoip_th dnat ip to iifname . ip saddr map @ipportmap4
tests/shell/testcases/sets/dumps/0067nat_interval_0.nft new file +12 -0
@@ -0,0 +1,12 @@ +table ip nat { + map ipportmap { + type ipv4_addr : interval ipv4_addr . inet_service + flags interval + elements = { 192.168.1.2 : 10.141.10.1-10.141.10.3 . 8888-8999, 192.168.2.0/24 : 10.141.11.5-10.141.11.20 . 8888-8999 } + } + + chain prerouting { + type nat hook prerouting priority dstnat; policy accept; + ip protocol tcp dnat ip to ip saddr map @ipportmap + } +}
Signature · 1 line
2.30.2
Pablo Neira Ayuso
maintainerPATCH v2 9/11 tests: shell: split map test
In reply to Pablo Neira AyusoSplit interval + concatenation into a separated file, so older kernels with no pipapo can still run what it is supported.
---
v2: no changes
tests/shell/testcases/maps/0012map_0 | 19 --------------- tests/shell/testcases/maps/0012map_concat_0 | 24 +++++++++++++++++++ .../shell/testcases/maps/dumps/0012map_0.nft | 13 ---------- .../testcases/maps/dumps/0012map_concat_0.nft | 14 +++++++++++ 4 files changed, 38 insertions(+), 32 deletions(-) create mode 100755 tests/shell/testcases/maps/0012map_concat_0 create mode 100644 tests/shell/testcases/maps/dumps/0012map_concat_0.nft
tests/shell/testcases/maps/0012map_0 +0 -19
@@ -15,22 +15,3 @@ table ip x { }" $NFT -f - <<< "$EXPECTED" - -EXPECTED="table ip x { - map w { - typeof ip saddr . meta mark : verdict - flags interval - counter - elements = { - 127.0.0.1-127.0.0.4 . 0x123434-0xb00122 : accept, - } - } - - chain k { - type filter hook input priority filter + 1; policy accept; - meta mark set 0x123434 - ip saddr . meta mark vmap @w - } -}" - -$NFT -f - <<< "$EXPECTED"
tests/shell/testcases/maps/0012map_concat_0 new file +24 -0
@@ -0,0 +1,24 @@ +#!/bin/bash + +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_pipapo) + +set -e + +EXPECTED="table ip x { + map w { + typeof ip saddr . meta mark : verdict + flags interval + counter + elements = { + 127.0.0.1-127.0.0.4 . 0x123434-0xb00122 : accept, + } + } + + chain k { + type filter hook input priority filter + 1; policy accept; + meta mark set 0x123434 + ip saddr . meta mark vmap @w + } +}" + +$NFT -f - <<< "$EXPECTED"
tests/shell/testcases/maps/dumps/0012map_0.nft +0 -13
@@ -6,20 +6,7 @@ table ip x { "eth1" : drop } } - map w { - typeof ip saddr . meta mark : verdict - flags interval - counter - elements = { 127.0.0.1-127.0.0.4 . 0x00123434-0x00b00122 counter packets 0 bytes 0 : accept } - } - chain y { iifname vmap { "lo" : accept, "eth0" : drop, "eth1" : drop } } - - chain k { - type filter hook input priority filter + 1; policy accept; - meta mark set 0x00123434 - ip saddr . meta mark vmap @w - } }
tests/shell/testcases/maps/dumps/0012map_concat_0.nft new file +14 -0
@@ -0,0 +1,14 @@ +table ip x { + map w { + typeof ip saddr . meta mark : verdict + flags interval + counter + elements = { 127.0.0.1-127.0.0.4 . 0x00123434-0x00b00122 counter packets 0 bytes 0 : accept } + } + + chain k { + type filter hook input priority filter + 1; policy accept; + meta mark set 0x00123434 + ip saddr . meta mark vmap @w + } +}
Signature · 1 line
2.30.2
Pablo Neira Ayuso
maintainerPATCH v2 10/11 tests: shell: split single element in anonymous set
In reply to Pablo Neira AyusoSplit this to move set stateful expression support into a separated test not to harm existing coverage.
---
v2: no changes
.../optimizations/dumps/single_anon_set.nft | 1 - .../dumps/single_anon_set_expr.nft | 5 ++++ .../testcases/optimizations/single_anon_set | 3 --- .../optimizations/single_anon_set_expr | 26 +++++++++++++++++++ 4 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 tests/shell/testcases/optimizations/dumps/single_anon_set_expr.nft create mode 100755 tests/shell/testcases/optimizations/single_anon_set_expr
tests/shell/testcases/optimizations/dumps/single_anon_set.nft +0 -1
@@ -11,6 +11,5 @@ table ip test { ip daddr . tcp dport { 192.168.0.1 . 22 } accept meta mark set ip daddr map { 192.168.0.1 : 0x00000001 } ct state { established, related } accept - meta mark { 0x0000000a counter packets 0 bytes 0 } } }
tests/shell/testcases/optimizations/dumps/single_anon_set_expr.nft new file +5 -0
@@ -0,0 +1,5 @@ +table ip test { + chain test { + meta mark { 0x0000000a counter packets 0 bytes 0 } + } +}
tests/shell/testcases/optimizations/single_anon_set +0 -3
@@ -46,9 +46,6 @@ table ip test { # ct state cannot be both established and related # at the same time, but this needs extra work. ct state { established, related } accept - - # with stateful statement - meta mark { 0x0000000a counter } } } EOF
tests/shell/testcases/optimizations/single_anon_set_expr new file +26 -0
@@ -0,0 +1,26 @@ +#!/bin/bash + +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_set_expr) + +set -e + +test -d "$NFT_TEST_TESTTMPDIR" + +# Input file contains rules with anon sets that contain +# one element, plus extra rule with two elements (that should be +# left alone). + +# Dump file has the simplified rules where anon sets have been +# replaced by equality tests where possible. +file_input1="$NFT_TEST_TESTTMPDIR/input1.nft" + +cat <<EOF > "$file_input1" +table ip test { + chain test { + # with stateful statement + meta mark { 0x0000000a counter } + } +} +EOF + +$NFT -f "$file_input1"
Signature · 1 line
2.30.2
Pablo Neira Ayuso
maintainerPATCH v2 11/11 tests: shell: split merge nat optimization in two tests
In reply to Pablo Neira AyusoOne without pipapo support and another with not to harm existing coverage.
---
v2: no changes
.../optimizations/dumps/merge_nat.nft | 8 -------- .../optimizations/dumps/merge_nat_concat.nft | 8 ++++++++ tests/shell/testcases/optimizations/merge_nat | 13 ------------- .../testcases/optimizations/merge_nat_concat | 18 ++++++++++++++++++ 4 files changed, 26 insertions(+), 21 deletions(-) create mode 100644 tests/shell/testcases/optimizations/dumps/merge_nat_concat.nft create mode 100755 tests/shell/testcases/optimizations/merge_nat_concat
tests/shell/testcases/optimizations/dumps/merge_nat.nft +0 -8
@@ -11,14 +11,6 @@ table ip test2 { ip saddr { 10.141.11.0/24, 10.141.13.0/24 } masquerade } } -table ip test3 { - chain y { - oif "lo" accept - snat to ip saddr . tcp sport map { 1.1.1.1 . 1024-65535 : 3.3.3.3, 2.2.2.2 . 1024-65535 : 4.4.4.4 } - oifname "enp2s0" snat ip to ip saddr map { 10.1.1.0/24 : 72.2.3.66-72.2.3.78 } - tcp dport { 8888, 9999 } redirect - } -} table ip test4 { chain y { oif "lo" accept
tests/shell/testcases/optimizations/dumps/merge_nat_concat.nft new file +8 -0
@@ -0,0 +1,8 @@ +table ip test3 { + chain y { + oif "lo" accept + snat to ip saddr . tcp sport map { 1.1.1.1 . 1024-65535 : 3.3.3.3, 2.2.2.2 . 1024-65535 : 4.4.4.4 } + oifname "enp2s0" snat ip to ip saddr map { 10.1.1.0/24 : 72.2.3.66-72.2.3.78 } + tcp dport { 8888, 9999 } redirect + } +}
tests/shell/testcases/optimizations/merge_nat +0 -13
@@ -24,19 +24,6 @@ RULESET="table ip test2 { $NFT -o -f - <<< $RULESET -RULESET="table ip test3 { - chain y { - oif lo accept - ip saddr 1.1.1.1 tcp sport 1024-65535 snat to 3.3.3.3 - ip saddr 2.2.2.2 tcp sport 1024-65535 snat to 4.4.4.4 - oifname enp2s0 snat ip to ip saddr map { 10.1.1.0/24 : 72.2.3.66-72.2.3.78 } - tcp dport 8888 redirect - tcp dport 9999 redirect - } -}" - -$NFT -o -f - <<< $RULESET - RULESET="table ip test4 { chain y { oif lo accept
tests/shell/testcases/optimizations/merge_nat_concat new file +18 -0
@@ -0,0 +1,18 @@ +#!/bin/bash + +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_pipapo) + +set -e + +RULESET="table ip test3 { + chain y { + oif lo accept + ip saddr 1.1.1.1 tcp sport 1024-65535 snat to 3.3.3.3 + ip saddr 2.2.2.2 tcp sport 1024-65535 snat to 4.4.4.4 + oifname enp2s0 snat ip to ip saddr map { 10.1.1.0/24 : 72.2.3.66-72.2.3.78 } + tcp dport 8888 redirect + tcp dport 9999 redirect + } +}" + +$NFT -o -f - <<< $RULESET
Signature · 1 line
2.30.2