ip_set_hash_ipportnet.c 15 KB

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