]> git.karo-electronics.de Git - karo-tx-linux.git/blob - net/netfilter/ipset/ip_set_list_set.c
Merge remote-tracking branch 'wireless-next/master'
[karo-tx-linux.git] / net / netfilter / ipset / ip_set_list_set.c
1 /* Copyright (C) 2008-2013 Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
2  *
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License version 2 as
5  * published by the Free Software Foundation.
6  */
7
8 /* Kernel module implementing an IP set type: the list:set type */
9
10 #include <linux/module.h>
11 #include <linux/ip.h>
12 #include <linux/skbuff.h>
13 #include <linux/errno.h>
14
15 #include <linux/netfilter/ipset/ip_set.h>
16 #include <linux/netfilter/ipset/ip_set_list.h>
17
18 #define IPSET_TYPE_REV_MIN      0
19 /*                              1    Counters support added */
20 #define IPSET_TYPE_REV_MAX      2 /* Comments support added */
21
22 MODULE_LICENSE("GPL");
23 MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>");
24 IP_SET_MODULE_DESC("list:set", IPSET_TYPE_REV_MIN, IPSET_TYPE_REV_MAX);
25 MODULE_ALIAS("ip_set_list:set");
26
27 /* Member elements  */
28 struct set_elem {
29         ip_set_id_t id;
30 };
31
32 struct set_adt_elem {
33         ip_set_id_t id;
34         ip_set_id_t refid;
35         int before;
36 };
37
38 /* Type structure */
39 struct list_set {
40         u32 size;               /* size of set list array */
41         struct timer_list gc;   /* garbage collection */
42         struct net *net;        /* namespace */
43         struct set_elem members[0]; /* the set members */
44 };
45
46 #define list_set_elem(set, map, id)     \
47         (struct set_elem *)((void *)(map)->members + (id) * (set)->dsize)
48
49 static int
50 list_set_ktest(struct ip_set *set, const struct sk_buff *skb,
51                const struct xt_action_param *par,
52                struct ip_set_adt_opt *opt, const struct ip_set_ext *ext)
53 {
54         struct list_set *map = set->data;
55         struct set_elem *e;
56         u32 i, cmdflags = opt->cmdflags;
57         int ret;
58
59         /* Don't lookup sub-counters at all */
60         opt->cmdflags &= ~IPSET_FLAG_MATCH_COUNTERS;
61         if (opt->cmdflags & IPSET_FLAG_SKIP_SUBCOUNTER_UPDATE)
62                 opt->cmdflags &= ~IPSET_FLAG_SKIP_COUNTER_UPDATE;
63         for (i = 0; i < map->size; i++) {
64                 e = list_set_elem(set, map, i);
65                 if (e->id == IPSET_INVALID_ID)
66                         return 0;
67                 if (SET_WITH_TIMEOUT(set) &&
68                     ip_set_timeout_expired(ext_timeout(e, set)))
69                         continue;
70                 ret = ip_set_test(e->id, skb, par, opt);
71                 if (ret > 0) {
72                         if (SET_WITH_COUNTER(set))
73                                 ip_set_update_counter(ext_counter(e, set),
74                                                       ext, &opt->ext,
75                                                       cmdflags);
76                         return ret;
77                 }
78         }
79         return 0;
80 }
81
82 static int
83 list_set_kadd(struct ip_set *set, const struct sk_buff *skb,
84               const struct xt_action_param *par,
85               struct ip_set_adt_opt *opt, const struct ip_set_ext *ext)
86 {
87         struct list_set *map = set->data;
88         struct set_elem *e;
89         u32 i;
90         int ret;
91
92         for (i = 0; i < map->size; i++) {
93                 e = list_set_elem(set, map, i);
94                 if (e->id == IPSET_INVALID_ID)
95                         return 0;
96                 if (SET_WITH_TIMEOUT(set) &&
97                     ip_set_timeout_expired(ext_timeout(e, set)))
98                         continue;
99                 ret = ip_set_add(e->id, skb, par, opt);
100                 if (ret == 0)
101                         return ret;
102         }
103         return 0;
104 }
105
106 static int
107 list_set_kdel(struct ip_set *set, const struct sk_buff *skb,
108               const struct xt_action_param *par,
109               struct ip_set_adt_opt *opt, const struct ip_set_ext *ext)
110 {
111         struct list_set *map = set->data;
112         struct set_elem *e;
113         u32 i;
114         int ret;
115
116         for (i = 0; i < map->size; i++) {
117                 e = list_set_elem(set, map, i);
118                 if (e->id == IPSET_INVALID_ID)
119                         return 0;
120                 if (SET_WITH_TIMEOUT(set) &&
121                     ip_set_timeout_expired(ext_timeout(e, set)))
122                         continue;
123                 ret = ip_set_del(e->id, skb, par, opt);
124                 if (ret == 0)
125                         return ret;
126         }
127         return 0;
128 }
129
130 static int
131 list_set_kadt(struct ip_set *set, const struct sk_buff *skb,
132               const struct xt_action_param *par,
133               enum ipset_adt adt, struct ip_set_adt_opt *opt)
134 {
135         struct ip_set_ext ext = IP_SET_INIT_KEXT(skb, opt, set);
136
137         switch (adt) {
138         case IPSET_TEST:
139                 return list_set_ktest(set, skb, par, opt, &ext);
140         case IPSET_ADD:
141                 return list_set_kadd(set, skb, par, opt, &ext);
142         case IPSET_DEL:
143                 return list_set_kdel(set, skb, par, opt, &ext);
144         default:
145                 break;
146         }
147         return -EINVAL;
148 }
149
150 static bool
151 id_eq(const struct ip_set *set, u32 i, ip_set_id_t id)
152 {
153         const struct list_set *map = set->data;
154         const struct set_elem *e;
155
156         if (i >= map->size)
157                 return 0;
158
159         e = list_set_elem(set, map, i);
160         return !!(e->id == id &&
161                  !(SET_WITH_TIMEOUT(set) &&
162                    ip_set_timeout_expired(ext_timeout(e, set))));
163 }
164
165 static int
166 list_set_add(struct ip_set *set, u32 i, struct set_adt_elem *d,
167              const struct ip_set_ext *ext)
168 {
169         struct list_set *map = set->data;
170         struct set_elem *e = list_set_elem(set, map, i);
171
172         if (e->id != IPSET_INVALID_ID) {
173                 if (i == map->size - 1) {
174                         /* Last element replaced: e.g. add new,before,last */
175                         ip_set_put_byindex(map->net, e->id);
176                         ip_set_ext_destroy(set, e);
177                 } else {
178                         struct set_elem *x = list_set_elem(set, map,
179                                                            map->size - 1);
180
181                         /* Last element pushed off */
182                         if (x->id != IPSET_INVALID_ID) {
183                                 ip_set_put_byindex(map->net, x->id);
184                                 ip_set_ext_destroy(set, x);
185                         }
186                         memmove(list_set_elem(set, map, i + 1), e,
187                                 set->dsize * (map->size - (i + 1)));
188                         /* Extensions must be initialized to zero */
189                         memset(e, 0, set->dsize);
190                 }
191         }
192
193         e->id = d->id;
194         if (SET_WITH_TIMEOUT(set))
195                 ip_set_timeout_set(ext_timeout(e, set), ext->timeout);
196         if (SET_WITH_COUNTER(set))
197                 ip_set_init_counter(ext_counter(e, set), ext);
198         if (SET_WITH_COMMENT(set))
199                 ip_set_init_comment(ext_comment(e, set), ext);
200         return 0;
201 }
202
203 static int
204 list_set_del(struct ip_set *set, u32 i)
205 {
206         struct list_set *map = set->data;
207         struct set_elem *e = list_set_elem(set, map, i);
208
209         ip_set_put_byindex(map->net, e->id);
210         ip_set_ext_destroy(set, e);
211
212         if (i < map->size - 1)
213                 memmove(e, list_set_elem(set, map, i + 1),
214                         set->dsize * (map->size - (i + 1)));
215
216         /* Last element */
217         e = list_set_elem(set, map, map->size - 1);
218         e->id = IPSET_INVALID_ID;
219         return 0;
220 }
221
222 static void
223 set_cleanup_entries(struct ip_set *set)
224 {
225         struct list_set *map = set->data;
226         struct set_elem *e;
227         u32 i = 0;
228
229         while (i < map->size) {
230                 e = list_set_elem(set, map, i);
231                 if (e->id != IPSET_INVALID_ID &&
232                     ip_set_timeout_expired(ext_timeout(e, set)))
233                         list_set_del(set, i);
234                         /* Check element moved to position i in next loop */
235                 else
236                         i++;
237         }
238 }
239
240 static int
241 list_set_utest(struct ip_set *set, void *value, const struct ip_set_ext *ext,
242                struct ip_set_ext *mext, u32 flags)
243 {
244         struct list_set *map = set->data;
245         struct set_adt_elem *d = value;
246         struct set_elem *e;
247         u32 i;
248         int ret;
249
250         for (i = 0; i < map->size; i++) {
251                 e = list_set_elem(set, map, i);
252                 if (e->id == IPSET_INVALID_ID)
253                         return 0;
254                 else if (SET_WITH_TIMEOUT(set) &&
255                          ip_set_timeout_expired(ext_timeout(e, set)))
256                         continue;
257                 else if (e->id != d->id)
258                         continue;
259
260                 if (d->before == 0)
261                         return 1;
262                 else if (d->before > 0)
263                         ret = id_eq(set, i + 1, d->refid);
264                 else
265                         ret = i > 0 && id_eq(set, i - 1, d->refid);
266                 return ret;
267         }
268         return 0;
269 }
270
271
272 static int
273 list_set_uadd(struct ip_set *set, void *value, const struct ip_set_ext *ext,
274               struct ip_set_ext *mext, u32 flags)
275 {
276         struct list_set *map = set->data;
277         struct set_adt_elem *d = value;
278         struct set_elem *e;
279         bool flag_exist = flags & IPSET_FLAG_EXIST;
280         u32 i, ret = 0;
281
282         if (SET_WITH_TIMEOUT(set))
283                 set_cleanup_entries(set);
284
285         /* Check already added element */
286         for (i = 0; i < map->size; i++) {
287                 e = list_set_elem(set, map, i);
288                 if (e->id == IPSET_INVALID_ID)
289                         goto insert;
290                 else if (e->id != d->id)
291                         continue;
292
293                 if ((d->before > 1 && !id_eq(set, i + 1, d->refid)) ||
294                     (d->before < 0 &&
295                      (i == 0 || !id_eq(set, i - 1, d->refid))))
296                         /* Before/after doesn't match */
297                         return -IPSET_ERR_REF_EXIST;
298                 if (!flag_exist)
299                         /* Can't re-add */
300                         return -IPSET_ERR_EXIST;
301                 /* Update extensions */
302                 ip_set_ext_destroy(set, e);
303
304                 if (SET_WITH_TIMEOUT(set))
305                         ip_set_timeout_set(ext_timeout(e, set), ext->timeout);
306                 if (SET_WITH_COUNTER(set))
307                         ip_set_init_counter(ext_counter(e, set), ext);
308                 if (SET_WITH_COMMENT(set))
309                         ip_set_init_comment(ext_comment(e, set), ext);
310                 /* Set is already added to the list */
311                 ip_set_put_byindex(map->net, d->id);
312                 return 0;
313         }
314 insert:
315         ret = -IPSET_ERR_LIST_FULL;
316         for (i = 0; i < map->size && ret == -IPSET_ERR_LIST_FULL; i++) {
317                 e = list_set_elem(set, map, i);
318                 if (e->id == IPSET_INVALID_ID)
319                         ret = d->before != 0 ? -IPSET_ERR_REF_EXIST
320                                 : list_set_add(set, i, d, ext);
321                 else if (e->id != d->refid)
322                         continue;
323                 else if (d->before > 0)
324                         ret = list_set_add(set, i, d, ext);
325                 else if (i + 1 < map->size)
326                         ret = list_set_add(set, i + 1, d, ext);
327         }
328
329         return ret;
330 }
331
332 static int
333 list_set_udel(struct ip_set *set, void *value, const struct ip_set_ext *ext,
334               struct ip_set_ext *mext, u32 flags)
335 {
336         struct list_set *map = set->data;
337         struct set_adt_elem *d = value;
338         struct set_elem *e;
339         u32 i;
340
341         for (i = 0; i < map->size; i++) {
342                 e = list_set_elem(set, map, i);
343                 if (e->id == IPSET_INVALID_ID)
344                         return d->before != 0 ? -IPSET_ERR_REF_EXIST
345                                               : -IPSET_ERR_EXIST;
346                 else if (SET_WITH_TIMEOUT(set) &&
347                          ip_set_timeout_expired(ext_timeout(e, set)))
348                         continue;
349                 else if (e->id != d->id)
350                         continue;
351
352                 if (d->before == 0)
353                         return list_set_del(set, i);
354                 else if (d->before > 0) {
355                         if (!id_eq(set, i + 1, d->refid))
356                                 return -IPSET_ERR_REF_EXIST;
357                         return list_set_del(set, i);
358                 } else if (i == 0 || !id_eq(set, i - 1, d->refid))
359                         return -IPSET_ERR_REF_EXIST;
360                 else
361                         return list_set_del(set, i);
362         }
363         return -IPSET_ERR_EXIST;
364 }
365
366 static int
367 list_set_uadt(struct ip_set *set, struct nlattr *tb[],
368               enum ipset_adt adt, u32 *lineno, u32 flags, bool retried)
369 {
370         struct list_set *map = set->data;
371         ipset_adtfn adtfn = set->variant->adt[adt];
372         struct set_adt_elem e = { .refid = IPSET_INVALID_ID };
373         struct ip_set_ext ext = IP_SET_INIT_UEXT(set);
374         struct ip_set *s;
375         int ret = 0;
376
377         if (unlikely(!tb[IPSET_ATTR_NAME] ||
378                      !ip_set_optattr_netorder(tb, IPSET_ATTR_TIMEOUT) ||
379                      !ip_set_optattr_netorder(tb, IPSET_ATTR_CADT_FLAGS) ||
380                      !ip_set_optattr_netorder(tb, IPSET_ATTR_PACKETS) ||
381                      !ip_set_optattr_netorder(tb, IPSET_ATTR_BYTES)))
382                 return -IPSET_ERR_PROTOCOL;
383
384         if (tb[IPSET_ATTR_LINENO])
385                 *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
386
387         ret = ip_set_get_extensions(set, tb, &ext);
388         if (ret)
389                 return ret;
390         e.id = ip_set_get_byname(map->net, nla_data(tb[IPSET_ATTR_NAME]), &s);
391         if (e.id == IPSET_INVALID_ID)
392                 return -IPSET_ERR_NAME;
393         /* "Loop detection" */
394         if (s->type->features & IPSET_TYPE_NAME) {
395                 ret = -IPSET_ERR_LOOP;
396                 goto finish;
397         }
398
399         if (tb[IPSET_ATTR_CADT_FLAGS]) {
400                 u32 f = ip_set_get_h32(tb[IPSET_ATTR_CADT_FLAGS]);
401                 e.before = f & IPSET_FLAG_BEFORE;
402         }
403
404         if (e.before && !tb[IPSET_ATTR_NAMEREF]) {
405                 ret = -IPSET_ERR_BEFORE;
406                 goto finish;
407         }
408
409         if (tb[IPSET_ATTR_NAMEREF]) {
410                 e.refid = ip_set_get_byname(map->net,
411                                             nla_data(tb[IPSET_ATTR_NAMEREF]),
412                                             &s);
413                 if (e.refid == IPSET_INVALID_ID) {
414                         ret = -IPSET_ERR_NAMEREF;
415                         goto finish;
416                 }
417                 if (!e.before)
418                         e.before = -1;
419         }
420         if (adt != IPSET_TEST && SET_WITH_TIMEOUT(set))
421                 set_cleanup_entries(set);
422
423         ret = adtfn(set, &e, &ext, &ext, flags);
424
425 finish:
426         if (e.refid != IPSET_INVALID_ID)
427                 ip_set_put_byindex(map->net, e.refid);
428         if (adt != IPSET_ADD || ret)
429                 ip_set_put_byindex(map->net, e.id);
430
431         return ip_set_eexist(ret, flags) ? 0 : ret;
432 }
433
434 static void
435 list_set_flush(struct ip_set *set)
436 {
437         struct list_set *map = set->data;
438         struct set_elem *e;
439         u32 i;
440
441         for (i = 0; i < map->size; i++) {
442                 e = list_set_elem(set, map, i);
443                 if (e->id != IPSET_INVALID_ID) {
444                         ip_set_put_byindex(map->net, e->id);
445                         ip_set_ext_destroy(set, e);
446                         e->id = IPSET_INVALID_ID;
447                 }
448         }
449 }
450
451 static void
452 list_set_destroy(struct ip_set *set)
453 {
454         struct list_set *map = set->data;
455
456         if (SET_WITH_TIMEOUT(set))
457                 del_timer_sync(&map->gc);
458         list_set_flush(set);
459         kfree(map);
460
461         set->data = NULL;
462 }
463
464 static int
465 list_set_head(struct ip_set *set, struct sk_buff *skb)
466 {
467         const struct list_set *map = set->data;
468         struct nlattr *nested;
469
470         nested = ipset_nest_start(skb, IPSET_ATTR_DATA);
471         if (!nested)
472                 goto nla_put_failure;
473         if (nla_put_net32(skb, IPSET_ATTR_SIZE, htonl(map->size)) ||
474             nla_put_net32(skb, IPSET_ATTR_REFERENCES, htonl(set->ref - 1)) ||
475             nla_put_net32(skb, IPSET_ATTR_MEMSIZE,
476                           htonl(sizeof(*map) + map->size * set->dsize)))
477                 goto nla_put_failure;
478         if (unlikely(ip_set_put_flags(skb, set)))
479                 goto nla_put_failure;
480         ipset_nest_end(skb, nested);
481
482         return 0;
483 nla_put_failure:
484         return -EMSGSIZE;
485 }
486
487 static int
488 list_set_list(const struct ip_set *set,
489               struct sk_buff *skb, struct netlink_callback *cb)
490 {
491         const struct list_set *map = set->data;
492         struct nlattr *atd, *nested;
493         u32 i, first = cb->args[2];
494         const struct set_elem *e;
495
496         atd = ipset_nest_start(skb, IPSET_ATTR_ADT);
497         if (!atd)
498                 return -EMSGSIZE;
499         for (; cb->args[2] < map->size; cb->args[2]++) {
500                 i = cb->args[2];
501                 e = list_set_elem(set, map, i);
502                 if (e->id == IPSET_INVALID_ID)
503                         goto finish;
504                 if (SET_WITH_TIMEOUT(set) &&
505                     ip_set_timeout_expired(ext_timeout(e, set)))
506                         continue;
507                 nested = ipset_nest_start(skb, IPSET_ATTR_DATA);
508                 if (!nested) {
509                         if (i == first) {
510                                 nla_nest_cancel(skb, atd);
511                                 return -EMSGSIZE;
512                         } else
513                                 goto nla_put_failure;
514                 }
515                 if (nla_put_string(skb, IPSET_ATTR_NAME,
516                                    ip_set_name_byindex(map->net, e->id)))
517                         goto nla_put_failure;
518                 if (ip_set_put_extensions(skb, set, e, true))
519                         goto nla_put_failure;
520                 ipset_nest_end(skb, nested);
521         }
522 finish:
523         ipset_nest_end(skb, atd);
524         /* Set listing finished */
525         cb->args[2] = 0;
526         return 0;
527
528 nla_put_failure:
529         nla_nest_cancel(skb, nested);
530         if (unlikely(i == first)) {
531                 cb->args[2] = 0;
532                 return -EMSGSIZE;
533         }
534         ipset_nest_end(skb, atd);
535         return 0;
536 }
537
538 static bool
539 list_set_same_set(const struct ip_set *a, const struct ip_set *b)
540 {
541         const struct list_set *x = a->data;
542         const struct list_set *y = b->data;
543
544         return x->size == y->size &&
545                a->timeout == b->timeout &&
546                a->extensions == b->extensions;
547 }
548
549 static const struct ip_set_type_variant set_variant = {
550         .kadt   = list_set_kadt,
551         .uadt   = list_set_uadt,
552         .adt    = {
553                 [IPSET_ADD] = list_set_uadd,
554                 [IPSET_DEL] = list_set_udel,
555                 [IPSET_TEST] = list_set_utest,
556         },
557         .destroy = list_set_destroy,
558         .flush  = list_set_flush,
559         .head   = list_set_head,
560         .list   = list_set_list,
561         .same_set = list_set_same_set,
562 };
563
564 static void
565 list_set_gc(unsigned long ul_set)
566 {
567         struct ip_set *set = (struct ip_set *) ul_set;
568         struct list_set *map = set->data;
569
570         write_lock_bh(&set->lock);
571         set_cleanup_entries(set);
572         write_unlock_bh(&set->lock);
573
574         map->gc.expires = jiffies + IPSET_GC_PERIOD(set->timeout) * HZ;
575         add_timer(&map->gc);
576 }
577
578 static void
579 list_set_gc_init(struct ip_set *set, void (*gc)(unsigned long ul_set))
580 {
581         struct list_set *map = set->data;
582
583         init_timer(&map->gc);
584         map->gc.data = (unsigned long) set;
585         map->gc.function = gc;
586         map->gc.expires = jiffies + IPSET_GC_PERIOD(set->timeout) * HZ;
587         add_timer(&map->gc);
588 }
589
590 /* Create list:set type of sets */
591
592 static bool
593 init_list_set(struct net *net, struct ip_set *set, u32 size)
594 {
595         struct list_set *map;
596         struct set_elem *e;
597         u32 i;
598
599         map = kzalloc(sizeof(*map) + size * set->dsize, GFP_KERNEL);
600         if (!map)
601                 return false;
602
603         map->size = size;
604         map->net = net;
605         set->data = map;
606
607         for (i = 0; i < size; i++) {
608                 e = list_set_elem(set, map, i);
609                 e->id = IPSET_INVALID_ID;
610         }
611
612         return true;
613 }
614
615 static int
616 list_set_create(struct net *net, struct ip_set *set, struct nlattr *tb[],
617                 u32 flags)
618 {
619         u32 size = IP_SET_LIST_DEFAULT_SIZE;
620
621         if (unlikely(!ip_set_optattr_netorder(tb, IPSET_ATTR_SIZE) ||
622                      !ip_set_optattr_netorder(tb, IPSET_ATTR_TIMEOUT) ||
623                      !ip_set_optattr_netorder(tb, IPSET_ATTR_CADT_FLAGS)))
624                 return -IPSET_ERR_PROTOCOL;
625
626         if (tb[IPSET_ATTR_SIZE])
627                 size = ip_set_get_h32(tb[IPSET_ATTR_SIZE]);
628         if (size < IP_SET_LIST_MIN_SIZE)
629                 size = IP_SET_LIST_MIN_SIZE;
630
631         set->variant = &set_variant;
632         set->dsize = ip_set_elem_len(set, tb, sizeof(struct set_elem));
633         if (!init_list_set(net, set, size))
634                 return -ENOMEM;
635         if (tb[IPSET_ATTR_TIMEOUT]) {
636                 set->timeout = ip_set_timeout_uget(tb[IPSET_ATTR_TIMEOUT]);
637                 list_set_gc_init(set, list_set_gc);
638         }
639         return 0;
640 }
641
642 static struct ip_set_type list_set_type __read_mostly = {
643         .name           = "list:set",
644         .protocol       = IPSET_PROTOCOL,
645         .features       = IPSET_TYPE_NAME | IPSET_DUMP_LAST,
646         .dimension      = IPSET_DIM_ONE,
647         .family         = NFPROTO_UNSPEC,
648         .revision_min   = IPSET_TYPE_REV_MIN,
649         .revision_max   = IPSET_TYPE_REV_MAX,
650         .create         = list_set_create,
651         .create_policy  = {
652                 [IPSET_ATTR_SIZE]       = { .type = NLA_U32 },
653                 [IPSET_ATTR_TIMEOUT]    = { .type = NLA_U32 },
654                 [IPSET_ATTR_CADT_FLAGS] = { .type = NLA_U32 },
655         },
656         .adt_policy     = {
657                 [IPSET_ATTR_NAME]       = { .type = NLA_STRING,
658                                             .len = IPSET_MAXNAMELEN },
659                 [IPSET_ATTR_NAMEREF]    = { .type = NLA_STRING,
660                                             .len = IPSET_MAXNAMELEN },
661                 [IPSET_ATTR_TIMEOUT]    = { .type = NLA_U32 },
662                 [IPSET_ATTR_LINENO]     = { .type = NLA_U32 },
663                 [IPSET_ATTR_CADT_FLAGS] = { .type = NLA_U32 },
664                 [IPSET_ATTR_BYTES]      = { .type = NLA_U64 },
665                 [IPSET_ATTR_PACKETS]    = { .type = NLA_U64 },
666                 [IPSET_ATTR_COMMENT]    = { .type = NLA_NUL_STRING },
667         },
668         .me             = THIS_MODULE,
669 };
670
671 static int __init
672 list_set_init(void)
673 {
674         return ip_set_type_register(&list_set_type);
675 }
676
677 static void __exit
678 list_set_fini(void)
679 {
680         ip_set_type_unregister(&list_set_type);
681 }
682
683 module_init(list_set_init);
684 module_exit(list_set_fini);