]> granicus.if.org Git - ipset/commitdiff
Add new testsuite entries to verify counters and the new type implementations
authorJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Thu, 4 Apr 2013 14:32:20 +0000 (16:32 +0200)
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Tue, 9 Apr 2013 19:42:16 +0000 (21:42 +0200)
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
24 files changed:
tests/bitmap:ip.t
tests/check_counters [new file with mode: 0644]
tests/check_extensions [new file with mode: 0644]
tests/check_klog.sh
tests/check_sendip_packets [new file with mode: 0644]
tests/hash:ip,port,ip.t
tests/hash:ip,port,net.t
tests/hash:ip,port.t
tests/hash:ip.t
tests/hash:ip6,port,ip6.t
tests/hash:ip6,port,net6.t
tests/hash:ip6,port.t
tests/hash:ip6.t
tests/hash:net,iface.t
tests/hash:net,port.t
tests/hash:net.t
tests/hash:net6,port.t
tests/hash:net6.t
tests/macipmap.t
tests/portmap.t
tests/resizen.sh [new file with mode: 0644]
tests/resizet.sh [new file with mode: 0644]
tests/runtest.sh
tests/setlist.t

index 4389d8fa1744173e8ec5dad7130f82eca1f52afb..252bde498377e6eb7bb6a2bf80fc1af1e90a2d0e 100644 (file)
 0 ipset test test 1.1.1.1
 # Full: Delete test set
 0 ipset destroy test
+# Counters: create set
+0 ipset n test bitmap:ip range 2.0.0.1-2.1.0.0 counters
+# Counters: add element with packet, byte counters
+0 ipset a test 2.0.0.1 packets 5 bytes 3456
+# Counters: check element
+0 ipset t test 2.0.0.1
+# Counters: check counters
+0 ./check_counters test 2.0.0.1 5 3456
+# Counters: delete element
+0 ipset d test 2.0.0.1
+# Counters: test deleted element
+1 ipset t test 2.0.0.1
+# Counters: add element with packet, byte counters
+0 ipset a test 2.0.0.10 packets 12 bytes 9876
+# Counters: check counters
+0 ./check_counters test 2.0.0.10 12 9876
+# Counters: update counters
+0 ipset -! a test 2.0.0.10 packets 13 bytes 12479
+# Counters: check counters
+0 ./check_counters test 2.0.0.10 13 12479
+# Counters: destroy set
+0 ipset x test
+# Counters and timeout: create set
+0 ipset n test bitmap:ip range 2.0.0.1-2.1.0.0 counters timeout 600
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test 2.0.0.1 packets 5 bytes 3456
+# Counters and timeout: check element
+0 ipset t test 2.0.0.1
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.1 600 5 3456
+# Counters and timeout: delete element
+0 ipset d test 2.0.0.1
+# Counters and timeout: test deleted element
+1 ipset t test 2.0.0.1
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test 2.0.0.10 packets 12 bytes 9876
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.10 600 12 9876
+# Counters and timeout: update counters
+0 ipset -! a test 2.0.0.10 packets 13 bytes 12479
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.10 600 13 12479
+# Counters and timeout: update timeout
+0 ipset -! a test 2.0.0.10 timeout 700
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.10 700 13 12479
+# Counters and timeout: destroy set
+0 ipset x test
+# Counters: require sendip
+skip which sendip
+# Counters: create set 
+0 ipset n test bitmap:ip range 10.255.0.0/16 counters
+# Counters: add elemet with zero counters
+0 ipset a test 10.255.255.64
+# Counters: generate packets
+0 ./check_sendip_packets -4 src 5
+# Counters: check counters
+0 ./check_counters test 10.255.255.64 5 $((5*40))
+# Counters: destroy set
+0 ipset x test
+# Counters and timeout: create set 
+0 ipset n test bitmap:ip range 10.255.0.0/16 counters timeout 600
+# Counters and timeout: add elemet with zero counters
+0 ipset a test 10.255.255.64
+# Counters and timeout: generate packets
+0 ./check_sendip_packets -4 src 6
+# Counters and timeout: check counters
+0 ./check_extensions test 10.255.255.64 600 6 $((6*40))
+# Counters and timeout: destroy set
+0 ipset x test
 # eof
diff --git a/tests/check_counters b/tests/check_counters
new file mode 100644 (file)
index 0000000..0099f23
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+read ip p packets b bytes <<< $(../src/ipset l $1 | grep ^$2)
+test -z "$packets" -o -z "$bytes" && exit 1
+test $packets -ne $3 -o $bytes -ne $4 && exit 1
+exit 0
+
+
+
diff --git a/tests/check_extensions b/tests/check_extensions
new file mode 100644 (file)
index 0000000..5848b38
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+read ip t timeout p packets b bytes <<< $(../src/ipset l $1 | grep ^$2)
+test -z "$timeout" -o -z "$packets" -o -z "$bytes" && exit 1
+test $timeout -gt $3 -o $timeout -lt $(($3 - 10)) && exit 1
+test $packets -ne $4 -o $bytes -ne $5 && exit 1
+exit 0
+
+
+
index 489fa714bc6fc7e855e19460d06aac124969ab28..a39da773b34eede23f28780b8dd0d051b52c4903 100755 (executable)
@@ -37,7 +37,7 @@ proto=`echo $1 | tr a-z A-Z`; shift
 port=$1; shift
 
 for setname in $@; do
-       match=`grep -e "in set $setname: .* SRC=$ipaddr .* PROTO=$proto SPT=$port .*" /var/log/kern.log`
+       match=`dmesg| tail -n 2 | grep -e "in set $setname: .* SRC=$ipaddr .* PROTO=$proto SPT=$port .*"`
        if [ -z "$match" ]; then
                echo "no match!"
                exit 1
diff --git a/tests/check_sendip_packets b/tests/check_sendip_packets
new file mode 100644 (file)
index 0000000..0dad3d0
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+# -4|-6 dirs pkt-count
+
+set -e
+
+if [ "$1" = "-4" ]; then
+    cmd=iptables
+    proto=ipv4
+    src=10.255.255.64
+    dst=127.0.0.1
+else
+    cmd=ip6tables
+    proto=ipv6
+    src=1002:1002:1002:1002::32
+    dst=::1
+fi
+
+$cmd -A INPUT -m set --match-set test $2 -j DROP
+for x in `seq 1 $3`; do
+    sendip -p $proto -id $dst -is $src -p tcp -td 80 -ts 1025 $dst
+done
+$cmd -D INPUT -m set --match-set test $2 -j DROP
+
index 8096d0c64d8de86eef88773ac149de4a2caa2703..0cb2e0bdbe3eed34ce43f3e11be45ee1615aa3f6 100644 (file)
 0 n=`ipset save test|wc -l` && test $n -eq 1
 # Destroy set
 0 ipset -X test
