summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJozsef Kadlecsik <kadlec@blackhole.kfki.hu>2011-05-06 22:08:09 +0200
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>2011-05-06 22:08:09 +0200
commit32d1d2fa35c6ff61ce376f9f5eb734132599ff44 (patch)
treece584314e7b447a903d1246abfabf7c1a64d339a /tests
parent896447190b8ced40819cb91250db00bc38423bbf (diff)
Fix adding ranges to hash types
When ranges are added to hash types, the elements may trigger rehashing the set. However, the last successfully added element was not kept track so the adding started again with the first element after the rehashing. Bug reported by Mr Dash Four.
Diffstat (limited to 'tests')
-rw-r--r--tests/hash:ip,port,ip.t8
-rw-r--r--tests/hash:ip,port,net.t8
-rw-r--r--tests/hash:ip,port.t8
-rw-r--r--tests/hash:ip.t8
-rw-r--r--tests/hash:ip6,port,ip6.t8
-rw-r--r--tests/hash:ip6,port,net6.t8
-rw-r--r--tests/hash:ip6,port.t8
-rw-r--r--tests/hash:net,port.t8
-rw-r--r--tests/hash:net6,port.t8
9 files changed, 72 insertions, 0 deletions
diff --git a/tests/hash:ip,port,ip.t b/tests/hash:ip,port,ip.t
index 7a6f952..5b79ab8 100644
--- a/tests/hash:ip,port,ip.t
+++ b/tests/hash:ip,port,ip.t
@@ -54,4 +54,12 @@
0 n=`ipset save test|wc -l` && test $n -eq 17
# Delete test set
0 ipset destroy test
+# Create set to add a range
+0 ipset new test hash:ip,port,ip hashsize 64
+# Add a range which forces a resizing
+0 ipset add test 10.0.0.0-10.0.3.255,tcp:80-82,192.168.0.1
+# Check that correct number of elements are added
+0 n=`ipset list test|grep 10.0|wc -l` && test $n -eq 3072
+# Destroy set
+0 ipset -X test
# eof
diff --git a/tests/hash:ip,port,net.t b/tests/hash:ip,port,net.t
index 34cdc1a..89b046c 100644
--- a/tests/hash:ip,port,net.t
+++ b/tests/hash:ip,port,net.t
@@ -38,4 +38,12 @@
0 ipset flush test
# Delete set
0 ipset destroy test
+# Create set to add a range
+0 ipset new test hash:ip,port,net hashsize 64
+# Add a range which forces a resizing
+0 ipset add test 10.0.0.0-10.0.3.255,tcp:80-82,192.168.0.1/24
+# Check that correct number of elements are added
+0 n=`ipset list test|grep 10.0|wc -l` && test $n -eq 3072
+# Destroy set
+0 ipset -X test
# eof
diff --git a/tests/hash:ip,port.t b/tests/hash:ip,port.t
index 9befcb8..639bfe6 100644
--- a/tests/hash:ip,port.t
+++ b/tests/hash:ip,port.t
@@ -74,4 +74,12 @@
0 diff -u -I 'Size in memory.*' .foo hash:ip,port.t.list2
# Delete set
0 ipset destroy test
+# Create set to add a range
+0 ipset new test hash:ip,port hashsize 64
+# Add a range which forces a resizing
+0 ipset add test 10.0.0.0-10.0.3.255,tcp:80-82
+# Check that correct number of elements are added
+0 n=`ipset list test|grep 10.0|wc -l` && test $n -eq 3072
+# Destroy set
+0 ipset -X test
# eof
diff --git a/tests/hash:ip.t b/tests/hash:ip.t
index e21ab6e..10a1809 100644
--- a/tests/hash:ip.t
+++ b/tests/hash:ip.t
@@ -60,6 +60,14 @@
0 n=`ipset -S test | wc -l` && test $n -eq 8161
# IP: Destroy sets
0 ipset -X
+# IP: Create set to add a range
+0 ipset new test hash:ip hashsize 64
+# IP: Add a range which forces a resizing
+0 ipset add test 10.0.0.0-10.0.3.255
+# IP: Check that correct number of elements are added
+0 n=`ipset list test|grep 10.0|wc -l` && test $n -eq 1024
+# IP: Destroy sets
+0 ipset -X
# Network: Create a set with timeout
0 ipset -N test iphash --hashsize 128 --netmask 24 timeout 5
# Network: Add zero valued element
diff --git a/tests/hash:ip6,port,ip6.t b/tests/hash:ip6,port,ip6.t
index 485a8e9..078ab6c 100644
--- a/tests/hash:ip6,port,ip6.t
+++ b/tests/hash:ip6,port,ip6.t
@@ -54,4 +54,12 @@
0 ipset test test 1::1,udp:80,2::2
# Delete test set
0 ipset destroy test
+# Create set to add a range
+0 ipset new test hash:ip,port,ip -6 hashsize 64
+# Add a range which forces a resizing
+0 ipset add test 1::1,tcp:80-1105,2::2
+# Check that correct number of elements are added
+0 n=`ipset list test|grep 1::1|wc -l` && test $n -eq 1026
+# Destroy set
+0 ipset -X test
# eof
diff --git a/tests/hash:ip6,port,net6.t b/tests/hash:ip6,port,net6.t
index 91dc60f..71814cf 100644
--- a/tests/hash:ip6,port,net6.t
+++ b/tests/hash:ip6,port,net6.t
@@ -42,4 +42,12 @@
0 ipset -F test
# Range: Delete test set
0 ipset -X test
+# Create set to add a range
+0 ipset new test hash:ip,port,net -6 hashsize 64
+# Add a range which forces a resizing
+0 ipset add test 1::1,tcp:80-1105,2::2/12
+# Check that correct number of elements are added
+0 n=`ipset list test|grep 1::1|wc -l` && test $n -eq 1026
+# Destroy set
+0 ipset -X test
# eof
diff --git a/tests/hash:ip6,port.t b/tests/hash:ip6,port.t
index 684074c..884933c 100644
--- a/tests/hash:ip6,port.t
+++ b/tests/hash:ip6,port.t
@@ -46,4 +46,12 @@
0 ipset test test 1::1,udp:80
# Delete test set
0 ipset destroy test
+# Create set to add a range
+0 ipset new test hash:ip,port -6 hashsize 64
+# Add a range which forces a resizing
+0 ipset add test 1::1,tcp:80-1105
+# Check that correct number of elements are added
+0 n=`ipset list test|grep 1::1|wc -l` && test $n -eq 1026
+# Destroy set
+0 ipset -X test
# eof
diff --git a/tests/hash:net,port.t b/tests/hash:net,port.t
index ed8209a..d5f420c 100644
--- a/tests/hash:net,port.t
+++ b/tests/hash:net,port.t
@@ -54,4 +54,12 @@
0 n=`ipset save test|wc -l` && test $n -eq 4
# Delete test set
0 ipset destroy test
+# Create set to add a range
+0 ipset new test hash:net,port hashsize 64
+# Add a range which forces a resizing
+0 ipset add test 10.0.0.0/24,tcp:80-1105
+# Check that correct number of elements are added
+0 n=`ipset list test|grep 10.0|wc -l` && test $n -eq 1026
+# Destroy set
+0 ipset -X test
# eof
diff --git a/tests/hash:net6,port.t b/tests/hash:net6,port.t
index ac23288..1638157 100644
--- a/tests/hash:net6,port.t
+++ b/tests/hash:net6,port.t
@@ -64,4 +64,12 @@
0 n=`ipset save test|wc -l` && test $n -eq 4
# Delete test set
0 ipset destroy test
+# Create set to add a range
+0 ipset new test hash:net,port -6 hashsize 64
+# Add a range which forces a resizing
+0 ipset add test 1::1/64,tcp:80-1105
+# Check that correct number of elements are added
+0 n=`ipset list test|grep 1::|wc -l` && test $n -eq 1026
+# Destroy set
+0 ipset -X test
# eof