1 // SPDX-License-Identifier: GPL-2.0-only
2 /* Copyright (C) 2003-2013 Jozsef Kadlecsik <kadlec@netfilter.org>
3 * Copyright (C) 2013 Oliver Smith <oliver@8.c.9.b.0.7.4.0.1.0.0.2.ip6.arpa>
4 */
5
6 /* Kernel module implementing an IP set type: the hash:net type */
7
8 #include <linux/jhash.h>
9 #include <linux/module.h>
10 #include <linux/ip.h>
11 #include <linux/skbuff.h>
12 #include <linux/errno.h>
13 #include <linux/random.h>
14 #include <net/ip.h>
15 #include <net/ipv6.h>
16 #include <net/netlink.h>
17
18 #include <linux/netfilter.h>
19 #include <linux/netfilter/ipset/pfxlen.h>
20 #include <linux/netfilter/ipset/ip_set.h>
21 #include <linux/netfilter/ipset/ip_set_hash.h>
22
23 #define IPSET_TYPE_REV_MIN 0
24 /* 1 Forceadd support added */
25 /* 2 skbinfo support added */
26 /* 3 bucketsize, initval support added */
27 #define IPSET_TYPE_REV_MAX 4 /* bitmask support added */
28
29 MODULE_LICENSE("GPL");
30 MODULE_AUTHOR("Oliver Smith <oliver@8.c.9.b.0.7.4.0.1.0.0.2.ip6.arpa>");
31 IP_SET_MODULE_DESC("hash:net,net", IPSET_TYPE_REV_MIN, IPSET_TYPE_REV_MAX);
32 MODULE_ALIAS("ip_set_hash:net,net");
33
34 /* Type specific function prefix */
35 #define HTYPE hash_netnet
36 #define IP_SET_HASH_WITH_NETS
37 #define IP_SET_HASH_WITH_NETMASK
38 #define IP_SET_HASH_WITH_BITMASK
39 #define IPSET_NET_COUNT 2
40
41 /* IPv4 variants */
42
43 /* Member elements */
44 struct hash_netnet4_elem {
45 union {
46 __be32 ip[2];
47 __be64 ipcmp;
48 };
49 u8 nomatch;
50 u8 padding;
51 union {
52 u8 cidr[2];
53 u16 ccmp;
54 };
55 };
56
57 /* Common functions */
58
59 static bool
hash_netnet4_data_equal(const struct hash_netnet4_elem * ip1,const struct hash_netnet4_elem * ip2,u32 * multi)60 hash_netnet4_data_equal(const struct hash_netnet4_elem *ip1,
61 const struct hash_netnet4_elem *ip2,
62 u32 *multi)
63 {
64 return ip1->ipcmp == ip2->ipcmp &&
65 ip1->ccmp == ip2->ccmp;
66 }
67
68 static int
hash_netnet4_do_data_match(const struct hash_netnet4_elem * elem)69 hash_netnet4_do_data_match(const struct hash_netnet4_elem *elem)
70 {
71 return elem->nomatch ? -ENOTEMPTY : 1;
72 }
73
74 static void
hash_netnet4_data_set_flags(struct hash_netnet4_elem * elem,u32 flags)75 hash_netnet4_data_set_flags(struct hash_netnet4_elem *elem, u32 flags)
76 {
77 elem->nomatch = (flags >> 16) & IPSET_FLAG_NOMATCH;
78 }
79
80 static void
hash_netnet4_data_reset_flags(struct hash_netnet4_elem * elem,u8 * flags)81 hash_netnet4_data_reset_flags(struct hash_netnet4_elem *elem, u8 *flags)
82 {
83 swap(*flags, elem->nomatch);
84 }
85
86 static void
hash_netnet4_data_reset_elem(struct hash_netnet4_elem * elem,struct hash_netnet4_elem * orig)87 hash_netnet4_data_reset_elem(struct hash_netnet4_elem *elem,
88 struct hash_netnet4_elem *orig)
89 {
90 elem->ip[1] = orig->ip[1];
91 }
92
93 static void
hash_netnet4_data_netmask(struct hash_netnet4_elem * elem,u8 cidr,bool inner)94 hash_netnet4_data_netmask(struct hash_netnet4_elem *elem, u8 cidr, bool inner)
95 {
96 if (inner) {
97 elem->ip[1] &= ip_set_netmask(cidr);
98 elem->cidr[1] = cidr;
99 } else {
100 elem->ip[0] &= ip_set_netmask(cidr);
101 elem->cidr[0] = cidr;
102 }
103 }
104
105 static bool
hash_netnet4_data_list(struct sk_buff * skb,const struct hash_netnet4_elem * data)106 hash_netnet4_data_list(struct sk_buff *skb,
107 const struct hash_netnet4_elem *data)
108 {
109 u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0;
110
111 if (nla_put_ipaddr4(skb, IPSET_ATTR_IP, data->ip[0]) ||
112 nla_put_ipaddr4(skb, IPSET_ATTR_IP2, data->ip[1]) ||
113 nla_put_u8(skb, IPSET_ATTR_CIDR, data->cidr[0]) ||
114 nla_put_u8(skb, IPSET_ATTR_CIDR2, data->cidr[1]) ||
115 (flags &&
116 nla_put_net32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags))))
117 goto nla_put_failure;
118 return false;
119
120 nla_put_failure:
121 return true;
122 }
123
124 static void
hash_netnet4_data_next(struct hash_netnet4_elem * next,const struct hash_netnet4_elem * d)125 hash_netnet4_data_next(struct hash_netnet4_elem *next,
126 const struct hash_netnet4_elem *d)
127 {
128 next->ipcmp = d->ipcmp;
129 }
130
131 #define MTYPE hash_netnet4
132 #define HOST_MASK 32
133 #include "ip_set_hash_gen.h"
134
135 static void
hash_netnet4_init(struct hash_netnet4_elem * e)136 hash_netnet4_init(struct hash_netnet4_elem *e)
137 {
138 e->cidr[0] = HOST_MASK;
139 e->cidr[1] = HOST_MASK;
140 }
141
142 static int
hash_netnet4_kadt(struct ip_set * set,const struct sk_buff * skb,const struct xt_action_param * par,enum ipset_adt adt,struct ip_set_adt_opt * opt)143 hash_netnet4_kadt(struct ip_set *set, const struct sk_buff *skb,
144 const struct xt_action_param *par,
145 enum ipset_adt adt, struct ip_set_adt_opt *opt)
146 {
147 const struct hash_netnet4 *h = set->data;
148 ipset_adtfn adtfn = set->variant->adt[adt];
149 struct hash_netnet4_elem e = { };
150 struct ip_set_ext ext = IP_SET_INIT_KEXT(skb, opt, set);
151
152 rcu_read_lock_bh();
153 e.cidr[0] = INIT_CIDR(h->rnets[0], HOST_MASK);
154 e.cidr[1] = INIT_CIDR(h->rnets[1], HOST_MASK);
155 rcu_read_unlock_bh();
156 if (adt == IPSET_TEST)
157 e.ccmp = (HOST_MASK << (sizeof(e.cidr[0]) * 8)) | HOST_MASK;
158
159 ip4addrptr(skb, opt->flags & IPSET_DIM_ONE_SRC, &e.ip[0]);
160 ip4addrptr(skb, opt->flags & IPSET_DIM_TWO_SRC, &e.ip[1]);
161 e.ip[0] &= (ip_set_netmask(e.cidr[0]) & h->bitmask.ip);
162 e.ip[1] &= (ip_set_netmask(e.cidr[1]) & h->bitmask.ip);
163
164 return adtfn(set, &e, &ext, &opt->ext, opt->cmdflags);
165 }
166
167 static int
hash_netnet4_uadt(struct ip_set * set,struct nlattr * tb[],enum ipset_adt adt,u32 * lineno,u32 flags,bool retried)168 hash_netnet4_uadt(struct ip_set *set, struct nlattr *tb[],
169 enum ipset_adt adt, u32 *lineno, u32 flags, bool retried)
170 {
171 struct hash_netnet4 *h = set->data;
172 ipset_adtfn adtfn = set->variant->adt[adt];
173 struct hash_netnet4_elem e = { };
174 struct ip_set_ext ext = IP_SET_INIT_UEXT(set);
175 u32 ip = 0, ip_to = 0;
176 u32 ip2 = 0, ip2_from = 0, ip2_to = 0, i = 0;
177 int ret;
178
179 if (tb[IPSET_ATTR_LINENO])
180 *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
181
182 hash_netnet4_init(&e);
183 if (unlikely(!tb[IPSET_ATTR_IP] || !tb[IPSET_ATTR_IP2] ||
184 !ip_set_optattr_netorder(tb, IPSET_ATTR_CADT_FLAGS)))
185 return -IPSET_ERR_PROTOCOL;
186
187 ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP], &ip);
188 if (ret)
189 return ret;
190
191 ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP2], &ip2_from);
192 if (ret)
193 return ret;
194
195 ret = ip_set_get_extensions(set, tb, &ext);
196 if (ret)
197 return ret;
198
199 if (tb[IPSET_ATTR_CIDR]) {
200 e.cidr[0] = nla_get_u8(tb[IPSET_ATTR_CIDR]);
201 if (!e.cidr[0] || e.cidr[0] > HOST_MASK)
202 return -IPSET_ERR_INVALID_CIDR;
203 }
204
205 if (tb[IPSET_ATTR_CIDR2]) {
206 e.cidr[1] = nla_get_u8(tb[IPSET_ATTR_CIDR2]);
207 if (!e.cidr[1] || e.cidr[1] > HOST_MASK)
208 return -IPSET_ERR_INVALID_CIDR;
209 }
210
211 if (tb[IPSET_ATTR_CADT_FLAGS]) {
212 u32 cadt_flags = ip_set_get_h32(tb[IPSET_ATTR_CADT_FLAGS]);
213
214 if (cadt_flags & IPSET_FLAG_NOMATCH)
215 flags |= (IPSET_FLAG_NOMATCH << 16);
216 }
217
218 if (adt == IPSET_TEST || !(tb[IPSET_ATTR_IP_TO] ||
219 tb[IPSET_ATTR_IP2_TO])) {
220 e.ip[0] = htonl(ip & ntohl(h->bitmask.ip) & ip_set_hostmask(e.cidr[0]));
221 e.ip[1] = htonl(ip2_from & ntohl(h->bitmask.ip) & ip_set_hostmask(e.cidr[1]));
222 ret = adtfn(set, &e, &ext, &ext, flags);
223 return ip_set_enomatch(ret, flags, adt, set) ? -ret :
224 ip_set_eexist(ret, flags) ? 0 : ret;
225 }
226
227 ip_to = ip;
228 if (tb[IPSET_ATTR_IP_TO]) {
229 ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP_TO], &ip_to);
230 if (ret)
231 return ret;
232 if (ip_to < ip)
233 swap(ip, ip_to);
234 if (unlikely(ip + UINT_MAX == ip_to))
235 return -IPSET_ERR_HASH_RANGE;
236 } else {
237 ip_set_mask_from_to(ip, ip_to, e.cidr[0]);
238 }
239
240 ip2_to = ip2_from;
241 if (tb[IPSET_ATTR_IP2_TO]) {
242 ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP2_TO], &ip2_to);
243 if (ret)
244 return ret;
245 if (ip2_to < ip2_from)
246 swap(ip2_from, ip2_to);
247 if (unlikely(ip2_from + UINT_MAX == ip2_to))
248 return -IPSET_ERR_HASH_RANGE;
249 } else {
250 ip_set_mask_from_to(ip2_from, ip2_to, e.cidr[1]);
251 }
252
253 if (retried) {
254 ip = ntohl(h->next.ip[0]);
255 ip2 = ntohl(h->next.ip[1]);
256 } else {
257 ip2 = ip2_from;
258 }
259
260 do {
261 e.ip[0] = htonl(ip);
262 ip = ip_set_range_to_cidr(ip, ip_to, &e.cidr[0]);
263 do {
264 i++;
265 e.ip[1] = htonl(ip2);
266 if (i > IPSET_MAX_RANGE) {
267 hash_netnet4_data_next(&h->next, &e);
268 return -ERANGE;
269 }
270 ip2 = ip_set_range_to_cidr(ip2, ip2_to, &e.cidr[1]);
271 ret = adtfn(set, &e, &ext, &ext, flags);
272 if (ret && !ip_set_eexist(ret, flags))
273 return ret;
274
275 ret = 0;
276 } while (ip2++ < ip2_to);
277 ip2 = ip2_from;
278 } while (ip++ < ip_to);
279 return ret;
280 }
281
282 /* IPv6 variants */
283
284 struct hash_netnet6_elem {
285 union nf_inet_addr ip[2];
286 u8 nomatch;
287 u8 padding;
288 union {
289 u8 cidr[2];
290 u16 ccmp;
291 };
292 };
293
294 /* Common functions */
295
296 static bool
hash_netnet6_data_equal(const struct hash_netnet6_elem * ip1,const struct hash_netnet6_elem * ip2,u32 * multi)297 hash_netnet6_data_equal(const struct hash_netnet6_elem *ip1,
298 const struct hash_netnet6_elem *ip2,
299 u32 *multi)
300 {
301 return ipv6_addr_equal(&ip1->ip[0].in6, &ip2->ip[0].in6) &&
302 ipv6_addr_equal(&ip1->ip[1].in6, &ip2->ip[1].in6) &&
303 ip1->ccmp == ip2->ccmp;
304 }
305
306 static int
hash_netnet6_do_data_match(const struct hash_netnet6_elem * elem)307 hash_netnet6_do_data_match(const struct hash_netnet6_elem *elem)
308 {
309 return elem->nomatch ? -ENOTEMPTY : 1;
310 }
311
312 static void
hash_netnet6_data_set_flags(struct hash_netnet6_elem * elem,u32 flags)313 hash_netnet6_data_set_flags(struct hash_netnet6_elem *elem, u32 flags)
314 {
315 elem->nomatch = (flags >> 16) & IPSET_FLAG_NOMATCH;
316 }
317
318 static void
hash_netnet6_data_reset_flags(struct hash_netnet6_elem * elem,u8 * flags)319 hash_netnet6_data_reset_flags(struct hash_netnet6_elem *elem, u8 *flags)
320 {
321 swap(*flags, elem->nomatch);
322 }
323
324 static void
hash_netnet6_data_reset_elem(struct hash_netnet6_elem * elem,struct hash_netnet6_elem * orig)325 hash_netnet6_data_reset_elem(struct hash_netnet6_elem *elem,
326 struct hash_netnet6_elem *orig)
327 {
328 elem->ip[1] = orig->ip[1];
329 }
330
331 static void
hash_netnet6_data_netmask(struct hash_netnet6_elem * elem,u8 cidr,bool inner)332 hash_netnet6_data_netmask(struct hash_netnet6_elem *elem, u8 cidr, bool inner)
333 {
334 if (inner) {
335 ip6_netmask(&elem->ip[1], cidr);
336 elem->cidr[1] = cidr;
337 } else {
338 ip6_netmask(&elem->ip[0], cidr);
339 elem->cidr[0] = cidr;
340 }
341 }
342
343 static bool
hash_netnet6_data_list(struct sk_buff * skb,const struct hash_netnet6_elem * data)344 hash_netnet6_data_list(struct sk_buff *skb,
345 const struct hash_netnet6_elem *data)
346 {
347 u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0;
348
349 if (nla_put_ipaddr6(skb, IPSET_ATTR_IP, &data->ip[0].in6) ||
350 nla_put_ipaddr6(skb, IPSET_ATTR_IP2, &data->ip[1].in6) ||
351 nla_put_u8(skb, IPSET_ATTR_CIDR, data->cidr[0]) ||
352 nla_put_u8(skb, IPSET_ATTR_CIDR2, data->cidr[1]) ||
353 (flags &&
354 nla_put_net32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags))))
355 goto nla_put_failure;
356 return false;
357
358 nla_put_failure:
359 return true;
360 }
361
362 static void
hash_netnet6_data_next(struct hash_netnet6_elem * next,const struct hash_netnet6_elem * d)363 hash_netnet6_data_next(struct hash_netnet6_elem *next,
364 const struct hash_netnet6_elem *d)
365 {
366 }
367
368 #undef MTYPE
369 #undef HOST_MASK
370
371 #define MTYPE hash_netnet6
372 #define HOST_MASK 128
373 #define IP_SET_EMIT_CREATE
374 #include "ip_set_hash_gen.h"
375
376 static void
hash_netnet6_init(struct hash_netnet6_elem * e)377 hash_netnet6_init(struct hash_netnet6_elem *e)
378 {
379 e->cidr[0] = HOST_MASK;
380 e->cidr[1] = HOST_MASK;
381 }
382
383 static int
hash_netnet6_kadt(struct ip_set * set,const struct sk_buff * skb,const struct xt_action_param * par,enum ipset_adt adt,struct ip_set_adt_opt * opt)384 hash_netnet6_kadt(struct ip_set *set, const struct sk_buff *skb,
385 const struct xt_action_param *par,
386 enum ipset_adt adt, struct ip_set_adt_opt *opt)
387 {
388 const struct hash_netnet6 *h = set->data;
389 ipset_adtfn adtfn = set->variant->adt[adt];
390 struct hash_netnet6_elem e = { };
391 struct ip_set_ext ext = IP_SET_INIT_KEXT(skb, opt, set);
392
393 rcu_read_lock_bh();
394 e.cidr[0] = INIT_CIDR(h->rnets[0], HOST_MASK);
395 e.cidr[1] = INIT_CIDR(h->rnets[1], HOST_MASK);
396 rcu_read_unlock_bh();
397 if (adt == IPSET_TEST)
398 e.ccmp = (HOST_MASK << (sizeof(u8) * 8)) | HOST_MASK;
399
400 ip6addrptr(skb, opt->flags & IPSET_DIM_ONE_SRC, &e.ip[0].in6);
401 ip6addrptr(skb, opt->flags & IPSET_DIM_TWO_SRC, &e.ip[1].in6);
402 ip6_netmask(&e.ip[0], e.cidr[0]);
403 ip6_netmask(&e.ip[1], e.cidr[1]);
404
405 nf_inet_addr_mask_inplace(&e.ip[0], &h->bitmask);
406 nf_inet_addr_mask_inplace(&e.ip[1], &h->bitmask);
407 if (e.cidr[0] == HOST_MASK && ipv6_addr_any(&e.ip[0].in6))
408 return -EINVAL;
409
410 return adtfn(set, &e, &ext, &opt->ext, opt->cmdflags);
411 }
412
413 static int
hash_netnet6_uadt(struct ip_set * set,struct nlattr * tb[],enum ipset_adt adt,u32 * lineno,u32 flags,bool retried)414 hash_netnet6_uadt(struct ip_set *set, struct nlattr *tb[],
415 enum ipset_adt adt, u32 *lineno, u32 flags, bool retried)
416 {
417 ipset_adtfn adtfn = set->variant->adt[adt];
418 struct hash_netnet6_elem e = { };
419 struct ip_set_ext ext = IP_SET_INIT_UEXT(set);
420 const struct hash_netnet6 *h = set->data;
421 int ret;
422
423 if (tb[IPSET_ATTR_LINENO])
424 *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
425
426 hash_netnet6_init(&e);
427 if (unlikely(!tb[IPSET_ATTR_IP] || !tb[IPSET_ATTR_IP2] ||
428 !ip_set_optattr_netorder(tb, IPSET_ATTR_CADT_FLAGS)))
429 return -IPSET_ERR_PROTOCOL;
430 if (unlikely(tb[IPSET_ATTR_IP_TO] || tb[IPSET_ATTR_IP2_TO]))
431 return -IPSET_ERR_HASH_RANGE_UNSUPPORTED;
432
433 ret = ip_set_get_ipaddr6(tb[IPSET_ATTR_IP], &e.ip[0]);
434 if (ret)
435 return ret;
436
437 ret = ip_set_get_ipaddr6(tb[IPSET_ATTR_IP2], &e.ip[1]);
438 if (ret)
439 return ret;
440
441 ret = ip_set_get_extensions(set, tb, &ext);
442 if (ret)
443 return ret;
444
445 if (tb[IPSET_ATTR_CIDR]) {
446 e.cidr[0] = nla_get_u8(tb[IPSET_ATTR_CIDR]);
447 if (!e.cidr[0] || e.cidr[0] > HOST_MASK)
448 return -IPSET_ERR_INVALID_CIDR;
449 }
450
451 if (tb[IPSET_ATTR_CIDR2]) {
452 e.cidr[1] = nla_get_u8(tb[IPSET_ATTR_CIDR2]);
453 if (!e.cidr[1] || e.cidr[1] > HOST_MASK)
454 return -IPSET_ERR_INVALID_CIDR;
455 }
456
457 ip6_netmask(&e.ip[0], e.cidr[0]);
458 ip6_netmask(&e.ip[1], e.cidr[1]);
459
460 nf_inet_addr_mask_inplace(&e.ip[0], &h->bitmask);
461 nf_inet_addr_mask_inplace(&e.ip[1], &h->bitmask);
462 if (e.cidr[0] == HOST_MASK && ipv6_addr_any(&e.ip[0].in6))
463 return -IPSET_ERR_HASH_ELEM;
464
465 if (tb[IPSET_ATTR_CADT_FLAGS]) {
466 u32 cadt_flags = ip_set_get_h32(tb[IPSET_ATTR_CADT_FLAGS]);
467
468 if (cadt_flags & IPSET_FLAG_NOMATCH)
469 flags |= (IPSET_FLAG_NOMATCH << 16);
470 }
471
472 ret = adtfn(set, &e, &ext, &ext, flags);
473
474 return ip_set_enomatch(ret, flags, adt, set) ? -ret :
475 ip_set_eexist(ret, flags) ? 0 : ret;
476 }
477
478 static struct ip_set_type hash_netnet_type __read_mostly = {
479 .name = "hash:net,net",
480 .protocol = IPSET_PROTOCOL,
481 .features = IPSET_TYPE_IP | IPSET_TYPE_IP2 | IPSET_TYPE_NOMATCH,
482 .dimension = IPSET_DIM_TWO,
483 .family = NFPROTO_UNSPEC,
484 .revision_min = IPSET_TYPE_REV_MIN,
485 .revision_max = IPSET_TYPE_REV_MAX,
486 .create_flags[IPSET_TYPE_REV_MAX] = IPSET_CREATE_FLAG_BUCKETSIZE,
487 .create = hash_netnet_create,
488 .create_policy = {
489 [IPSET_ATTR_HASHSIZE] = { .type = NLA_U32 },
490 [IPSET_ATTR_MAXELEM] = { .type = NLA_U32 },
491 [IPSET_ATTR_INITVAL] = { .type = NLA_U32 },
492 [IPSET_ATTR_BUCKETSIZE] = { .type = NLA_U8 },
493 [IPSET_ATTR_RESIZE] = { .type = NLA_U8 },
494 [IPSET_ATTR_TIMEOUT] = { .type = NLA_U32 },
495 [IPSET_ATTR_CADT_FLAGS] = { .type = NLA_U32 },
496 [IPSET_ATTR_NETMASK] = { .type = NLA_U8 },
497 [IPSET_ATTR_BITMASK] = { .type = NLA_NESTED },
498 },
499 .adt_policy = {
500 [IPSET_ATTR_IP] = { .type = NLA_NESTED },
501 [IPSET_ATTR_IP_TO] = { .type = NLA_NESTED },
502 [IPSET_ATTR_IP2] = { .type = NLA_NESTED },
503 [IPSET_ATTR_IP2_TO] = { .type = NLA_NESTED },
504 [IPSET_ATTR_CIDR] = { .type = NLA_U8 },
505 [IPSET_ATTR_CIDR2] = { .type = NLA_U8 },
506 [IPSET_ATTR_TIMEOUT] = { .type = NLA_U32 },
507 [IPSET_ATTR_LINENO] = { .type = NLA_U32 },
508 [IPSET_ATTR_CADT_FLAGS] = { .type = NLA_U32 },
509 [IPSET_ATTR_BYTES] = { .type = NLA_U64 },
510 [IPSET_ATTR_PACKETS] = { .type = NLA_U64 },
511 [IPSET_ATTR_COMMENT] = { .type = NLA_NUL_STRING,
512 .len = IPSET_MAX_COMMENT_SIZE },
513 [IPSET_ATTR_SKBMARK] = { .type = NLA_U64 },
514 [IPSET_ATTR_SKBPRIO] = { .type = NLA_U32 },
515 [IPSET_ATTR_SKBQUEUE] = { .type = NLA_U16 },
516 },
517 .me = THIS_MODULE,
518 };
519
520 static int __init
hash_netnet_init(void)521 hash_netnet_init(void)
522 {
523 return ip_set_type_register(&hash_netnet_type);
524 }
525
526 static void __exit
hash_netnet_fini(void)527 hash_netnet_fini(void)
528 {
529 rcu_barrier();
530 ip_set_type_unregister(&hash_netnet_type);
531 }
532
533 module_init(hash_netnet_init);
534 module_exit(hash_netnet_fini);
535