]> git.ipfire.org Git - thirdparty/ipset.git/commitdiff
4.1 version released v4.1
authorJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Wed, 11 Nov 2009 19:29:31 +0000 (20:29 +0100)
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Wed, 11 Nov 2009 19:29:31 +0000 (20:29 +0100)
ChangeLog
Makefile
ipset.8
kernel/ChangeLog
kernel/include/linux/netfilter_ipv4/ip_set_hashes.h
kernel/ip_set.c
kernel/ip_set_ipportiphash.c
kernel/ip_set_ipportnethash.c

index 91264580a1e2ff48928b33e6fe99399ff31a1a35..13707ed2546f7f7bc2c16c1fdaf68aa139cfca49 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+4.1
+  - Manpage fixes and corrections (Jan Engelhardt)
+
 4.0
   - New protocol is introduced to handle aligment issues properly
     (bug reported by Georg Chini)
index c8bf0ea61cdb14a8e7cf04b90e4fa5c5da7fda9a..b0f337efa3036b749bc2e8736daa88a162b7e7a2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -20,7 +20,7 @@ ifndef V
 V=0
 endif
 
-IPSET_VERSION:=4.0
+IPSET_VERSION:=4.1
 
 PREFIX:=/usr/local
 LIBDIR:=$(PREFIX)/lib
diff --git a/ipset.8 b/ipset.8
index 55e5d9bf5b3c040b3181d34cd6ad0e62cda168d3..fa73298ca1c4cc17a9c7f9d1f3ed81f9baeb8199 100644 (file)
--- a/ipset.8
+++ b/ipset.8
 .\"
 .\"
 .SH NAME
