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 /* 0 Comments support added */ 29 /* 1 Forceadd support added */ 30 #define IPSET_TYPE_REV_MAX 2 /* skbinfo support added */ 31 32 MODULE_LICENSE("GPL"); 33 MODULE_AUTHOR("Oliver Smith <oliver@8.c.9.b.0.7.4.0.1.0.0.2.ip6.arpa>"); 34 IP_SET_MODULE_DESC("hash:net,port,net", IPSET_TYPE_REV_MIN, IPSET_TYPE_REV_MAX); 35 MODULE_ALIAS("ip_set_hash:net,port,net"); 36 37 /* Type specific function prefix */ 38 #define HTYPE hash_netportnet 39 #define IP_SET_HASH_WITH_PROTO 40 #define IP_SET_HASH_WITH_NETS 41 #define IPSET_NET_COUNT 2 42 43 /* IPv4 variant */ 44 45 /* Member elements */ 46 struct hash_netportnet4_elem { 47 union { 48 __be32 ip[2]; 49 __be64 ipcmp; 50 }; 51 __be16 port; 52 union { 53 u8 cidr[2]; 54 u16 ccmp; 55 }; 56 u16 padding; 57 u8 nomatch; 58 u8 proto; 59 }; 60 61 /* Common functions */ 62 63 static inline bool 64 hash_netportnet4_data_equal(const struct hash_netportnet4_elem *ip1, 65 const struct hash_netportnet4_elem *ip2, 66 u32 *multi) 67 { 68 return ip1->ipcmp == ip2->ipcmp && 69 ip1->ccmp == ip2->ccmp && 70 ip1->port == ip2->port && 71 ip1->proto == ip2->proto; 72 } 73 74 static inline int 75 hash_netportnet4_do_data_match(const struct hash_netportnet4_elem *elem) 76 { 77 return elem->nomatch ? -ENOTEMPTY : 1; 78 } 79 80 static inline void 81 hash_netportnet4_data_set_flags(struct hash_netportnet4_elem *elem, u32 flags) 82 { 83 elem->nomatch = !!((flags >> 16) & IPSET_FLAG_NOMATCH); 84 } 85 86 static inline void 87 hash_netportnet4_data_reset_flags(struct hash_netportnet4_elem *elem, u8 *flags) 88 { 89 swap(*flags, elem->nomatch); 90 } 91 92 static inline void 93 hash_netportnet4_data_reset_elem(struct hash_netportnet4_elem *elem, 94 struct hash_netportnet4_elem *orig) 95 { 96 elem->ip[1] = orig->ip[1]; 97 } 98 99 static inline void 100 hash_netportnet4_data_netmask(struct hash_netportnet4_elem *elem, 101 u8 cidr, bool inner) 102 { 103 if (inner) { 104 elem->ip[1] &= ip_set_netmask(cidr); 105 elem->cidr[1] = cidr; 106 } else { 107 elem->ip[0] &= ip_set_netmask(cidr); 108 elem->cidr[0] = cidr; 109 } 110 } 111 112 static bool 113 hash_netportnet4_data_list(struct sk_buff *skb, 114 const struct hash_netportnet4_elem *data) 115 { 116 u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; 117 118 if (nla_put_ipaddr4(skb, IPSET_ATTR_IP, data->ip[0]) || 119 nla_put_ipaddr4(skb, IPSET_ATTR_IP2, data->ip[1]) || 120 nla_put_net16(skb, IPSET_ATTR_PORT, data->port) || 121 nla_put_u8(skb, IPSET_ATTR_CIDR, data->cidr[0]) || 122 nla_put_u8(skb, IPSET_ATTR_CIDR2, data->cidr[1]) || 123 nla_put_u8(skb, IPSET_ATTR_PROTO, data->proto) || 124 (flags && 125 nla_put_net32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)))) 126 goto nla_put_failure; 127 return false; 128 129 nla_put_failure: 130 return true; 131 } 132 133 static inline void 134 hash_netportnet4_data_next(struct hash_netportnet4_elem *next, 135 const struct hash_netportnet4_elem *d) 136 { 137 next->ipcmp = d->ipcmp; 138 next->port = d->port; 139 } 140 141 #define MTYPE hash_netportnet4 142 #define HOST_MASK 32 143 #include "ip_set_hash_gen.h" 144 145 static int 146 hash_netportnet4_kadt(struct ip_set *set, const struct sk_buff *skb, 147 const struct xt_action_param *par, 148 enum ipset_adt adt, struct ip_set_adt_opt *opt) 149 { 150 const struct hash_netportnet *h = set->data; 151 ipset_adtfn adtfn = set->variant->adt[adt]; 152 struct hash_netportnet4_elem e = { }; 153 struct ip_set_ext ext = IP_SET_INIT_KEXT(skb, opt, set); 154 155 e.cidr[0] = INIT_CIDR(h->nets[0].cidr[0], HOST_MASK); 156 e.cidr[1] = INIT_CIDR(h->nets[0].cidr[1], HOST_MASK); 157 if (adt == IPSET_TEST) 158 e.ccmp = (HOST_MASK << (sizeof(e.cidr[0]) * 8)) | HOST_MASK; 159 160 if (!ip_set_get_ip4_port(skb, opt->flags & IPSET_DIM_TWO_SRC, 161 &e.port, &e.proto)) 162 return -EINVAL; 163 164 ip4addrptr(skb, opt->flags & IPSET_DIM_ONE_SRC, &e.ip[0]); 165 ip4addrptr(skb, opt->flags & IPSET_DIM_THREE_SRC, &e.ip[1]); 166 e.ip[0] &= ip_set_netmask(e.cidr[0]); 167 e.ip[1] &= ip_set_netmask(e.cidr[1]); 168 169 return adtfn(set, &e, &ext, &opt->ext, opt->cmdflags); 170 } 171 172 static int 173 hash_netportnet4_uadt(struct ip_set *set, struct nlattr *tb[], 174 enum ipset_adt adt, u32 *lineno, u32 flags, bool retried) 175 { 176 const struct hash_netportnet *h = set->data; 177 ipset_adtfn adtfn = set->variant->adt[adt]; 178 struct hash_netportnet4_elem e = { .cidr = { HOST_MASK, HOST_MASK, }, }; 179 struct ip_set_ext ext = IP_SET_INIT_UEXT(set); 180 u32 ip = 0, ip_to = 0, ip_last, p = 0, port, port_to; 181 u32 ip2_from = 0, ip2_to = 0, ip2_last, ip2; 182 bool with_ports = false; 183 int ret; 184 185 if (tb[IPSET_ATTR_LINENO]) 186 *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]); 187 188 if (unlikely(!tb[IPSET_ATTR_IP] || !tb[IPSET_ATTR_IP2] || 189 !ip_set_attr_netorder(tb, IPSET_ATTR_PORT) || 190 !ip_set_optattr_netorder(tb, IPSET_ATTR_PORT_TO) || 191 !ip_set_optattr_netorder(tb, IPSET_ATTR_CADT_FLAGS))) 192 return -IPSET_ERR_PROTOCOL; 193 194 ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP], &ip); 195 if (ret) 196 return ret; 197 198 ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP2], &ip2_from); 199 if (ret) 200 return ret; 201 202 ret = ip_set_get_extensions(set, tb, &ext); 203 if (ret) 204 return ret; 205 206 if (tb[IPSET_ATTR_CIDR]) { 207 e.cidr[0] = nla_get_u8(tb[IPSET_ATTR_CIDR]); 208 if (!e.cidr[0] || e.cidr[0] > HOST_MASK) 209 return -IPSET_ERR_INVALID_CIDR; 210 } 211 212 if (tb[IPSET_ATTR_CIDR2]) { 213 e.cidr[1] = nla_get_u8(tb[IPSET_ATTR_CIDR2]); 214 if (!e.cidr[1] || e.cidr[1] > HOST_MASK) 215 return -IPSET_ERR_INVALID_CIDR; 216 } 217 218 e.port = nla_get_be16(tb[IPSET_ATTR_PORT]); 219 220 if (tb[IPSET_ATTR_PROTO]) { 221 e.proto = nla_get_u8(tb[IPSET_ATTR_PROTO]); 222 with_ports = ip_set_proto_with_ports(e.proto); 223 224 if (e.proto == 0) 225 return -IPSET_ERR_INVALID_PROTO; 226 } else 227 return -IPSET_ERR_MISSING_PROTO; 228 229 if (!(with_ports || e.proto == IPPROTO_ICMP)) 230 e.port = 0; 231 232 if (tb[IPSET_ATTR_CADT_FLAGS]) { 233 u32 cadt_flags = ip_set_get_h32(tb[IPSET_ATTR_CADT_FLAGS]); 234 if (cadt_flags & IPSET_FLAG_NOMATCH) 235 flags |= (IPSET_FLAG_NOMATCH << 16); 236 } 237 238 with_ports = with_ports && tb[IPSET_ATTR_PORT_TO]; 239 if (adt == IPSET_TEST || 240 !(tb[IPSET_ATTR_IP_TO] || with_ports || tb[IPSET_ATTR_IP2_TO])) { 241 e.ip[0] = htonl(ip & ip_set_hostmask(e.cidr[0])); 242 e.ip[1] = htonl(ip2_from & ip_set_hostmask(e.cidr[1])); 243 ret = adtfn(set, &e, &ext, &ext, flags); 244 return ip_set_enomatch(ret, flags, adt, set) ? -ret : 245 ip_set_eexist(ret, flags) ? 0 : ret; 246 } 247 248 ip_to = ip; 249 if (tb[IPSET_ATTR_IP_TO]) { 250 ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP_TO], &ip_to); 251 if (ret) 252 return ret; 253 if (ip > ip_to) 254 swap(ip, ip_to); 255 if (unlikely(ip + UINT_MAX == ip_to)) 256 return -IPSET_ERR_HASH_RANGE; 257 } else 258 ip_set_mask_from_to(ip, ip_to, e.cidr[0]); 259 260 port_to = port = ntohs(e.port); 261 if (tb[IPSET_ATTR_PORT_TO]) { 262 port_to = ip_set_get_h16(tb[IPSET_ATTR_PORT_TO]); 263 if (port > port_to) 264 swap(port, port_to); 265 } 266 267 ip2_to = ip2_from; 268 if (tb[IPSET_ATTR_IP2_TO]) { 269 ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP2_TO], &ip2_to); 270 if (ret) 271 return ret; 272 if (ip2_from > ip2_to) 273 swap(ip2_from, ip2_to); 274 if (unlikely(ip2_from + UINT_MAX == ip2_to)) 275 return -IPSET_ERR_HASH_RANGE; 276 } else 277 ip_set_mask_from_to(ip2_from, ip2_to, e.cidr[1]); 278 279 if (retried) 280 ip = ntohl(h->next.ip[0]); 281 282 while (!after(ip, ip_to)) { 283 e.ip[0] = htonl(ip); 284 ip_last = ip_set_range_to_cidr(ip, ip_to, &e.cidr[0]); 285 p = retried && ip == ntohl(h->next.ip[0]) ? ntohs(h->next.port) 286 : port; 287 for (; p <= port_to; p++) { 288 e.port = htons(p); 289 ip2 = (retried && ip == ntohl(h->next.ip[0]) && 290 p == ntohs(h->next.port)) ? ntohl(h->next.ip[1]) 291 : ip2_from; 292 while (!after(ip2, ip2_to)) { 293 e.ip[1] = htonl(ip2); 294 ip2_last = ip_set_range_to_cidr(ip2, ip2_to, 295 &e.cidr[1]); 296 ret = adtfn(set, &e, &ext, &ext, flags); 297 if (ret && !ip_set_eexist(ret, flags)) 298 return ret; 299 else 300 ret = 0; 301 ip2 = ip2_last + 1; 302 } 303 } 304 ip = ip_last + 1; 305 } 306 return ret; 307 } 308 309 /* IPv6 variant */ 310 311 struct hash_netportnet6_elem { 312 union nf_inet_addr ip[2]; 313 __be16 port; 314 union { 315 u8 cidr[2]; 316 u16 ccmp; 317 }; 318 u16 padding; 319 u8 nomatch; 320 u8 proto; 321 }; 322 323 /* Common functions */ 324 325 static inline bool 326 hash_netportnet6_data_equal(const struct hash_netportnet6_elem *ip1, 327 const struct hash_netportnet6_elem *ip2, 328 u32 *multi) 329 { 330 return ipv6_addr_equal(&ip1->ip[0].in6, &ip2->ip[0].in6) && 331 ipv6_addr_equal(&ip1->ip[1].in6, &ip2->ip[1].in6) && 332 ip1->ccmp == ip2->ccmp && 333 ip1->port == ip2->port && 334 ip1->proto == ip2->proto; 335 } 336 337 static inline int 338 hash_netportnet6_do_data_match(const struct hash_netportnet6_elem *elem) 339 { 340 return elem->nomatch ? -ENOTEMPTY : 1; 341 } 342 343 static inline void 344 hash_netportnet6_data_set_flags(struct hash_netportnet6_elem *elem, u32 flags) 345 { 346 elem->nomatch = !!((flags >> 16) & IPSET_FLAG_NOMATCH); 347 } 348 349 static inline void 350 hash_netportnet6_data_reset_flags(struct hash_netportnet6_elem *elem, u8 *flags) 351 { 352 swap(*flags, elem->nomatch); 353 } 354 355 static inline void 356 hash_netportnet6_data_reset_elem(struct hash_netportnet6_elem *elem, 357 struct hash_netportnet6_elem *orig) 358 { 359 elem->ip[1] = orig->ip[1]; 360 } 361 362 static inline void 363 hash_netportnet6_data_netmask(struct hash_netportnet6_elem *elem, 364 u8 cidr, bool inner) 365 { 366 if (inner) { 367 ip6_netmask(&elem->ip[1], cidr); 368 elem->cidr[1] = cidr; 369 } else { 370 ip6_netmask(&elem->ip[0], cidr); 371 elem->cidr[0] = cidr; 372 } 373 } 374 375 static bool 376 hash_netportnet6_data_list(struct sk_buff *skb, 377 const struct hash_netportnet6_elem *data) 378 { 379 u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; 380 381 if (nla_put_ipaddr6(skb, IPSET_ATTR_IP, &data->ip[0].in6) || 382 nla_put_ipaddr6(skb, IPSET_ATTR_IP2, &data->ip[1].in6) || 383 nla_put_net16(skb, IPSET_ATTR_PORT, data->port) || 384 nla_put_u8(skb, IPSET_ATTR_CIDR, data->cidr[0]) || 385 nla_put_u8(skb, IPSET_ATTR_CIDR2, data->cidr[1]) || 386 nla_put_u8(skb, IPSET_ATTR_PROTO, data->proto) || 387 (flags && 388 nla_put_net32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)))) 389 goto nla_put_failure; 390 return false; 391 392 nla_put_failure: 393 return true; 394 } 395 396 static inline void 397 hash_netportnet6_data_next(struct hash_netportnet4_elem *next, 398 const struct hash_netportnet6_elem *d) 399 { 400 next->port = d->port; 401 } 402 403 #undef MTYPE 404 #undef HOST_MASK 405 406 #define MTYPE hash_netportnet6 407 #define HOST_MASK 128 408 #define IP_SET_EMIT_CREATE 409 #include "ip_set_hash_gen.h" 410 411 static int 412 hash_netportnet6_kadt(struct ip_set *set, const struct sk_buff *skb, 413 const struct xt_action_param *par, 414 enum ipset_adt adt, struct ip_set_adt_opt *opt) 415 { 416 const struct hash_netportnet *h = set->data; 417 ipset_adtfn adtfn = set->variant->adt[adt]; 418 struct hash_netportnet6_elem e = { }; 419 struct ip_set_ext ext = IP_SET_INIT_KEXT(skb, opt, set); 420 421 e.cidr[0] = INIT_CIDR(h->nets[0].cidr[0], HOST_MASK); 422 e.cidr[1] = INIT_CIDR(h->nets[0].cidr[1], HOST_MASK); 423 if (adt == IPSET_TEST) 424 e.ccmp = (HOST_MASK << (sizeof(u8) * 8)) | HOST_MASK; 425 426 if (!ip_set_get_ip6_port(skb, opt->flags & IPSET_DIM_TWO_SRC, 427 &e.port, &e.proto)) 428 return -EINVAL; 429 430 ip6addrptr(skb, opt->flags & IPSET_DIM_ONE_SRC, &e.ip[0].in6); 431 ip6addrptr(skb, opt->flags & IPSET_DIM_THREE_SRC, &e.ip[1].in6); 432 ip6_netmask(&e.ip[0], e.cidr[0]); 433 ip6_netmask(&e.ip[1], e.cidr[1]); 434 435 return adtfn(set, &e, &ext, &opt->ext, opt->cmdflags); 436 } 437 438 static int 439 hash_netportnet6_uadt(struct ip_set *set, struct nlattr *tb[], 440 enum ipset_adt adt, u32 *lineno, u32 flags, bool retried) 441 { 442 const struct hash_netportnet *h = set->data; 443 ipset_adtfn adtfn = set->variant->adt[adt]; 444 struct hash_netportnet6_elem e = { .cidr = { HOST_MASK, HOST_MASK, }, }; 445 struct ip_set_ext ext = IP_SET_INIT_UEXT(set); 446 u32 port, port_to; 447 bool with_ports = false; 448 int ret; 449 450 if (tb[IPSET_ATTR_LINENO]) 451 *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]); 452 453 if (unlikely(!tb[IPSET_ATTR_IP] || !tb[IPSET_ATTR_IP2] || 454 !ip_set_attr_netorder(tb, IPSET_ATTR_PORT) || 455 !ip_set_optattr_netorder(tb, IPSET_ATTR_PORT_TO) || 456 !ip_set_optattr_netorder(tb, IPSET_ATTR_CADT_FLAGS))) 457 return -IPSET_ERR_PROTOCOL; 458 if (unlikely(tb[IPSET_ATTR_IP_TO] || tb[IPSET_ATTR_IP2_TO])) 459 return -IPSET_ERR_HASH_RANGE_UNSUPPORTED; 460 461 ret = ip_set_get_ipaddr6(tb[IPSET_ATTR_IP], &e.ip[0]); 462 if (ret) 463 return ret; 464 465 ret = ip_set_get_ipaddr6(tb[IPSET_ATTR_IP2], &e.ip[1]); 466 if (ret) 467 return ret; 468 469 ret = ip_set_get_extensions(set, tb, &ext); 470 if (ret) 471 return ret; 472 473 if (tb[IPSET_ATTR_CIDR]) { 474 e.cidr[0] = nla_get_u8(tb[IPSET_ATTR_CIDR]); 475 if (!e.cidr[0] || e.cidr[0] > HOST_MASK) 476 return -IPSET_ERR_INVALID_CIDR; 477 } 478 479 if (tb[IPSET_ATTR_CIDR2]) { 480 e.cidr[1] = nla_get_u8(tb[IPSET_ATTR_CIDR2]); 481 if (!e.cidr[1] || e.cidr[1] > HOST_MASK) 482 return -IPSET_ERR_INVALID_CIDR; 483 } 484 485 ip6_netmask(&e.ip[0], e.cidr[0]); 486 ip6_netmask(&e.ip[1], e.cidr[1]); 487 488 e.port = nla_get_be16(tb[IPSET_ATTR_PORT]); 489 490 if (tb[IPSET_ATTR_PROTO]) { 491 e.proto = nla_get_u8(tb[IPSET_ATTR_PROTO]); 492 with_ports = ip_set_proto_with_ports(e.proto); 493 494 if (e.proto == 0) 495 return -IPSET_ERR_INVALID_PROTO; 496 } else 497 return -IPSET_ERR_MISSING_PROTO; 498 499 if (!(with_ports || e.proto == IPPROTO_ICMPV6)) 500 e.port = 0; 501 502 if (tb[IPSET_ATTR_CADT_FLAGS]) { 503 u32 cadt_flags = ip_set_get_h32(tb[IPSET_ATTR_CADT_FLAGS]); 504 if (cadt_flags & IPSET_FLAG_NOMATCH) 505 flags |= (IPSET_FLAG_NOMATCH << 16); 506 } 507 508 if (adt == IPSET_TEST || !with_ports || !tb[IPSET_ATTR_PORT_TO]) { 509 ret = adtfn(set, &e, &ext, &ext, flags); 510 return ip_set_enomatch(ret, flags, adt, set) ? -ret : 511 ip_set_eexist(ret, flags) ? 0 : ret; 512 } 513 514 port = ntohs(e.port); 515 port_to = ip_set_get_h16(tb[IPSET_ATTR_PORT_TO]); 516 if (port > port_to) 517 swap(port, port_to); 518 519 if (retried) 520 port = ntohs(h->next.port); 521 for (; port <= port_to; port++) { 522 e.port = htons(port); 523 ret = adtfn(set, &e, &ext, &ext, flags); 524 525 if (ret && !ip_set_eexist(ret, flags)) 526 return ret; 527 else 528 ret = 0; 529 } 530 return ret; 531 } 532 533 static struct ip_set_type hash_netportnet_type __read_mostly = { 534 .name = "hash:net,port,net", 535 .protocol = IPSET_PROTOCOL, 536 .features = IPSET_TYPE_IP | IPSET_TYPE_PORT | IPSET_TYPE_IP2 | 537 IPSET_TYPE_NOMATCH, 538 .dimension = IPSET_DIM_THREE, 539 .family = NFPROTO_UNSPEC, 540 .revision_min = IPSET_TYPE_REV_MIN, 541 .revision_max = IPSET_TYPE_REV_MAX, 542 .create = hash_netportnet_create, 543 .create_policy = { 544 [IPSET_ATTR_HASHSIZE] = { .type = NLA_U32 }, 545 [IPSET_ATTR_MAXELEM] = { .type = NLA_U32 }, 546 [IPSET_ATTR_PROBES] = { .type = NLA_U8 }, 547 [IPSET_ATTR_RESIZE] = { .type = NLA_U8 }, 548 [IPSET_ATTR_TIMEOUT] = { .type = NLA_U32 }, 549 [IPSET_ATTR_CADT_FLAGS] = { .type = NLA_U32 }, 550 }, 551 .adt_policy = { 552 [IPSET_ATTR_IP] = { .type = NLA_NESTED }, 553 [IPSET_ATTR_IP_TO] = { .type = NLA_NESTED }, 554 [IPSET_ATTR_IP2] = { .type = NLA_NESTED }, 555 [IPSET_ATTR_IP2_TO] = { .type = NLA_NESTED }, 556 [IPSET_ATTR_PORT] = { .type = NLA_U16 }, 557 [IPSET_ATTR_PORT_TO] = { .type = NLA_U16 }, 558 [IPSET_ATTR_CIDR] = { .type = NLA_U8 }, 559 [IPSET_ATTR_CIDR2] = { .type = NLA_U8 }, 560 [IPSET_ATTR_PROTO] = { .type = NLA_U8 }, 561 [IPSET_ATTR_CADT_FLAGS] = { .type = NLA_U32 }, 562 [IPSET_ATTR_TIMEOUT] = { .type = NLA_U32 }, 563 [IPSET_ATTR_LINENO] = { .type = NLA_U32 }, 564 [IPSET_ATTR_BYTES] = { .type = NLA_U64 }, 565 [IPSET_ATTR_PACKETS] = { .type = NLA_U64 }, 566 [IPSET_ATTR_COMMENT] = { .type = NLA_NUL_STRING, 567 .len = IPSET_MAX_COMMENT_SIZE }, 568 [IPSET_ATTR_SKBMARK] = { .type = NLA_U64 }, 569 [IPSET_ATTR_SKBPRIO] = { .type = NLA_U32 }, 570 [IPSET_ATTR_SKBQUEUE] = { .type = NLA_U16 }, 571 }, 572 .me = THIS_MODULE, 573 }; 574 575 static int __init 576 hash_netportnet_init(void) 577 { 578 return ip_set_type_register(&hash_netportnet_type); 579 } 580 581 static void __exit 582 hash_netportnet_fini(void) 583 { 584 rcu_barrier(); 585 ip_set_type_unregister(&hash_netportnet_type); 586 } 587 588 module_init(hash_netportnet_init); 589 module_exit(hash_netportnet_fini); 590