+# Timeout: Check that resizing keeps timeout values
+0 ./resizet.sh -4 ipportip
+# Counters: create set
+0 ipset n test hash:ip,port,ip counters
+# Counters: add element with packet, byte counters
+0 ipset a test 2.0.0.1,80,192.168.199.200 packets 5 bytes 3456
+# Counters: check element
+0 ipset t test 2.0.0.1,80,192.168.199.200
+# Counters: check counters
+0 ./check_counters test 2.0.0.1 5 3456
+# Counters: delete element
+0 ipset d test 2.0.0.1,80,192.168.199.200
+# Counters: test deleted element
+1 ipset t test 2.0.0.1,80,192.168.199.200
+# Counters: add element with packet, byte counters
+0 ipset a test 2.0.0.20,453,10.0.0.1 packets 12 bytes 9876
+# Counters: check counters
+0 ./check_counters test 2.0.0.20 12 9876
+# Counters: update counters
+0 ipset -! a test 2.0.0.20,453,10.0.0.1 packets 13 bytes 12479
+# Counters: check counters
+0 ./check_counters test 2.0.0.20 13 12479
+# Counters: destroy set
+0 ipset x test
+# Counters and timeout: create set
+0 ipset n test hash:ip,port,ip counters timeout 600
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test 2.0.0.1,80,192.168.199.200 packets 5 bytes 3456
+# Counters and timeout: check element
+0 ipset t test 2.0.0.1,80,192.168.199.200
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.1 600 5 3456
+# Counters and timeout: delete element
+0 ipset d test 2.0.0.1,80,192.168.199.200
+# Counters and timeout: test deleted element
+1 ipset t test 2.0.0.1,80,192.168.199.200
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test 2.0.0.20,453,10.0.0.1 packets 12 bytes 9876
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.20 600 12 9876
+# Counters and timeout: update counters
+0 ipset -! a test 2.0.0.20,453,10.0.0.1 packets 13 bytes 12479
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.20 600 13 12479
+# Counters and timeout: update timeout
+0 ipset -! a test 2.0.0.20,453,10.0.0.1 timeout 700
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.20 700 13 12479
+# Counters and timeout: destroy set
+0 ipset x test
 # eof
index e0c8c08fc611392debcf241d80f37c5d8be6ad72..22c2b131a527f967c190684d1f852e38195adc41 100644 (file)
 0 n=`ipset save test|wc -l` && test $n -eq 1
 # Destroy set
 0 ipset -X test
+# Timeout: Check that resizing keeps timeout values
+0 ./resizet.sh -4 ipportnet
+# Nomatch: Check that resizing keeps the nomatch flag
+0 ./resizen.sh -4 ipportnet
+# Counters: create set
+0 ipset n test hash:ip,port,net counters
+# Counters: add element with packet, byte counters
+0 ipset a test 2.0.0.1,80,192.168.199.200 packets 5 bytes 3456
+# Counters: check element
+0 ipset t test 2.0.0.1,80,192.168.199.200
+# Counters: check counters
+0 ./check_counters test 2.0.0.1 5 3456
+# Counters: delete element
+0 ipset d test 2.0.0.1,80,192.168.199.200
+# Counters: test deleted element
+1 ipset t test 2.0.0.1,80,192.168.199.200
+# Counters: add element with packet, byte counters
+0 ipset a test 2.0.0.20,453,10.0.0.1 packets 12 bytes 9876
+# Counters: check counters
+0 ./check_counters test 2.0.0.20 12 9876
+# Counters: update counters
+0 ipset -! a test 2.0.0.20,453,10.0.0.1 packets 13 bytes 12479
+# Counters: check counters
+0 ./check_counters test 2.0.0.20 13 12479
+# Counters: destroy set
+0 ipset x test
+# Counters and timeout: create set
+0 ipset n test hash:ip,port,net counters timeout 600
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test 2.0.0.1,80,192.168.199.200 packets 5 bytes 3456
+# Counters and timeout: check element
+0 ipset t test 2.0.0.1,80,192.168.199.200
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.1 600 5 3456
+# Counters and timeout: delete element
+0 ipset d test 2.0.0.1,80,192.168.199.200
+# Counters and timeout: test deleted element
+1 ipset t test 2.0.0.1,80,192.168.199.200
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test 2.0.0.20,453,10.0.0.1 packets 12 bytes 9876
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.20 600 12 9876
+# Counters and timeout: update counters
+0 ipset -! a test 2.0.0.20,453,10.0.0.1 packets 13 bytes 12479
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.20 600 13 12479
+# Counters and timeout: update timeout
+0 ipset -! a test 2.0.0.20,453,10.0.0.1 timeout 700
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.20 700 13 12479
+# Counters and timeout: destroy set
+0 ipset x test
 # eof
index 253c6af0d358bfc3eb99e3c023b8423e39bf0e5e..fc5d466aa321eae27ee39c7130c3943d7811e67d 100644 (file)
 0 n=`ipset save test|wc -l` && test $n -eq 1
 # Destroy set
 0 ipset -X test
+# Timeout: Check that resizing keeps timeout values
+0 ./resizet.sh -4 ipport
+# Counters: create set
+0 ipset n test hash:ip,port counters
+# Counters: add element with packet, byte counters
+0 ipset a test 2.0.0.1,80 packets 5 bytes 3456
+# Counters: check element
+0 ipset t test 2.0.0.1,80
+# Counters: check counters
+0 ./check_counters test 2.0.0.1 5 3456
+# Counters: delete element
+0 ipset d test 2.0.0.1,80
+# Counters: test deleted element
+1 ipset t test 2.0.0.1,80
+# Counters: add element with packet, byte counters
+0 ipset a test 2.0.0.20,453 packets 12 bytes 9876
+# Counters: check counters
+0 ./check_counters test 2.0.0.20 12 9876
+# Counters: update counters
+0 ipset -! a test 2.0.0.20,453 packets 13 bytes 12479
+# Counters: check counters
+0 ./check_counters test 2.0.0.20 13 12479
+# Counters: destroy set
+0 ipset x test
+# Counters and timeout: create set
+0 ipset n test hash:ip,port counters timeout 600
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test 2.0.0.1,80 packets 5 bytes 3456
+# Counters and timeout: check element
+0 ipset t test 2.0.0.1,80
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.1 600 5 3456
+# Counters and timeout: delete element
+0 ipset d test 2.0.0.1,80
+# Counters and timeout: test deleted element
+1 ipset t test 2.0.0.1,80
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test 2.0.0.20,453 packets 12 bytes 9876
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.20 600 12 9876
+# Counters and timeout: update counters
+0 ipset -! a test 2.0.0.20,453 packets 13 bytes 12479
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.20 600 13 12479
+# Counters and timeout: update timeout
+0 ipset -! a test 2.0.0.20,453 timeout 700
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.20 700 13 12479
+# Counters and timeout: destroy set
+0 ipset x test
 # eof
