]> git.karo-electronics.de Git - karo-tx-linux.git/blob - net/netfilter/ipset/ip_set_hash_ipportnet.c
Merge remote-tracking branch 'net-next/master'
[karo-tx-linux.git] / net / netfilter / ipset / ip_set_hash_ipportnet.c
1 /* Copyright (C) 2003-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 hash:ip,port,net type */
9
10 #include <linux/jhash.h>
11 #include <linux/module.h>
12 #include <linux/ip.h>
13 #include <linux/skbuff.h>
14 #include <linux/errno.h>
15 #include <linux/random.h>
16 #include <net/ip.h>
17 #include <net/ipv6.h>
18 #include <net/netlink.h>
19 #include <net/tcp.h>
20
21 #include <linux/netfilter.h>
22 #include <linux/netfilter/ipset/pfxlen.h>
23 #include <linux/netfilter/ipset/ip_set.h>
24 #include <linux/netfilter/ipset/ip_set_getport.h>
25 #include <linux/netfilter/ipset/ip_set_hash.h>
26
27 #define IPSET_TYPE_REV_MIN      0
28 /*                              1    SCTP and UDPLITE support added */
29 /*                              2    Range as input support for IPv4 added */
30 /*                              3    nomatch flag support added */
31 /*                              4    Counters support added */
32 #define IPSET_TYPE_REV_MAX      5 /* Comments support added */
33
34 MODULE_LICENSE("GPL");
35 MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>");
36 IP_SET_MODULE_DESC("hash:ip,port,net", IPSET_TYPE_REV_MIN, IPSET_TYPE_REV_MAX);
37 MODULE_ALIAS("ip_set_hash:ip,port,net");
38
39 /* Type specific function prefix */
40 #define HTYPE           hash_ipportnet
41
42 /* We squeeze the "nomatch" flag into cidr: we don't support cidr == 0
43  * However this way we have to store internally cidr - 1,
44  * dancing back and forth.
45  */
46 #define IP_SET_HASH_WITH_NETS_PACKED
47 #define IP_SET_HASH_WITH_PROTO
48 #define IP_SET_HASH_WITH_NETS
49
50 /* IPv4 variant */
51
52 /* Member elements */
53 struct hash_ipportnet4_elem {
54         __be32 ip;
55         __be32 ip2;
56         __be16 port;
57         u8 cidr:7;
58         u8 nomatch:1;
59         u8 proto;
60 };
61
62 /* Common functions */
63
64 static inline bool
65 hash_ipportnet4_data_equal(const struct hash_ipportnet4_elem *ip1,
66                            const struct hash_ipportnet4_elem *ip2,
67                            u32 *multi)
68 {
69         return ip1->ip == ip2->ip &&
70                ip1->ip2 == ip2->ip2 &&
71                ip1->cidr == ip2->cidr &&
72                ip1->port == ip2->port &&
73                ip1->proto == ip2->proto;
74 }
75
76 static inline int
77 hash_ipportnet4_do_data_match(const struct hash_ipportnet4_elem *elem)
78 {
79         return elem->nomatch ? -ENOTEMPTY : 1;
80 }
81
82 static inline void
83 hash_ipportnet4_data_set_flags(struct hash_ipportnet4_elem *elem, u32 flags)
84 {
85         elem->nomatch = !!((flags >> 16) & IPSET_FLAG_NOMATCH);
86 }
87
88 static inline void
89 hash_ipportnet4_data_reset_flags(struct hash_ipportnet4_elem *elem, u8 *flags)
90 {
91         swap(*flags, elem->nomatch);
92 }
93
94 static inline void
95 hash_ipportnet4_data_netmask(struct hash_ipportnet4_elem *elem, u8 cidr)
96 {
97         elem->ip2 &= ip_set_netmask(cidr);
98         elem->cidr = cidr - 1;
99 }
100
101 static bool
102 hash_ipportnet4_data_list(struct sk_buff *skb,
103                           const struct hash_ipportnet4_elem *data)
104 {
105         u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0;
106
107         if (nla_put_ipaddr4(skb, IPSET_ATTR_IP, data->ip) ||
108             nla_put_ipaddr4(skb, IPSET_ATTR_IP2, data->ip2) ||
109             nla_put_net16(skb, IPSET_ATTR_PORT, data->port) ||
110             nla_put_u8(skb, IPSET_ATTR_CIDR2, data->cidr + 1) ||
111             nla_put_u8(skb, IPSET_ATTR_PROTO, data->proto) ||
112             (flags &&
113              nla_put_net32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags))))
114                 goto nla_put_failure;
115         return 0;
116
117 nla_put_failure:
118         return 1;
119 }
120
121 static inline void
122 hash_ipportnet4_data_next(struct hash_ipportnet4_elem *next,
123                           const struct hash_ipportnet4_elem *d)
124 {
125         next->ip = d->ip;
126         next->port = d->port;
127         next->ip2 = d->ip2;
128 }
129
130 #define MTYPE           hash_ipportnet4
131 #define PF              4
132 #define HOST_MASK       32
133 #include "ip_set_hash_gen.h"
134
135 static int
136 hash_ipportnet4_kadt(struct ip_set *set, const struct sk_buff *skb,
137                      const struct xt_action_param *par,
138                      enum ipset_adt adt, struct ip_set_adt_opt *opt)
139 {
140         const struct hash_ipportnet *h = set->data;
141         ipset_adtfn adtfn = set->variant->adt[adt];
142         struct hash_ipportnet4_elem e = {
143                 .cidr = IP_SET_INIT_CIDR(h->nets[0].cidr[0], HOST_MASK) - 1,
144         };
145         struct ip_set_ext ext = IP_SET_INIT_KEXT(skb, opt, set);
146
147         if (adt == IPSET_TEST)
148                 e.cidr = HOST_MASK - 1;
149
150         if (!ip_set_get_ip4_port(skb, opt->flags & IPSET_DIM_TWO_SRC,
151                                  &e.port, &e.proto))
152                 return -EINVAL;
153
154         ip4addrptr(skb, opt->flags & IPSET_DIM_ONE_SRC, &e.ip);
155         ip4addrptr(skb, opt->flags & IPSET_DIM_THREE_SRC, &e.ip2);
156         e.ip2 &= ip_set_netmask(e.cidr + 1);
157
158         return adtfn(set, &e, &ext, &opt->ext, opt->cmdflags);
159 }
160
161 static int
162 hash_ipportnet4_uadt(struct ip_set *set, struct nlattr *tb[],
163                      enum ipset_adt adt, u32 *lineno, u32 flags, bool retried)
164 {
165         const struct hash_ipportnet *h = set->data;
166         ipset_adtfn adtfn = set->variant->adt[adt];
167         struct hash_ipportnet4_elem e = { .cidr = HOST_MASK - 1 };
168         struct ip_set_ext ext = IP_SET_INIT_UEXT(set);
169         u32 ip = 0, ip_to = 0, p = 0, port, port_to;
170         u32 ip2_from = 0, ip2_to = 0, ip2_last, ip2;
171         bool with_ports = false;
172         u8 cidr;
173         int ret;
174
175         if (unlikely(!tb[IPSET_ATTR_IP] || !tb[IPSET_ATTR_IP2] ||
176                      !ip_set_attr_netorder(tb, IPSET_ATTR_PORT) ||
177                      !ip_set_optattr_netorder(tb, IPSET_ATTR_PORT_TO) ||
178                      !ip_set_optattr_netorder(tb, IPSET_ATTR_TIMEOUT) ||
179                      !ip_set_optattr_netorder(tb, IPSET_ATTR_CADT_FLAGS) ||
180                      !ip_set_optattr_netorder(tb, IPSET_ATTR_PACKETS) ||
181                      !ip_set_optattr_netorder(tb, IPSET_ATTR_BYTES)))
182                 return -IPSET_ERR_PROTOCOL;
183
184         if (tb[IPSET_ATTR_LINENO])
185                 *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
186
187         ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP], &ip) ||
188               ip_set_get_extensions(set, tb, &ext);
189         if (ret)
190                 return ret;
191
192         ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP2], &ip2_from);
193         if (ret)
194                 return ret;
195
196         if (tb[IPSET_ATTR_CIDR2]) {
197                 cidr = nla_get_u8(tb[IPSET_ATTR_CIDR2]);
198                 if (!cidr || cidr > HOST_MASK)
199                         return -IPSET_ERR_INVALID_CIDR;
200                 e.cidr = cidr - 1;
201         }
202
203         if (tb[IPSET_ATTR_PORT])
204                 e.port = nla_get_be16(tb[IPSET_ATTR_PORT]);
205         else
206                 return -IPSET_ERR_PROTOCOL;
207
208         if (tb[IPSET_ATTR_PROTO]) {
209                 e.proto = nla_get_u8(tb[IPSET_ATTR_PROTO]);
210                 with_ports = ip_set_proto_with_ports(e.proto);
211
212                 if (e.proto == 0)
213                         return -IPSET_ERR_INVALID_PROTO;
214         } else
215                 return -IPSET_ERR_MISSING_PROTO;
216
217         if (!(with_ports || e.proto == IPPROTO_ICMP))
218                 e.port = 0;
219
220         if (tb[IPSET_ATTR_CADT_FLAGS]) {
221                 u32 cadt_flags = ip_set_get_h32(tb[IPSET_ATTR_CADT_FLAGS]);
222                 if (cadt_flags & IPSET_FLAG_NOMATCH)
223                         flags |= (IPSET_FLAG_NOMATCH << 16);
224         }
225
226         with_ports = with_ports && tb[IPSET_ATTR_PORT_TO];
227         if (adt == IPSET_TEST ||
228             !(tb[IPSET_ATTR_CIDR] || tb[IPSET_ATTR_IP_TO] || with_ports ||
229               tb[IPSET_ATTR_IP2_TO])) {
230                 e.ip = htonl(ip);
231                 e.ip2 = htonl(ip2_from & ip_set_hostmask(e.cidr + 1));
232                 ret = adtfn(set, &e, &ext, &ext, flags);
233                 return ip_set_enomatch(ret, flags, adt, set) ? -ret :
234                        ip_set_eexist(ret, flags) ? 0 : ret;
235         }
236
237         ip_to = ip;
238         if (tb[IPSET_ATTR_IP_TO]) {
239                 ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP_TO], &ip_to);
240                 if (ret)
241                         return ret;
242                 if (ip > ip_to)
243                         swap(ip, ip_to);
244         } else if (tb[IPSET_ATTR_CIDR]) {
245                 cidr = nla_get_u8(tb[IPSET_ATTR_CIDR]);
246
247                 if (!cidr || cidr > 32)
248                         return -IPSET_ERR_INVALID_CIDR;
249                 ip_set_mask_from_to(ip, ip_to, cidr);
250         }
251
252         port_to = port = ntohs(e.port);
253         if (tb[IPSET_ATTR_PORT_TO]) {
254                 port_to = ip_set_get_h16(tb[IPSET_ATTR_PORT_TO]);
255                 if (port > port_to)
256                         swap(port, port_to);
257         }
258
259         ip2_to = ip2_from;
260         if (tb[IPSET_ATTR_IP2_TO]) {
261                 ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP2_TO], &ip2_to);
262                 if (ret)
263                         return ret;
264                 if (ip2_from > ip2_to)
265                         swap(ip2_from, ip2_to);
266                 if (ip2_from + UINT_MAX == ip2_to)
267                         return -IPSET_ERR_HASH_RANGE;
268         } else
269                 ip_set_mask_from_to(ip2_from, ip2_to, e.cidr + 1);
270
271         if (retried)
272                 ip = ntohl(h->next.ip);
273         for (; !before(ip_to, ip); ip++) {
274                 e.ip = htonl(ip);
275                 p = retried && ip == ntohl(h->next.ip) ? ntohs(h->next.port)
276                                                        : port;
277                 for (; p <= port_to; p++) {
278                         e.port = htons(p);
279                         ip2 = retried &&
280                               ip == ntohl(h->next.ip) &&
281                               p == ntohs(h->next.port)
282                                 ? ntohl(h->next.ip2) : ip2_from;
283                         while (!after(ip2, ip2_to)) {
284                                 e.ip2 = htonl(ip2);
285                                 ip2_last = ip_set_range_to_cidr(ip2, ip2_to,
286                                                                 &cidr);
287                                 e.cidr = cidr - 1;
288                                 ret = adtfn(set, &e, &ext, &ext, flags);
289
290                                 if (ret && !ip_set_eexist(ret, flags))
291                                         return ret;
292                                 else
293                                         ret = 0;
294                                 ip2 = ip2_last + 1;
295                         }
296                 }
297         }
298         return ret;
299 }
300
301 /* IPv6 variant */
302
303 struct hash_ipportnet6_elem {
304         union nf_inet_addr ip;
305         union nf_inet_addr ip2;
306         __be16 port;
307         u8 cidr:7;
308         u8 nomatch:1;
309         u8 proto;
310 };
311
312 /* Common functions */
313
314 static inline bool
315 hash_ipportnet6_data_equal(const struct hash_ipportnet6_elem *ip1,
316                            const struct hash_ipportnet6_elem *ip2,
317                            u32 *multi)
318 {
319         return ipv6_addr_equal(&ip1->ip.in6, &ip2->ip.in6) &&
320                ipv6_addr_equal(&ip1->ip2.in6, &ip2->ip2.in6) &&
321                ip1->cidr == ip2->cidr &&
322                ip1->port == ip2->port &&
323                ip1->proto == ip2->proto;
324 }
325
326 static inline int
327 hash_ipportnet6_do_data_match(const struct hash_ipportnet6_elem *elem)
328 {
329         return elem->nomatch ? -ENOTEMPTY : 1;
330 }
331
332 static inline void
333 hash_ipportnet6_data_set_flags(struct hash_ipportnet6_elem *elem, u32 flags)
334 {
335         elem->nomatch = !!((flags >> 16) & IPSET_FLAG_NOMATCH);
336 }
337
338 static inline void
339 hash_ipportnet6_data_reset_flags(struct hash_ipportnet6_elem *elem, u8 *flags)
340 {
341         swap(*flags, elem->nomatch);
342 }
343
344 static inline void
345 hash_ipportnet6_data_netmask(struct hash_ipportnet6_elem *elem, u8 cidr)
346 {
347         ip6_netmask(&elem->ip2, cidr);
348         elem->cidr = cidr - 1;
349 }
350
351 static bool
352 hash_ipportnet6_data_list(struct sk_buff *skb,
353                           const struct hash_ipportnet6_elem *data)
354 {
355         u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0;
356
357         if (nla_put_ipaddr6(skb, IPSET_ATTR_IP, &data->ip.in6) ||
358             nla_put_ipaddr6(skb, IPSET_ATTR_IP2, &data->ip2.in6) ||
359             nla_put_net16(skb, IPSET_ATTR_PORT, data->port) ||
360             nla_put_u8(skb, IPSET_ATTR_CIDR2, data->cidr + 1) ||
361             nla_put_u8(skb, IPSET_ATTR_PROTO, data->proto) ||
362             (flags &&
363              nla_put_net32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags))))
364                 goto nla_put_failure;
365         return 0;
366
367 nla_put_failure:
368         return 1;
369 }
370
371 static inline void
372 hash_ipportnet6_data_next(struct hash_ipportnet4_elem *next,
373                           const struct hash_ipportnet6_elem *d)
374 {
375         next->port = d->port;
376 }
377
378 #undef MTYPE
379 #undef PF
380 #undef HOST_MASK
381
382 #define MTYPE           hash_ipportnet6
383 #define PF              6
384 #define HOST_MASK       128
385 #define IP_SET_EMIT_CREATE
386 #include "ip_set_hash_gen.h"
387
388 static int
389 hash_ipportnet6_kadt(struct ip_set *set, const struct sk_buff *skb,
390                      const struct xt_action_param *par,
391                      enum ipset_adt adt, struct ip_set_adt_opt *opt)
392 {
393         const struct hash_ipportnet *h = set->data;
394         ipset_adtfn adtfn = set->variant->adt[adt];
395         struct hash_ipportnet6_elem e = {
396                 .cidr = IP_SET_INIT_CIDR(h->nets[0].cidr[0], HOST_MASK) - 1,
397         };
398         struct ip_set_ext ext = IP_SET_INIT_KEXT(skb, opt, set);
399
400         if (adt == IPSET_TEST)
401                 e.cidr = HOST_MASK - 1;
402
403         if (!ip_set_get_ip6_port(skb, opt->flags & IPSET_DIM_TWO_SRC,
404                                  &e.port, &e.proto))
405                 return -EINVAL;
406
407         ip6addrptr(skb, opt->flags & IPSET_DIM_ONE_SRC, &e.ip.in6);
408         ip6addrptr(skb, opt->flags & IPSET_DIM_THREE_SRC, &e.ip2.in6);
409         ip6_netmask(&e.ip2, e.cidr + 1);
410
411         return adtfn(set, &e, &ext, &opt->ext, opt->cmdflags);
412 }
413
414 static int
415 hash_ipportnet6_uadt(struct ip_set *set, struct nlattr *tb[],
416                      enum ipset_adt adt, u32 *lineno, u32 flags, bool retried)
417 {
418         const struct hash_ipportnet *h = set->data;
419         ipset_adtfn adtfn = set->variant->adt[adt];
420         struct hash_ipportnet6_elem e = { .cidr = HOST_MASK - 1 };
421         struct ip_set_ext ext = IP_SET_INIT_UEXT(set);
422         u32 port, port_to;
423         bool with_ports = false;
424         u8 cidr;
425         int ret;
426
427         if (unlikely(!tb[IPSET_ATTR_IP] || !tb[IPSET_ATTR_IP2] ||
428                      !ip_set_attr_netorder(tb, IPSET_ATTR_PORT) ||
429                      !ip_set_optattr_netorder(tb, IPSET_ATTR_PORT_TO) ||
430                      !ip_set_optattr_netorder(tb, IPSET_ATTR_TIMEOUT) ||
431                      !ip_set_optattr_netorder(tb, IPSET_ATTR_CADT_FLAGS) ||
432                      !ip_set_optattr_netorder(tb, IPSET_ATTR_PACKETS) ||
433                      !ip_set_optattr_netorder(tb, IPSET_ATTR_BYTES) ||
434                      tb[IPSET_ATTR_IP_TO] ||
435                      tb[IPSET_ATTR_CIDR]))
436                 return -IPSET_ERR_PROTOCOL;
437         if (unlikely(tb[IPSET_ATTR_IP_TO]))
438                 return -IPSET_ERR_HASH_RANGE_UNSUPPORTED;
439
440         if (tb[IPSET_ATTR_LINENO])
441                 *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
442
443         ret = ip_set_get_ipaddr6(tb[IPSET_ATTR_IP], &e.ip) ||
444               ip_set_get_extensions(set, tb, &ext);
445         if (ret)
446                 return ret;
447
448         ret = ip_set_get_ipaddr6(tb[IPSET_ATTR_IP2], &e.ip2);
449         if (ret)
450                 return ret;
451
452         if (tb[IPSET_ATTR_CIDR2]) {
453                 cidr = nla_get_u8(tb[IPSET_ATTR_CIDR2]);
454                 if (!cidr || cidr > HOST_MASK)
455                         return -IPSET_ERR_INVALID_CIDR;
456                 e.cidr = cidr - 1;
457         }
458
459         ip6_netmask(&e.ip2, e.cidr + 1);
460
461         if (tb[IPSET_ATTR_PORT])
462                 e.port = nla_get_be16(tb[IPSET_ATTR_PORT]);
463         else
464                 return -IPSET_ERR_PROTOCOL;
465
466         if (tb[IPSET_ATTR_PROTO]) {
467                 e.proto = nla_get_u8(tb[IPSET_ATTR_PROTO]);
468                 with_ports = ip_set_proto_with_ports(e.proto);
469
470                 if (e.proto == 0)
471                         return -IPSET_ERR_INVALID_PROTO;
472         } else
473                 return -IPSET_ERR_MISSING_PROTO;
474
475         if (!(with_ports || e.proto == IPPROTO_ICMPV6))
476                 e.port = 0;
477
478         if (tb[IPSET_ATTR_CADT_FLAGS]) {
479                 u32 cadt_flags = ip_set_get_h32(tb[IPSET_ATTR_CADT_FLAGS]);
480                 if (cadt_flags & IPSET_FLAG_NOMATCH)
481                         flags |= (IPSET_FLAG_NOMATCH << 16);
482         }
483
484         if (adt == IPSET_TEST || !with_ports || !tb[IPSET_ATTR_PORT_TO]) {
485                 ret = adtfn(set, &e, &ext, &ext, flags);
486                 return ip_set_enomatch(ret, flags, adt, set) ? -ret :
487                        ip_set_eexist(ret, flags) ? 0 : ret;
488         }
489
490         port = ntohs(e.port);
491         port_to = ip_set_get_h16(tb[IPSET_ATTR_PORT_TO]);
492         if (port > port_to)
493                 swap(port, port_to);
494
495         if (retried)
496                 port = ntohs(h->next.port);
497         for (; port <= port_to; port++) {
498                 e.port = htons(port);
499                 ret = adtfn(set, &e, &ext, &ext, flags);
500
501                 if (ret && !ip_set_eexist(ret, flags))
502                         return ret;
503                 else
504                         ret = 0;
505         }
506         return ret;
507 }
508
509 static struct ip_set_type hash_ipportnet_type __read_mostly = {
510         .name           = "hash:ip,port,net",
511         .protocol       = IPSET_PROTOCOL,
512         .features       = IPSET_TYPE_IP | IPSET_TYPE_PORT | IPSET_TYPE_IP2 |
513                           IPSET_TYPE_NOMATCH,
514         .dimension      = IPSET_DIM_THREE,
515         .family         = NFPROTO_UNSPEC,
516         .revision_min   = IPSET_TYPE_REV_MIN,
517         .revision_max   = IPSET_TYPE_REV_MAX,
518         .create         = hash_ipportnet_create,
519         .create_policy  = {
520                 [IPSET_ATTR_HASHSIZE]   = { .type = NLA_U32 },
521                 [IPSET_ATTR_MAXELEM]    = { .type = NLA_U32 },
522                 [IPSET_ATTR_PROBES]     = { .type = NLA_U8 },
523                 [IPSET_ATTR_RESIZE]     = { .type = NLA_U8  },
524                 [IPSET_ATTR_TIMEOUT]    = { .type = NLA_U32 },
525                 [IPSET_ATTR_CADT_FLAGS] = { .type = NLA_U32 },
526         },
527         .adt_policy     = {
528                 [IPSET_ATTR_IP]         = { .type = NLA_NESTED },
529                 [IPSET_ATTR_IP_TO]      = { .type = NLA_NESTED },
530                 [IPSET_ATTR_IP2]        = { .type = NLA_NESTED },
531                 [IPSET_ATTR_IP2_TO]     = { .type = NLA_NESTED },
532                 [IPSET_ATTR_PORT]       = { .type = NLA_U16 },
533                 [IPSET_ATTR_PORT_TO]    = { .type = NLA_U16 },
534                 [IPSET_ATTR_CIDR]       = { .type = NLA_U8 },
535                 [IPSET_ATTR_CIDR2]      = { .type = NLA_U8 },
536                 [IPSET_ATTR_PROTO]      = { .type = NLA_U8 },
537                 [IPSET_ATTR_CADT_FLAGS] = { .type = NLA_U32 },
538                 [IPSET_ATTR_TIMEOUT]    = { .type = NLA_U32 },
539                 [IPSET_ATTR_LINENO]     = { .type = NLA_U32 },
540                 [IPSET_ATTR_BYTES]      = { .type = NLA_U64 },
541                 [IPSET_ATTR_PACKETS]    = { .type = NLA_U64 },
542                 [IPSET_ATTR_COMMENT]    = { .type = NLA_NUL_STRING },
543         },
544         .me             = THIS_MODULE,
545 };
546
547 static int __init
548 hash_ipportnet_init(void)
549 {
550         return ip_set_type_register(&hash_ipportnet_type);
551 }
552
553 static void __exit
554 hash_ipportnet_fini(void)
555 {
556         ip_set_type_unregister(&hash_ipportnet_type);
557 }
558
559 module_init(hash_ipportnet_init);
560 module_exit(hash_ipportnet_fini);