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 230 if (!(with_ports || e.proto == IPPROTO_ICMP)) 231 e.port = 0; 232 233 if (tb[IPSET_ATTR_CADT_FLAGS]) { 234 u32 cadt_flags = ip_set_get_h32(tb[IPSET_ATTR_CADT_FLAGS]); 235 236 if (cadt_flags & IPSET_FLAG_NOMATCH) 237 flags |= (IPSET_FLAG_NOMATCH << 16); 238 } 239 240 with_ports = with_ports && tb[IPSET_ATTR_PORT_TO]; 241 if (adt == IPSET_TEST || 242 !(tb[IPSET_ATTR_IP_TO] || with_ports || tb[IPSET_ATTR_IP2_TO])) { 243 e.ip[0] = htonl(ip & ip_set_hostmask(e.cidr[0])); 244 e.ip[1] = htonl(ip2_from & ip_set_hostmask(e.cidr[1])); 245 ret = adtfn(set, &e, &ext, &ext, flags); 246 return ip_set_enomatch(ret, flags, adt, set) ? -ret : 247 ip_set_eexist(ret, flags) ? 0 : ret; 248 } 249 250 ip_to = ip; 251 if (tb[IPSET_ATTR_IP_TO]) { 252 ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP_TO], &ip_to); 253 if (ret) 254 return ret; 255 if (ip > ip_to) 256 swap(ip, ip_to); 257 if (unlikely(ip + UINT_MAX == ip_to)) 258 return -IPSET_ERR_HASH_RANGE; 259 } else { 260 ip_set_mask_from_to(ip, ip_to, e.cidr[0]); 261 } 262 263 port_to = port = ntohs(e.port); 264 if (tb[IPSET_ATTR_PORT_TO]) { 265 port_to = ip_set_get_h16(tb[IPSET_ATTR_PORT_TO]); 266 if (port > port_to) 267 swap(port, port_to); 268 } 269 270 ip2_to = ip2_from; 271 if (tb[IPSET_ATTR_IP2_TO]) { 272 ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP2_TO], &ip2_to); 273 if (ret) 274 return ret; 275 if (ip2_from > ip2_to) 276 swap(ip2_from, ip2_to); 277 if (unlikely(ip2_from + UINT_MAX == ip2_to)) 278 return -IPSET_ERR_HASH_RANGE; 279 } else { 280 ip_set_mask_from_to(ip2_from, ip2_to, e.cidr[1]); 281 } 282 283 if (retried) 284 ip = ntohl(h->next.ip[0]); 285 286 while (!after(ip, ip_to)) { 287 e.ip[0] = htonl(ip); 288 ip_last = ip_set_range_to_cidr(ip, ip_to, &e.cidr[0]); 289 p = retried && ip == ntohl(h->next.ip[0]) ? ntohs(h->next.port) 290 : port; 291 for (; p <= port_to; p++) { 292 e.port = htons(p); 293 ip2 = (retried && ip == ntohl(h->next.ip[0]) && 294 p == ntohs(h->next.port)) ? ntohl(h->next.ip[1]) 295 : ip2_from; 296 while (!after(ip2, ip2_to)) { 297 e.ip[1] = htonl(ip2); 298 ip2_last = ip_set_range_to_cidr(ip2, ip2_to, 299 &e.cidr[1]); 300 ret = adtfn(set, &e, &ext, &ext, flags); 301 if (ret && !ip_set_eexist(ret, flags)) 302 return ret; 303 304 ret = 0; 305 ip2 = ip2_last + 1; 306 } 307 } 308 ip = ip_last + 1; 309 } 310 return ret; 311 } 312 313 /* IPv6 variant */ 314 315 struct hash_netportnet6_elem { 316 union nf_inet_addr ip[2]; 317 __be16 port; 318 union { 319 u8 cidr[2]; 320 u16 ccmp; 321 }; 322 u16 padding; 323 u8 nomatch; 324 u8 proto; 325 }; 326 327 /* Common functions */ 328 329 static inline bool 330 hash_netportnet6_data_equal(const struct hash_netportnet6_elem *ip1, 331 const struct hash_netportnet6_elem *ip2, 332 u32 *multi) 333 { 334 return ipv6_addr_equal(&ip1->ip[0].in6, &ip2->ip[0].in6) && 335 ipv6_addr_equal(&ip1->ip[1].in6, &ip2->ip[1].in6) && 336 ip1->ccmp == ip2->ccmp && 337 ip1->port == ip2->port && 338 ip1->proto == ip2->proto; 339 } 340 341 static inline int 342 hash_netportnet6_do_data_match(const struct hash_netportnet6_elem *elem) 343 { 344 return elem->nomatch ? -ENOTEMPTY : 1; 345 } 346 347 static inline void 348 hash_netportnet6_data_set_flags(struct hash_netportnet6_elem *elem, u32 flags) 349 { 350 elem->nomatch = !!((flags >> 16) & IPSET_FLAG_NOMATCH); 351 } 352 353 static inline void 354 hash_netportnet6_data_reset_flags(struct hash_netportnet6_elem *elem, u8 *flags) 355 { 356 swap(*flags, elem->nomatch); 357 } 358 359 static inline void 360 hash_netportnet6_data_reset_elem(struct hash_netportnet6_elem *elem, 361 struct hash_netportnet6_elem *orig) 362 { 363 elem->ip[1] = orig->ip[1]; 364 } 365 366 static inline void 367 hash_netportnet6_data_netmask(struct hash_netportnet6_elem *elem, 368 u8 cidr, bool inner) 369 { 370 if (inner) { 371 ip6_netmask(&elem->ip[1], cidr); 372 elem->cidr[1] = cidr; 373 } else { 374 ip6_netmask(&elem->ip[0], cidr); 375 elem->cidr[0] = cidr; 376 } 377 } 378 379 static bool 380 hash_netportnet6_data_list(struct sk_buff *skb, 381 const struct hash_netportnet6_elem *data) 382 { 383 u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; 384 385 if (nla_put_ipaddr6(skb, IPSET_ATTR_IP, &data->ip[0].in6) || 386 nla_put_ipaddr6(skb, IPSET_ATTR_IP2, &data->ip[1].in6) || 387 nla_put_net16(skb, IPSET_ATTR_PORT, data->port) || 388 nla_put_u8(skb, IPSET_ATTR_CIDR, data->cidr[0]) || 389 nla_put_u8(skb, IPSET_ATTR_CIDR2, data->cidr[1]) || 390 nla_put_u8(skb, IPSET_ATTR_PROTO, data->proto) || 391 (flags && 392 nla_put_net32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)))) 393 goto nla_put_failure; 394 return false; 395 396 nla_put_failure: 397 return true; 398 } 399 400 static inline void 401 hash_netportnet6_data_next(struct hash_netportnet4_elem *next, 402 const struct hash_netportnet6_elem *d) 403 { 404 next->port = d->port; 405 } 406 407 #undef MTYPE 408 #undef HOST_MASK 409 410 #define MTYPE hash_netportnet6 411 #define HOST_MASK 128 412 #define IP_SET_EMIT_CREATE 413 #include "ip_set_hash_gen.h" 414 415 static int 416 hash_netportnet6_kadt(struct ip_set *set, const struct sk_buff *skb, 417 const struct xt_action_param *par, 418 enum ipset_adt adt, struct ip_set_adt_opt *opt) 419 { 420 const struct hash_netportnet *h = set->data; 421 ipset_adtfn adtfn = set->variant->adt[adt]; 422 struct hash_netportnet6_elem e = { }; 423 struct ip_set_ext ext = IP_SET_INIT_KEXT(skb, opt, set); 424 425 e.cidr[0] = INIT_CIDR(h->nets[0].cidr[0], HOST_MASK); 426 e.cidr[1] = INIT_CIDR(h->nets[0].cidr[1], HOST_MASK); 427 if (adt == IPSET_TEST) 428 e.ccmp = (HOST_MASK << (sizeof(u8) * 8)) | HOST_MASK; 429 430 if (!ip_set_get_ip6_port(skb, opt->flags & IPSET_DIM_TWO_SRC, 431 &e.port, &e.proto)) 432 return -EINVAL; 433 434 ip6addrptr(skb, opt->flags & IPSET_DIM_ONE_SRC, &e.ip[0].in6); 435 ip6addrptr(skb, opt->flags & IPSET_DIM_THREE_SRC, &e.ip[1].in6); 436 ip6_netmask(&e.ip[0], e.cidr[0]); 437 ip6_netmask(&e.ip[1], e.cidr[1]); 438 439 return adtfn(set, &e, &ext, &opt->ext, opt->cmdflags); 440 } 441 442 static int 443 hash_netportnet6_uadt(struct ip_set *set, struct nlattr *tb[], 444 enum ipset_adt adt, u32 *lineno, u32 flags, bool retried) 445 { 446 const struct hash_netportnet *h = set->data; 447 ipset_adtfn adtfn = set->variant->adt[adt]; 448 struct hash_netportnet6_elem e = { .cidr = { HOST_MASK, HOST_MASK, }, }; 449 struct ip_set_ext ext = IP_SET_INIT_UEXT(set); 450 u32 port, port_to; 451 bool with_ports = false; 452 int ret; 453 454 if (tb[IPSET_ATTR_LINENO]) 455 *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]); 456 457 if (unlikely(!tb[IPSET_ATTR_IP] || !tb[IPSET_ATTR_IP2] || 458 !ip_set_attr_netorder(tb, IPSET_ATTR_PORT) || 459 !ip_set_optattr_netorder(tb, IPSET_ATTR_PORT_TO) || 460 !ip_set_optattr_netorder(tb, IPSET_ATTR_CADT_FLAGS))) 461 return -IPSET_ERR_PROTOCOL; 462 if (unlikely(tb[IPSET_ATTR_IP_TO] || tb[IPSET_ATTR_IP2_TO])) 463 return -IPSET_ERR_HASH_RANGE_UNSUPPORTED; 464 465 ret = ip_set_get_ipaddr6(tb[IPSET_ATTR_IP], &e.ip[0]); 466 if (ret) 467 return ret; 468 469 ret = ip_set_get_ipaddr6(tb[IPSET_ATTR_IP2], &e.ip[1]); 470 if (ret) 471 return ret; 472 473 ret = ip_set_get_extensions(set, tb, &ext); 474 if (ret) 475 return ret; 476 477 if (tb[IPSET_ATTR_CIDR]) { 478 e.cidr[0] = nla_get_u8(tb[IPSET_ATTR_CIDR]); 479 if (!e.cidr[0] || e.cidr[0] > HOST_MASK) 480 return -IPSET_ERR_INVALID_CIDR; 481 } 482 483 if (tb[IPSET_ATTR_CIDR2]) { 484 e.cidr[1] = nla_get_u8(tb[IPSET_ATTR_CIDR2]); 485 if (!e.cidr[1] || e.cidr[1] > HOST_MASK) 486 return -IPSET_ERR_INVALID_CIDR; 487 } 488 489 ip6_netmask(&e.ip[0], e.cidr[0]); 490 ip6_netmask(&e.ip[1], e.cidr[1]); 491 492 e.port = nla_get_be16(tb[IPSET_ATTR_PORT]); 493 494 if (tb[IPSET_ATTR_PROTO]) { 495 e.proto = nla_get_u8(tb[IPSET_ATTR_PROTO]); 496 with_ports = ip_set_proto_with_ports(e.proto); 497 498 if (e.proto == 0) 499 return -IPSET_ERR_INVALID_PROTO; 500 } else { 501 return -IPSET_ERR_MISSING_PROTO; 502 } 503 504 if (!(with_ports || e.proto == IPPROTO_ICMPV6)) 505 e.port = 0; 506 507 if (tb[IPSET_ATTR_CADT_FLAGS]) { 508 u32 cadt_flags = ip_set_get_h32(tb[IPSET_ATTR_CADT_FLAGS]); 509 510 if (cadt_flags & IPSET_FLAG_NOMATCH) 511 flags |= (IPSET_FLAG_NOMATCH << 16); 512 } 513 514 if (adt == IPSET_TEST || !with_ports || !tb[IPSET_ATTR_PORT_TO]) { 515 ret = adtfn(set, &e, &ext, &ext, flags); 516 return ip_set_enomatch(ret, flags, adt, set) ? -ret : 517 ip_set_eexist(ret, flags) ? 0 : ret; 518 } 519 520 port = ntohs(e.port); 521 port_to = ip_set_get_h16(tb[IPSET_ATTR_PORT_TO]); 522 if (port > port_to) 523 swap(port, port_to); 524 525 if (retried) 526 port = ntohs(h->next.port); 527 for (; port <= port_to; port++) { 528 e.port = htons(port); 529 ret = adtfn(set, &e, &ext, &ext, flags); 530 531 if (ret && !ip_set_eexist(ret, flags)) 532 return ret; 533 534 ret = 0; 535 } 536 return ret; 537 } 538 539 static struct ip_set_type hash_netportnet_type __read_mostly = { 540 .name = "hash:net,port,net", 541 .protocol = IPSET_PROTOCOL, 542 .features = IPSET_TYPE_IP | IPSET_TYPE_PORT | IPSET_TYPE_IP2 | 543 IPSET_TYPE_NOMATCH, 544 .dimension = IPSET_DIM_THREE, 545 .family = NFPROTO_UNSPEC, 546 .revision_min = IPSET_TYPE_REV_MIN, 547 .revision_max = IPSET_TYPE_REV_MAX, 548 .create = hash_netportnet_create, 549 .create_policy = { 550 [IPSET_ATTR_HASHSIZE] = { .type = NLA_U32 }, 551 [IPSET_ATTR_MAXELEM] = { .type = NLA_U32 }, 552 [IPSET_ATTR_PROBES] = { .type = NLA_U8 }, 553 [IPSET_ATTR_RESIZE] = { .type = NLA_U8 }, 554 [IPSET_ATTR_TIMEOUT] = { .type = NLA_U32 }, 555 [IPSET_ATTR_CADT_FLAGS] = { .type = NLA_U32 }, 556 }, 557 .adt_policy = { 558 [IPSET_ATTR_IP] = { .type = NLA_NESTED }, 559 [IPSET_ATTR_IP_TO] = { .type = NLA_NESTED }, 560 [IPSET_ATTR_IP2] = { .type = NLA_NESTED }, 561 [IPSET_ATTR_IP2_TO] = { .type = NLA_NESTED }, 562 [IPSET_ATTR_PORT] = { .type = NLA_U16 }, 563 [IPSET_ATTR_PORT_TO] = { .type = NLA_U16 }, 564 [IPSET_ATTR_CIDR] = { .type = NLA_U8 }, 565 [IPSET_ATTR_CIDR2] = { .type = NLA_U8 }, 566 [IPSET_ATTR_PROTO] = { .type = NLA_U8 }, 567 [IPSET_ATTR_CADT_FLAGS] = { .type = NLA_U32 }, 568 [IPSET_ATTR_TIMEOUT] = { .type = NLA_U32 }, 569 [IPSET_ATTR_LINENO] = { .type = NLA_U32 }, 570 [IPSET_ATTR_BYTES] = { .type = NLA_U64 }, 571 [IPSET_ATTR_PACKETS] = { .type = NLA_U64 }, 572 [IPSET_ATTR_COMMENT] = { .type = NLA_NUL_STRING, 573 .len = IPSET_MAX_COMMENT_SIZE }, 574 [IPSET_ATTR_SKBMARK] = { .type = NLA_U64 }, 575 [IPSET_ATTR_SKBPRIO] = { .type = NLA_U32 }, 576 [IPSET_ATTR_SKBQUEUE] = { .type = NLA_U16 }, 577 }, 578 .me = THIS_MODULE, 579 }; 580 581 static int __init 582 hash_netportnet_init(void) 583 { 584 return ip_set_type_register(&hash_netportnet_type); 585 } 586 587 static void __exit 588 hash_netportnet_fini(void) 589 { 590 rcu_barrier(); 591 ip_set_type_unregister(&hash_netportnet_type); 592 } 593 594 module_init(hash_netportnet_init); 595 module_exit(hash_netportnet_fini); 596