]> granicus.if.org Git - ipset/log
ipset
9 years agoFix coding styles reported by checkpatch.pl
Jozsef Kadlecsik [Wed, 17 Dec 2014 06:43:45 +0000 (07:43 +0100)]
Fix coding styles reported by checkpatch.pl

9 years agoUse nlmsg_total_size instead of NLMSG_SPACE in ip_set_core.c.
Jozsef Kadlecsik [Thu, 11 Dec 2014 20:43:56 +0000 (21:43 +0100)]
Use nlmsg_total_size instead of NLMSG_SPACE in ip_set_core.c.

9 years agoThere's no need to call synchronize_rcu() with kfree_rcu()
Jozsef Kadlecsik [Tue, 6 Jan 2015 07:22:05 +0000 (08:22 +0100)]
There's no need to call synchronize_rcu() with kfree_rcu()

9 years agoCall rcu_barrier() in module removal path
Jozsef Kadlecsik [Wed, 10 Dec 2014 06:34:43 +0000 (07:34 +0100)]
Call rcu_barrier() in module removal path

9 years agoCall synchronize_rcu() in set type (un)register functions only when needed
Jozsef Kadlecsik [Wed, 10 Dec 2014 06:31:43 +0000 (07:31 +0100)]
Call synchronize_rcu() in set type (un)register functions only when needed

9 years agoRemove an unused macro
Jozsef Kadlecsik [Wed, 10 Dec 2014 06:31:01 +0000 (07:31 +0100)]
Remove an unused macro

9 years agoGive a better name to a macro in ip_set_core.c
Jozsef Kadlecsik [Wed, 10 Dec 2014 06:29:29 +0000 (07:29 +0100)]
Give a better name to a macro in ip_set_core.c

9 years agoResolve the STREQ macro to make the code more readable, and use nla_strlcpy where...
Jozsef Kadlecsik [Wed, 10 Dec 2014 06:27:35 +0000 (07:27 +0100)]
Resolve the STREQ macro to make the code more readable, and use nla_strlcpy where possible

9 years agoUse MSEC_PER_SEC consistently
Jozsef Kadlecsik [Mon, 1 Dec 2014 06:11:54 +0000 (07:11 +0100)]
Use MSEC_PER_SEC consistently

9 years agoMake possible to pass extra flags to sparse (userspace)
Jozsef Kadlecsik [Thu, 27 Nov 2014 17:05:40 +0000 (18:05 +0100)]
Make possible to pass extra flags to sparse (userspace)

9 years agoRemove unnecessary integer RCU handling and fix sparse warnings
Jozsef Kadlecsik [Thu, 27 Nov 2014 16:54:52 +0000 (17:54 +0100)]
Remove unnecessary integer RCU handling and fix sparse warnings

9 years agoFix sparse warning
Jozsef Kadlecsik [Thu, 27 Nov 2014 06:47:06 +0000 (07:47 +0100)]
Fix sparse warning

"warning: cast to restricted __be32" warnings are fixed

9 years agoipset 6.24 released v6.24
Jozsef Kadlecsik [Mon, 24 Nov 2014 20:46:45 +0000 (21:46 +0100)]
ipset 6.24 released

9 years agonetfilter: ipset: small potential read beyond the end of buffer
Dan Carpenter [Tue, 18 Nov 2014 08:55:17 +0000 (09:55 +0100)]
netfilter: ipset: small potential read beyond the end of buffer

We could be reading 8 bytes into a 4 byte buffer here.  It seems
harmless but adding a check is the right thing to do and it silences a
static checker warning.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9 years agoThe "extra" subdirectory for kernel modules may have a full subtree
Jozsef Kadlecsik [Tue, 18 Nov 2014 07:15:42 +0000 (08:15 +0100)]
The "extra" subdirectory for kernel modules may have a full subtree

Jesper Dangaard Brouer reported that on Red Hat Enterprise Linux
Server release 6.5 the extra subdirectory contains the full subtree
path

/lib/modules/*/extra/netfilter/ipset/

and not

/lib/modules/*/extra/ipset/

Check only "/extra/" in the path.

9 years agoFix parallel resizing and listing of the same set
Jozsef Kadlecsik [Sat, 25 Oct 2014 22:11:29 +0000 (00:11 +0200)]
Fix parallel resizing and listing of the same set

When elements added to a hash:* type of set and resizing triggered,
parallel listing could start to list the original set (before resizing)
and "continue" with listing the new set. Fix it by references and
using the original hash table for listing. Therefore the destroying
the original hash table may happen from the resizing or listing functions.

9 years agostyles warned by checkpatch.pl fixed
Jozsef Kadlecsik [Tue, 18 Nov 2014 07:00:56 +0000 (08:00 +0100)]
styles warned by checkpatch.pl fixed

9 years agoIntroduce RCU in all set types instead of rwlock per set
Jozsef Kadlecsik [Tue, 30 Sep 2014 07:46:41 +0000 (09:46 +0200)]
Introduce RCU in all set types instead of rwlock per set

Performance is tested by Jesper Dangaard Brouer:

Simple drop in FORWARD
~~~~~~~~~~~~~~~~~~~~~~

Dropping via simple iptables net-mask match::

 iptables -t raw -N simple || iptables -t raw -F simple
 iptables -t raw -I simple  -s 198.18.0.0/15 -j DROP
 iptables -t raw -D PREROUTING -j simple
 iptables -t raw -I PREROUTING -j simple

Drop performance in "raw": 11.3Mpps

Generator: sending 12.2Mpps (tx:12264083 pps)

Drop via original ipset in RAW table
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Create a set with lots of elements::

 sudo ./ipset destroy test
 echo "create test hash:ip hashsize 65536" > test.set
 for x in `seq 0 255`; do
    for y in `seq 0 255`; do
        echo "add test 198.18.$x.$y" >> test.set
    done
 done
 sudo ./ipset restore < test.set

