netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: Jozsef Kadlecsik <kadlec@netfilter.org>
Cc: netfilter-devel@vger.kernel.org, Pablo Neira Ayuso <pablo@netfilter.org>
Subject: [ipset PATCH 2/4] tests: xlate: Make test input valid
Date: Tue,  7 Mar 2023 14:58:10 +0100	[thread overview]
Message-ID: <20230307135812.25993-3-phil@nwl.cc> (raw)
In-Reply-To: <20230307135812.25993-1-phil@nwl.cc>

Make sure ipset at least accepts the test input by running it against
plain ipset once for sanity. This exposed two issues:

* Set 'hip5' doesn't have comment support, so add the commented elements
  to 'hip6' instead (likely a typo).
* Set 'bip1' range 2.0.0.1-2.1.0.1 exceeds the max allowed for bitmap
  sets. Reduce it accordingly.

Fixes: 7587d1c4b5465 ("tests: add tests ipset to nftables")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 tests/xlate/runtest.sh  | 10 ++++++++++
 tests/xlate/xlate.t     |  6 +++---
 tests/xlate/xlate.t.nft |  4 ++--
 3 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/tests/xlate/runtest.sh b/tests/xlate/runtest.sh
index 6a2f80c0d9e61..8b42f0b414d72 100755
--- a/tests/xlate/runtest.sh
+++ b/tests/xlate/runtest.sh
@@ -6,8 +6,18 @@ if [ ! -x "$DIFF" ] ; then
 	exit 1
 fi
 
+ipset=${IPSET_BIN:-../../src/ipset}
 ipset_xlate=${IPSET_XLATE_BIN:-$(dirname $0)/ipset-translate}
 
+$ipset restore < xlate.t
+rc=$?
+$ipset destroy
+if [ $rc -ne 0 ]
+then
+	echo -e "[\033[0;31mERROR\033[0m] invalid test input"
+	exit 1
+fi
+
 TMP=$(mktemp)
 $ipset_xlate restore < xlate.t &> $TMP
 if [ $? -ne 0 ]
diff --git a/tests/xlate/xlate.t b/tests/xlate/xlate.t
index f09cb202bb6c0..38cbc787bb854 100644
--- a/tests/xlate/xlate.t
+++ b/tests/xlate/xlate.t
@@ -11,8 +11,8 @@ add hip4 192.168.10.0
 create hip5 hash:ip maxelem 24
 add hip5 192.168.10.0
 create hip6 hash:ip comment
-add hip5 192.168.10.1
-add hip5 192.168.10.2 comment "this is a comment"
+add hip6 192.168.10.1
+add hip6 192.168.10.2 comment "this is a comment"
 create ipp1 hash:ip,port
 add ipp1 192.168.10.1,0
 add ipp1 192.168.10.2,5
@@ -23,7 +23,7 @@ create ipp3 hash:ip,port counters
 add ipp3 192.168.10.3,20 packets 5 bytes 3456
 create ipp4 hash:ip,port timeout 4 counters
 add ipp4 192.168.10.3,20 packets 5 bytes 3456
-create bip1 bitmap:ip range 2.0.0.1-2.1.0.1 timeout 5
+create bip1 bitmap:ip range 2.0.0.1-2.0.1.1 timeout 5
 create bip2 bitmap:ip range 10.0.0.0/8 netmask 24 timeout 5
 add bip2 10.10.10.0
 add bip2 10.10.20.0 timeout 12
diff --git a/tests/xlate/xlate.t.nft b/tests/xlate/xlate.t.nft
index 0152a30811258..8fb2a29b9c79f 100644
--- a/tests/xlate/xlate.t.nft
+++ b/tests/xlate/xlate.t.nft
@@ -12,8 +12,8 @@ add element inet global hip4 { 192.168.10.0/24 }
 add set inet global hip5 { type ipv4_addr; size 24; }
 add element inet global hip5 { 192.168.10.0 }
 add set inet global hip6 { type ipv4_addr; }
-add element inet global hip5 { 192.168.10.1 }
-add element inet global hip5 { 192.168.10.2 comment "this is a comment" }
+add element inet global hip6 { 192.168.10.1 }
+add element inet global hip6 { 192.168.10.2 comment "this is a comment" }
 add set inet global ipp1 { type ipv4_addr . inet_proto . inet_service; }
 add element inet global ipp1 { 192.168.10.1 . tcp . 0 }
 add element inet global ipp1 { 192.168.10.2 . tcp . 5 }
-- 
2.38.0


  parent reply	other threads:[~2023-03-07 13:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-07 13:58 [ipset PATCH 0/4] Some testsuite improvements Phil Sutter
2023-03-07 13:58 ` [ipset PATCH 1/4] tests: xlate: Test built binary by default Phil Sutter
2023-03-07 13:58 ` Phil Sutter [this message]
2023-03-07 13:58 ` [ipset PATCH 3/4] tests: cidr.sh: Add ipcalc fallback Phil Sutter
2023-03-07 13:58 ` [ipset PATCH 4/4] tests: hash:ip,port.t: 'vrrp' is printed as 'carp' Phil Sutter
2023-03-10 11:56 ` [ipset PATCH 0/4] Some testsuite improvements Pablo Neira Ayuso
2023-03-10 12:19 ` Phil Sutter

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=20230307135812.25993-3-phil@nwl.cc \
    --to=phil@nwl.cc \
    --cc=kadlec@netfilter.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /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).