r7543 - in trunk/ipset: . tests

kadlec at blackhole.kfki.hu kadlec at blackhole.kfki.hu
Thu Jun 12 11:22:25 CEST 2008


Author: kadlec at blackhole.kfki.hu
Date: 2008-06-12 11:22:25 +0200 (Thu, 12 Jun 2008)
New Revision: 7543

Added:
   trunk/ipset/tests/
   trunk/ipset/tests/init.t
   trunk/ipset/tests/iphash.t
   trunk/ipset/tests/iphash.t.restore
   trunk/ipset/tests/ipmap.t
   trunk/ipset/tests/ipporthash.t
   trunk/ipset/tests/iptree.t
   trunk/ipset/tests/iptreemap.t
   trunk/ipset/tests/macipmap.t
   trunk/ipset/tests/nethash.t
   trunk/ipset/tests/portmap.t
   trunk/ipset/tests/runtest.sh
Modified:
   trunk/ipset/ChangeLog
   trunk/ipset/Makefile
   trunk/ipset/ipset.8
   trunk/ipset/ipset.c
   trunk/ipset/ipset_iphash.c
   trunk/ipset/ipset_nethash.c
Log:
ipset -U segfault fix committed.
Testsuite added.


Modified: trunk/ipset/ChangeLog
===================================================================
--- trunk/ipset/ChangeLog	2008-06-10 06:44:09 UTC (rev 7542)
+++ trunk/ipset/ChangeLog	2008-06-12 09:22:25 UTC (rev 7543)
@@ -1,3 +1,12 @@
+2.3.1
+ - segfault on --unbind :all: :all: fixed (reported by bugzilla,
+   report and patch sent by Tom Eastep)
+ - User input parameters are sanitized everywhere
+ - Initial testsuite added and 'test' target to the Makefile
+   added: few bugs discovered and fixed
+   - typo in macipmap type prevented to use max size set of this type
+   - *map types are made sure to allow and use max size of sets
+
 2.3.0
  - jiffies rollover bug in iptree type fixed (reported by Lukasz Nierycho
    and others)

Modified: trunk/ipset/Makefile
===================================================================
--- trunk/ipset/Makefile	2008-06-10 06:44:09 UTC (rev 7542)
+++ trunk/ipset/Makefile	2008-06-12 09:22:25 UTC (rev 7543)
@@ -8,7 +8,7 @@
 KERNEL_DIR=/usr/src/linux
 endif
 
-IPSET_VERSION:=2.3.0
+IPSET_VERSION:=2.3.1
 
 PREFIX:=/usr/local
 LIBDIR:=$(PREFIX)/lib
@@ -21,7 +21,7 @@
 RELEASE_DIR:=/tmp
 
 COPT_FLAGS:=-O2
-CFLAGS:=$(COPT_FLAGS) -Wall -Wunused -I$(KERNEL_DIR)/include -I. -g -DIPSET_DEBUG #-pg # -DIPTC_DEBUG
+CFLAGS:=$(COPT_FLAGS) -Wall -Wunused -I$(KERNEL_DIR)/include -I. # -g -DIPSET_DEBUG #-pg # -DIPTC_DEBUG
 SH_CFLAGS:=$(CFLAGS) -fPIC
 SETTYPES:=ipmap portmap macipmap iphash nethash iptree iptreemap ipporthash
 
@@ -32,6 +32,11 @@
 
 all: $(PROGRAMS) $(SHARED_LIBS)
 
+.PHONY: tests
+
+tests:
+	cd tests; ./runtest.sh
+
 install: all $(INSTALL)
 
 clean: $(EXTRA_CLEANS)

Modified: trunk/ipset/ipset.8
===================================================================
--- trunk/ipset/ipset.8	2008-06-10 06:44:09 UTC (rev 7542)
+++ trunk/ipset/ipset.8	2008-06-12 09:22:25 UTC (rev 7543)
@@ -308,7 +308,7 @@
 parameter specified, network addresses will be 
 stored in the set instead of IP addresses.
 .P