index 1f00be702b27cc2d16f423cc60942692ec644ab4..56b3004b46bb82d561313a84161eac9eaa586d39 100644 (file)
 0 n=`ipset save test|wc -l` && test $n -eq 1
 # Range: Delete test set
 0 ipset destroy test
+# Timeout: Check that resizing keeps timeout values
+0 ./resizet.sh -4 ip
+# Counters: create set
+0 ipset n test hash:ip counters
+# Counters: add element with packet, byte counters
+0 ipset a test 2.0.0.1 packets 5 bytes 3456
+# Counters: check element
+0 ipset t test 2.0.0.1
+# Counters: check counters
+0 ./check_counters test 2.0.0.1 5 3456
+# Counters: delete element
+0 ipset d test 2.0.0.1
+# Counters: test deleted element
+1 ipset t test 2.0.0.1
+# Counters: add element with packet, byte counters
+0 ipset a test 2.0.0.10 packets 12 bytes 9876
+# Counters: check counters
+0 ./check_counters test 2.0.0.10 12 9876
+# Counters: update counters
+0 ipset -! a test 2.0.0.10 packets 13 bytes 12479
+# Counters: check counters
+0 ./check_counters test 2.0.0.10 13 12479
+# Counters: destroy set
+0 ipset x test
+# Counters and timeout: create set
+0 ipset n test hash:ip counters timeout 600
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test 2.0.0.1 packets 5 bytes 3456
+# Counters and timeout: check element
+0 ipset t test 2.0.0.1
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.1 600 5 3456
+# Counters and timeout: delete element
+0 ipset d test 2.0.0.1
+# Counters and timeout: test deleted element
+1 ipset t test 2.0.0.1
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test 2.0.0.10 packets 12 bytes 9876
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.10 600 12 9876
+# Counters and timeout: update counters
+0 ipset -! a test 2.0.0.10 packets 13 bytes 12479
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.10 600 13 12479
+# Counters and timeout: update timeout
+0 ipset -! a test 2.0.0.10 timeout 700
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.10 700 13 12479
+# Counters and timeout: destroy set
+0 ipset x test
+# Counters: require sendip
+skip which sendip
+# Counters: create set 
+0 ipset n test hash:ip counters
+# Counters: add elemet with zero counters
+0 ipset a test 10.255.255.64
+# Counters: generate packets
+0 ./check_sendip_packets -4 src 5
+# Counters: check counters
+0 ./check_counters test 10.255.255.64 5 $((5*40))
+# Counters: destroy set
+0 ipset x test
+# Counters and timeout: create set 
+0 ipset n test hash:ip counters timeout 600
+# Counters and timeout: add elemet with zero counters
+0 ipset a test 10.255.255.64
+# Counters and timeout: generate packets
+0 ./check_sendip_packets -4 src 6
+# Counters and timeout: check counters
+0 ./check_extensions test 10.255.255.64 600 6 $((6*40))
+# Counters and timeout: destroy set
+0 ipset x test
 # eof
index 80e15343da68de4405e9e0af4cf49f49afa311a7..6f7f4db14b8382f197fea0b39e061b8bc019936c 100644 (file)
 0 n=`ipset list test|grep 1::1|wc -l` && test $n -eq 1026
 # Destroy set
 0 ipset -X test
+# Timeout: Check that resizing keeps timeout values
+0 ./resizet.sh -6 ipportip
+# Counters: create set
+0 ipset n test hash:ip,port,ip -6 counters
+# Counters: add element with packet, byte counters
+0 ipset a test 2:0:0::1,80,2002:24:ff::1 packets 5 bytes 3456
+# Counters: check element
+0 ipset t test 2:0:0::1,80,2002:24:ff::1
+# Counters: check counters
+0 ./check_counters test 2::1 5 3456
+# Counters: delete element
+0 ipset d test 2:0:0::1,80,2002:24:ff::1
+# Counters: test deleted element
+1 ipset t test 2:0:0::1,80,2002:24:ff::1
+# Counters: add element with packet, byte counters
+0 ipset a test 2:0:0::20,453,2002:ff:24::ab packets 12 bytes 9876
+# Counters: check counters
+0 ./check_counters test 2::20 12 9876
+# Counters: update counters
+0 ipset -! a test 2:0:0::20,453,2002:ff:24::ab packets 13 bytes 12479
+# Counters: check counters
+0 ./check_counters test 2::20 13 12479
+# Counters: destroy set
+0 ipset x test
+# Counters and timeout: create set
+0 ipset n test hash:ip,port,ip -6 counters timeout 600
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test 2:0:0::1,80,2002:24:ff::1 packets 5 bytes 3456
+# Counters and timeout: check element
+0 ipset t test 2:0:0::1,80,2002:24:ff::1
+# Counters and timeout: check counters
+0 ./check_extensions test 2::1 600 5 3456
+# Counters and timeout: delete element
+0 ipset d test 2:0:0::1,80,2002:24:ff::1
+# Counters and timeout: test deleted element
+1 ipset t test 2:0:0::1,80,2002:24:ff::1
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test 2:0:0::20,453,2002:ff:24::ab packets 12 bytes 9876
+# Counters and timeout: check counters
+0 ./check_extensions test 2::20 600 12 9876
+# Counters and timeout: update counters
+0 ipset -! a test 2:0:0::20,453,2002:ff:24::ab packets 13 bytes 12479
+# Counters and timeout: check counters
+0 ./check_extensions test 2::20 600 13 12479
+# Counters and timeout: update timeout
+0 ipset -! a test 2:0:0::20,453,2002:ff:24::ab timeout 700
+# Counters and timeout: check counters
+0 ./check_extensions test 2::20 700 13 12479
+# Counters and timeout: destroy set
+0 ipset x test
 # eof
index 1c4e856ba453de282e3b0cd2992ade777af1faae..d4f9f26675c849cff326f70668a1381391d78c4c 100644 (file)
 0 ipset -T test 2:2:2::2,80,1:1:1::F
 # Delete test set
 0 ipset destroy test