Dropping via ipset::

 iptables -t raw -F
 iptables -t raw -N net198 || iptables -t raw -F net198
 iptables -t raw -I net198 -m set --match-set test src -j DROP
 iptables -t raw -I PREROUTING -j net198

Drop performance in "raw" with ipset: 8Mpps

Perf report numbers ipset drop in "raw"::

 +   24.65%  ksoftirqd/1  [ip_set]           [k] ip_set_test
 -   21.42%  ksoftirqd/1  [kernel.kallsyms]  [k] _raw_read_lock_bh
    - _raw_read_lock_bh
       + 99.88% ip_set_test
 -   19.42%  ksoftirqd/1  [kernel.kallsyms]  [k] _raw_read_unlock_bh
    - _raw_read_unlock_bh
       + 99.72% ip_set_test
 +    4.31%  ksoftirqd/1  [ip_set_hash_ip]   [k] hash_ip4_kadt
 +    2.27%  ksoftirqd/1  [ixgbe]            [k] ixgbe_fetch_rx_buffer
 +    2.18%  ksoftirqd/1  [ip_tables]        [k] ipt_do_table
 +    1.81%  ksoftirqd/1  [ip_set_hash_ip]   [k] hash_ip4_test
 +    1.61%  ksoftirqd/1  [kernel.kallsyms]  [k] __netif_receive_skb_core
 +    1.44%  ksoftirqd/1  [kernel.kallsyms]  [k] build_skb
 +    1.42%  ksoftirqd/1  [kernel.kallsyms]  [k] ip_rcv
 +    1.36%  ksoftirqd/1  [kernel.kallsyms]  [k] __local_bh_enable_ip
 +    1.16%  ksoftirqd/1  [kernel.kallsyms]  [k] dev_gro_receive
 +    1.09%  ksoftirqd/1  [kernel.kallsyms]  [k] __rcu_read_unlock
 +    0.96%  ksoftirqd/1  [ixgbe]            [k] ixgbe_clean_rx_irq
 +    0.95%  ksoftirqd/1  [kernel.kallsyms]  [k] __netdev_alloc_frag
 +    0.88%  ksoftirqd/1  [kernel.kallsyms]  [k] kmem_cache_alloc
 +    0.87%  ksoftirqd/1  [xt_set]           [k] set_match_v3
 +    0.85%  ksoftirqd/1  [kernel.kallsyms]  [k] inet_gro_receive
 +    0.83%  ksoftirqd/1  [kernel.kallsyms]  [k] nf_iterate
 +    0.76%  ksoftirqd/1  [kernel.kallsyms]  [k] put_compound_page
 +    0.75%  ksoftirqd/1  [kernel.kallsyms]  [k] __rcu_read_lock

Drop via ipset in RAW table with RCU-locking
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

With RCU locking, the RW-lock is gone.

Drop performance in "raw" with ipset with RCU-locking: 11.3Mpps

Performance-tested-by: Jesper Dangaard Brouer <brouer@redhat.com>
9 years agoRemove rbtree from hash:net,iface in order to run under RCU
Jozsef Kadlecsik [Thu, 9 Oct 2014 09:20:09 +0000 (11:20 +0200)]
Remove rbtree from hash:net,iface in order to run under RCU

9 years agoExplicitly add padding elements to hash:net,net and hash:net,port,net
Jozsef Kadlecsik [Thu, 9 Oct 2014 08:58:30 +0000 (10:58 +0200)]
Explicitly add padding elements to hash:net,net and hash:net,port,net

The elements must be u32 sized for the used hash function.

9 years agoAllocate the proper size of memory when /0 networks are supported
Jozsef Kadlecsik [Fri, 3 Oct 2014 05:06:00 +0000 (07:06 +0200)]
Allocate the proper size of memory when /0 networks are supported

9 years agoSimplify cidr handling for hash:*net* types
Jozsef Kadlecsik [Fri, 3 Oct 2014 05:53:39 +0000 (07:53 +0200)]
Simplify cidr handling for hash:*net* types

9 years agoIndicate when /0 networks are supported
Jozsef Kadlecsik [Fri, 3 Oct 2014 05:10:14 +0000 (07:10 +0200)]
Indicate when /0 networks are supported

9 years agoAdd more compatibility checkings to support older kernel releases
Jozsef Kadlecsik [Mon, 10 Nov 2014 18:20:29 +0000 (19:20 +0100)]
Add more compatibility checkings to support older kernel releases

9 years agoMake_global.am: Don't include host headers
Baruch Siach [Tue, 28 Oct 2014 19:21:34 +0000 (21:21 +0200)]
Make_global.am: Don't include host headers

This is bad for cross compilation.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
9 years agoKernel API changes in em_ipset.c, support both old and new ones
Jozsef Kadlecsik [Mon, 3 Nov 2014 17:35:28 +0000 (18:35 +0100)]
Kernel API changes in em_ipset.c, support both old and new ones

9 years agonetfilter: Convert uses of __constant_<foo> to <foo>
Joe Perches [Mon, 3 Nov 2014 16:37:26 +0000 (17:37 +0100)]
netfilter: Convert uses of __constant_<foo> to <foo>

The use of __constant_<foo> has been unnecessary for quite awhile now.

Make these uses consistent with the rest of the kernel.

Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9 years agonet: use the new API kvfree()
WANG Cong [Mon, 3 Nov 2014 16:35:30 +0000 (17:35 +0100)]
net: use the new API kvfree()

It is available since v3.15-rc5.

Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
9 years agotreewide: fix errors in printk
Masanari Iida [Mon, 3 Nov 2014 16:10:49 +0000 (17:10 +0100)]
treewide: fix errors in printk