-The iphash type of sets can store up to 65535 entries. If a set is full,
+The iphash type of sets can store up to 65536 entries. If a set is full,
 no new entries can be added to it.
 .P
 Sets created by zero valued resize parameter won't be resized at all.
@@ -346,7 +346,7 @@
 Increase the hash size by this many percent (default 50) when adding
 an IP to the hash could not be performed after
 .P
-The nethash type of sets can store up to 65535 entries. If a set is full,
+The nethash type of sets can store up to 65536 entries. If a set is full,
 no new entries can be added to it.
 .P
 An IP address will be in a nethash type of set if it is in any of the
@@ -425,7 +425,7 @@
 parameter then one may add IP addresses to the set with a specific 
 timeout value using the syntax 
 .I IP:timeout-value.
-Similarly to the hash types, the iptree type of sets can store up to 65535
+Similarly to the hash types, the iptree type of sets can store up to 65536
 entries.
 .SS iptreemap
 The iptreemap set type uses a tree to store IP addresses or networks, 
@@ -462,6 +462,8 @@
 Joakim Axelsson, Patrick Schaaf and Martin Josefsson.
 .P
 Sven Wegener wrote the iptreemap type.
+.SH LAST REMARK
+.BR "I stand on the shoulder of giants."
 .\" .. and did I mention that we are incredibly cool people?
 .\" .. sexy, too ..
 .\" .. witty, charming, powerful ..

Modified: trunk/ipset/ipset.c
===================================================================
--- trunk/ipset/ipset.c	2008-06-10 06:44:09 UTC (rev 7542)
+++ trunk/ipset/ipset.c	2008-06-12 09:22:25 UTC (rev 7543)
@@ -1638,7 +1638,7 @@
 	DP("(%s, %s) -> %s", set ? set->name : IPSET_TOKEN_ALL, adt, binding);
 
 	/* Ugly */
-	if (strcmp(set->settype->typename, "iptreemap") == 0)
+	if (set && strcmp(set->settype->typename, "iptreemap") == 0)
 		exit_error(PARAMETER_PROBLEM,
 			"iptreemap type of sets cannot be used at binding operations\n");
 	/* Alloc memory for the data to send */

Modified: trunk/ipset/ipset_iphash.c
===================================================================
--- trunk/ipset/ipset_iphash.c	2008-06-10 06:44:09 UTC (rev 7542)
+++ trunk/ipset/ipset_iphash.c	2008-06-12 09:22:25 UTC (rev 7543)
@@ -191,7 +191,7 @@
 	
 	return bits;
 }
-	
+
 void printheader(struct set *set, unsigned options)
 {
 	struct ip_set_iphash *mysetdata =

Modified: trunk/ipset/ipset_nethash.c
===================================================================
--- trunk/ipset/ipset_nethash.c	2008-06-10 06:44:09 UTC (rev 7542)
+++ trunk/ipset/ipset_nethash.c	2008-06-12 09:22:25 UTC (rev 7543)
@@ -173,22 +173,6 @@
 	map->resize = header->resize;
 }
 
