From 0d32c5c070f817229110f92d7b31df9a3e4eeec5 Mon Sep 17 00:00:00 2001 From: Jozsef Kadlecsik Date: Sun, 24 Oct 2010 21:42:48 +0200 Subject: Fixes, cleanups, comments - More comments added to the code - ICMP and ICMPv6 support added to the hash:ip,port, hash:ip,port,ip and hash:ip,port,net types - hash:net and hash:ip,port,net types are reworked - hash:net,port type added - Wrong direction parameters fixed in hash:ip,port - Helps and manpage are updated - More tests added - Ugly macros are rewritten to functions in parse.c (Holger Eitzenberger) - resize related bug in hash types fixed (Holger Eitzenberger) - autoreconf patches by Jan Engelhardt applied - netlink patch minimalized: dumping can be initialized by a second parsing of the message (thanks to David and Patrick for the suggestion) - IPv4/IPv6 address attributes are introduced in order to fix the context (suggested by David) --- lib/types.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'lib/types.c') diff --git a/lib/types.c b/lib/types.c index e3cad35..3d9b034 100644 --- a/lib/types.c +++ b/lib/types.c @@ -11,6 +11,7 @@ #include /* AF_ */ #include /* malloc, free */ #include /* FIXME: debug */ +#include /* MNL_ALIGN */ #include /* D() */ #include /* ipset_data_* */ @@ -438,14 +439,25 @@ type_max_size(struct ipset_type *type, uint8_t family) continue; if (!(IPSET_FLAG(opt) & type->full[IPSET_ADD])) continue; - max += ipset_data_sizeof(opt, family); + max += MNL_ALIGN(ipset_data_sizeof(opt, family)) + + MNL_ATTR_HDRLEN; + switch (opt) { + case IPSET_OPT_IP: + case IPSET_OPT_IP_TO: + case IPSET_OPT_IP2: + /* Nested attributes */ + max += MNL_ATTR_HDRLEN; + break; + default: + break; + } } type->maxsize[sizeid] = max; } /** * ipset_type_add - add (register) a userspace set type - * @type: set type structure + * @type: pointer to the set type structure * * Add the given set type to the type list. The types * are added sorted, in descending revision number. -- cgit v1.2.3