]> granicus.if.org Git - ipset/log
ipset
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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 years agoipset: fix timeout data type size
Nikolay Martynov [Thu, 31 Oct 2013 04:34:31 +0000 (00:34 -0400)]
ipset: fix timeout data type size

Currently it is impossible to set timeout on some architectures
(MIPS ar71xx at least) because timeout is parsed into long long data
type but used as uint32 without proper conversion. This patch fixes
this issue. Tested on ar71xx router.

Signed-off-by: Nikolay Martynov <mar.kolya@gmail.com>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
11 years agoipset 6.20.1 released v6.20.1
Jozsef Kadlecsik [Sun, 27 Oct 2013 18:38:37 +0000 (19:38 +0100)]
ipset 6.20.1 released

11 years agobuild: fix incorrect library versioning
Jan Engelhardt [Sun, 20 Oct 2013 13:17:24 +0000 (15:17 +0200)]
build: fix incorrect library versioning

Commit v6.20~12 caused libipset to shift from libipset.so.3 to
.so.2. That is the wrong thing to do. Set it back to 3+2, as
intended.

Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
11 years agonetfilter: ipset: remove duplicate define
Michael Opdenacker [Sun, 27 Oct 2013 18:06:45 +0000 (19:06 +0100)]
netfilter: ipset: remove duplicate define

This patch removes a duplicate define from
net/netfilter/ipset/ip_set_hash_gen.h

Signed-off-by: Michael Opdenacker <michael.opdenacker@free-electrons.com>
11 years agonet->user_ns is available starting from 3.8, add compatibility checking
Jozsef Kadlecsik [Sun, 27 Oct 2013 18:00:36 +0000 (19:00 +0100)]
net->user_ns is available starting from 3.8, add compatibility checking

Reported by Jan Engelhardt

11 years agoFix memory allocation for bitmap:port
Jozsef Kadlecsik [Fri, 18 Oct 2013 12:03:41 +0000 (14:03 +0200)]
Fix memory allocation for bitmap:port