-unsigned int
-mask_to_bits(ip_set_ip_t mask)
-{
-	unsigned int bits = 32;
-	ip_set_ip_t maskaddr;
-	
-	if (mask == 0xFFFFFFFF)
-		return bits;
-	
-	maskaddr = 0xFFFFFFFE;
-	while (--bits >= 0 && maskaddr != mask)
-		maskaddr <<= 1;
-	
-	return bits;
-}
-	
 void printheader(struct set *set, unsigned options)
 {
 	struct ip_set_nethash *mysetdata =

Added: trunk/ipset/tests/init.t
===================================================================
--- trunk/ipset/tests/init.t	                        (rev 0)
+++ trunk/ipset/tests/init.t	2008-06-12 09:22:25 UTC (rev 7543)
@@ -0,0 +1,7 @@
+# Load in the ip_set kernel module
+0 modprobe ip_set
+# List our test set: the testsuite fails if it exists
+1 ipset -L test >/dev/null
+# Delete our test set: the testsuite fails if it exists
+1 ipset -X test
+# eof

Added: trunk/ipset/tests/iphash.t
===================================================================
--- trunk/ipset/tests/iphash.t	                        (rev 0)
+++ trunk/ipset/tests/iphash.t	2008-06-12 09:22:25 UTC (rev 7543)
@@ -0,0 +1,35 @@
+# IP: Create a set 
+0 ipset -N test iphash --hashsize 128 
+# IP: Add first random value
+0 ipset -A test 2.0.0.1
+# IP: Add second random value
+0 ipset -A test 192.168.68.69
+# IP: Test first random value
+0 ipset -T test 2.0.0.1
+# IP: Test second random value
+0 ipset -T test 192.168.68.69
+# IP: Test value not added to the set
+1 ipset -T test 2.0.0.2
+# IP: Delete test set
+0 ipset -X test
+# IP: Restore values so that rehashing is triggered
+0 ipset -R < iphash.t.restore
+# IP: Check that all values are restored
+0 (egrep -v '#|-N' iphash.t.restore | sort > .foo.1) && (ipset -S test | egrep -v '#|-N' | sort > .foo.2) && cmp .foo.1 .foo.2 && rm .foo.*
+# IP: Delete test set
+0 ipset -X test
+# Network: Create a set 
+0 ipset -N test iphash --hashsize 128 --netmask 24
+# Network: Add first random network
+0 ipset -A test 2.0.0.1
+# Network: Add second random network
+0 ipset -A test 192.168.68.69
+# Network: Test first random value
+0 ipset -T test 2.0.0.255
+# Network: Test second random value
+0 ipset -T test 192.168.68.95
+# Network: Test value not added to the set
+1 ipset -T test 2.0.1.0
+# Network: Delete test set
+0 ipset -X test
+# eof

Added: trunk/ipset/tests/iphash.t.restore
===================================================================
--- trunk/ipset/tests/iphash.t.restore	                        (rev 0)
+++ trunk/ipset/tests/iphash.t.restore	2008-06-12 09:22:25 UTC (rev 7543)
@@ -0,0 +1,131 @@
+-N test iphash --hashsize 128
+-A test 10.0.0.0
+-A test 10.0.0.1
+-A test 10.0.0.10
+-A test 10.0.0.100
+-A test 10.0.0.101
+-A test 10.0.0.102
+-A test 10.0.0.103
+-A test 10.0.0.104
+-A test 10.0.0.105
+-A test 10.0.0.106
+-A test 10.0.0.107
+-A test 10.0.0.108
+-A test 10.0.0.109
+-A test 10.0.0.11
+-A test 10.0.0.110
+-A test 10.0.0.111
+-A test 10.0.0.112
+-A test 10.0.0.113
+-A test 10.0.0.114
+-A test 10.0.0.115
+-A test 10.0.0.116
+-A test 10.0.0.117
+-A test 10.0.0.118
+-A test 10.0.0.119
+-A test 10.0.0.12
+-A test 10.0.0.120
+-A test 10.0.0.121
+-A test 10.0.0.122
+-A test 10.0.0.123
+-A test 10.0.0.124
+-A test 10.0.0.125
+-A test 10.0.0.126
+-A test 10.0.0.127
+-A test 10.0.0.128
+-A test 10.0.0.13
+-A test 10.0.0.14
+-A test 10.0.0.15
+-A test 10.0.0.16
+-A test 10.0.0.17
+-A test 10.0.0.18
+-A test 10.0.0.19
+-A test 10.0.0.2
+-A test 10.0.0.20
+-A test 10.0.0.21
+-A test 10.0.0.22
+-A test 10.0.0.23
+-A test 10.0.0.24
+-A test 10.0.0.25
+-A test 10.0.0.26
+-A test 10.0.0.27
+-A test 10.0.0.28
+-A test 10.0.0.29
+-A test 10.0.0.3
+-A test 10.0.0.30
+-A test 10.0.0.31
+-A test 10.0.0.32
+-A test 10.0.0.33
+-A test 10.0.0.34
+-A test 10.0.0.35
+-A test 10.0.0.36
+-A test 10.0.0.37
+-A test 10.0.0.38
+-A test 10.0.0.39
+-A test 10.0.0.4
+-A test 10.0.0.40
+-A test 10.0.0.41
+-A test 10.0.0.42
+-A test 10.0.0.43
+-A test 10.0.0.44
+-A test 10.0.0.45
+-A test 10.0.0.46
+-A test 10.0.0.47
+-A test 10.0.0.48
+-A test 10.0.0.49
+-A test 10.0.0.5
+-A test 10.0.0.50
+-A test 10.0.0.51
+-A test 10.0.0.52
+-A test 10.0.0.53
+-A test 10.0.0.54
+-A test 10.0.0.55
+-A test 10.0.0.56
+-A test 10.0.0.57
+-A test 10.0.0.58
+-A test 10.0.0.59
+-A test 10.0.0.6
+-A test 10.0.0.60
+-A test 10.0.0.61
+-A test 10.0.0.62
+-A test 10.0.0.63
+-A test 10.0.0.64
+-A test 10.0.0.65
+-A test 10.0.0.66
+-A test 10.0.0.67
+-A test 10.0.0.68
+-A test 10.0.0.69
+-A test 10.0.0.7
+-A test 10.0.0.70
+-A test 10.0.0.71
+-A test 10.0.0.72
+-A test 10.0.0.73
+-A test 10.0.0.74
+-A test 10.0.0.75
+-A test 10.0.0.76
+-A test 10.0.0.77
+-A test 10.0.0.78
+-A test 10.0.0.79
+-A test 10.0.0.8
+-A test 10.0.0.80
+-A test 10.0.0.81
+-A test 10.0.0.82
+-A test 10.0.0.83
+-A test 10.0.0.84
+-A test 10.0.0.85
+-A test 10.0.0.86
+-A test 10.0.0.87
+-A test 10.0.0.88
+-A test 10.0.0.89
+-A test 10.0.0.9
+-A test 10.0.0.90
+-A test 10.0.0.91
+-A test 10.0.0.92
+-A test 10.0.0.93
+-A test 10.0.0.94
+-A test 10.0.0.95
+-A test 10.0.0.96
+-A test 10.0.0.97
+-A test 10.0.0.98
+-A test 10.0.0.99
+COMMIT

Added: trunk/ipset/tests/ipmap.t
===================================================================
--- trunk/ipset/tests/ipmap.t	                        (rev 0)
+++ trunk/ipset/tests/ipmap.t	2008-06-12 09:22:25 UTC (rev 7543)
@@ -0,0 +1,85 @@
+# Range: Try to create from an invalid range
+2 ipset -N test ipmap --from 2.0.0.1 --to 2.1.0.1
+# Range: Create a set from a valid range
+0 ipset -N test ipmap --from 2.0.0.1 --to 2.1.0.0
+# Range: Add lower boundary
+0 ipset -A test 2.0.0.1
+# Range: Add upper boundary
+0 ipset -A test 2.1.0.0
+# Range: Test lower boundary
+0 ipset -T test 2.0.0.1
+# Range: Test upper boundary
+0 ipset -T test 2.1.0.0
+# Range: Test value not added to the set
+1 ipset -T test 2.0.0.2
+# Range: Test value before lower boundary
+1 ipset -T test 2.0.0.0
+# Range: Test value after upper boundary
+1 ipset -T test 2.1.0.1
+# Range: Try to add value before lower boundary
+1 ipset -A test 2.0.0.0
+# Range: Try to add value after upper boundary
+1 ipset -A test 2.1.0.1
+# Range: Delete test test
+0 ipset -X test
+# Network: Try to create a set from an invalid network
+2 ipset -N test ipmap --network 2.0.0.0/15
+# Network: Create a set from a valid network
+0 ipset -N test ipmap --network 2.0.0.0/16
+# Network: Add lower boundary
+0 ipset -A test 2.0.0.0
+# Network: Add upper boundary
+0 ipset -A test 2.0.255.255
+# Network: Test lower boundary
+0 ipset -T test 2.0.0.0
+# Network: Test upper boundary
+0 ipset -T test 2.0.255.255
+# Network: Test value not added to the set
+1 ipset -T test 2.0.0.1
+# Network: Test value before lower boundary
+1 ipset -T test 1.255.255.255
+# Network: Test value after upper boundary
+1 ipset -T test 2.1.0.0
+# Network: Try to add value before lower boundary
+1 ipset -A test 1.255.255.255
+# Network: Try to add value after upper boundary
+1 ipset -A test 2.1.0.0
+# Network: Delete test test
+0 ipset -X test
+# Subnets: Create a set to store networks
+0 ipset -N test ipmap --network 10.0.0.0/8 --netmask 24
+# Subnets: Add lower boundary
+0 ipset -A test 10.0.0.0
+# Subnets: Add upper boundary
+0 ipset -A test 10.255.255.255
+# Subnets: Test lower boundary
+0 ipset -T test 10.0.0.255
+# Subnets: Test upper boundary
+0 ipset -T test 10.255.255.0
+# Subnets: Test value not added to the set
+1 ipset -T test 10.1.0.0
+# Subnets: Test value before lower boundary
+1 ipset -T test 9.255.255.255
+# Subnets: Test value after upper boundary
+1 ipset -T test 11.0.0.0
+# Subnets: Try to add value before lower boundary
+1 ipset -A test 9.255.255.255
+# Subnets: Try to add value after upper boundary
+1 ipset -A test 11.0.0.0
+# Subnets: Delete test test
+0 ipset -X test
+# Full: Create full IPv4 space with /16 networks
+0 ipset -N test ipmap --network 0.0.0.0/0 --netmask 16
+# Full: Add lower boundary
+0 ipset -A test 0.0.255.255
+# Full: Add upper boundary
+0 ipset -A test 255.255.0.0
+# Full: Test lower boundary
+0 ipset -T test 0.0.0.0
+# Full: Test upper boundary
+0 ipset -T test 255.255.255.255
+# Full: Test value not added to the set
+1 ipset -T test 0.1.0.0
+# Full: Delete test test
+0 ipset -X test
+# eof

Added: trunk/ipset/tests/ipporthash.t
===================================================================
--- trunk/ipset/tests/ipporthash.t	                        (rev 0)
+++ trunk/ipset/tests/ipporthash.t	2008-06-12 09:22:25 UTC (rev 7543)
@@ -0,0 +1,53 @@
+# Range: Try to create from an invalid range
+2 ipset -N test ipporthash --from 2.0.0.1 --to 2.1.0.1
+# Range: Create a set from a valid range
+0 ipset -N test ipporthash --from 2.0.0.1 --to 2.1.0.0
+# Range: Add lower boundary
+0 ipset -A test 2.0.0.1:5
+# Range: Add upper boundary
+0 ipset -A test 2.1.0.0:128
+# Range: Test lower boundary
+0 ipset -T test 2.0.0.1:5
+# Range: Test upper boundary
+0 ipset -T test 2.1.0.0:128
+# Range: Test value not added to the set
+1 ipset -T test 2.0.0.1:4
+# Range: Test value not added to the set
+1 ipset -T test 2.0.0.1:6
+# Range: Test value before lower boundary
+1 ipset -T test 2.0.0.0:5
+# Range: Test value after upper boundary
+1 ipset -T test 2.1.0.1:128
+# Range: Try to add value before lower boundary
+1 ipset -A test 2.0.0.0:5
+# Range: Try to add value after upper boundary
+1 ipset -A test 2.1.0.1:128
+# Range: Delete test test
+0 ipset -X test
+# Network: Try to create a set from an invalid network
+2 ipset -N test ipporthash --network 2.0.0.0/15
+# Network: Create a set from a valid network
+0 ipset -N test ipporthash --network 2.0.0.0/16
+# Network: Add lower boundary
+0 ipset -A test 2.0.0.0:5
+# Network: Add upper boundary
+0 ipset -A test 2.0.255.255:128
+# Network: Test lower boundary
+0 ipset -T test 2.0.0.0:5
+# Network: Test upper boundary
+0 ipset -T test 2.0.255.255:128
+# Network: Test value not added to the set
+1 ipset -T test 2.0.0.0:4
+# Network: Test value not added to the set
+1 ipset -T test 2.0.0.0:6
+# Network: Test value before lower boundary
+1 ipset -T test 1.255.255.255:5
+# Network: Test value after upper boundary
+1 ipset -T test 2.1.0.0:128
+# Network: Try to add value before lower boundary
+1 ipset -A test 1.255.255.255:5
+# Network: Try to add value after upper boundary
+1 ipset -A test 2.1.0.0:128
+# Network: Delete test test
+0 ipset -X test
+# eof

Added: trunk/ipset/tests/iptree.t
===================================================================
--- trunk/ipset/tests/iptree.t	                        (rev 0)
+++ trunk/ipset/tests/iptree.t	2008-06-12 09:22:25 UTC (rev 7543)
@@ -0,0 +1,43 @@
+# Static: Create a set without timeout
+0 ipset -N test iptree
+# Static: Add first random entry
+0 ipset -A test 2.0.0.1
+# Static: Add second random value
+0 ipset -A test 192.168.68.69
+# Static: Test first random value
+0 ipset -T test 2.0.0.1
+# Static: Test second random value
+0 ipset -T test 192.168.68.69
+# Static: Test value not added to the set
+1 ipset -T test 2.0.0.2
+# Static: Test value not added to the set
+1 ipset -T test 192.168.68.70
+# Static: Delete test test
+0 ipset -X test
+# Timeout: Create a set with a timeout parameter
+0 ipset -N test iptree --timeout 5
+# Timeout: Add first random entry
+0 ipset -A test 2.0.0.1
+# Timeout: Add second random value
+0 ipset -A test 192.168.68.69
+# Timeout: Test first random value
+0 ipset -T test 2.0.0.1
+# Timeout: Test second random value
+0 ipset -T test 192.168.68.69
+# Timeout: Test value not added to the set
+1 ipset -T test 2.0.0.2
+# Timeout: Test value not added to the set
+1 ipset -T test 192.168.68.70
+# Timeout: Sleep 5s so that entries can time out
+0 sleep 5
+# Timeout: Test first random value
+1 ipset -T test 2.0.0.1
+# Timeout: Test second random value
+1 ipset -T test 192.168.68.69
+# Timeout: Test value not added to the set
+1 ipset -T test 2.0.0.2
+# Timeout: Test value not added to the set
+1 ipset -T test 192.168.68.70
+# Timeout: Delete test test
+0 ipset -X test
+# eof

Added: trunk/ipset/tests/iptreemap.t
===================================================================
--- trunk/ipset/tests/iptreemap.t	                        (rev 0)
+++ trunk/ipset/tests/iptreemap.t	2008-06-12 09:22:25 UTC (rev 7543)
@@ -0,0 +1,45 @@
+# Create a set without timeout
+0 ipset -N test iptreemap
+# Add first random IP entry
+0 ipset -A test 2.0.0.1
+# Add second random IP entry
+0 ipset -A test 192.168.68.69
+# Test first random IP entry
+0 ipset -T test 2.0.0.1
+# Test second random IP entry
+0 ipset -T test 192.168.68.69
+# Test value not added to the set
+1 ipset -T test 2.0.0.2
+# Test value not added to the set
+1 ipset -T test 192.168.68.70
+# Add IP range
+0 ipset -A test 3.0.0.0:3.0.0.2
+# Test the three members of the range: first
+0 ipset -T test 3.0.0.0
+# Test the three members of the range: second
+0 ipset -T test 3.0.0.1
+# Test the three members of the range: third
+0 ipset -T test 3.0.0.2
+# Delete the middle of the range
+0 ipset -D test 3.0.0.1
+# Test the range: first
+0 ipset -T test 3.0.0.0
+# Test the range: second
+1 ipset -T test 3.0.0.1
+# Test the range: third
+0 ipset -T test 3.0.0.2
+# Add a network block
+0 ipset -A test 192.168.68.69/27
+# Test the lower bound of the network
+0 ipset -T test 192.168.68.64
+# Test the upper bound of the network
+0 ipset -T test 192.168.68.95
+# Test element from the middle
+0 ipset -T test 192.168.68.71
+# Delete a network from the middle
+0 ipset -D test 192.168.68.70/30
+# Test element from the middle
+1 ipset -T test 192.168.68.71
+# Delete test test
+0 ipset -X test
+# eof

Added: trunk/ipset/tests/macipmap.t
===================================================================
--- trunk/ipset/tests/macipmap.t	                        (rev 0)
+++ trunk/ipset/tests/macipmap.t	2008-06-12 09:22:25 UTC (rev 7543)
@@ -0,0 +1,49 @@
+# Range: Try to create from an invalid range
+2 ipset -N test macipmap --from 2.0.0.1 --to 2.1.0.1
+# Range: Create a set from a valid range
+0 ipset -N test macipmap --from 2.0.0.1 --to 2.1.0.0
+# Range: Add lower boundary
+0 ipset -A test 2.0.0.1
+# Range: Add upper boundary
+0 ipset -A test 2.1.0.0
+# Range: Test lower boundary
+0 ipset -T test 2.0.0.1
+# Range: Test upper boundary
+0 ipset -T test 2.1.0.0
+# Range: Test value not added to the set
+1 ipset -T test 2.0.0.2
+# Range: Test value before lower boundary
+1 ipset -T test 2.0.0.0
+# Range: Test value after upper boundary
+1 ipset -T test 2.1.0.1
+# Range: Try to add value before lower boundary
+1 ipset -A test 2.0.0.0
+# Range: Try to add value after upper boundary
+1 ipset -A test 2.1.0.1
+# Range: Delete test test
+0 ipset -X test
+# Network: Try to create a set from an invalid network
+2 ipset -N test macipmap --network 2.0.0.0/15
+# Network: Create a set from a valid network
+0 ipset -N test macipmap --network 2.0.0.0/16
+# Network: Add lower boundary
+0 ipset -A test 2.0.0.0
+# Network: Add upper boundary
+0 ipset -A test 2.0.255.255
+# Network: Test lower boundary
+0 ipset -T test 2.0.0.0
+# Network: Test upper boundary
+0 ipset -T test 2.0.255.255
+# Network: Test value not added to the set
+1 ipset -T test 2.0.0.1
+# Network: Test value before lower boundary
+1 ipset -T test 1.255.255.255
+# Network: Test value after upper boundary
+1 ipset -T test 2.1.0.0
+# Network: Try to add value before lower boundary
+1 ipset -A test 1.255.255.255
+# Network: Try to add value after upper boundary
+1 ipset -A test 2.1.0.0
+# Network: Delete test test
+0 ipset -X test
+# eof

Added: trunk/ipset/tests/nethash.t
===================================================================
--- trunk/ipset/tests/nethash.t	                        (rev 0)
+++ trunk/ipset/tests/nethash.t	2008-06-12 09:22:25 UTC (rev 7543)
@@ -0,0 +1,15 @@
+# Create a set 
+0 ipset -N test nethash --hashsize 128 
+# Add first random network
+0 ipset -A test 2.0.0.1/24
+# Add second random network
+0 ipset -A test 192.168.68.69/27
+# Test first random value
+0 ipset -T test 2.0.0.255
+# Test second random value
+0 ipset -T test 192.168.68.95
+# Test value not added to the set
+1 ipset -T test 2.0.1.0
+# Delete test set
+0 ipset -X test
+# eof

Added: trunk/ipset/tests/portmap.t
===================================================================
--- trunk/ipset/tests/portmap.t	                        (rev 0)
+++ trunk/ipset/tests/portmap.t	2008-06-12 09:22:25 UTC (rev 7543)
@@ -0,0 +1,37 @@
+# Range: Create a set from a valid range
+0 ipset -N test portmap --from 1 --to 1024
+# Range: Add lower boundary
+0 ipset -A test 1
+# Range: Add upper boundary
+0 ipset -A test 1024
+# Range: Test lower boundary
+0 ipset -T test 1
+# Range: Test upper boundary
+0 ipset -T test 1024
+# Range: Test value not added to the set
+1 ipset -T test 1023
+# Range: Test value before lower boundary
+1 ipset -T test 0
+# Range: Test value after upper boundary
+1 ipset -T test 1025
+# Range: Try to add value before lower boundary
+1 ipset -A test 0
+# Range: Try to add value after upper boundary
+1 ipset -A test 1025
+# Range: Delete test test
+0 ipset -X test
+# Full: Create a full set of ports
+0 ipset -N test portmap --from 0 --to 65535
+# Full: Add lower boundary
+0 ipset -A test 0
+# Full: Add upper boundary
+0 ipset -A test 65535
+# Full: Test lower boundary
+0 ipset -T test 0
+# Full: Test upper boundary
+0 ipset -T test 65535
+# Full: Test value not added to the set
+1 ipset -T test 1
+# Full: Delete test test
+0 ipset -X test
+# eof

Added: trunk/ipset/tests/runtest.sh
===================================================================
--- trunk/ipset/tests/runtest.sh	                        (rev 0)
+++ trunk/ipset/tests/runtest.sh	2008-06-12 09:22:25 UTC (rev 7543)
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+tests="init"
+tests+=" ipmap macipmap portmap"
+tests+=" iphash nethash ipporthash"
+tests+=" iptree iptreemap"
+
+for types in $tests; do
+    ipset -X test >/dev/null 2>&1
+    while read ret cmd; do
+	case $ret in
+	    \#)
+	    	if [ "$cmd" = "eof" ]; then
+	    		break
+	    	fi
+	    	what=$cmd
+		continue
+		;;
+	    *)
+		;;
+	esac
+	echo -ne "$types: $what: "
+	eval $cmd >/dev/null 2>&1
+	r=$?
+	# echo $ret $r
+	if [ "$ret" = "$r" ]; then
+		echo "OK"
+	else
+		echo "FAILED"
+		echo "Failed test: $cmd"
+		exit 1
+	fi
+	# sleep 1
+    done < $types.t
+done
+for x in $tests; do
+	case $x in
+	init)
+		;;
+	*)
+		rmmod ip_set_$x >/dev/null 2>&1
+		;;
+	esac
+done
+rmmod ip_set >/dev/null 2>&1
+echo "All tests are OK"
+


Property changes on: trunk/ipset/tests/runtest.sh
___________________________________________________________________
Name: svn:executable
   + *




More information about the netfilter-cvslog mailing list