This patch fix spelling typo in printk.

Signed-off-by: Masanari Iida <standby24x7@gmail.com>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
9 years agonetfilter: use IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
Pablo Neira Ayuso [Mon, 3 Nov 2014 07:07:22 +0000 (08:07 +0100)]
netfilter: use IS_ENABLED(CONFIG_BRIDGE_NETFILTER)

In 34666d4 ("netfilter: bridge: move br_netfilter out of the core"),
the bridge netfilter code has been modularized.

Use IS_ENABLED instead of ifdef to cover the module case.

Fixes: 34666d4 ("netfilter: bridge: move br_netfilter out of the core")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9 years agoUse IS_ENABLED macro and define it if required
Jozsef Kadlecsik [Mon, 3 Nov 2014 07:06:19 +0000 (08:06 +0100)]
Use IS_ENABLED macro and define it if required

9 years agoAlignment problem between 64bit kernel 32bit userspace
Jozsef Kadlecsik [Mon, 3 Nov 2014 06:35:36 +0000 (07:35 +0100)]
Alignment problem between 64bit kernel 32bit userspace

Sven-Haegar Koch reported the issue:

sims:~# iptables -A OUTPUT -m set --match-set testset src -j ACCEPT
iptables: Invalid argument. Run `dmesg' for more information.

In syslog:
x_tables: ip_tables: set.3 match: invalid size 48 (kernel) != (user) 32

which was introduced by the counter extension in ipset.

The patch fixes the alignment issue with introducing a new set match
revision with the fixed underlying 'struct ip_set_counter_match'
structure.

9 years agoAdd script to check libipset.map for missing symbols
Jozsef Kadlecsik [Tue, 28 Oct 2014 16:36:25 +0000 (17:36 +0100)]
Add script to check libipset.map for missing symbols

9 years agoUpdate libipset.map with ipset_parse_tcp_udp_port
Thomas Backlund [Tue, 28 Oct 2014 16:19:53 +0000 (17:19 +0100)]
Update libipset.map with ipset_parse_tcp_udp_port

Commit:

author  Quentin Armitage <quentin@armitage.org.uk>      2013-08-09 11:26:33 (GMT)
committer       Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>     2013-08-17 19:31:29 (GMT)
commit  480761a3bdaa55bf8c966e4dab950ebf84775863 (patch)
tree    6d750f948abf1ae4f93e4c704502d085ac13d679
parent  3a4419954a3ae0ba5dafd711e6b8dd8f0beb5c21 (diff)
Add specifying protocol for bitmap:port
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
added ipset_parse_tcp_udp_port(), but forgot to update libipset.map

so we get:

/usr/lib64/ipset/ipset_bitmap_port.so: /usr/lib64/ipset/ipset_bitmap_port.so: undefined symbol: ipset_parse_tcp_udp_port

so update the map.

Signed-off-by: Thomas Backlund <tmb@mageia.org>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
9 years agolibipset: Bump lib version and update map file
Neutron Soutmun [Fri, 24 Oct 2014 09:36:22 +0000 (16:36 +0700)]
libipset: Bump lib version and update map file

The ipset_parse_uint16() was introduced but no lib version bumped and
no map file updated.

Bump lib version to 9:0:6. (current and age was bumped)

Signed-off-by: Neutron Soutmun <neo.neutron@gmail.com>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agonetfilter: ipset: off by one in ip_set_nfnl_get_byindex()
Dan Carpenter [Tue, 21 Oct 2014 16:18:14 +0000 (18:18 +0200)]
netfilter: ipset: off by one in ip_set_nfnl_get_byindex()

The ->ip_set_list[] array is initialized in ip_set_net_init() and it
has ->ip_set_max elements so this check should be >= instead of >
otherwise we are off by one.

Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agoBash utilities updated
Jozsef Kadlecsik [Tue, 30 Sep 2014 07:48:51 +0000 (09:48 +0200)]
Bash utilities updated

10 years agoipset: Fix hyphen used as minus sign in manpage
Neutron Soutmun [Thu, 25 Sep 2014 07:56:11 +0000 (14:56 +0700)]
ipset: Fix hyphen used as minus sign in manpage

Signed-off-by: Neutron Soutmun <neo.neutron@gmail.com>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agoipset 6.23 released v6.23
Jozsef Kadlecsik [Tue, 23 Sep 2014 11:18:34 +0000 (13:18 +0200)]
ipset 6.23 released

10 years agoThe utils are updated from their sources
Jozsef Kadlecsik [Tue, 23 Sep 2014 11:08:54 +0000 (13:08 +0200)]
The utils are updated from their sources

10 years agoOrder create and add options in manpage so that generic ones come first
Jozsef Kadlecsik [Tue, 23 Sep 2014 11:06:36 +0000 (13:06 +0200)]
Order create and add options in manpage so that generic ones come first

10 years agoCentralise generic create options (family, hashsize, maxelem) on top of man page...
Mart Frauenlob [Mon, 22 Sep 2014 16:08:55 +0000 (18:08 +0200)]
Centralise generic create options (family, hashsize, maxelem) on top of man page in the generic options section.

Signed-off-by: Mart Frauenlob <mart.frauenlob@chello.at>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agoSupport glibc < 2.9 (fixes bugzilla id #891)
Jozsef Kadlecsik [Tue, 23 Sep 2014 09:43:20 +0000 (11:43 +0200)]
Support glibc < 2.9 (fixes bugzilla id #891)

10 years agoSupport updating extensions when the set is full
Jozsef Kadlecsik [Tue, 23 Sep 2014 09:10:12 +0000 (11:10 +0200)]
Support updating extensions when the set is full

When the set was full (hash type and maxelem reached), it was not
possible to update the extension part of already existing elements.
The patch removes this limitation. (Fixes netfilter bugzilla id 880.)

10 years agoAdd description of hash:mac set type to man page.
Mart Frauenlob [Fri, 19 Sep 2014 11:30:49 +0000 (13:30 +0200)]
Add description of hash:mac set type to man page.

Signed-off-by: Mart Frauenlob <mart.frauenlob@chello.at>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agoAdd missing space for skbinfo option synopsis.
Mart Frauenlob [Fri, 19 Sep 2014 11:23:43 +0000 (13:23 +0200)]
Add missing space for skbinfo option synopsis.

Signed-off-by: Mart Frauenlob <mart.frauenlob@chello.at>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agoThe library/API versions were forgotten to bump (reported by Sergei Zhirikov)
Jozsef Kadlecsik [Mon, 22 Sep 2014 05:44:23 +0000 (07:44 +0200)]
The library/API versions were forgotten to bump (reported by Sergei Zhirikov)

With introducing the skbinfo extension, the library/API versions should
have been incremented, which is fixed now.

10 years agoRetry printing when sprintf fails (reported by Stig Thormodsrud)
Jozsef Kadlecsik [Mon, 22 Sep 2014 05:32:38 +0000 (07:32 +0200)]
Retry printing when sprintf fails (reported by Stig Thormodsrud)

Instead of returning the length of the string which would have been
printed, sprintf sometimes simply returns an error code. Handle
the case and flush the printing buffer and retry.

10 years agoipset 6.22 released v6.22
Jozsef Kadlecsik [Mon, 15 Sep 2014 16:10:08 +0000 (18:10 +0200)]
ipset 6.22 released

10 years agohash:mac type added to ipset
Jozsef Kadlecsik [Mon, 15 Sep 2014 15:36:06 +0000 (17:36 +0200)]
hash:mac type added to ipset

10 years agoskbinfo extension: send nonzero extension elements only to userspace
Jozsef Kadlecsik [Mon, 15 Sep 2014 15:30:54 +0000 (17:30 +0200)]
skbinfo extension: send nonzero extension elements only to userspace

10 years agoAdd test to check mark mapping
Jozsef Kadlecsik [Sun, 14 Sep 2014 19:50:28 +0000 (21:50 +0200)]
Add test to check mark mapping

Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agoipset: remove extran newline on debug output
Holger Eitzenberger [Mon, 8 Sep 2014 14:30:48 +0000 (16:30 +0200)]
ipset: remove extran newline on debug output

    [ The following text is in the "utf-8" character set. ]
    [ Your display is set for the "ISO-8859-2" character set.  ]
    [ Some characters may be displayed incorrectly. ]

Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agoipset: avoid duplicate command flags
Holger Eitzenberger [Mon, 8 Sep 2014 14:30:38 +0000 (16:30 +0200)]
ipset: avoid duplicate command flags

    [ The following text is in the "utf-8" character set. ]
    [ Your display is set for the "ISO-8859-2" character set.  ]
    [ Some characters may be displayed incorrectly. ]

NLM_F_DUMP is #defined as (NLM_F_ROOT | NLM_F_ACK), so specifying
all of them is redundant.

Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agoRemove a duplicate debug print
Holger Eitzenberger [Mon, 8 Sep 2014 14:30:33 +0000 (16:30 +0200)]
Remove a duplicate debug print

    [ The following text is in the "utf-8" character set. ]
    [ Your display is set for the "ISO-8859-2" character set.  ]
    [ Some characters may be displayed incorrectly. ]

Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agonetfilter: Convert pr_warning to pr_warn
Joe Perches [Sun, 14 Sep 2014 18:57:03 +0000 (20:57 +0200)]
netfilter: Convert pr_warning to pr_warn

Use the more common pr_warn.

Other miscellanea:

o Coalesce formats
o Realign arguments

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agonetfilter: ipset: Add skbinfo extension support to SET target.
Anton Danilov [Tue, 2 Sep 2014 10:21:20 +0000 (14:21 +0400)]
netfilter: ipset: Add skbinfo extension support to SET target.

Signed-off-by: Anton Danilov <littlesmilingcloud@gmail.com>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agoipset: man: Add the skbinfo extension documentation.
Anton Danilov [Thu, 28 Aug 2014 06:11:35 +0000 (10:11 +0400)]
ipset: man: Add the skbinfo extension documentation.

Signed-off-by: Anton Danilov <littlesmilingcloud@gmail.com>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agolibipset: Add userspace support of the skbinfo extension of the list set type.
Anton Danilov [Thu, 28 Aug 2014 06:11:34 +0000 (10:11 +0400)]
libipset: Add userspace support of the skbinfo extension of the list set type.

Add userspace part for support of new revisions of the list set type
with the skbinfo extension.

Signed-off-by: Anton Danilov <littlesmilingcloud@gmail.com>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agolibipset: Add userspace support of the skbinfo extension of the hash set types.
Anton Danilov [Thu, 28 Aug 2014 06:11:33 +0000 (10:11 +0400)]
libipset: Add userspace support of the skbinfo extension of the hash set types.

Add userspace part for support of new revisions of the hash set types
with the skbinfo extension.

Signed-off-by: Anton Danilov <littlesmilingcloud@gmail.com>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agolibipset: Add userspace support of the skbinfo extension of the bitmap set types.
Anton Danilov [Thu, 28 Aug 2014 06:11:32 +0000 (10:11 +0400)]
libipset: Add userspace support of the skbinfo extension of the bitmap set types.

Add userspace part for support of new revisions of the bitmap set types
with the skbinfo extension.

Signed-off-by: Anton Danilov <littlesmilingcloud@gmail.com>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agolibipset: Add userspace code for the skbinfo extension support.
Anton Danilov [Thu, 28 Aug 2014 06:11:31 +0000 (10:11 +0400)]
libipset: Add userspace code for the skbinfo extension support.

Add userspace code to support of the skbinfo extension independly of set types.
Defines constants, flag and function for print/parse/send/recieve of skbinfo
parameters.

Signed-off-by: Anton Danilov <littlesmilingcloud@gmail.com>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agonetfilter: ipset: Add skbinfo extension kernel support for the list set type.
Anton Danilov [Thu, 28 Aug 2014 06:11:30 +0000 (10:11 +0400)]
netfilter: ipset: Add skbinfo extension kernel support for the list set type.

Add skbinfo extension kernel support for the list set type.
Introduce the new revision of the list set type.

Signed-off-by: Anton Danilov <littlesmilingcloud@gmail.com>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agonetfilter: ipset: Add skbinfo extension kernel support for the hash set types.
Anton Danilov [Thu, 28 Aug 2014 06:11:29 +0000 (10:11 +0400)]
netfilter: ipset: Add skbinfo extension kernel support for the hash set types.

Add skbinfo extension kernel support for the hash set types.
Inroduce the new revisions of all hash set types.

Signed-off-by: Anton Danilov <littlesmilingcloud@gmail.com>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agonetfilter: ipset: Add skbinfo extension kernel support for the bitmap set types.
Anton Danilov [Thu, 28 Aug 2014 06:11:28 +0000 (10:11 +0400)]
netfilter: ipset: Add skbinfo extension kernel support for the bitmap set types.

Add skbinfo extension kernel support for the bitmap set types.
Inroduce the new revisions of bitmap_ip, bitmap_ipmac and bitmap_port set types.

Signed-off-by: Anton Danilov <littlesmilingcloud@gmail.com>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agonetfilter: ipset: Add skbinfo extension kernel support in the ipset core.
Anton Danilov [Thu, 28 Aug 2014 06:11:27 +0000 (10:11 +0400)]
netfilter: ipset: Add skbinfo extension kernel support in the ipset core.

Skbinfo extension provides mapping of metainformation with lookup in the ipset tables.
This patch defines the flags, the constants, the functions and the structures
for the data type independent support of the extension.
Note the firewall mark stores in the kernel structures as two 32bit values,
but transfered through netlink as one 64bit value.

Signed-off-by: Anton Danilov <littlesmilingcloud@gmail.com>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agoFix static checker warning in ip_set_core.c
Jozsef Kadlecsik [Mon, 1 Sep 2014 16:58:43 +0000 (18:58 +0200)]
Fix static checker warning in ip_set_core.c

Dan Carpenter reported the following static checker warning:

        net/netfilter/ipset/ip_set_core.c:1414 call_ad()
        error: 'nlh->nlmsg_len' from user is not capped properly

The payload size is limited now by the max size of size_t.

10 years agoMake possible to compile ipset with IPSET_DEBUG from the dist.
Clinton Roy [Tue, 19 Aug 2014 13:53:16 +0000 (15:53 +0200)]
Make possible to compile ipset with IPSET_DEBUG from the dist.

Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agoFix warn: integer overflows 'sizeof(*map) + size * set->dsize'
Jozsef Kadlecsik [Tue, 5 Aug 2014 20:02:34 +0000 (22:02 +0200)]
Fix warn: integer overflows 'sizeof(*map) + size * set->dsize'

Dan Carpenter reported that the static checker emits the warning

        net/netfilter/ipset/ip_set_list_set.c:600 init_list_set()
        warn: integer overflows 'sizeof(*map) + size * set->dsize'

Limit the maximal number of elements in list type of sets.

10 years agonet/netfilter/ipset: Resolve missing-field-initializer warnings
Mark Rustad [Tue, 5 Aug 2014 11:56:21 +0000 (04:56 -0700)]
net/netfilter/ipset: Resolve missing-field-initializer warnings

Resolve missing-field-initializer warnings by providing a
directed initializer.

Signed-off-by: Mark Rustad <mark.d.rustad@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agonetnet,netportnet: Fix value range support for IPv4
Sergey Popovich [Mon, 5 May 2014 08:07:06 +0000 (11:07 +0300)]
netnet,netportnet: Fix value range support for IPv4

Ranges of values are broken with hash:net,net and hash:net,port,net.

hash:net,net
============

   # ipset create test-nn hash:net,net
   # ipset add test-nn 10.0.10.1-10.0.10.127,10.0.0.0/8

   # ipset list test-nn
   Name: test-nn
   Type: hash:net,net
   Revision: 0
   Header: family inet hashsize 1024 maxelem 65536
   Size in memory: 16960
   References: 0
   Members:
   10.0.10.1,10.0.0.0/8

   # ipset test test-nn 10.0.10.65,10.0.0.1
   10.0.10.65,10.0.0.1 is NOT in set test-nn.
   # ipset test test-nn 10.0.10.1,10.0.0.1
   10.0.10.1,10.0.0.1 is in set test-nn.

hash:net,port,net
=================

   # ipset create test-npn hash:net,port,net
   # ipset add test-npn 10.0.10.1-10.0.10.127,tcp:80,10.0.0.0/8
   # ipset list test-npn
   Name: test-npn
   Type: hash:net,port,net
   Revision: 0
   Header: family inet hashsize 1024 maxelem 65536
   Size in memory: 17344
   References: 0
   Members:
   10.0.10.8/29,tcp:80,10.0.0.0
   10.0.10.16/28,tcp:80,10.0.0.0
   10.0.10.2/31,tcp:80,10.0.0.0
   10.0.10.64/26,tcp:80,10.0.0.0
   10.0.10.32/27,tcp:80,10.0.0.0
   10.0.10.4/30,tcp:80,10.0.0.0
   10.0.10.1,tcp:80,10.0.0.0
   # ipset list test-npn
   # ipset test test-npn 10.0.10.126,tcp:80,10.0.0.2
   10.0.10.126,tcp:80,10.0.0.2 is NOT in set test-npn.
   # ipset test test-npn 10.0.10.126,tcp:80,10.0.0.0
   10.0.10.126,tcp:80,10.0.0.0 is in set test-npn.

   # ipset create test-npn hash:net,port,net
   # ipset add test-npn 10.0.10.0/24,tcp:80-81,10.0.0.0/8
   # ipset list test-npn
   Name: test-npn
   Type: hash:net,port,net
   Revision: 0
   Header: family inet hashsize 1024 maxelem 65536
   Size in memory: 17024
   References: 0
   Members:
   10.0.10.0,tcp:80,10.0.0.0
   10.0.10.0,tcp:81,10.0.0.0
   # ipset test test-npn 10.0.10.126,tcp:80,10.0.0.0
   10.0.10.126,tcp:80,10.0.0.0 is NOT in set test-npn.
   # ipset test test-npn 10.0.10.0,tcp:80,10.0.0.0
   10.0.10.0,tcp:80,10.0.0.0 is in set test-npn.

Correctly setup from..to variables where no IPSET_ATTR_IP_TO{,2}
attribute is given, so in range processing loop we construct proper
cidr value. Check whenever we have no ranges and can short cut in
hash:net,net properly. Use unlikely() where appropriate, to comply
with other modules.

Signed-off-by: Sergey Popovich <popovich_sergei@mail.ru>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agolibipset: print third element in debugging
Sergey Popovich [Mon, 5 May 2014 08:07:05 +0000 (11:07 +0300)]
libipset: print third element in debugging

We have that done for first and second elements when
parsing element string, do this for third element for
convenience.

Signed-off-by: Sergey Popovich <popovich_sergei@mail.ru>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agoipset: Handle missing leading zeros in ethernet address parser
Janeks Jaunups [Tue, 6 May 2014 05:30:15 +0000 (07:30 +0200)]
ipset: Handle missing leading zeros in ethernet address parser

ipset would not parse ether addresses which are not exactly
17 characters long, for ex. 1:2:3:4:5:6, which is fixed in
the patch.

Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agoRemoved invalid IPSET_ATTR_MARKMASK validation
Vytas Dauksa [Fri, 4 Apr 2014 15:10:14 +0000 (16:10 +0100)]
Removed invalid IPSET_ATTR_MARKMASK validation

Markmask is an u32, hence it can't be greater then 4294967295 ( i.e.
0xffffffff ). This was causing smatch warning:
 net/netfilter/ipset/ip_set_hash_gen.h:1084 hash_ipmark_create() warn:
 impossible condition '(markmask > 4294967295) => (0-u32max > u32max)'

Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agoipset: Pass IPSET_BIN to test scripts to change binary location
Neutron Soutmun [Fri, 4 Apr 2014 03:24:22 +0000 (10:24 +0700)]
ipset: Pass IPSET_BIN to test scripts to change binary location

In the "as-installed" package testing situation, the test scripts should
invokes the system installed "ipset" binary.
Therefore, the IPSET_BIN could be passed to change the binary location.

  IPSET_BIN=/sbin/ipset ./runtest.sh

The test scripts run fine in build source tree without IPSET_BIN.

Signed-off-by: Neutron Soutmun <neo.neutron@gmail.com>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agoipset: Fix grammar error in manpage
Neutron Soutmun [Tue, 1 Apr 2014 10:46:34 +0000 (17:46 +0700)]
ipset: Fix grammar error in manpage

Refer to: https://bugs.launchpad.net/ubuntu/+source/lintian/+bug/608231

The "allows to" is a common grammar error which it will probably be replaced
by "allows one to" as a suggestion in above bug report page.

Signed-off-by: Neutron Soutmun <neo.neutron@gmail.com>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agoipset: Fix printf format warning
Neutron Soutmun [Tue, 1 Apr 2014 10:44:52 +0000 (17:44 +0700)]
ipset: Fix printf format warning

Using PRIx32 macro is portable across multiple architectures and
also fix the printf format warning on any architectures that
"%llx" is not refer to 32 bits size.

Signed-off-by: Neutron Soutmun <neo.neutron@gmail.com>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agoipset 6.21.1 released v6.21.1
Jozsef Kadlecsik [Fri, 7 Mar 2014 12:22:12 +0000 (13:22 +0100)]
ipset 6.21.1 released

10 years agonetfilter: ip_set: rename nfnl_dereference()/nfnl_set()
Patrick McHardy [Fri, 7 Mar 2014 12:18:28 +0000 (13:18 +0100)]
netfilter: ip_set: rename nfnl_dereference()/nfnl_set()

The next patch will introduce a nfnl_dereference() macro that actually
checks that the appropriate mutex is held and therefore needs a
subsystem argument.

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agoThe bash utilities are updated
Jozsef Kadlecsik [Fri, 7 Mar 2014 12:10:01 +0000 (13:10 +0100)]
The bash utilities are updated

10 years agoFix libipset library release versioning
Jozsef Kadlecsik [Fri, 7 Mar 2014 12:03:37 +0000 (13:03 +0100)]
Fix libipset library release versioning

Patch "add hash:ip,mark data type to ipset" broke the API and
library release versioning with not incrementing "current",
just "age", which is fixed here. Reported by Mathieu Bridon.

10 years agoipset 6.21 released v6.21
Jozsef Kadlecsik [Tue, 4 Mar 2014 20:40:26 +0000 (21:40 +0100)]
ipset 6.21 released

10 years agoipset: add userspace support for forceadd
Josh Hunt [Sat, 1 Mar 2014 03:14:58 +0000 (22:14 -0500)]
ipset: add userspace support for forceadd

The userspace side of the forceadd changes.

Signed-off-by: Josh Hunt <johunt@akamai.com>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agoipset: add forceadd kernel support for hash set types
Josh Hunt [Sat, 1 Mar 2014 03:14:57 +0000 (22:14 -0500)]
ipset: add forceadd kernel support for hash set types

Adds a new property for hash set types, where if a set is created
with the 'forceadd' option and the set becomes full the next addition
to the set may succeed and evict a random entry from the set.

To keep overhead low eviction is done very simply. It checks to see
which bucket the new entry would be added. If the bucket's pos value
is non-zero (meaning there's at least one entry in the bucket) it
replaces the first entry in the bucket. If pos is zero, then it continues
down the normal add process.

This property is useful if you have a set for 'ban' lists where it may
not matter if you release some entries from the set early.

Signed-off-by: Josh Hunt <johunt@akamai.com>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agonetfilter: ipset: move registration message to init from net_init
Ilia Mirkin [Sun, 16 Feb 2014 10:18:52 +0000 (11:18 +0100)]
netfilter: ipset: move registration message to init from net_init

Commit 1785e8f473 ("netfiler: ipset: Add net namespace for ipset") moved
the initialization print into net_init, which can get called a lot due
to namespaces. Move it back into init, reduce to pr_info.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agokernel: uapi: fix MARKMASK attr ABI breakage
Florian Westphal [Thu, 13 Feb 2014 11:40:59 +0000 (12:40 +0100)]
kernel: uapi: fix MARKMASK attr ABI breakage

commit 2dfb973c0dcc6d2211 (add markmask for hash:ip,mark data type)
inserted IPSET_ATTR_MARKMASK in-between other enum values, i.e.
changing values of all further attributes.  This causes 'ipset list'
segfault on existing kernels since ipset no longer finds
IPSET_ATTR_MEMSIZE (it has a different value on kernel side).

Jozsef points out it should be moved below IPSET_ATTR_MARK which
works since there is some extra reserved space after that value.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agolib: fix ifname 'physdev:' prefix parsing
Florian Westphal [Wed, 12 Feb 2014 09:27:19 +0000 (10:27 +0100)]
lib: fix ifname 'physdev:' prefix parsing

hash:net,iface supports matching on the bridge port as well,
but userspace currently doesn't handle it correctly as it passes
in 'physdev:eth0' instead of 'eth0'+IPSET_OPT_PHYSDEV.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agoPrepare the kernel for create option flags when no extension is needed
Jozsef Kadlecsik [Thu, 13 Feb 2014 11:19:56 +0000 (12:19 +0100)]
Prepare the kernel for create option flags when no extension is needed

10 years agoprint mark & mark mask in hex rather then decimal
Vytas Dauksa [Thu, 23 Jan 2014 06:37:48 +0000 (07:37 +0100)]
print mark & mark mask in hex rather then decimal

modified ipset_print_mark to print in hex rather then decimal and
altered accordingly test cases.

Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agoadd markmask for hash:ip,mark data type
Vytas Dauksa [Tue, 17 Dec 2013 14:01:44 +0000 (14:01 +0000)]
add markmask for hash:ip,mark data type

Introduce packet mark mask for hash:ip,mark data type. This allows to
set mark bit filter for the ip set.

Change-Id: Id8dd9ca7e64477c4f7b022a1d9c1a5b187f1c96e

Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agoadd hash:ip,mark data type to ipset
Vytas Dauksa [Tue, 17 Dec 2013 14:01:43 +0000 (14:01 +0000)]
add hash:ip,mark data type to ipset

Introduce packet mark support with new ip,mark hash set. This includes
userspace and kernelspace code, hash:ip,mark set tests and man page
updates.

The intended use of ip,mark set is similar to the ip:port type, but for
protocols which don't use a predictable port number. Instead of port
number it matches a firewall mark determined by a layer 7 filtering
program like opendpi.

As well as allowing or blocking traffic it will also be used for
accounting packets and bytes sent for each protocol.

Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agoipset: remove unused code
Stephen Hemminger [Tue, 7 Jan 2014 16:31:47 +0000 (17:31 +0100)]
ipset: remove unused code

Function never used in current upstream code.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agonetfilter: ipset: Add hash: fix coccinelle warnings
Fengguang Wu [Fri, 27 Dec 2013 10:13:03 +0000 (11:13 +0100)]
netfilter: ipset: Add hash: fix coccinelle warnings

net/netfilter/ipset/ip_set_hash_netnet.c:115:8-9: WARNING: return of 0/1 in function 'hash_netnet4_data_list' with return type bool
/c/kernel-tests/src/cocci/net/netfilter/ipset/ip_set_hash_netnet.c:338:8-9: WARNING: return of 0/1 in function 'hash_netnet6_data_list' with return type bool

Return statements in functions returning bool should use
true/false instead of 1/0.
Generated by: coccinelle/misc/boolreturn.cocci

Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
10 years agoTypo in ip_set_hash_netnet.c fixed
David Binderman [Tue, 3 Dec 2013 16:11:23 +0000 (17:11 +0100)]
Typo in ip_set_hash_netnet.c fixed

I just ran the static analyser "cppcheck" over the source
code of linux-3.13-rc1. It said

[linux-3.13-rc1/net/netfilter/ipset/ip_set_hash_netnet.c:62] ->
[linux-3.13-rc1/net/net
filter/ipset/ip_set_hash_netnet.c:62]: (style)
Same expression on both sides of '=='.

Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agoipset: manpage: correct add action synopsis for hash:net,port,net.
Mart Frauenlob [Mon, 18 Nov 2013 14:20:52 +0000 (15:20 +0100)]
ipset: manpage: correct add action synopsis for hash:net,port,net.

Signed-off-by: Mart Frauenlob <mart.frauenlob@chello.at>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agoipset: manpage: remove spare comma for hash:net,net test action.
Mart Frauenlob [Mon, 18 Nov 2013 14:18:50 +0000 (15:18 +0100)]
ipset: manpage: remove spare comma for hash:net,net test action.

Signed-off-by: Mart Frauenlob <mart.frauenlob@chello.at>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agonet ipset: use rbtree postorder iteration instead of opencoding
Cody P Schafer [Wed, 13 Nov 2013 09:30:35 +0000 (10:30 +0100)]
net ipset: use rbtree postorder iteration instead of opencoding

Use rbtree_postorder_for_each_entry_safe() to destroy the rbtree instead
of opencoding an alternate postorder iteration that modifies the tree

Signed-off-by: Cody P Schafer <cody@linux.vnet.ibm.com>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agoFix all set output from list/save when set with counters in use.
Sergey Popovich [Tue, 12 Nov 2013 10:30:56 +0000 (12:30 +0200)]
Fix all set output from list/save when set with counters in use.

Using upstream version with counters support we have following
output when listing all sets currently configured:
--------------------------------------------------

 # ipset create test-1 hash:ip
 # ipset create test-2 hash:ip counters
 # ipset add test-2 192.0.2.1/32
 # ipset create test-3 hash:ip
 # ipset add test-3 192.0.2.1/32
 # ipset list
 Name: test-1
 Type: hash:ip
 Revision: 2
 Header: family inet hashsize 1024 maxelem 65536
 Size in memory: 16504
 References: 0
 Members:

 Name: test-2
 Type: hash:ip
 Revision: 2
 Header: family inet hashsize 1024 maxelem 65536 counters
 Size in memory: 16616
 References: 0
 Members:
 192.0.2.1 packets 0 bytes 0

 Name: test-3
 Type: hash:ip
 Revision: 2
 Header: family inet hashsize 1024 maxelem 65536 counters
 Size in memory: 16520
 References: 0
 Members:
 192.0.2.1 packets 0 bytes 0

Set test-3 created without counters, but displayed as with counters
present.

Restricting output to list only test-3 set we have:
---------------------------------------------------
  # ipset list test-3
  Name: test-3
  Type: hash:ip
  Revision: 2
  Header: family inet hashsize 1024 maxelem 65536
  Size in memory: 16520
  References: 0
  Members:
  192.0.2.1

So test-3 set created correctly without counters support, but in
all sets listing it displayed as such one with counters.

It seems with commit 5a6021823aa0da24b83f8d03f46ad4202f149fa3
(Support counters in the ipset library) we fogot to add counter
options flags to IPSET_CREATE_FLAGS and IPSET_ADT_FLAGS defines to
clear these flags when preparing output in callback_list() from
lib/session.c.

v2: Remove IPSET_OPT_BYTES, IPSET_PAKETS from CREATE and
    IPSET_OPT_COUNTERS from ADT.

Signed-off-by: Sergey Popovich <popovich_sergei@mail.ru>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agoipset: Follow manual page behavior for SET target on list:set
Sergey Popovich [Thu, 7 Nov 2013 10:56:45 +0000 (12:56 +0200)]
ipset: Follow manual page behavior for SET target on list:set

ipset(8) for list:set says:
  The match will try to find a matching entry in the sets and the
  target will try to add an entry to the first set to which it can
  be added.

However real behavior is bit differ from described. Consider example:

 # ipset create test-1-v4 hash:ip family inet
 # ipset create test-1-v6 hash:ip family inet6
 # ipset create test-1 list:set
 # ipset add test-1 test-1-v4
 # ipset add test-1 test-1-v6

 # iptables  -A INPUT -p tcp --destination-port 25 -j SET --add-set test-1 src
 # ip6tables -A INPUT -p tcp --destination-port 25 -j SET --add-set test-1 src

And then when iptables/ip6tables rule matches packet IPSET target
tries to add src from packet to the list:set test-1 where first
entry is test-1-v4 and the second one is test-1-v6.

For IPv4, as it first entry in test-1 src added to test-1-v4
correctly, but for IPv6 src not added!

Placing test-1-v6 to the first element of list:set makes behavior
correct for IPv6, but brokes for IPv4.

This is due to result, returned from ip_set_add() and ip_set_del() from
net/netfilter/ipset/ip_set_core.c when set in list:set equires more
parameters than given or address families do not match (which is this
case).

It seems wrong returning 0 from ip_set_add() and ip_set_del() in
this case, as 0 should be returned only when an element successfuly
added/deleted to/from the set, contrary to ip_set_test() which
returns 0 when no entry exists and >0 when entry found in set.

Signed-off-by: Sergey Popovich <popovich_sergei@mail.ru>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 years agoipset: Fix malformed output from list/save for ICMP types in port field.
Sergey Popovich [Thu, 7 Nov 2013 10:56:15 +0000 (12:56 +0200)]
ipset: Fix malformed output from list/save for ICMP types in port field.

Found with ipset 6.12.1, but upstream version is still affected.

Creating set of dimension three, adding elements to it and then
displaying gives following results:
-----------------------------------

 # ipset create test-1 hash:ip,port,ip
 # ipset add test-1 192.0.2.1,icmp:echo-request,192.0.2.1
 # ipset add test-1 192.0.2.1,icmp:ttl-zero-during-reassembly,192.0.2.1
 # ipset list test-1
 Name: test-1
 Type: hash:ip,port,ip
 Header: family inet hashsize 1024 maxelem 65536
 Size in memory: 16608
 References: 0
 Members:
 192.0.2.1,icmp:ttl-zero-during-reass,192.0.2.1
 192.0.2.1,icmp:echo-re,192.0.2.1

Same results with -output save|xml.

ipset_print_proto_port() from lib/print.c returns incorrect length
of printed string when ICMP/ICMPv6 specified in port field.

Signed-off-by: Sergey Popovich <popovich_sergei@mail.ru>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>