]> git.ipfire.org Git - thirdparty/ipset.git/commitdiff
tests: xlate: Make test input valid
authorPhil Sutter <phil@nwl.cc>
Sun, 5 Mar 2023 11:46:49 +0000 (12:46 +0100)
committerPhil Sutter <phil@nwl.cc>
Fri, 10 Mar 2023 12:16:51 +0000 (13:16 +0100)
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
tests/xlate/xlate.t
tests/xlate/xlate.t.nft

index 6a2f80c0d9e611d1c1dc00a85169c6fd62c66a09..8b42f0b414d726770d669235d56df9a549ddc142 100755 (executable)
@@ -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 ]
index f09cb202bb6c0bdf4ebcaa99845c4914771df7af..38cbc787bb854e0efb8c4df7bd811996683f324c 100644 (file)
@@ -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
index 0152a308112583240aa8c5d249c62b79ee10f6c2..8fb2a29b9c79f88df0ef1f5b4c48c0f104aa1959 100644 (file)
@@ -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 }