tests: shell: connlimit tests requires set expression support
Pablo Neira Ayuso
maintainerPATCH 1/8 tests: shell: connlimit tests requires set expression support
Signed-off-by Pablo Neira Ayuso <[email protected]>
--- tests/shell/testcases/sets/0062set_connlimit_0 | 2 ++ 1 file changed, 2 insertions(+)
tests/shell/testcases/sets/0062set_connlimit_0 +2 -0
@@ -1,5 +1,7 @@ #!/bin/bash +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_set_expr) + set -e RULESET="table ip x {
Signature · 1 line
2.30.2
Pablo Neira Ayuso
maintainerPATCH 2/8 tests: shell: skip stateful object updates if unsupported
Signed-off-by Pablo Neira Ayuso <[email protected]>
--- .../shell/features/stateful_object_update.sh | 21 +++++++++++++++++++ .../optionals/update_object_handles_0 | 2 ++ 2 files changed, 23 insertions(+) create mode 100755 tests/shell/features/stateful_object_update.sh
tests/shell/features/stateful_object_update.sh new file +21 -0
@@ -0,0 +1,21 @@ +#!/bin/bash + +# d62d0ba97b58 ("netfilter: nf_tables: Introduce stateful object update operation") +# v5.4-rc1~131^2~59^2~2 + +set -e +$NFT add table test-ip +$NFT add quota test-ip traffic-quota 25 mbytes +$NFT add quota test-ip traffic-quota 50 mbytes + +EXPECTED="table ip test-ip { + quota traffic-quota { + 50 mbytes + } +}" + +GET="$($NFT list ruleset)" +if [ "$EXPECTED" != "$GET" ] ; then + diff -u <(echo "$EXPECTED") <(echo "$GET") + exit 1 +fi
tests/shell/testcases/optionals/update_object_handles_0 +2 -0
@@ -1,5 +1,7 @@ #!/bin/bash +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_stateful_object_update) + set -e $NFT add table test-ip $NFT add counter test-ip traffic-counter
Signature · 1 line
2.30.2
Pablo Neira Ayuso
maintainerPATCH 3/8 tests: shell: detach synproxy test
In reply to Pablo Neira AyusoOld kernels do not support synproxy, split existing tests with stateful objects.
Signed-off-by Pablo Neira Ayuso <[email protected]>
--- .../shell/testcases/sets/0024named_objects_0 | 15 ---------- tests/shell/testcases/sets/0024synproxy_0 | 29 +++++++++++++++++++ .../sets/dumps/0024named_objects_0.nft | 18 ------------ .../testcases/sets/dumps/0024synproxy_0.nft | 23 +++++++++++++++ 4 files changed, 52 insertions(+), 33 deletions(-) create mode 100755 tests/shell/testcases/sets/0024synproxy_0 create mode 100644 tests/shell/testcases/sets/dumps/0024synproxy_0.nft
tests/shell/testcases/sets/0024named_objects_0 +0 -15
@@ -18,15 +18,6 @@ table inet x { quota user124 { over 2000 bytes } - synproxy https-synproxy { - mss 1460 - wscale 7 - timestamp sack-perm - } - synproxy other-synproxy { - mss 1460 - wscale 5 - } set y { type ipv4_addr }
@@ -34,15 +25,9 @@ table inet x { type ipv4_addr : quota elements = { 192.168.2.2 : "user124", 192.168.2.3 : "user124"} } - map test2 { - type ipv4_addr : synproxy - flags interval - elements = { 192.168.1.0/24 : "https-synproxy", 192.168.2.0/24 : "other-synproxy" } - } chain y { type filter hook input priority 0; policy accept; counter name ip saddr map { 192.168.2.2 : "user123", 1.1.1.1 : "user123", 2.2.2.2 : "user123"} - synproxy name ip saddr map { 192.168.1.0/24 : "https-synproxy", 192.168.2.0/24 : "other-synproxy" } quota name ip saddr map @test drop } }"
tests/shell/testcases/sets/0024synproxy_0 new file +29 -0
@@ -0,0 +1,29 @@ +#!/bin/bash + +# * creating valid named objects +# * referencing them from a valid rule + +RULESET=" +table inet x { + synproxy https-synproxy { + mss 1460 + wscale 7 + timestamp sack-perm + } + synproxy other-synproxy { + mss 1460 + wscale 5 + } + map test2 { + type ipv4_addr : synproxy + flags interval + elements = { 192.168.1.0/24 : "https-synproxy", 192.168.2.0/24 : "other-synproxy" } + } + chain y { + type filter hook input priority 0; policy accept; + synproxy name ip saddr map { 192.168.1.0/24 : "https-synproxy", 192.168.2.0/24 : "other-synproxy" } + } +}" + +set -e +$NFT -f - <<< "$RULESET"
tests/shell/testcases/sets/dumps/0024named_objects_0.nft +0 -18
@@ -15,17 +15,6 @@ table inet x { over 2000 bytes } - synproxy https-synproxy { - mss 1460 - wscale 7 - timestamp sack-perm - } - - synproxy other-synproxy { - mss 1460 - wscale 5 - } - set y { type ipv4_addr }
@@ -35,16 +24,9 @@ table inet x { elements = { 192.168.2.2 : "user124", 192.168.2.3 : "user124" } } - map test2 { - type ipv4_addr : synproxy - flags interval - elements = { 192.168.1.0/24 : "https-synproxy", 192.168.2.0/24 : "other-synproxy" } - } - chain y { type filter hook input priority filter; policy accept; counter name ip saddr map { 1.1.1.1 : "user123", 2.2.2.2 : "user123", 192.168.2.2 : "user123" } - synproxy name ip saddr map { 192.168.1.0/24 : "https-synproxy", 192.168.2.0/24 : "other-synproxy" } quota name ip saddr map @test drop } }
tests/shell/testcases/sets/dumps/0024synproxy_0.nft new file +23 -0
@@ -0,0 +1,23 @@ +table inet x { + synproxy https-synproxy { + mss 1460 + wscale 7 + timestamp sack-perm + } + + synproxy other-synproxy { + mss 1460 + wscale 5 + } + + map test2 { + type ipv4_addr : synproxy + flags interval + elements = { 192.168.1.0/24 : "https-synproxy", 192.168.2.0/24 : "other-synproxy" } + } + + chain y { + type filter hook input priority filter; policy accept; + synproxy name ip saddr map { 192.168.1.0/24 : "https-synproxy", 192.168.2.0/24 : "other-synproxy" } + } +}
Signature · 1 line
2.30.2
Pablo Neira Ayuso
maintainerPATCH 4/8 tests: shell: skip synproxy test if kernel does not support it
In reply to Pablo Neira AyusoSigned-off-by Pablo Neira Ayuso <[email protected]>
--- tests/shell/features/synproxy.nft | 9 +++++++++ tests/shell/testcases/sets/0024synproxy_0 | 2 ++ 2 files changed, 11 insertions(+) create mode 100644 tests/shell/features/synproxy.nft
tests/shell/features/synproxy.nft new file +9 -0
@@ -0,0 +1,9 @@ +# v5.3-rc1~140^2~44^2~10 +# ad49d86e07a4 ("netfilter: nf_tables: Add synproxy support") +table inet x { + synproxy https-synproxy { + mss 1460 + wscale 7 + timestamp sack-perm + } +}
tests/shell/testcases/sets/0024synproxy_0 +2 -0
@@ -1,5 +1,7 @@ #!/bin/bash +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_synproxy) + # * creating valid named objects # * referencing them from a valid rule
Signature · 1 line
2.30.2
Pablo Neira Ayuso
maintainerPATCH 5/8 tests: shell: skip nat inet if kernel does not support it
In reply to Pablo Neira AyusoSigned-off-by Pablo Neira Ayuso <[email protected]>
--- tests/shell/features/inet_nat.nft | 7 +++++++ tests/shell/testcases/maps/0010concat_map_0 | 2 ++ 2 files changed, 9 insertions(+) create mode 100644 tests/shell/features/inet_nat.nft
tests/shell/features/inet_nat.nft new file +7 -0
@@ -0,0 +1,7 @@ +# v5.2-rc1~133^2~174^2~15 +# d164385ec572 ("netfilter: nat: add inet family nat support") +table inet x { + chain y { + type nat hook prerouting priority dstnat; + } +}
tests/shell/testcases/maps/0010concat_map_0 +2 -0
@@ -1,5 +1,7 @@ #!/bin/bash +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_inet_nat) + set -e EXPECTED="table inet x {
Signature · 1 line
2.30.2
Pablo Neira Ayuso
maintainerPATCH 6/8 tests: shell: split nat inet tests
In reply to Pablo Neira AyusoDetach nat inet from existing tests not to reduce test coverage.
Signed-off-by Pablo Neira Ayuso <[email protected]>
--- .../optimizations/dumps/merge_nat.nft | 11 ---------- .../optimizations/dumps/merge_nat_inet.nft | 11 ++++++++++ tests/shell/testcases/optimizations/merge_nat | 16 -------------- .../testcases/optimizations/merge_nat_inet | 21 +++++++++++++++++++ 4 files changed, 32 insertions(+), 27 deletions(-) create mode 100644 tests/shell/testcases/optimizations/dumps/merge_nat_inet.nft create mode 100755 tests/shell/testcases/optimizations/merge_nat_inet
tests/shell/testcases/optimizations/dumps/merge_nat.nft +0 -11
@@ -19,14 +19,3 @@ table ip test4 { tcp dport 85 redirect } } -table inet nat { - chain prerouting { - oif "lo" accept - dnat ip to iifname . ip daddr . tcp dport map { "enp2s0" . 72.2.3.70 . 80 : 10.1.1.52 . 80, "enp2s0" . 72.2.3.66 . 53122 : 10.1.1.10 . 22, "enp2s0" . 72.2.3.66 . 443 : 10.1.1.52 . 443 } - } - - chain postrouting { - oif "lo" accept - snat ip to ip daddr map { 72.2.3.66 : 10.2.2.2, 72.2.3.67 : 10.2.3.3 } - } -}
tests/shell/testcases/optimizations/dumps/merge_nat_inet.nft new file +11 -0
@@ -0,0 +1,11 @@ +table inet nat { + chain prerouting { + oif "lo" accept + dnat ip to iifname . ip daddr . tcp dport map { "enp2s0" . 72.2.3.70 . 80 : 10.1.1.52 . 80, "enp2s0" . 72.2.3.66 . 53122 : 10.1.1.10 . 22, "enp2s0" . 72.2.3.66 . 443 : 10.1.1.52 . 443 } + } + + chain postrouting { + oif "lo" accept + snat ip to ip daddr map { 72.2.3.66 : 10.2.2.2, 72.2.3.67 : 10.2.3.3 } + } +}
tests/shell/testcases/optimizations/merge_nat +0 -16
@@ -36,19 +36,3 @@ RULESET="table ip test4 { }" $NFT -o -f - <<< $RULESET - -RULESET="table inet nat { - chain prerouting { - oif lo accept - iifname enp2s0 ip daddr 72.2.3.66 tcp dport 53122 dnat to 10.1.1.10:22 - iifname enp2s0 ip daddr 72.2.3.66 tcp dport 443 dnat to 10.1.1.52:443 - iifname enp2s0 ip daddr 72.2.3.70 tcp dport 80 dnat to 10.1.1.52:80 - } - chain postrouting { - oif lo accept - ip daddr 72.2.3.66 snat to 10.2.2.2 - ip daddr 72.2.3.67 snat to 10.2.3.3 - } -}" - -$NFT -o -f - <<< $RULESET
tests/shell/testcases/optimizations/merge_nat_inet new file +21 -0
@@ -0,0 +1,21 @@ +#!/bin/bash + +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_inet_nat) + +set -e + +RULESET="table inet nat { + chain prerouting { + oif lo accept + iifname enp2s0 ip daddr 72.2.3.66 tcp dport 53122 dnat to 10.1.1.10:22 + iifname enp2s0 ip daddr 72.2.3.66 tcp dport 443 dnat to 10.1.1.52:443 + iifname enp2s0 ip daddr 72.2.3.70 tcp dport 80 dnat to 10.1.1.52:80 + } + chain postrouting { + oif lo accept + ip daddr 72.2.3.66 snat to 10.2.2.2 + ip daddr 72.2.3.67 snat to 10.2.3.3 + } +}" + +$NFT -o -f - <<< $RULESET
Signature · 1 line
2.30.2
Pablo Neira Ayuso
maintainerPATCH 7/8 tests: shell: skip secmark tests if kernel does not support it
In reply to Pablo Neira AyusoSigned-off-by Pablo Neira Ayuso <[email protected]>
--- tests/shell/features/secmark.nft | 7 +++++++ tests/shell/testcases/json/0005secmark_objref_0 | 1 + 2 files changed, 8 insertions(+) create mode 100644 tests/shell/features/secmark.nft
tests/shell/features/secmark.nft new file +7 -0
@@ -0,0 +1,7 @@ +# fb961945457f ("netfilter: nf_tables: add SECMARK support") +# v4.20-rc1~14^2~125^2~5 +table inet x { + secmark ssh_server { + "system_u:object_r:ssh_server_packet_t:s0" + } +}
tests/shell/testcases/json/0005secmark_objref_0 +1 -0
@@ -1,6 +1,7 @@ #!/bin/bash # NFT_TEST_REQUIRES(NFT_TEST_HAVE_json) +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_secmark) set -e
Signature · 1 line
2.30.2
Pablo Neira Ayuso
maintainerPATCH 8/8 tests: shell: skip if kernel does not allow to restore set element expiration
In reply to Pablo Neira AyusoSigned-off-by Pablo Neira Ayuso <[email protected]>
--- tests/shell/features/setelem_expiration.sh | 18 ++++++++++++++++++ .../sets/0036add_set_element_expiration_0 | 2 ++ 2 files changed, 20 insertions(+) create mode 100755 tests/shell/features/setelem_expiration.sh
tests/shell/features/setelem_expiration.sh new file +18 -0
@@ -0,0 +1,18 @@ +#!/bin/bash + +# v5.3-rc1~140^2~153^2~8 +# 79ebb5bb4e38 ("netfilter: nf_tables: enable set expiration time for set elements") + +EXPECTED="table ip x { + set y { + type ipv4_addr + flags dynamic,timeout; + elements = { 1.1.1.1 expires 30s } + } +}" + +$NFT -f - <<< $EXPECTED + +$NFT list ruleset | grep "expires" +[ $? -ne 1 ] && exit 1 +exit 0
tests/shell/testcases/sets/0036add_set_element_expiration_0 +2 -0
@@ -1,5 +1,7 @@ #!/bin/bash +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_setelem_expiration) + set -e drop_seconds() {
Signature · 1 line
2.30.2