From: Stefano Brivio <sbrivio@redhat.com>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: PetrB <petr.boltik@gmail.com>, netfilter-devel@vger.kernel.org
Subject: [PATCH nft 2/2] tests: Introduce 0043_concatenated_ranges_1 for subnets of different sizes
Date: Thu, 6 May 2021 00:23:14 +0200 [thread overview]
Message-ID: <def76b5915ae21136ef76dad8fb3590893c4bc6a.1620252768.git.sbrivio@redhat.com> (raw)
In-Reply-To: <cover.1620252768.git.sbrivio@redhat.com>
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>
---
.../testcases/sets/0043concatenated_ranges_1 | 23 +++++++++++++++++++
1 file changed, 23 insertions(+)
create mode 100755 tests/shell/testcases/sets/0043concatenated_ranges_1
diff --git a/tests/shell/testcases/sets/0043concatenated_ranges_1 b/tests/shell/testcases/sets/0043concatenated_ranges_1
new file mode 100755
index 000000000000..bab189c56d8c
--- /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
--
2.30.2
prev parent reply other threads:[~2021-05-05 22:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-05 22:23 [PATCH nft 0/2] Fix display of < 64 bits IPv6 masks in concatenated elements Stefano Brivio
2021-05-05 22:23 ` [PATCH nft 1/2] segtree: Fix range_mask_len() for subnet ranges exceeding unsigned int Stefano Brivio
2021-05-06 9:18 ` Phil Sutter
2021-05-06 10:00 ` Stefano Brivio
2021-05-06 11:18 ` Phil Sutter
2021-05-05 22:23 ` Stefano Brivio [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=def76b5915ae21136ef76dad8fb3590893c4bc6a.1620252768.git.sbrivio@redhat.com \
--to=sbrivio@redhat.com \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=petr.boltik@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).