+# Timeout: Check that resizing keeps timeout values
+0 ./resizet.sh -6 ipportnet
+# Nomatch: Check that resizing keeps the nomatch flag
+0 ./resizen.sh -6 ipportnet
+# Counters: create set
+0 ipset n test hash:ip,port,net -6 counters
+# Counters: add element with packet, byte counters
+0 ipset a test 2:0:0::1,80,2002:24:ff::1/64 packets 5 bytes 3456
+# Counters: check element
+0 ipset t test 2:0:0::1,80,2002:24:ff::1/64
+# Counters: check counters
+0 ./check_counters test 2::1 5 3456
+# Counters: delete element
+0 ipset d test 2:0:0::1,80,2002:24:ff::1/64
+# Counters: test deleted element
+1 ipset t test 2:0:0::1,80,2002:24:ff::1/64
+# Counters: add element with packet, byte counters
+0 ipset a test 2:0:0::20,453,2002:ff:24::ab/54 packets 12 bytes 9876
+# Counters: check counters
+0 ./check_counters test 2::20 12 9876
+# Counters: update counters
+0 ipset -! a test 2:0:0::20,453,2002:ff:24::ab/54 packets 13 bytes 12479
+# Counters: check counters
+0 ./check_counters test 2::20 13 12479
+# Counters: destroy set
+0 ipset x test
+# Counters and timeout: create set
+0 ipset n test hash:ip,port,net -6 counters timeout 600
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test 2:0:0::1,80,2002:24:ff::1/64 packets 5 bytes 3456
+# Counters and timeout: check element
+0 ipset t test 2:0:0::1,80,2002:24:ff::1/64
+# Counters and timeout: check counters
+0 ./check_extensions test 2::1 600 5 3456
+# Counters and timeout: delete element
+0 ipset d test 2:0:0::1,80,2002:24:ff::1/64
+# Counters and timeout: test deleted element
+1 ipset t test 2:0:0::1,80,2002:24:ff::1/64
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test 2:0:0::20,453,2002:ff:24::ab/54 packets 12 bytes 9876
+# Counters and timeout: check counters
+0 ./check_extensions test 2::20 600 12 9876
+# Counters and timeout: update counters
+0 ipset -! a test 2:0:0::20,453,2002:ff:24::ab/54 packets 13 bytes 12479
+# Counters and timeout: check counters
+0 ./check_extensions test 2::20 600 13 12479
+# Counters and timeout: update timeout
+0 ipset -! a test 2:0:0::20,453,2002:ff:24::ab/54 timeout 700
+# Counters and timeout: check counters
+0 ./check_extensions test 2::20 700 13 12479
+# Counters and timeout: destroy set
+0 ipset x test
 # eof
index d583415db28ed79ea263d353e9906c7c1cccfa12..b142f22e3a7958b94de8e1fb807eac329e97b018 100644 (file)
 0 n=`ipset list test|grep 1::1|wc -l` && test $n -eq 1026
 # Destroy set
 0 ipset -X test
+# Timeout: Check that resizing keeps timeout values
+0 ./resizet.sh -6 ipport
+# Counters: create set
+0 ipset n test hash:ip,port -6 counters
+# Counters: add element with packet, byte counters
+0 ipset a test 2:0:0::1,80 packets 5 bytes 3456
+# Counters: check element
+0 ipset t test 2:0:0::1,80
+# Counters: check counters
+0 ./check_counters test 2::1 5 3456
+# Counters: delete element
+0 ipset d test 2:0:0::1,80
+# Counters: test deleted element
+1 ipset t test 2:0:0::1,80
+# Counters: add element with packet, byte counters
+0 ipset a test 2:0:0::20,453 packets 12 bytes 9876
+# Counters: check counters
+0 ./check_counters test 2::20 12 9876
+# Counters: update counters
+0 ipset -! a test 2:0:0::20,453 packets 13 bytes 12479
+# Counters: check counters
+0 ./check_counters test 2::20 13 12479
+# Counters: destroy set
+0 ipset x test
+# Counters and timeout: create set
+0 ipset n test hash:ip,port -6 counters timeout 600
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test 2:0:0::1,80 packets 5 bytes 3456
+# Counters and timeout: check element
+0 ipset t test 2:0:0::1,80
+# Counters and timeout: check counters
+0 ./check_extensions test 2::1 600 5 3456
+# Counters and timeout: delete element
+0 ipset d test 2:0:0::1,80
+# Counters and timeout: test deleted element
+1 ipset t test 2:0:0::1,80
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test 2:0:0::20,453 packets 12 bytes 9876
+# Counters and timeout: check counters
+0 ./check_extensions test 2::20 600 12 9876
+# Counters and timeout: update counters
+0 ipset -! a test 2:0:0::20,453 packets 13 bytes 12479
+# Counters and timeout: check counters
+0 ./check_extensions test 2::20 600 13 12479
+# Counters and timeout: update timeout
+0 ipset -! a test 2:0:0::20,453 timeout 700
+# Counters and timeout: check counters
+0 ./check_extensions test 2::20 700 13 12479
+# Counters and timeout: destroy set
+0 ipset x test
 # eof
index 4ab5f5bd00aa4c4277fa5c3e7bead8ad2aeebf25..2baaa8346c1a1f03e2ab3084568d07ce8d3c3867 100644 (file)
 0 diff -u -I 'Size in memory.*' .foo restore.t.list1
 # Destroy by restore
 0 ipset restore < restore.t.destroy
+# Timeout: Check that resizing keeps timeout values
+0 ./resizet.sh -6 ip
+# Counters: create set
+0 ipset n test hash:ip -6 counters
+# Counters: add element with packet, byte counters
+0 ipset a test 2:0:0::1 packets 5 bytes 3456
+# Counters: check element
+0 ipset t test 2:0:0::1
+# Counters: check counters
+0 ./check_counters test 2::1 5 3456
+# Counters: delete element
+0 ipset d test 2:0:0::1
+# Counters: test deleted element
+1 ipset t test 2:0:0::1
+# Counters: add element with packet, byte counters
+0 ipset a test 2:0:0::20 packets 12 bytes 9876
+# Counters: check counters
+0 ./check_counters test 2::20 12 9876
+# Counters: update counters
+0 ipset -! a test 2:0:0::20 packets 13 bytes 12479
+# Counters: check counters
+0 ./check_counters test 2::20 13 12479
+# Counters: destroy set
+0 ipset x test
+# Counters and timeout: create set
+0 ipset n test hash:ip -6 counters timeout 600
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test 2:0:0::1 packets 5 bytes 3456
+# Counters and timeout: check element
+0 ipset t test 2:0:0::1
+# Counters and timeout: check counters
+0 ./check_extensions test 2::1 600 5 3456
+# Counters and timeout: delete element
+0 ipset d test 2:0:0::1
+# Counters and timeout: test deleted element
+1 ipset t test 2:0:0::1
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test 2:0:0::20 packets 12 bytes 9876
+# Counters and timeout: check counters
+0 ./check_extensions test 2::20 600 12 9876
+# Counters and timeout: update counters
+0 ipset -! a test 2:0:0::20 packets 13 bytes 12479
+# Counters and timeout: check counters
+0 ./check_extensions test 2::20 600 13 12479
+# Counters and timeout: update timeout
+0 ipset -! a test 2:0:0::20 timeout 700
+# Counters and timeout: check counters
+0 ./check_extensions test 2::20 700 13 12479
+# Counters and timeout: destroy set
+0 ipset x test
 # eof
