summaryrefslogtreecommitdiffstats
path: root/tests/shell/testcases
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2021-05-06 00:23:14 +0200
committerFlorian Westphal <fw@strlen.de>2021-05-08 16:58:58 +0200
commitf87bcafe1360ae017bfe87ed6c63225a9ed0db2e (patch)
tree137af5dd3364eaab7afcf428b4bbf0a9b841dfe6 /tests/shell/testcases
parentb2eb1c97507dde3b183012ea59a6533e0e0f4b8f (diff)
tests: Introduce 0043_concatenated_ranges_1 for subnets of different sizes
The report from https://bugzilla.netfilter.org/show_bug.cgi?id=1520 showed a display issue with particular IPv6 mask lengths in elements of sets with concatenations. Make sure we cover insertion and listing of different mask lengths in concatenated set elements for IPv4 and IPv6. Signed-off-by: Stefano Brivio <sbrivio@redhat.com> Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'tests/shell/testcases')
-rwxr-xr-xtests/shell/testcases/sets/0043concatenated_ranges_123
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/shell/testcases/sets/0043concatenated_ranges_1 b/tests/shell/testcases/sets/0043concatenated_ranges_1
new file mode 100755
index 00000000..bab189c5
--- /dev/null
+++ b/tests/shell/testcases/sets/0043concatenated_ranges_1
@@ -0,0 +1,23 @@
+#!/bin/sh -e
+#
+# 0043concatenated_ranges_1 - Insert and list subnets of different sizes
+
+check() {
+ $NFT add element "${1}" t s "{ ${2} . ${3} }"
+ [ "$( $NFT list set "${1}" t s | grep -c "${2} . ${3}" )" = 1 ]
+}
+
+$NFT add table ip6 t
+$NFT add table ip t
+
+$NFT add set ip6 t s '{ type ipv6_addr . ipv6_addr ; flags interval ; }'
+$NFT add set ip t s '{ type ipv4_addr . ipv4_addr ; flags interval ; }'
+
+for n in $(seq 32 127); do
+ h="$(printf %x "${n}")"
+ check ip6 "2001:db8::/${n}" "2001:db8:${h}::-2001:db8:${h}::${h}:1"
+done
+
+for n in $(seq 24 31); do
+ check ip "192.0.2.0/${n}" "192.0.2.$((n * 3))-192.0.2.$((n * 3 + 2))"
+done