-ipset \- administration tool for IP sets
+ipset \(em administration tool for IP sets
 .SH SYNOPSIS
-.BR "ipset -N " "set type-specification [options]"
-.br
-.BR "ipset -[XFLSHh] " "[set] [options]"
-.br
-.BR "ipset -[EW] " "from-set to-set"
-.br
-.BR "ipset -[ADT] " "set entry"
-.br
-.BR "ipset -R "
-.br
-.BR "ipset -[Vv] "
+.PP
+\fBipset \-N\fP \fIset\fP \fItype-specification\fP [\fIoptions\fP...]
+.PP
+\fBipset\fP {\fB\-F\fP|\fB\-H\fP|\fB\-L\fP|\fB\-S\fP|\fB\-X\fP} [\fIset\fP]
+[\fIoptions\fP...]
+.PP
+\fBipset\fP {\fB\-E\fP|\fB\-W\fP} \fIfrom-set\fP \fIto-set\fP
+.PP
+\fBipset\fP {\fB\-A\fP|\fB\-D\fP|\fB\-T\fP} \fIset\fP \fIentry\fP
+.PP
+\fBipset \-R\fP
+.PP
+\fBipset\fP {\fB-V\fP|\fB\-v\fP}
 .SH DESCRIPTION
 .B ipset
 is used to set up, maintain and inspect so called IP sets in the Linux
@@ -53,42 +55,42 @@ need to use only enough letters to ensure that
 .B ipset
 can differentiate it from all other options.
 .TP
-.BI "-N, --create " "\fIsetname\fP type type-specific-options"
+\fB\-N\fP, \fB\-\-create\fP \fIsetname\fP \fItype\fP \fItype-specific-options\fP
 Create a set identified with setname and specified type. 
 Type-specific options must be supplied.
 .TP
-.BI "-X, --destroy " "[\fIsetname\fP]"
+\fB\-X\fP, \fB\-\-destroy\fP [\fIsetname\fP]
 Destroy the specified set or all the sets if none is given.
 
 If the set has got references, nothing is done.
 .TP
-.BI "-F, --flush " "[\fIsetname\fP]"
+\fB\-F\fP, \fB\-\-flush\fP [\fIsetname\fP]
 Delete all entries from the specified set or flush
 all sets if none is given.
 .TP
-.BI "-E, --rename " "\fIfrom-setname\fP \fIto-setname\fP"
+\fB\-E\fP, \fB\-\-rename\fP \fIfrom-setname\fP \fIto-setname\fP
 Rename a set. Set identified by to-setname must not exist.
 .TP
-.BI "-W, --swap " "\fIfrom-setname\fP \fIto-setname\fP"
+\fB\-W\fP, \fB\-\-swap\fP \fIfrom-setname\fP \fIto-setname\fP
 Swap the content of two sets, or in another words, 
 exchange the name of two sets. The referred sets must exist and
 identical type of sets can be swapped only.
 .TP
-.BI "-L, --list " "[\fIsetname\fP]"
+\fB\-L\fP, \fB\-\-list\fP [\fIsetname\fP]
 List the entries for the specified set, or for
 all sets if none is given. The
-.B "-r, --resolve"
+\fB\-r\fP/\fB\-\-resolve\fP
 option can be used to force name lookups (which may be slow). When the
-.B "-s, --sorted"
+\fB\-s\fP/\fB\-\-sorted\fP
 option is given, the entries are listed sorted (if the given set
 type supports the operation).
 .TP
-.BI "-S, --save " "[\fIsetname\fP]"
+\fB\-S\fP, \fB\-\-save\fP [\fIsetname\fP]
 Save the given set, or all sets if none is given
-to stdout in a format that --restore can read.
+to stdout in a format that \fB\-\-restore\fP can read.
 .TP
-.BI "-R, --restore "
-Restore a saved session generated by --save. The saved session
+\fB\-R\fP, \fB\-\-restore\fP
+Restore a saved session generated by \fB\-\-save\fP. The saved session
 can be fed from stdin.
 
 When generating a session file please note that the supported commands
@@ -97,27 +99,27 @@ the set, then add all elements. Then create the next set, add all its elements
 and so on. Also, it is a restore operation, so the sets being restored must 
 not exist.
 .TP
-.BI "-A, --add " "\fIsetname\fP \fIIP\fP"
-Add an IP entry to a set.
+\fB\-A\fP, \fB\-\-add\fP \fIsetname\fP \fIentry\fP
+Add an entry to a set.
 .TP
-.BI "-D, --del " "\fIsetname\fP \fIIP\fP"
-Delete an IP entry from a set. 
+\fB\-D\fP, \fB\-\-del\fP \fIsetname\fP \fIentry\fP
+Delete an entry from a set.
 .TP
-.BI "-T, --test " "\fIsetname\fP \fIIP
-Test wether an IP entry is in a set or not. Exit status number is zero
-if the tested IP is in the set and nonzero if it is missing from 
+\fB-T\fP, \fB\-\-test\fP \fIsetname\fP \fIentry\fP
+Test wether an entry is in a set or not. Exit status number is zero
+if the tested entry is in the set and nonzero if it is missing from
 the set.
 .TP
-.BI "-H, --help " "[settype]"
+\fB\-H\fP, \fB\-\-help\fP [\fIsettype\fP]
 Print help and settype specific help if settype specified.
 .TP
-.BI "-V, -v, --version "
+\fB\-V\fP, \fB\-v\fP, \fB\-\-version\fP
 Print program version and protocol version.
 .P
 .SS "OTHER OPTIONS"
 The following additional options can be specified:
 .TP
-.B "-r, --resolve"
+\fB\-r\fP, \fB\-\-resolve\fP
 When listing sets, enforce name lookup. The 
 program will try to display the IP entries resolved to 
 host names or services (whenever applicable), which can trigger
@@ -126,14 +128,14 @@ slow
 DNS 
 lookups.
 .TP
-.B "-s, --sorted"
+\fB\-s\fP, \fB\-\-sorted\fP
 Sorted output. When listing sets, entries are listed sorted.
 .TP
-.B "-n, --numeric"
+\fB\-n\fP, \fB\-\-numeric\fP
 Numeric output. When listing sets, IP addresses and 
 port numbers will be printed in numeric format. This is the default.
 .TP
-.B "-q, --quiet"
+\fB\-q\fP, \fB\-\-quiet\fP
 Suppress any output to stdout and stderr. ipset will still return
 possible errors.
 .SH SET TYPES
@@ -143,7 +145,7 @@ The ipmap set type uses a memory range, where each bit represents
 one IP address. An ipmap set can store up to 65536 (B-class network)
 IP addresses. The ipmap set type is very fast and memory cheap, great
 for use when one want to match certain IPs in a range. If the optional
-.B "--netmask"
+\fB\-\-netmask\fP
 parameter is specified with a CIDR netmask value between 1-31 then
 network addresses are stored in the given set: i.e an
 IP address will be in the set if the network address, which is resulted
@@ -151,20 +153,20 @@ by masking the address with the specified netmask, can be found in the set.
 .P
 Options to use when creating an ipmap set:
 .TP
-.BR "--from " from-IP
+\fB\-\-from\fP \fIfrom-addr\fP
 .TP
-.BR "--to " to-IP
-Create an ipmap set from the specified range.
+\fB\-\-to\fP \fIto-addr\fP
+Create an ipmap set from the specified address range.
 .TP
-.BR "--network " IP/mask
+\fB\-\-network\fP \fIaddr\fP\fB/\fP\fImask\fP
 Create an ipmap set from the specified network.
 .TP
-.BR "--netmask " CIDR-netmask
+\fB\-\-netmask\fP \fIprefixlen\fP
 When the optional
-.B "--netmask"
+\fB\-\-netmask\fP
 parameter specified, network addresses will be 
-stored in the set instead of IP addresses, and the from-IP parameter
-must be a network address. The CIDR-netmask value must be between 1-31.
+stored in the set instead of IP addresses, and the \fIfrom-addr\fP parameter
+must be a network address. The \fIprefixlen\fP value must be between 1-31.
 .PP
 Example:
 .IP
@@ -174,33 +176,31 @@ The macipmap set type uses a memory range, where each 8 bytes
 represents one IP and a MAC addresses. A macipmap set type can store
 up to 65536 (B-class network) IP addresses with MAC.
 When adding an entry to a macipmap set, you must specify the entry as
-.I IP,MAC.
+"\fIaddress\fP\fB,\fP\fImac\fP".
 When deleting or testing macipmap entries, the
-.I ,MAC
+"\fB,\fP\fImac\fP"
 part is not mandatory.
 .P
 Options to use when creating an macipmap set:
 .TP
-.BR "--from " from-IP
+\fB\-\-from\fP \fIfrom-addr\fP
 .TP
-.BR "--to " to-IP
-Create a macipmap set from the specified range.
+\fB\-\-to\fP \fIto-addr\fP
+Create a macipmap set from the specified address range.
 .TP
-.BR "--network " IP/mask
+\fB\-\-network\fP \fIaddr\fP\fB/\fP\fImask\fP
 Create a macipmap set from the specified network.
 .TP
-.BR "--matchunset"
+\fB\-\-matchunset\fP
 When the optional
-.B "--matchunset"
+\fB\-\-matchunset\fP
 parameter specified, IP addresses which could be stored 
 in the set but not set yet, will always match.
 .P
 Please note, the 
-.I
-set
+"set"
 and
-.I
-SET
+"SET"
 netfilter kernel modules
 .B
 always
@@ -213,42 +213,41 @@ The portmap set type is very fast and memory cheap.
 .P
 Options to use when creating an portmap set:
 .TP
-.BR "--from " from-port
+\fB\-\-from\fP \fIfrom-port\fP
 .TP
-.BR "--to " to-port
-Create a portmap set from the specified range.
+\fB\-\-to\fP \fIto-port\fP
+Create a portmap set from the specified port range.
 .SS iphash
 The iphash set type uses a hash to store IP addresses.
 In order to avoid clashes in the hash double-hashing, and as a last
 resort, dynamic growing of the hash performed. The iphash set type is
 great to store random addresses. If the optional
-.B "--netmask"
-parameter is specified with a CIDR netmask value between 1-31 then
+\fB\-\-netmask\fP
+parameter is specified with a CIDR prefix length value between 1-31 then
 network addresses are stored in the given set: i.e an
 IP address will be in the set if the network address, which is resulted
 by masking the address with the specified netmask, can be found in the set.
 .P
 Options to use when creating an iphash set:
 .TP
-.BR "--hashsize " hashsize
+\fB\-\-hashsize\fP \fIhashsize\fP
 The initial hash size (default 1024)
 .TP
-.BR "--probes " probes
+\fB\-\-probes\fP \fIprobes\fP
 How many times try to resolve clashing at adding an IP to the hash 
 by double-hashing (default 8).
 .TP
-.BR "--resize " percent
+\fB\-\-resize\fP \fIpercent\fP
 Increase the hash size by this many percent (default 50) when adding
 an IP to the hash could not be performed after
-.B
-probes
+\fIprobes\fP
 number of double-hashing. 
 .TP
-.BR "--netmask " CIDR-netmask
+\fB\-\-netmask\fP \fIprefixlen\fP
 When the optional
-.B "--netmask"
+\fB\-\-netmask\fP
 parameter specified, network addresses will be 
-stored in the set instead of IP addresses. The CIDR-netmask value must
+stored in the set instead of IP addresses. The \fIprefixlen\fP value must
 be between 1-31.
 .P
 The iphash type of sets can store up to 65536 entries. If a set is full,
@@ -257,11 +256,9 @@ no new entries can be added to it.
 Sets created by zero valued resize parameter won't be resized at all.
 The lookup time in an iphash type of set grows approximately linearly with
 the value of the 
-.B
-probes
+\fIprobes\fP
 parameter. In general higher 
-.B
-probe
+\fIprobes\fP
 value results better utilized hash while smaller value
 produces larger, sparser hash.
 .PP
@@ -272,24 +269,23 @@ ipset \-N test iphash \-\-probes 2
 The nethash set type uses a hash to store different size of
 network addresses. The
 .I
-IP
-"address" used in the ipset commands must be in the form
-.I
-IP-address/cidr-size
-where the CIDR block size must be in the inclusive range of 1-31.
+entry
+used in the ipset commands must be in the form
+"\fIaddress\fP\fB/\fP\fIprefixlen\fP"
+where prefixlen must be in the inclusive range of 1-31.
 In order to avoid clashes in the hash 
 double-hashing, and as a last resort, dynamic growing of the hash performed.
 .P
 Options to use when creating an nethash set:
 .TP
-.BR "--hashsize " hashsize
+\fB\-\-hashsize\fP \fIhashsize\fP
 The initial hash size (default 1024)
 .TP
-.BR "--probes " probes
+\fB\-\-probes\fP \fIprobes\fP
 How many times try to resolve clashing at adding an IP to the hash 
 by double-hashing (default 4).
 .TP
-.BR "--resize " percent
+\fB\-\-resize\fP \fIpercent\fP
 Increase the hash size by this many percent (default 50) when adding
 an IP to the hash could not be performed after
 .P
@@ -301,15 +297,13 @@ netblocks added to the set. The matching always start from the smallest
 size of netblock (most specific netmask) to the largest ones (least
 specific netmasks). When adding/deleting IP addresses
 to a nethash set by the
-.I
-SET
+"SET"
 netfilter kernel module, it will be added/deleted by the smallest
 netblock size which can be found in the set, or by /31 if the set is empty.
 .P
 The lookup time in a nethash type of set grows approximately linearly 
 with the times of the
-.B
-probes
+\fIprobes\fP
 parameter and the number of different mask parameters in the hash.
 Otherwise the same speed and memory efficiency comments applies here 
 as at the iphash type.
@@ -320,39 +314,35 @@ resort, dynamic growing of the hash performed. An ipporthash set can
 store up to 65536 (B-class network) IP addresses with all possible port
 values. When adding, deleting and testing values in an ipporthash type of
 set, the entries must be specified as
-.B
-"IP,port".
+"\fIaddress\fP\fB,\fP\fIport\fP".
 .P
 The ipporthash types of sets evaluates two src/dst parameters of the 
-.I
-set
+"set"
 match and 
-.I
-SET
+"SET"
 target. 
 .P
 Options to use when creating an ipporthash set:
 .TP
-.BR "--from " from-IP
+\fB\-\-from\fP \fIfrom-addr\fP
 .TP
-.BR "--to " to-IP
-Create an ipporthash set from the specified range.
+\fB\-\-to\fP \fIto-addr\fP
+Create an ipporthash set from the specified address range.
 .TP
-.BR "--network " IP/mask
+\fB\-\-network\fP \fIaddr\fP\fB/\fP\fImask\fP
 Create an ipporthash set from the specified network.
 .TP
-.BR "--hashsize " hashsize
+\fB\-\-hashsize\fP \fIhashsize\fP
 The initial hash size (default 1024)
 .TP
-.BR "--probes " probes
+\fB\-\-probes\fP \fIprobes\fP
 How many times try to resolve clashing at adding an IP to the hash 
 by double-hashing (default 8).
 .TP
-.BR "--resize " percent
+\fB\-\-resize\fP \fIpercent\fP
 Increase the hash size by this many percent (default 50) when adding
 an IP to the hash could not be performed after
-.B
-probes
+\fIprobes\fP
 number of double-hashing.
 .P
 The same resizing, speed and memory efficiency comments applies here 
@@ -363,39 +353,35 @@ address triples. The first IP address must come form a maximum /16
 sized network or range while the port number and the second IP address
 parameters are arbitrary. When adding, deleting and testing values in an 
 ipportiphash type of set, the entries must be specified as
-.B
-"IP,port,IP".
+"\fIaddress\fP\fB,\fP\fIport\fP\fB,\fP\fIaddress\fP".
 .P
 The ipportiphash types of sets evaluates three src/dst parameters of the 
-.I
-set
+"set"
 match and 
-.I
-SET
+"SET"
 target. 
 .P
 Options to use when creating an ipportiphash set:
 .TP
-.BR "--from " from-IP
+\fB\-\-from\fP \fIfrom-addr\fP
 .TP
-.BR "--to " to-IP
-Create an ipportiphash set from the specified range.
+\fB\-\-to\fP \fIto-addr\fP
+Create an ipportiphash set from the specified address range.
 .TP
-.BR "--network " IP/mask
+\fB\-\-network\fP \fIaddr\fP\fB/\fP\fImask\fP
 Create an ipportiphash set from the specified network.
 .TP
-.BR "--hashsize " hashsize
+\fB\-\-hashsize\fP \fIhashsize\fP
 The initial hash size (default 1024)
 .TP
-.BR "--probes " probes
+\fB\-\-probes\fP \fIprobes\fP
 How many times try to resolve clashing at adding an IP to the hash 
 by double-hashing (default 8).
 .TP
-.BR "--resize " percent
+\fB\-\-resize\fP \fIpercent\fP
 Increase the hash size by this many percent (default 50) when adding
 an IP to the hash could not be performed after
-.B
-probes
+\fIprobes\fP
 number of double-hashing.
 .P
 The same resizing, speed and memory efficiency comments applies here 
@@ -408,39 +394,35 @@ parameters are arbitrary, but the size of the network address must be
 between /1-/31. When adding, deleting 
 and testing values in an ipportnethash type of set, the entries must be
 specified as
-.B
-"IP,port,IP/cidr-size".
+"\fIaddress\fP\fB,\fP\fIport\fP\fB,\fP\fIaddress\fP\fB/\fP\fIprefixlen\fP".
 .P
 The ipportnethash types of sets evaluates three src/dst parameters of the 
-.I
-set
+"set"
 match and 
-.I
-SET
+"SET"
 target. 
 .P
 Options to use when creating an ipportnethash set:
 .TP
-.BR "--from " from-IP
+\fB\-\-from\fP \fIfrom-address\fP
 .TP
-.BR "--to " to-IP
+\fB\-\-to\fP \fIto-address\fP
 Create an ipporthash set from the specified range.
 .TP
-.BR "--network " IP/mask
+\fB\-\-network\fP \fIaddress\fP\fB/\fP\fImask\fP
 Create an ipporthash set from the specified network.
 .TP
-.BR "--hashsize " hashsize
+\fB\-\-hashsize\fP \fIhashsize\fP
 The initial hash size (default 1024)
 .TP
-.BR "--probes " probes
+\fB\-\-probes\fP \fIprobes\fP
 How many times try to resolve clashing at adding an IP to the hash 
 by double-hashing (default 8).
 .TP
-.BR "--resize " percent
+\fB\-\-resize\fP \fIpercent\fP
 Increase the hash size by this many percent (default 50) when adding
 an IP to the hash could not be performed after
-.B
-probes
+\fIprobes\fP
 number of double-hashing.
 .P
 The same resizing, speed and memory efficiency comments applies here 
@@ -451,14 +433,14 @@ with timeout values.
 .P
 Options to use when creating an iptree set:
 .TP
-.BR "--timeout " value
+\fB\-\-timeout\fP \fIvalue\fP
 The timeout value for the entries in seconds (default 0)
 .P
 If a set was created with a nonzero valued 
-.B "--timeout"
+\fB\-\-timeout\fP
 parameter then one may add IP addresses to the set with a specific 
 timeout value using the syntax 
-.I IP,timeout-value.
+"\fIaddress\fP\fB,\fP\fItimeout-value\fP".
 Similarly to the hash types, the iptree type of sets can store up to 65536
 entries.
 .SS iptreemap
@@ -466,37 +448,32 @@ The iptreemap set type uses a tree to store IP addresses or networks,
 where the last octet of an IP address are stored in a bitmap.
 As input entry, you can add IP addresses, CIDR blocks or network ranges
 to the set. Network ranges can be specified in the format
-.I IP1-IP2
+"\fIaddress1\fP\fB-\fP\fIaddress2\fP".
 .P
 Options to use when creating an iptreemap set:
 .TP
-.BR "--gc " value
+\fB\-\-gc\fP \fIvalue\fP
 How often the garbage collection should be called, in seconds (default 300)
 .SS setlist
 The setlist type uses a simple list in which you can store sets. By the
-.I
 ipset
 command you can add, delete and test sets in a setlist type of set.
 You can specify the sets as
-.B
-"setname[,after|before,setname]".
+"\fIsetname\fP[\fB,\fP{\fBafter\fP|\fBbefore\fP},\fIsetname\fP]".
 By default new sets are added after (appended to) the existing
 elements. Setlist type of sets cannot be added to a setlist type of set.
 .P
 Options to use when creating a setlist type of set:
 .TP
-.BR "--size " size
+\fB\-\-size\fP \fIsize\fP
 Create a setlist type of set with the given size (default 8).
 .PP
 By the
-.I
-set
+"set"
 match or
-.I
-SET
+"SET"
 target of
-.I
-iptables
+\fBiptables\fP(8)
 you can test, add or delete entries in the sets. The match
 will try to find a matching IP address/port in the sets and 
 the target will try to add the IP address/port to the first set
@@ -524,7 +501,7 @@ data storage in
 .I a
 set and add src to the first single or src,dst to the first double 
 data storage set in
-.I b.
+\fIb\fP.
 .P
 You can imagine a setlist type of set as an ordered union of
 the set elements. 
index d1b525e0c53f177fbdfb4fd3e7abb9fc753c7c45..f613c947a5a4fcf7302b0961963cf967dd18dad0 100644 (file)
@@ -1,3 +1,8 @@
+4.1
+  - Do not use init_MUTEX either (Jan Engelhardt)
+  - Improve listing/saving hash type of sets by not copying empty
+    entries unnecessarily to userspace.
+
 4.0
   - Compilation of ip_set_iptree.c fails with kernel 2.6.20 due to
     missing include of linux/jiffies.h (Jan Engelhardt)
index f62ae37347d90a0c8da7f0ce4fc94da710ea9b74..8eeced31403df2b0b0909a66d2136115ec455a45 100644 (file)
@@ -186,7 +186,7 @@ type##_list_members_size(const struct ip_set *set, char dont_align) \
 {                                                                      \
        const struct ip_set_##type *map = set->data;                    \
                                                                        \
-       return (map->hashsize * IPSET_VALIGN(sizeof(dtype), dont_align));\
+       return (map->elements * IPSET_VALIGN(sizeof(dtype), dont_align));\
 }
 
 #define HASH_LIST_MEMBERS(type, dtype)                                 \
@@ -195,27 +195,33 @@ type##_list_members(const struct ip_set *set, void *data, char dont_align)\
 {                                                                      \
        const struct ip_set_##type *map = set->data;                    \
        dtype *elem, *d;                                                \
-       uint32_t i;                                                     \
+       uint32_t i, n = 0;                                              \
                                                                        \
        for (i = 0; i < map->hashsize; i++) {                           \
                elem = HARRAY_ELEM(map->members, dtype *, i);           \
-               d = data + i * IPSET_VALIGN(sizeof(dtype), dont_align); \
-               *d = *elem;                                             \
+               if (*elem) {                                            \
+                       d = data + n * IPSET_VALIGN(sizeof(dtype), dont_align);\
+                       *d = *elem;                                     \
+                       n++;                                            \
+               }                                                       \
        }                                                               \
 }
 
-#define HASH_LIST_MEMBERS_MEMCPY(type, dtype)                          \
+#define HASH_LIST_MEMBERS_MEMCPY(type, dtype, nonzero)                 \
 static void                                                            \
 type##_list_members(const struct ip_set *set, void *data, char dont_align)\
 {                                                                      \
        const struct ip_set_##type *map = set->data;                    \
        dtype *elem;                                                    \
-       uint32_t i;                                                     \
+       uint32_t i, n = 0;                                              \
                                                                        \
        for (i = 0; i < map->hashsize; i++) {                           \
                elem = HARRAY_ELEM(map->members, dtype *, i);           \
-               memcpy(data + i * IPSET_VALIGN(sizeof(dtype), dont_align),\
-                      elem, sizeof(dtype));                            \
+               if (nonzero) {                                          \
+                       memcpy(data + n * IPSET_VALIGN(sizeof(dtype), dont_align),\
+                              elem, sizeof(dtype));                    \
+                       n++;                                            \
+               }                                                       \
        }                                                               \
 }
 
index 30185c56b241c6a1113c43e7dc9e5bedd6e89b1e..0ce9d3fd09d4a911a9dfcfc48cd4ed893d3b6596 100644 (file)
@@ -1474,7 +1474,8 @@ ip_set_init(void)
 {
        int res;
 
-       init_MUTEX(&ip_set_app_mutex);
+       /* For the -rt branch, DECLARE_MUTEX/init_MUTEX avoided */
+       sema_init(&ip_set_app_mutex, 1);
 
        if (max_sets)
                ip_set_max = max_sets;
index 5fe00f127061ce14c0556e772af6ff1b5fb59b5a..8b8f2a2a6f1f30a097df46126fb1a0e9f6bf96fb 100644 (file)
@@ -200,7 +200,8 @@ __ipportiphash_list_header(const struct ip_set_ipportiphash *map,
 
 HASH_LIST_HEADER(ipportiphash)
 HASH_LIST_MEMBERS_SIZE(ipportiphash, struct ipportip)
-HASH_LIST_MEMBERS_MEMCPY(ipportiphash, struct ipportip)
+HASH_LIST_MEMBERS_MEMCPY(ipportiphash, struct ipportip,
+                        (elem->ip || elem->ip1))
 
 IP_SET_RTYPE(ipportiphash, IPSET_TYPE_IP | IPSET_TYPE_PORT
                           | IPSET_TYPE_IP1 | IPSET_DATA_TRIPLE)
index 91791849b5929c9c15b776afc734a6a7c78164a4..f32897275e379261701da5e6dd11eed67510ffcd 100644 (file)
@@ -284,7 +284,8 @@ __ipportnethash_list_header(const struct ip_set_ipportnethash *map,
 HASH_LIST_HEADER(ipportnethash)
 
 HASH_LIST_MEMBERS_SIZE(ipportnethash, struct ipportip)
-HASH_LIST_MEMBERS_MEMCPY(ipportnethash, struct ipportip)
+HASH_LIST_MEMBERS_MEMCPY(ipportnethash, struct ipportip,
+                        (elem->ip || elem->ip1))
 
 IP_SET_RTYPE(ipportnethash, IPSET_TYPE_IP | IPSET_TYPE_PORT
                            | IPSET_TYPE_IP1 | IPSET_DATA_TRIPLE)