index f40f10b0f217b67927bc22b895737bd1553561d2..21ba1c7a7455ed5d7001ba5e4d3c83a753118b68 100644 (file)
 0 ipset -T test 1.1.1.3,eth0
 # Delete test set
 0 ipset destroy test
+# Timeout: Check that resizing keeps timeout values
+0 ./resizet.sh -4 netiface
+# Nomatch: Check that resizing keeps the nomatch flag
+0 ./resizen.sh -4 netiface
+# Counters: create set
+0 ipset n test hash:net,iface counters
+# Counters: add element with packet, byte counters
+0 ipset a test 2.0.0.1/24,eth0 packets 5 bytes 3456
+# Counters: check element
+0 ipset t test 2.0.0.1/24,eth0
+# Counters: check counters
+0 ./check_counters test 2.0.0.0/24,eth0 5 3456
+# Counters: delete element
+0 ipset d test 2.0.0.1/24,eth0
+# Counters: test deleted element
+1 ipset t test 2.0.0.1/24,eth0
+# Counters: add element with packet, byte counters
+0 ipset a test 2.0.0.20/25,wlan0 packets 12 bytes 9876
+# Counters: check counters
+0 ./check_counters test 2.0.0.0/25,wlan0 12 9876
+# Counters: update counters
+0 ipset -! a test 2.0.0.20/25,wlan0 packets 13 bytes 12479
+# Counters: check counters
+0 ./check_counters test 2.0.0.0/25,wlan0 13 12479
+# Counters: destroy set
+0 ipset x test
+# Counters and timeout: create set
+0 ipset n test hash:net,iface counters timeout 600
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test 2.0.0.1/24,eth0 packets 5 bytes 3456
+# Counters and timeout: check element
+0 ipset t test 2.0.0.1/24,eth0
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.0/24,eth0 600 5 3456
+# Counters and timeout: delete element
+0 ipset d test 2.0.0.1/24,eth0
+# Counters and timeout: test deleted element
+1 ipset t test 2.0.0.1/24,eth0
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test 2.0.0.20/25,wlan0 packets 12 bytes 9876
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.0/25,wlan0 600 12 9876
+# Counters and timeout: update counters
+0 ipset -! a test 2.0.0.20/25,wlan0 packets 13 bytes 12479
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.0/25,wlan0 600 13 12479
+# Counters and timeout: update timeout
+0 ipset -! a test 2.0.0.20/25,wlan0 timeout 700
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.0/25,wlan0 700 13 12479
+# Counters and timeout: destroy set
+0 ipset x test
 # eof
index 34b29f1c489d6cf0065b49650fa073abde7090aa..3d1586b99593462891f90ff17b525a2c261caa46 100644 (file)
 0 ipset -T test 1.1.1.3,80
 # Delete test set
 0 ipset destroy test
+# Timeout: Check that resizing keeps timeout values
+0 ./resizet.sh -4 netport
+# Nomatch: Check that resizing keeps the nomatch flag
+0 ./resizen.sh -4 netport
+# Counters: create set
+0 ipset n test hash:net,port counters
+# Counters: add element with packet, byte counters
+0 ipset a test 2.0.0.1/24,80 packets 5 bytes 3456
+# Counters: check element
+0 ipset t test 2.0.0.1/24,80
+# Counters: check counters
+0 ./check_counters test 2.0.0.0/24 5 3456
+# Counters: delete element
+0 ipset d test 2.0.0.1/24,80
+# Counters: test deleted element
+1 ipset t test 2.0.0.1/24,80
+# Counters: add element with packet, byte counters
+0 ipset a test 2.0.0.20/25,453 packets 12 bytes 9876
+# Counters: check counters
+0 ./check_counters test 2.0.0.0/25 12 9876
+# Counters: update counters
+0 ipset -! a test 2.0.0.20/25,453 packets 13 bytes 12479
+# Counters: check counters
+0 ./check_counters test 2.0.0.0/25 13 12479
+# Counters: destroy set
+0 ipset x test
+# Counters and timeout: create set
+0 ipset n test hash:net,port counters timeout 600
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test 2.0.0.1/24,80 packets 5 bytes 3456
+# Counters and timeout: check element
+0 ipset t test 2.0.0.1/24,80
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.0/24 600 5 3456
+# Counters and timeout: delete element
+0 ipset d test 2.0.0.1/24,80
+# Counters and timeout: test deleted element
+1 ipset t test 2.0.0.1/24,80
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test 2.0.0.20/25,453 packets 12 bytes 9876
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.0/25 600 12 9876
+# Counters and timeout: update counters
+0 ipset -! a test 2.0.0.20/25,453 packets 13 bytes 12479
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.0/25 600 13 12479
+# Counters and timeout: update timeout
+0 ipset -! a test 2.0.0.20/25,453 timeout 700
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.0/25 700 13 12479
+# Counters and timeout: destroy set
+0 ipset x test
 # eof
index 78efe3df3a64b09de63ff1a8497330480c413ae3..ef82a6e1f8419d54cb470d33864d869ddedf4096 100644 (file)
 0 ipset destroy test
 # Check CIDR book-keeping
 0 ./check_cidrs.sh
+# Timeout: Check that resizing keeps timeout values
+0 ./resizet.sh -4 net
+# Nomatch: Check that resizing keeps the nomatch flag
+0 ./resizen.sh -4 net
+# Counters: create set
+0 ipset n test hash:net counters
+# Counters: add element with packet, byte counters
+0 ipset a test 2.0.0.1/24 packets 5 bytes 3456
+# Counters: check element
+0 ipset t test 2.0.0.1/24
+# Counters: check counters
+0 ./check_counters test 2.0.0.0/24 5 3456
+# Counters: delete element
+0 ipset d test 2.0.0.1/24
+# Counters: test deleted element
+1 ipset t test 2.0.0.1/24
+# Counters: add element with packet, byte counters
+0 ipset a test 2.0.0.20/25 packets 12 bytes 9876
+# Counters: check counters
+0 ./check_counters test 2.0.0.0/25 12 9876
+# Counters: update counters
+0 ipset -! a test 2.0.0.20/25 packets 13 bytes 12479
+# Counters: check counters
+0 ./check_counters test 2.0.0.0/25 13 12479
+# Counters: destroy set
+0 ipset x test
+# Counters and timeout: create set
+0 ipset n test hash:net counters timeout 600
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test 2.0.0.1/24 packets 5 bytes 3456
+# Counters and timeout: check element
+0 ipset t test 2.0.0.1/24
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.0/24 600 5 3456
+# Counters and timeout: delete element
+0 ipset d test 2.0.0.1/24
+# Counters and timeout: test deleted element
+1 ipset t test 2.0.0.1/24
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test 2.0.0.20/25 packets 12 bytes 9876
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.0/25 600 12 9876
+# Counters and timeout: update counters
+0 ipset -! a test 2.0.0.20/25 packets 13 bytes 12479
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.0/25 600 13 12479
+# Counters and timeout: update timeout
+0 ipset -! a test 2.0.0.20/25 timeout 700
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.0/25 700 13 12479
+# Counters and timeout: destroy set
+0 ipset x test
 # eof
