Jozsef Kadlecsik [Sun, 22 May 2011 10:18:36 +0000 (12:18 +0200)]
Take into account cidr value for the from address when creating the set
When creating a set from a range expressed as a network like
10.1.1.172/29, the from address was taken as the IP address part and
not masked with the netmask from the cidr.
Jozsef Kadlecsik [Sat, 21 May 2011 21:19:04 +0000 (23:19 +0200)]
Adding ranges to hash types with timeout could still fail, fixed
The patch "Fix adding ranges to hash types" had got a mistypeing
in the timeout variant of the hash types, which actually made
the patch ineffective. Fixed!
Jozsef Kadlecsik [Tue, 17 May 2011 17:28:10 +0000 (19:28 +0200)]
Remove outdated checking of IPv6 support from configure.ac
ipset can be compiled without IPv6 support since 6.0, however
the outdated checking in configure.ac made it not possible.
(reported by Denys Fedoryshchenko)
Jozsef Kadlecsik [Sun, 15 May 2011 10:04:19 +0000 (12:04 +0200)]
Support range for IPv4 at adding/deleting elements for hash:*net* types
The range internally is converted to the network(s) equal to the range.
Example:
# ipset new test hash:net
# ipset add test 10.2.0.0-10.2.1.12
# ipset list test
Name: test
Type: hash:net
Header: family inet hashsize 1024 maxelem 65536
Size in memory: 16888
References: 0
Members:
10.2.1.12
10.2.1.0/29
10.2.0.0/24
10.2.1.8/30
When ranges are added to hash types, the elements may trigger rehashing the set.
However, the last successfully added element was not kept track so the adding
started again with the first element after the rehashing. Bug reported by Mr Dash Four.
Current listing makes possible to list sets with full content only.
The patch adds support partial listings, i.e. listing just
the existing setnames or listing set headers, without set members.
A restoreable saving of sets requires that list:set type of sets
come last and the code part which should have taken into account
the ordering was broken. The patch fixes the listing order.
Testsuite entry added which checks the listing order.
The SET target with --del-set did not work due to using wrongly
the internal dimension of --add-set instead of --del-set.
Also, the checkentries did not release the set references when
returned an error. Bugs reported by Lennert Buytenhek.
Enforce that the second "src/dst" parameter of the set match and SET target
must be "src", because we have access to the source MAC only in the packet.
The previous behaviour, that the type required the second parameter
but actually ignored the value was counter-intuitive and confusing.
Jozsef Kadlecsik [Sun, 27 Mar 2011 19:01:33 +0000 (21:01 +0200)]
Timeout can be modified for already added elements
When an element to a set with timeout added, one can change the timeout
by "readding" the element with the "-exist" flag. That means the timeout
value is reset to the specified one (or to the default from the set
specification if the "timeout n" option is not used). Example
Jozsef Kadlecsik [Fri, 25 Mar 2011 10:10:29 +0000 (11:10 +0100)]
References are protected by rwlock instead of mutex
The timeout variant of the list:set type must reference the member sets.
However, its garbage collector runs at timer interrupt so the mutex protection
of the references is a no go. Therefore the reference protection
is converted to rwlock.
Jozsef Kadlecsik [Fri, 18 Mar 2011 16:23:43 +0000 (17:23 +0100)]
Fix checking the revision of the set type at create command
The revision number was not checked at the create command: if the userspace
sent a valid set type but with not supported revision number, it'd create
a loop.
Jozsef Kadlecsik [Fri, 18 Mar 2011 16:21:20 +0000 (17:21 +0100)]
hash:ip,port* types with IPv4
The hash:ip,port* types with IPv4 silently ignored when address ranges
with non TCP/UDP were added/deleted from the set and the first address from
the range was only used.
Patrick McHardy [Thu, 3 Feb 2011 09:27:49 +0000 (10:27 +0100)]
netfilter: ipset: fix linking with CONFIG_IPV6=n
Add some #ifdefs to unconditionally return false in
ip_set_get_ip6_port() when CONFIG_IPV6=n and convert
to ipv6_skip_exthdr() to avoid pulling in the ip6_tables
module when loading ipset.
When a message carries multiple commands and one of them triggers
an error, we have to report to the userspace which one was that.
The line number of the command plays this role and there's an attribute
reserved in the header part of the message to be filled out with the error
line number. In order not to modify the original message received from
the userspace, we construct a new, complete netlink error message and
modifies the attribute there, then send it.
Netlink is notified not to send its ACK/error message.
Patrick McHardy [Tue, 1 Feb 2011 19:53:53 +0000 (20:53 +0100)]
netfilter: ipset: remove unnecessary includes
None of the set types need uaccess.h since this is handled centrally
in ip_set_core. Most set types additionally don't need bitops.h and
spinlock.h since they use neither. tcp.h is only needed by those
using before(), udp.h is not needed at all.
After stripping off the global options there simply has to follow
a command name, there is no other syntax possible. Therefore the
argv[] loop is unnecessary.
Jozsef Kadlecsik [Thu, 27 Jan 2011 11:44:17 +0000 (12:44 +0100)]
Move the type specifici attribute validation to the core
The type specific attribute validation can be moved to the ipset core.
That way it's done centrally and thus can be eliminated from the individual
set types (suggested by Patrick McHardy).
Jozsef Kadlecsik [Wed, 26 Jan 2011 21:59:25 +0000 (22:59 +0100)]
Constified attribute cannot be written
Attribute is const so a little bit more work is needed to return
the error line number. A test is also added in order to check
the functionality. (Patrick McHardy's review)
Do not use time() as a Netlink sequence number for each message,
as otherwise the same seq number will be used when sending
another message in the same second. Instead use time() just for
initialization, then increment per message.
Note that passing errno values back is not done consistently at
various place, as there are some functions which set errno manually,
others pass -errno back. I use the -errno approach here, as it is
slightly shorter.
Jozsef Kadlecsik [Mon, 24 Jan 2011 16:38:26 +0000 (17:38 +0100)]
Avoid possible syntax clashing at saving hostnames
If resolving is requested and the resolved hostname contains a dash
character, print the unresolved IP address instead in order not to
clash with the IP/hostname range syntax.
Jozsef Kadlecsik [Fri, 21 Jan 2011 20:29:50 +0000 (21:29 +0100)]
Fixed broken ICMP and ICMPv6 handling
I mistyped the bitwise operator and the network-order conversion was
missing too. Sigh, sendip cannot generate proper packets to check
ICMP and ICMPv6 in the testsuite. :-(
Jozsef Kadlecsik [Fri, 21 Jan 2011 10:39:56 +0000 (11:39 +0100)]
Fix trailing whitespaces and pr_* messages
Some trailing whitespace slipped in, those are removed. With the deleted
ip_set_kernel.h, the pr_* messages lost the trailing "\n" character.
The messages were completed with it.
Jozsef Kadlecsik [Thu, 20 Jan 2011 16:54:26 +0000 (17:54 +0100)]
Enforce network-order data in the netlink protocol
Allow only network-order data, with NLA_F_NET_BYTEORDER flag.
Sanity checks also added to prevent processing broken messages
where mandatory attributes are missing. (Patrick McHardy's review)