At the restructuring of the bitmap types creation in ipset, for the
bitmap:port type wrong (too large) memory allocation was copied
(netfilter bugzilla id #859).

Reported-by: Quentin Armitage <quentin@armitage.org.uk>
11 years agonetfilter: ipset: Fix configure failure when --with-kmod=no
Oliver Smith [Fri, 11 Oct 2013 14:41:12 +0000 (16:41 +0200)]
netfilter: ipset: Fix configure failure when --with-kmod=no

When configuring the sources to build without kernel modules, the path
to the kernel sources was not set and the kernel header files were still
checked.

Now, we do not check the kernel sources for compatibility if we're not
going to build any kernel modules.

Signed-off-by: Oliver Smith <oliver@8.c.9.b.0.7.4.0.1.0.0.2.ip6.arpa>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
11 years agoAvoid clashing with configured kernel in [CONFIG_]IP_SET_MAX
Jozsef Kadlecsik [Tue, 8 Oct 2013 19:16:01 +0000 (21:16 +0200)]
Avoid clashing with configured kernel in [CONFIG_]IP_SET_MAX

11 years agoThe unnamed union initialization may lead to compilation error
Jozsef Kadlecsik [Tue, 8 Oct 2013 19:05:20 +0000 (21:05 +0200)]
The unnamed union initialization may lead to compilation error

The unnamed union should be possible to be initialized directly, but
unfortunately it's not so:

/usr/src/ipset/kernel/net/netfilter/ipset/ip_set_hash_netnet.c: In
function ?hash_netnet4_kadt?:
/usr/src/ipset/kernel/net/netfilter/ipset/ip_set_hash_netnet.c:141:
error: unknown field ?cidr? specified in initializer

Reported-by: Husnu Demir <hdemir@metu.edu.tr>
11 years agoUse dev_net() instead of the direct access to ->nd_net
Jozsef Kadlecsik [Fri, 4 Oct 2013 19:59:39 +0000 (21:59 +0200)]
Use dev_net() instead of the direct access to ->nd_net

We have to use dev_net() instead of the direct access to ->nd_net,
otherwise compilation fails if NET_NS is not enabled. Reported by
the kbuild test robot.

11 years agoipset 6.20 released v6.20
Jozsef Kadlecsik [Wed, 2 Oct 2013 20:53:23 +0000 (22:53 +0200)]
ipset 6.20 released

11 years agoMissing comment support added to hash:ip,port,ip and hash:net,iface types
Jozsef Kadlecsik [Wed, 2 Oct 2013 20:40:34 +0000 (22:40 +0200)]
Missing comment support added to hash:ip,port,ip and hash:net,iface types

11 years agoCompatibility code is modified not to rely on kernel version numbers
Jozsef Kadlecsik [Wed, 2 Oct 2013 15:31:15 +0000 (17:31 +0200)]
Compatibility code is modified not to rely on kernel version numbers

Instead the kernel source code is checked to verify the different
compatibility issues for the supported kernel releases.

This way hopefully backported features will be handled properly.

11 years agoUse netlink callback dump args only
Jozsef Kadlecsik [Wed, 2 Oct 2013 06:13:18 +0000 (08:13 +0200)]
Use netlink callback dump args only

Instead of cb->data, use callback dump args only and introduce symbolic
names instead of plain numbers at accessing the argument members.

11 years agoipset: Add userspace code to support hash:net,port,net kernel module.
Oliver Smith [Sat, 28 Sep 2013 18:20:01 +0000 (20:20 +0200)]
ipset: Add userspace code to support hash:net,port,net kernel module.

This adds the userspace library, tests to validate correct operation of
the module and also provides appropriate usage information in the man
page.

Signed-off-by: Oliver Smith <oliver@8.c.9.b.0.7.4.0.1.0.0.2.ip6.arpa>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
11 years agonetfilter: ipset: Add hash:net,port,net module to kernel.
Oliver Smith [Sat, 28 Sep 2013 18:33:23 +0000 (20:33 +0200)]
netfilter: ipset: Add hash:net,port,net module to kernel.

This adds a new set that provides similar functionality to ip,port,net
but permits arbitrary size subnets for both the first and last
parameter.

Signed-off-by: Oliver Smith <oliver@8.c.9.b.0.7.4.0.1.0.0.2.ip6.arpa>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
11 years agoipset: Add net namespace for ipset
Vitaly Lavrov [Sat, 28 Sep 2013 16:41:20 +0000 (18:41 +0200)]
ipset: Add net namespace for ipset

This patch adds netns support for ipset.

Major changes were made in ip_set_core.c and ip_set.h.
Global variables are moved to per net namespace.
Added initialization code and the destruction of the network namespace ipset subsystem.
In the prototypes of public functions ip_set_* added parameter "struct net*".

The remaining corrections related to the change prototypes of public functions ip_set_*.

The patch for git://git.netfilter.org/ipset.git commit 6a4ec96c0b8caac5c35474e40e319704d92ca347

Signed-off-by: Vitaly Lavrov <lve@guap.ru>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
11 years agoUse a common function at listing the extensions of the elements
Jozsef Kadlecsik [Wed, 25 Sep 2013 15:44:35 +0000 (17:44 +0200)]
Use a common function at listing the extensions of the elements

11 years agoTests added to check comment extension
Jozsef Kadlecsik [Tue, 24 Sep 2013 15:20:26 +0000 (17:20 +0200)]
Tests added to check comment extension

11 years agoFor set:list types, replaced elements must be zeroed out
Jozsef Kadlecsik [Mon, 23 Sep 2013 19:28:06 +0000 (21:28 +0200)]
For set:list types, replaced elements must be zeroed out

The new extensions require zero initialization for the new element
to be added into a slot from where another element was pushed away.

11 years agoFix hash resizing with comments
Jozsef Kadlecsik [Mon, 23 Sep 2013 15:45:21 +0000 (17:45 +0200)]
Fix hash resizing with comments

The destroy function must take into account that resizing doesn't
create new extensions so those cannot be destroyed at resize.

11 years agoipset: Add new userspace set revisions for comment support
Oliver Smith [Sun, 22 Sep 2013 18:56:36 +0000 (20:56 +0200)]
ipset: Add new userspace set revisions for comment support

This introduces new revisions of all hash and bitmap ipsets to
complement the comment functionality introduced into the kernel modules.

Currently all sets have a compile-time limit of 255 characters including
\0. This can otherwise be arbitrarily modified.

Signed-off-by: Oliver Smith <oliver@8.c.9.b.0.7.4.0.1.0.0.2.ip6.arpa>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
11 years agoipset: Support comments in the userspace library.
Oliver Smith [Sun, 22 Sep 2013 18:56:35 +0000 (20:56 +0200)]
ipset: Support comments in the userspace library.

This adds support to the userspace portion of ipset for handling ipsets
with the comment extension enabled. The library revision has been raised
accordingly.

Signed-off-by: Oliver Smith <oliver@8.c.9.b.0.7.4.0.1.0.0.2.ip6.arpa>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
11 years agoipset: Rework the "fake" argument parsing for ipset restore.
Oliver Smith [Sun, 22 Sep 2013 18:56:34 +0000 (20:56 +0200)]
ipset: Rework the "fake" argument parsing for ipset restore.

This reworks the argument parsing functionality of ipset to handle
quote-delimited lines in such a way that they are considered to be a
single argument.

This commit is necessary for ipset to successfully restore sets that
have comments.

Signed-off-by: Oliver Smith <oliver@8.c.9.b.0.7.4.0.1.0.0.2.ip6.arpa>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
11 years agonetfilter: ipset: Support comments in the list-type ipset.
Oliver Smith [Sun, 22 Sep 2013 18:56:33 +0000 (20:56 +0200)]
netfilter: ipset: Support comments in the list-type ipset.

This provides kernel support for creating list ipsets with the comment
annotation extension.

Signed-off-by: Oliver Smith <oliver@8.c.9.b.0.7.4.0.1.0.0.2.ip6.arpa>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
11 years agonetfilter: ipset: Support comments in bitmap-type ipsets.
Oliver Smith [Sun, 22 Sep 2013 18:56:32 +0000 (20:56 +0200)]
netfilter: ipset: Support comments in bitmap-type ipsets.

This provides kernel support for creating bitmap ipsets with comment
support.

As is the case for hashes, this incurs a penalty when flushing or
destroying the entire ipset as the entries must first be walked in order
to free the comment strings. This penalty is of course far less than the
cost of listing an ipset to userspace. Any set created without support
for comments will be flushed/destroyed as before.

Signed-off-by: Oliver Smith <oliver@8.c.9.b.0.7.4.0.1.0.0.2.ip6.arpa>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
11 years agonetfilter: ipset: Support comments in hash-type ipsets.
Oliver Smith [Sun, 22 Sep 2013 18:56:31 +0000 (20:56 +0200)]
netfilter: ipset: Support comments in hash-type ipsets.

This provides kernel support for creating ipsets with comment support.

This does incur a penalty to flushing/destroying an ipset since all
entries are walked in order to free the allocated strings, this penalty
is of course less expensive than the operation of listing an ipset to
userspace, so for general-purpose usage the overall impact is expected
to be little to none.

Signed-off-by: Oliver Smith <oliver@8.c.9.b.0.7.4.0.1.0.0.2.ip6.arpa>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
11 years agonetfilter: ipset: Support comments for ipset entries in the core.
Oliver Smith [Sun, 22 Sep 2013 18:56:30 +0000 (20:56 +0200)]
netfilter: ipset: Support comments for ipset entries in the core.

This adds the core support for having comments on ipset entries.

The comments are stored as standard null-terminated strings in
dynamically allocated memory after being passed to the kernel. As a
result of this, code has been added to the generic destroy function to
iterate all extensions and call that extension's destroy task if the set
has that extension activated, and if such a task is defined.

Signed-off-by: Oliver Smith <oliver@8.c.9.b.0.7.4.0.1.0.0.2.ip6.arpa>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
11 years agoipset: Add userspace code to support hash:net,net kernel module.
Oliver Smith [Fri, 20 Sep 2013 08:13:54 +0000 (10:13 +0200)]
ipset: Add userspace code to support hash:net,net kernel module.

This adds the userspace library, tests to validate correct operation of
the module and also provides appropriate usage information in the man
page. The library version has been bumped accordingly.

Signed-off-by: Oliver Smith <oliver@8.c.9.b.0.7.4.0.1.0.0.2.ip6.arpa>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
11 years agonetfilter: ipset: Add hash:net,net module to kernel.
Oliver Smith [Fri, 20 Sep 2013 08:13:53 +0000 (10:13 +0200)]
netfilter: ipset: Add hash:net,net module to kernel.

This adds a new set that provides the ability to configure pairs of
subnets. A small amount of additional handling code has been added to
the generic hash header file - this code is conditionally activated by a
preprocessor definition.

Signed-off-by: Oliver Smith <oliver@8.c.9.b.0.7.4.0.1.0.0.2.ip6.arpa>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
11 years agoKconfig: ipset needs NETFILTER_NETLINK
Jozsef Kadlecsik [Tue, 17 Sep 2013 08:32:58 +0000 (10:32 +0200)]
Kconfig: ipset needs NETFILTER_NETLINK

NETFILTER_NETLINK is not selectable in recent kernels, check and warn
if not enabled indirectly.

11 years agoAdd test to verify CIDR tracking
Jozsef Kadlecsik [Sun, 15 Sep 2013 13:11:17 +0000 (15:11 +0200)]
Add test to verify CIDR tracking

11 years agonetfilter: ipset: Fix serious failure in CIDR tracking
Oliver Smith [Sat, 14 Sep 2013 09:05:53 +0000 (11:05 +0200)]
netfilter: ipset: Fix serious failure in CIDR tracking

This fixes a serious bug affecting all hash types with a net element -
specifically, if a CIDR value is deleted such that none of the same size
exist any more, all larger (less-specific) values will then fail to
match. Adding back any prefix with a CIDR equal to or more specific than
the one deleted will fix it.

Steps to reproduce:
ipset -N test hash:net
ipset -A test 1.1.0.0/16
ipset -A test 2.2.2.0/24
ipset -T test 1.1.1.1 #1.1.1.1 IS in set
ipset -D test 2.2.2.0/24
ipset -T test 1.1.1.1 #1.1.1.1 IS NOT in set

This is due to the fact that the nets counter was unconditionally
decremented prior to the iteration that shifts up the entries. Now, we
first check if there is a proceeding entry and if not, decrement it and
return. Otherwise, we proceed to iterate and then zero the last element,
which, in most cases, will already be zero.

Signed-off-by: Oliver Smith <oliver@8.c.9.b.0.7.4.0.1.0.0.2.ip6.arpa>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
11 years agoconfigure: uclinux is also linux
Gustavo Zacarias [Tue, 10 Sep 2013 19:23:27 +0000 (16:23 -0300)]
configure: uclinux is also linux

Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
11 years agolist:set: make sure all elements are checked by the gc
Jozsef Kadlecsik [Mon, 9 Sep 2013 15:10:20 +0000 (17:10 +0200)]
list:set: make sure all elements are checked by the gc

When an element timed out, the next one was skipped by the garbage
collector, fixed.

11 years agoSupport extensions which need a per data destroy function
Jozsef Kadlecsik [Mon, 9 Sep 2013 12:44:29 +0000 (14:44 +0200)]
Support extensions which need a per data destroy function

11 years agoGeneralize extensions support
Jozsef Kadlecsik [Fri, 6 Sep 2013 22:43:52 +0000 (00:43 +0200)]
Generalize extensions support

Get rid of the structure based extensions and introduce a blob for
the extensions. Thus we can support more extension types easily.

11 years agoMove extension data to set structure
Jozsef Kadlecsik [Fri, 6 Sep 2013 22:10:07 +0000 (00:10 +0200)]
Move extension data to set structure

Default timeout and extension offsets are moved to struct set, because
all set types supports all extensions and it makes possible to generalize
extension support.

11 years agoRename extension offset ids to extension ids
Jozsef Kadlecsik [Fri, 6 Sep 2013 20:31:40 +0000 (22:31 +0200)]
Rename extension offset ids to extension ids

11 years agoPrepare ipset to support multiple networks for hash types
Jozsef Kadlecsik [Wed, 4 Sep 2013 14:56:12 +0000 (16:56 +0200)]
Prepare ipset to support multiple networks for hash types

In order to support hash:net,net, hash:net,port,net etc. types,
arrays are introduced for the book-keeping of existing cidr sizes
and network numbers in a set.

11 years agoIntroduce new operation to get both setname and family
Jozsef Kadlecsik [Wed, 4 Sep 2013 14:49:08 +0000 (16:49 +0200)]
Introduce new operation to get both setname and family

ip[6]tables set match and SET target need to know the family of the set
in order to reject adding rules which refer to a set with a non-mathcing
family. Currently such rules are silently accepted and then ignored
instead of generating a clear error message to the user, which is not
helpful.

11 years agoAdd specifying protocol for bitmap:port
Quentin Armitage [Fri, 9 Aug 2013 11:26:33 +0000 (12:26 +0100)]
Add specifying protocol for bitmap:port

Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
11 years agoRemove artifical restriction of netmask values for hash:ip type.
Jozsef Kadlecsik [Sat, 17 Aug 2013 19:12:53 +0000 (21:12 +0200)]
Remove artifical restriction of netmask values for hash:ip type.

Reported by Quentin Armitage, closes netfilter bugzilla id #844.

11 years agoMake sure called test scripts can be executed (reported by Tomas Budai)
Jozsef Kadlecsik [Fri, 16 Aug 2013 21:25:58 +0000 (23:25 +0200)]
Make sure called test scripts can be executed (reported by Tomas Budai)

11 years agoManpage fix: not just identical, but compatible type of sets can be swapped
Jozsef Kadlecsik [Wed, 14 Aug 2013 14:10:34 +0000 (16:10 +0200)]
Manpage fix: not just identical, but compatible type of sets can be swapped

Reported by Quentin Armitage, netfilter bugzilla id #843.

11 years agoValidate the set family and not the set type family at swapping.
Jozsef Kadlecsik [Wed, 14 Aug 2013 14:07:49 +0000 (16:07 +0200)]
Validate the set family and not the set type family at swapping.

Bug reported by Quentin Armitage, netfilter bugzilla id #843.

11 years agoFix error message typo
Jozsef Kadlecsik [Wed, 14 Aug 2013 13:59:54 +0000 (15:59 +0200)]
Fix error message typo

Reported by Quentin Armitage, netfilter bugzilla id #843.

11 years agoParse option "family" first, because other options may depend on it
Jozsef Kadlecsik [Wed, 14 Aug 2013 13:41:20 +0000 (15:41 +0200)]
Parse option "family" first, because other options may depend on it

Option like "netmask" depends on the INET family, so parse "family"
first, then the rest of the options.

Bug reported by Quentin Armitage, closed netfilter bugzilla #841.

11 years agoChange 2nd parameter type of ipset_parse_elem
Quentin Armitage [Thu, 1 Aug 2013 21:17:03 +0000 (23:17 +0200)]
Change 2nd parameter type of ipset_parse_elem

The only place in ipset where ipset_parse_elem is called is src/ipset.c. The
second parameter to the function call is type->last_elem_optional, which is of
type bool, but ipset_parse_elem is defined in lib/parse.c with the second
parameter having type enum ipset_opt.

The use in lib/parse.c is clearly as a bool.

11 years agoConsistent userspace testing with nomatch flag
Jozsef Kadlecsik [Sat, 20 Jul 2013 14:44:42 +0000 (16:44 +0200)]
Consistent userspace testing with nomatch flag

The "nomatch" commandline flag should invert the matching at testing,
similarly to the --return-nomatch flag of the "set" match of iptables.
Until now it worked with the elements with "nomatch" flag only. From
now on it works with elements without the flag too, i.e:

 # ipset n test hash:net
 # ipset a test 10.0.0.0/24 nomatch
 # ipset t test 10.0.0.1
 10.0.0.1 is NOT in set test.
 # ipset t test 10.0.0.1 nomatch
 10.0.0.1 is in set test.

 # ipset a test 192.168.0.0/24
 # ipset t test 192.168.0.1
 192.168.0.1 is in set test.
 # ipset t test 192.168.0.1 nomatch
 192.168.0.1 is NOT in set test.

 Before the patch the results were

 ...
 # ipset t test 192.168.0.1
 192.168.0.1 is in set test.
 # ipset t test 192.168.0.1 nomatch
 192.168.0.1 is in set test.

11 years agoReport broken netlink messages in debug mode
Jozsef Kadlecsik [Fri, 19 Jul 2013 19:54:02 +0000 (21:54 +0200)]
Report broken netlink messages in debug mode

11 years agoSkip really non-first fragments for IPv6 when getting port/protocol
Jozsef Kadlecsik [Fri, 31 May 2013 21:14:36 +0000 (23:14 +0200)]
Skip really non-first fragments for IPv6 when getting port/protocol

11 years agoipset standalone package needs to ship em_ipset.c
Jozsef Kadlecsik [Fri, 31 May 2013 20:52:54 +0000 (22:52 +0200)]
ipset standalone package needs to ship em_ipset.c

Due to the ipset kernel API changes, em_ipset.c needs to be provided
in the ipset package, reported by Jan Engelhardt:

WARNING: //lib/modules/3.7.10-jng15-default/kernel/net/sched/em_ipset.ko
disagrees about version of symbol ip_set_test

11 years agoipset: Fix hyphen used as minus sign in manpage
Neutron Soutmun [Sun, 12 May 2013 09:30:57 +0000 (16:30 +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>
11 years agolibipset.pc must be installed via 'make install'
Eric Leblond [Fri, 10 May 2013 20:25:17 +0000 (22:25 +0200)]
libipset.pc must be installed via 'make install'

libipset.pc was not installed by classic 'make install'. This
patch adds it to the list of installed files.

Signed-off-by: Eric Leblond <eric@regit.org>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
11 years agoipset 6.19 released v6.19
Jozsef Kadlecsik [Thu, 9 May 2013 15:33:39 +0000 (17:33 +0200)]
ipset 6.19 released

11 years agoCompatibility fixes to keep the support of kernels back to 2.6.32
Jozsef Kadlecsik [Thu, 9 May 2013 15:31:15 +0000 (17:31 +0200)]
Compatibility fixes to keep the support of kernels back to 2.6.32

11 years agoCheck at modules_install whether depmod ignores the extra subdir
Jozsef Kadlecsik [Thu, 9 May 2013 09:49:40 +0000 (11:49 +0200)]
Check at modules_install whether depmod ignores the extra subdir

The external kernel modules are installed in the extra subdir in
/lib/modules/<kernelrelease>/, but depmod in some distributions
(at least in Ubuntu 12.04 LTS) ingores the subdir. Warn about it,
because that way the modules are actually not available there.

Reported by Husnu Demir and tian fang.

11 years agoBackport nla_put_net64
Jozsef Kadlecsik [Thu, 9 May 2013 09:49:16 +0000 (11:49 +0200)]
Backport nla_put_net64

11 years agoThe utils are updated from their sources
Jozsef Kadlecsik [Tue, 7 May 2013 20:11:12 +0000 (22:11 +0200)]
The utils are updated from their sources

11 years agoSupport package fragments for IPv4 protos without ports
Anders K. Pedersen [Fri, 3 May 2013 21:15:48 +0000 (23:15 +0200)]
Support package fragments for IPv4 protos without ports

Enable ipset port set types to match IPv4 package fragments for
protocols that doesn't have ports (or the port information isn't
supported by ipset).

For example this allows a hash:ip,port ipset containing the entry
192.168.0.1,gre:0 to match all package fragments for PPTP VPN tunnels
to/from the host. Without this patch only the first package fragment
(with fragment offset 0) was matched, while subsequent fragments wasn't.

This is not possible for IPv6, where the protocol is in the fragmented
part of the package unlike IPv4, where the protocol is in the IP header.

IPPROTO_ICMPV6 is deliberately not included, because it isn't relevant
for IPv4.

Signed-off-by: Anders K. Pedersen <akp@surftown.com>
11 years agoManpage typing error correction (reported by Husnu Demir)
Jozsef Kadlecsik [Thu, 2 May 2013 11:37:33 +0000 (13:37 +0200)]
Manpage typing error correction (reported by Husnu Demir)

11 years agoUpdate testsuite as the trailing space was eliminated at listings
Jozsef Kadlecsik [Thu, 2 May 2013 09:36:06 +0000 (11:36 +0200)]
Update testsuite as the trailing space was eliminated at listings

11 years agoUse fix sized type for timeout in the extension part
Jozsef Kadlecsik [Thu, 2 May 2013 08:52:27 +0000 (10:52 +0200)]
Use fix sized type for timeout in the extension part

11 years agoAdd sparse checking support to userspace
Jozsef Kadlecsik [Thu, 2 May 2013 08:51:55 +0000 (10:51 +0200)]
Add sparse checking support to userspace

11 years agoImprove XML output: add element tag and root element (suggested by Lucas Hamie)
Jozsef Kadlecsik [Wed, 1 May 2013 17:50:41 +0000 (19:50 +0200)]
Improve XML output: add element tag and root element (suggested by Lucas Hamie)

11 years agoMake sure kernel configured properly for sparse checkings
Jozsef Kadlecsik [Wed, 1 May 2013 16:48:27 +0000 (18:48 +0200)]
Make sure kernel configured properly for sparse checkings

11 years agoFix "may be used uninitialized" warnings
Jozsef Kadlecsik [Wed, 1 May 2013 16:47:32 +0000 (18:47 +0200)]
Fix "may be used uninitialized" warnings

Reported-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoRename simple macro names to avoid namespace issues.
Jozsef Kadlecsik [Tue, 30 Apr 2013 21:02:43 +0000 (23:02 +0200)]
Rename simple macro names to avoid namespace issues.

Reported-by: David Laight <David.Laight@ACULAB.COM>
11 years agoFix sparse warnings due to missing rcu annotations
Jozsef Kadlecsik [Tue, 30 Apr 2013 19:23:18 +0000 (21:23 +0200)]
Fix sparse warnings due to missing rcu annotations

Reported-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoSparse warning about shadowed variable fixed
Jozsef Kadlecsik [Tue, 30 Apr 2013 16:40:43 +0000 (18:40 +0200)]
Sparse warning about shadowed variable fixed

net/netfilter/ipset/ip_set_hash_ipportnet.c:275:20:
warning: symbol 'cidr' shadows an earlier one

11 years agoDon't call ip_nest_end needlessly in the error path
Jozsef Kadlecsik [Sat, 27 Apr 2013 19:02:59 +0000 (21:02 +0200)]
Don't call ip_nest_end needlessly in the error path

Suggested-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoManpage updates
Jozsef Kadlecsik [Fri, 5 Apr 2013 14:55:02 +0000 (16:55 +0200)]
Manpage updates

Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
11 years agoAdd new testsuite entries to verify counters and the new type implementations
Jozsef Kadlecsik [Thu, 4 Apr 2013 14:32:20 +0000 (16:32 +0200)]
Add new testsuite entries to verify counters and the new type implementations

Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
11 years agoIntroduce the new set type revisions with counter support
Jozsef Kadlecsik [Tue, 9 Apr 2013 15:17:50 +0000 (17:17 +0200)]
Introduce the new set type revisions with counter support

Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
11 years agoSupport counters in the ipset library
Jozsef Kadlecsik [Tue, 9 Apr 2013 15:17:00 +0000 (17:17 +0200)]
Support counters in the ipset library

Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
11 years agoset match: add support to match the counters
Jozsef Kadlecsik [Tue, 9 Apr 2013 15:14:19 +0000 (17:14 +0200)]
set match: add support to match the counters

The new revision of the set match supports to match the counters
and to suppress updating the counters at matching too.

At the set:list types, the updating of the subcounters can be
suppressed as well.

Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
11 years agoThe list:set type with counter support
Jozsef Kadlecsik [Mon, 8 Apr 2013 21:11:32 +0000 (23:11 +0200)]
The list:set type with counter support

Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>