index b022e069ec7875cdcffb6ce38ec2ba81b257f7d4..06f82b7419b060109449f5abc6d697a05ffaed98 100644 (file)
 0 ipset -T test 1:1:1::F,80
 # Delete test set
 0 ipset destroy test
+# Timeout: Check that resizing keeps timeout values
+0 ./resizet.sh -6 netport
+# Nomatch: Check that resizing keeps the nomatch flag
+0 ./resizen.sh -6 netport
+# Counters: create set
+0 ipset n test hash:net,port -6 counters
+# Counters: add element with packet, byte counters
+0 ipset a test 2:0:0::1/64,80 packets 5 bytes 3456
+# Counters: check element
+0 ipset t test 2:0:0::1/64,80
+# Counters: check counters
+0 ./check_counters test 2:: 5 3456
+# Counters: delete element
+0 ipset d test 2:0:0::1/64,80
+# Counters: test deleted element
+1 ipset t test 2:0:0::1/64,80
+# Counters: add element with packet, byte counters
+0 ipset a test 2:0:0::20/54,453 packets 12 bytes 9876
+# Counters: check counters
+0 ./check_counters test 2:: 12 9876
+# Counters: update counters
+0 ipset -! a test 2:0:0::20/54,453 packets 13 bytes 12479
+# Counters: check counters
+0 ./check_counters test 2:: 13 12479
+# Counters: destroy set
+0 ipset x test
+# Counters and timeout: create set
+0 ipset n test hash:net,port -6 counters timeout 600
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test 2:0:0::1/64,80 packets 5 bytes 3456
+# Counters and timeout: check element
+0 ipset t test 2:0:0::1/64,80
+# Counters and timeout: check counters
+0 ./check_extensions test 2:: 600 5 3456
+# Counters and timeout: delete element
+0 ipset d test 2:0:0::1/64,80
+# Counters and timeout: test deleted element
+1 ipset t test 2:0:0::1/64,80
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test 2:0:0::20/54,453 packets 12 bytes 9876
+# Counters and timeout: check counters
+0 ./check_extensions test 2:: 600 12 9876
+# Counters and timeout: update counters
+0 ipset -! a test 2:0:0::20/54,453 packets 13 bytes 12479
+# Counters and timeout: check counters
+0 ./check_extensions test 2:: 600 13 12479
+# Counters and timeout: update timeout
+0 ipset -! a test 2:0:0::20/54,453 timeout 700
+# Counters and timeout: check counters
+0 ./check_extensions test 2:: 700 13 12479
+# Counters and timeout: destroy set
+0 ipset x test
 # eof
index d0c2652163748f447f8df1fee67e3698619d98b7..981dfdbcf3a75a68a77afcbf9489b87d80d9fe24 100644 (file)
 0 ipset -T test 1:1:1::F
 # Delete test set
 0 ipset destroy test
+# Timeout: Check that resizing keeps timeout values
+0 ./resizet.sh -6 net
+# Nomatch: Check that resizing keeps the nomatch flag
+0 ./resizen.sh -6 net
+# Counters: create set
+0 ipset n test hash:net -6 counters
+# Counters: add element with packet, byte counters
+0 ipset a test 2:0:0::1/64 packets 5 bytes 3456
+# Counters: check element
+0 ipset t test 2:0:0::1/64
+# Counters: check counters
+0 ./check_counters test 2:: 5 3456
+# Counters: delete element
+0 ipset d test 2:0:0::1/64
+# Counters: test deleted element
+1 ipset t test 2:0:0::1/64
+# Counters: add element with packet, byte counters
+0 ipset a test 2:0:0::20/54 packets 12 bytes 9876
+# Counters: check counters
+0 ./check_counters test 2:: 12 9876
+# Counters: update counters
+0 ipset -! a test 2:0:0::20/54 packets 13 bytes 12479
+# Counters: check counters
+0 ./check_counters test 2:: 13 12479
+# Counters: destroy set
+0 ipset x test
+# Counters and timeout: create set
+0 ipset n test hash:net -6 counters timeout 600
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test 2:0:0::1/64 packets 5 bytes 3456
+# Counters and timeout: check element
+0 ipset t test 2:0:0::1/64
+# Counters and timeout: check counters
+0 ./check_extensions test 2:: 600 5 3456
+# Counters and timeout: delete element
+0 ipset d test 2:0:0::1/64
+# Counters and timeout: test deleted element
+1 ipset t test 2:0:0::1/64
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test 2:0:0::20/54 packets 12 bytes 9876
+# Counters and timeout: check counters
+0 ./check_extensions test 2:: 600 12 9876
+# Counters and timeout: update counters
+0 ipset -! a test 2:0:0::20/54 packets 13 bytes 12479
+# Counters and timeout: check counters
+0 ./check_extensions test 2:: 600 13 12479
+# Counters and timeout: update timeout
+0 ipset -! a test 2:0:0::20/54 timeout 700
+# Counters and timeout: check counters
+0 ./check_extensions test 2:: 700 13 12479
+# Counters and timeout: destroy set
+0 ipset x test
 # eof
index e10fe03f1b1d44a261b7642f2dd94c525711312c..53b12fafcd89414e1ca752fe432ed37deef78466 100644 (file)
 0 ipset test test 2.0.200.214
 # Range: Delete test set
 0 ipset -X test
