aboutsummaryrefslogtreecommitdiffstats
path: root/net/netfilter
diff options
context:
space:
mode:
authorOliver Smith <oliver@8.c.9.b.0.7.4.0.1.0.0.2.ip6.arpa>2013-09-22 14:56:30 -0400
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>2013-09-30 15:33:28 -0400
commit68b63f08d22f23161c43cd2417104aa213ff877f (patch)
tree33271d9a7e9670cbc4506901c21ff87154f6bf3a /net/netfilter
parentea53ac5b630e813aec20c7cdcfe511daca70dee4 (diff)
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>
Diffstat (limited to 'net/netfilter')
-rw-r--r--net/netfilter/ipset/ip_set_core.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
index f35afed3814f..3bf9a3d29dff 100644
--- a/net/netfilter/ipset/ip_set_core.c
+++ b/net/netfilter/ipset/ip_set_core.c
@@ -315,6 +315,7 @@ ip_set_get_ipaddr6(struct nlattr *nla, union nf_inet_addr *ipaddr)
315} 315}
316EXPORT_SYMBOL_GPL(ip_set_get_ipaddr6); 316EXPORT_SYMBOL_GPL(ip_set_get_ipaddr6);
317 317
318typedef void (*destroyer)(void *);
318/* ipset data extension types, in size order */ 319/* ipset data extension types, in size order */
319 320
320const struct ip_set_ext_type ip_set_extensions[] = { 321const struct ip_set_ext_type ip_set_extensions[] = {
@@ -329,6 +330,13 @@ const struct ip_set_ext_type ip_set_extensions[] = {
329 .len = sizeof(unsigned long), 330 .len = sizeof(unsigned long),
330 .align = __alignof__(unsigned long), 331 .align = __alignof__(unsigned long),
331 }, 332 },
333 [IPSET_EXT_ID_COMMENT] = {
334 .type = IPSET_EXT_COMMENT | IPSET_EXT_DESTROY,
335 .flag = IPSET_FLAG_WITH_COMMENT,
336 .len = sizeof(struct ip_set_comment),
337 .align = __alignof__(struct ip_set_comment),
338 .destroy = (destroyer) ip_set_comment_free,
339 },
332}; 340};
333EXPORT_SYMBOL_GPL(ip_set_extensions); 341EXPORT_SYMBOL_GPL(ip_set_extensions);
334 342
@@ -380,6 +388,12 @@ ip_set_get_extensions(struct ip_set *set, struct nlattr *tb[],
380 ext->packets = be64_to_cpu(nla_get_be64( 388 ext->packets = be64_to_cpu(nla_get_be64(
381 tb[IPSET_ATTR_PACKETS])); 389 tb[IPSET_ATTR_PACKETS]));
382 } 390 }
391 if (tb[IPSET_ATTR_COMMENT]) {
392 if (!(set->extensions & IPSET_EXT_COMMENT))
393 return -IPSET_ERR_COMMENT;
394 ext->comment = ip_set_comment_uget(tb[IPSET_ATTR_COMMENT]);
395 }
396
383 return 0; 397 return 0;
384} 398}
385EXPORT_SYMBOL_GPL(ip_set_get_extensions); 399EXPORT_SYMBOL_GPL(ip_set_get_extensions);