+# Counters: create set
+0 ipset n test bitmap:ip,mac range 2.0.0.1-2.1.0.0 counters
+# Counters: add element with packet, byte counters
+0 ipset a test 2.0.0.1,00:11:22:33:44:57 packets 5 bytes 3456
+# Counters: check element
+0 ipset t test 2.0.0.1,00:11:22:33:44:57
+# Counters: check counters
+0 ./check_counters test 2.0.0.1,00:11:22:33:44:57 5 3456
+# Counters: delete element
+0 ipset d test 2.0.0.1,00:11:22:33:44:57
+# Counters: test deleted element
+1 ipset t test 2.0.0.1,00:11:22:33:44:57
+# Counters: add element with packet, byte counters
+0 ipset a test 2.0.0.1,00:11:22:33:44:57 packets 12 bytes 9876
+# Counters: check counters
+0 ./check_counters test 2.0.0.1,00:11:22:33:44:57 12 9876
+# Counters: update counters
+0 ipset -! a test 2.0.0.1,00:11:22:33:44:57 packets 13 bytes 12479
+# Counters: check counters
+0 ./check_counters test 2.0.0.1,00:11:22:33:44:57 13 12479
+# Counters: destroy set
+0 ipset x test
+# Counters and timeout: create set
+0 ipset n test bitmap:ip,mac range 2.0.0.1-2.1.0.0 counters timeout 600
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test 2.0.0.1,00:11:22:33:44:57 packets 5 bytes 3456
+# Counters and timeout: check element
+0 ipset t test 2.0.0.1,00:11:22:33:44:57
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.1,00:11:22:33:44:57 600 5 3456
+# Counters and timeout: delete element
+0 ipset d test 2.0.0.1,00:11:22:33:44:57
+# Counters and timeout: test deleted element
+1 ipset t test 2.0.0.1,00:11:22:33:44:57
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test 2.0.0.10,00:11:22:33:44:88 packets 12 bytes 9876
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.10,00:11:22:33:44:88 600 12 9876
+# Counters and timeout: update counters
+0 ipset -! a test 2.0.0.10,00:11:22:33:44:88 packets 13 bytes 12479
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.10,00:11:22:33:44:88 600 13 12479
+# Counters and timeout: update timeout
+0 ipset -! a test 2.0.0.10,00:11:22:33:44:88 timeout 700
+# Counters and timeout: check counters
+0 ./check_extensions test 2.0.0.10,00:11:22:33:44:88 700 13 12479
+# Counters and timeout: destroy set
+0 ipset x test
 # eof
index 36ad682f976ddd283f6244c9fbdfcc6be68ebd20..5eeaaffcdda0fe73543649e6a2f1795b72aba8e7 100644 (file)
 0 ipset test test 567
 # Full: Delete test set
 0 ipset -X test
+# Counters: create set
+0 ipset n test bitmap:port range 1024-65535 counters
+# Counters: add element with packet, byte counters
+0 ipset a test 12345 packets 5 bytes 3456
+# Counters: check element
+0 ipset t test 12345
+# Counters: check counters
+0 ./check_counters test 12345 5 3456
+# Counters: delete element
+0 ipset d test 12345
+# Counters: test deleted element
+1 ipset t test 12345
+# Counters: add element with packet, byte counters
+0 ipset a test 48310 packets 12 bytes 9876
+# Counters: check counters
+0 ./check_counters test 48310 12 9876
+# Counters: update counters
+0 ipset -! a test 48310 packets 13 bytes 12479
+# Counters: check counters
+0 ./check_counters test 48310 13 12479
+# Counters: destroy set
+0 ipset x test
+# Counters and timeout: create set
+0 ipset n test bitmap:port range 1024-65535 counters timeout 600
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test 12345 packets 5 bytes 3456
+# Counters and timeout: check element
+0 ipset t test 12345
+# Counters and timeout: check counters
+0 ./check_extensions test 12345 600 5 3456
+# Counters and timeout: delete element
+0 ipset d test 12345
+# Counters and timeout: test deleted element
+1 ipset t test 12345
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test 48310 packets 12 bytes 9876
+# Counters and timeout: check counters
+0 ./check_extensions test 48310 600 12 9876
+# Counters and timeout: update counters
+0 ipset -! a test 48310 packets 13 bytes 12479
+# Counters and timeout: check counters
+0 ./check_extensions test 48310 600 13 12479
+# Counters and timeout: update timeout
+0 ipset -! a test 48310 timeout 700
+# Counters and timeout: check counters
+0 ./check_extensions test 48310 700 13 12479
+# Counters and timeout: destroy set
+0 ipset x test
 # eof
diff --git a/tests/resizen.sh b/tests/resizen.sh
new file mode 100644 (file)
index 0000000..1294efc
--- /dev/null
@@ -0,0 +1,78 @@
+#!/bin/sh
+
+# set -x
+set -e
+
+ipset=../src/ipset
+
+case "$1" in
+    -4)
+       ip=10.0.
+       sep=.
+       net=32
+       ip2=192.168.162.33
+       ;;
+    -6)
+       ip=10::
+       sep=:
+       net=128
+       ip2=192:168::162:33
+       ;;
+esac
+
+case "$2" in
+    ipportnet)
+       $ipset n test hash:ip,port,net $1 hashsize 64
+       for x in `seq 0 16`; do
+           for y in `seq 0 255`; do
+               $ipset a test $ip$x$sep$y,1023,$ip2/$net nomatch
+           done
+       done
+       for x in `seq 0 16`; do
+           for y in `seq 0 255`; do
+               $ipset t test $ip$x$sep$y,1023,$ip2/$net nomatch 2>/dev/null
+           done
+       done
+       ;;
+    net)
+       $ipset n test hash:net $1 hashsize 64
+       for x in `seq 0 16`; do
+           for y in `seq 0 255`; do
+               $ipset a test $ip$x$sep$y/$net nomatch
+           done
+       done
+       for x in `seq 0 16`; do
+           for y in `seq 0 255`; do
+               $ipset t test $ip$x$sep$y/$net nomatch 2>/dev/null
+           done
+       done
+       ;;
+    netport)
+       $ipset n test hash:net,port $1 hashsize 64
+       for x in `seq 0 16`; do
+           for y in `seq 0 255`; do
+               $ipset a test $ip$x$sep$y/$net,1023 nomatch
+           done
+       done
+       for x in `seq 0 16`; do
+           for y in `seq 0 255`; do
+               $ipset t test $ip$x$sep$y/$net,1023 nomatch 2>/dev/null
+           done
+       done
+       ;;
+    netiface)
+       $ipset n test hash:net,iface $1 hashsize 64
+       for x in `seq 0 16`; do
+           for y in `seq 0 255`; do
+               $ipset a test $ip$x$sep$y/$net,eth0 nomatch
+           done
+       done
+       for x in `seq 0 16`; do
+           for y in `seq 0 255`; do
+               $ipset t test $ip$x$sep$y/$net,eth0 nomatch 2>/dev/null
+           done
+       done
+       ;;
+esac
+$ipset x
+exit 0
diff --git a/tests/resizet.sh b/tests/resizet.sh
new file mode 100644 (file)
index 0000000..74fb19e
--- /dev/null
@@ -0,0 +1,87 @@
+#!/bin/sh
+
+# set -x
+set -e
+
+ipset=../src/ipset
+
+case "$1" in
+    -4)
+       ip=10.0.
+       sep=.
+       net=32
+       ip2=192.168.162.33
+       ;;
+    -6)
+       ip=10::
+       sep=:
+       net=128
+       ip2=192:168::162:33
+       ;;
+esac
+
+case "$2" in
+    ip)
+       $ipset n test hash:ip $1 hashsize 64 timeout 100
+       for x in `seq 0 16`; do
+           for y in `seq 0 255`; do
+               $ipset a test $ip$x$sep$y
+           done
+       done
+       ;;
+    ipport)
+       $ipset n test hash:ip,port $1 hashsize 64 timeout 100
+       for x in `seq 0 16`; do
+           for y in `seq 0 255`; do
+               $ipset a test $ip$x$sep$y,1023
+           done
+       done
+       ;;
+    ipportip)
+       $ipset n test hash:ip,port,ip $1 hashsize 64 timeout 100
+       for x in `seq 0 16`; do
+           for y in `seq 0 255`; do
+               $ipset a test $ip$x$sep$y,1023,$ip2
+           done
+       done
+       ;;
+    ipportnet)
+       $ipset n test hash:ip,port,net $1 hashsize 64 timeout 100
+       for x in `seq 0 16`; do
+           for y in `seq 0 255`; do
+               $ipset a test $ip$x$sep$y,1023,$ip2/$net
+           done
+       done
+       ;;
+    net)
+       $ipset n test hash:net $1 hashsize 64 timeout 100
+       for x in `seq 0 16`; do
+           for y in `seq 0 255`; do
+               $ipset a test $ip$x$sep$y/$net
+           done
+       done
+       ;;
+    netport)
+       $ipset n test hash:net,port $1 hashsize 64 timeout 100
+       for x in `seq 0 16`; do
+           for y in `seq 0 255`; do
+               $ipset a test $ip$x$sep$y/$net,1023
+           done
+       done
+       ;;
+    netiface)
+       $ipset n test hash:net,iface $1 hashsize 64 timeout 100
+       for x in `seq 0 16`; do
+           for y in `seq 0 255`; do
+               $ipset a test $ip$x$sep$y/$net,eth0
+           done
+       done
+       ;;
+esac
+$ipset l test | grep ^$ip | while read x y z; do
+    if [ $z -lt 10 -o $z -gt 99 ]; then
+       exit 1
+    fi
+done
+$ipset x
+exit 0
index ad2ac4221404b1d85e07589ad40bbb161be10b6a..c34400b56e2c0d8d30fe9510312c9b83733b3ce8 100755 (executable)
@@ -27,11 +27,11 @@ add_tests() {
                cmd=ip6tables-save
                add=match_target6
        fi
-       line="`dmesg | tail -1 | cut -d " " -f 2-`"
-       if [ ! -e /var/log/kern.log -o -z "`grep -F \"$line\" /var/log/kern.log`" ]; then
-               echo "The destination for kernel log is not /var/log/kern.log, skipping $1 match and target tests"
-               return
-       fi
+       #line="`dmesg | tail -1 | cut -d " " -f 2-`"
+       #if [ ! -e /var/log/kern.log -o -z "`grep -F \"$line\" /var/log/kern.log`" ]; then
+       #       echo "The destination for kernel log is not /var/log/kern.log, skipping $1 match and target tests"
+       #       return
+       #fi
        c=${cmd%%-save}
        if [ "`$c -m set -h 2>&1| grep 'cannot open shared object'`" ]; then
                echo "$c does not support set match, skipping $1 match and target tests"
@@ -75,6 +75,14 @@ for types in $tests; do
                what=$cmd
                continue
                ;;
+           skip)
+               eval $cmd
+               if [ $? -ne 0 ]; then
+                       echo "Skipping tests, '$cmd' failed"
+                       break
+               fi
+               continue
+               ;;
            *)
                ;;
        esac
index aa360b97aa7f4ac55c6908c37d80359df0ca6d0c..d505f61cdbf0b9ad7a3050ae850d395e6d30fa39 100644 (file)
 0 ipset test test a
 # Flush all sets
 0 ipset flush
-# Delete all sets
-0 ipset -X
+# Delete test set
+0 ipset x test
+# Counters: create set
+0 ipset n test list:set counters
+# Counters: add element with packet, byte counters
+0 ipset a test a packets 5 bytes 3456
+# Counters: check counters
+0 ./check_counters test a 5 3456
+# Counters: delete element
+0 ipset d test a
+# Counters: add element with packet, byte counters
+0 ipset a test b packets 12 bytes 9876
+# Counters: check counters
+0 ./check_counters test b 12 9876
+# Counters: update counters
+0 ipset -! a test b packets 13 bytes 12479
+# Counters: check counters
+0 ./check_counters test b 13 12479
+# Counters: flush test set
+0 ipset f test
+# Counters: destroy set
+0 ipset x test
+# Counters and timeout: create set
+0 ipset n test list:set counters timeout 600
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test a packets 5 bytes 3456
+# Counters and timeout: check counters
+0 ./check_extensions test a 600 5 3456
+# Counters and timeout: add element with packet, byte counters
+0 ipset a test b packets 12 bytes 9876
+# Counters and timeout: check counters
+0 ./check_extensions test b 600 12 9876
+# Counters and timeout: update counters
+0 ipset -! a test b packets 13 bytes 12479
+# Counters and timeout: check counters
+0 ./check_extensions test b 600 13 12479
+# Counters and timeout: update timeout
+0 ipset -! a test b timeout 700
+# Counters and timeout: check counters
+0 ./check_extensions test b 700 13 12479
+# Counters and timeout: flush
+0 ipset f test
+# Counters and timeout: destroy sets
+0 ipset x
+# Counters: require sendip
+skip which sendip >/dev/null
+# Counters: create set 
+0 ipset n a hash:ip counters
+# Counters: create list set 
+0 ipset n test list:set counters
+# Counters: add elemet with zero counters
+0 ipset a a 10.255.255.64
+# Counters: add set to test set
+0 ipset a test a
+# Counters: generate packets
+0 ./check_sendip_packets -4 src 5
+# Counters: check counters
+0 ./check_counters a 10.255.255.64 5 $((5*40))
+# Counters: check counters in list set
+0 ./check_counters test a 5 $((5*40))
+# Counters: flush sets
+0 ipset f
+# Counters: destroy sets
+0 ipset x
+# Counters and timeout: create set 
+0 ipset n a hash:ip counters timeout 600
+# Counters and timeout: create list set 
+0 ipset n test list:set counters timeout 600
+# Counters and timeout: add elemet with zero counters
+0 ipset a a 10.255.255.64
+# Counters: add set to test set
+0 ipset a test a
+# Counters and timeout: generate packets
+0 ./check_sendip_packets -4 src 6
+# Counters and timeout: check counters
+0 ./check_extensions a 10.255.255.64 600 6 $((6*40))
+# Counters and timeout: check counters in list set
+0 ./check_extensions test a 600 6 $((6*40))
+# Counters and timeout: flush sets
+0 ipset f
+# Counters and timeout: destroy sets
+0 ipset x
 # eof