ip_set_hash_ipportnet.c 15.4 KB
Newer Older
1
/* Copyright (C) 2003-2013 Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

/* Kernel module implementing an IP set type: the hash:ip,port,net type */

#include <linux/jhash.h>
#include <linux/module.h>
#include <linux/ip.h>
#include <linux/skbuff.h>
#include <linux/errno.h>
#include <linux/random.h>
#include <net/ip.h>
#include <net/ipv6.h>
#include <net/netlink.h>
#include <net/tcp.h>

#include <linux/netfilter.h>
#include <linux/netfilter/ipset/pfxlen.h>
#include <linux/netfilter/ipset/ip_set.h>
#include <linux/netfilter/ipset/ip_set_getport.h>
#include <linux/netfilter/ipset/ip_set_hash.h>

27 28 29 30
#define IPSET_TYPE_REV_MIN	0
/*				1    SCTP and UDPLITE support added */
/*				2    Range as input support for IPv4 added */
/*				3    nomatch flag support added */
31
/*				4    Counters support added */
32
/*				5    Comments support added */
33 34
/*				6    Forceadd support added */
#define IPSET_TYPE_REV_MAX	7 /* skbinfo support added */
35

36 37
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>");
38
IP_SET_MODULE_DESC("hash:ip,port,net", IPSET_TYPE_REV_MIN, IPSET_TYPE_REV_MAX);
39 40 41
MODULE_ALIAS("ip_set_hash:ip,port,net");

/* Type specific function prefix */
42
#define HTYPE		hash_ipportnet
43

44 45 46 47 48
/* We squeeze the "nomatch" flag into cidr: we don't support cidr == 0
 * However this way we have to store internally cidr - 1,
 * dancing back and forth.
 */
#define IP_SET_HASH_WITH_NETS_PACKED
49 50
#define IP_SET_HASH_WITH_PROTO
#define IP_SET_HASH_WITH_NETS
51

52
/* IPv4 variant */
53 54

/* Member elements */
55 56 57 58
struct hash_ipportnet4_elem {
	__be32 ip;
	__be32 ip2;
	__be16 port;
59 60
	u8 cidr:7;
	u8 nomatch:1;
61 62 63
	u8 proto;
};

64 65
/* Common functions */

66 67
static inline bool
hash_ipportnet4_data_equal(const struct hash_ipportnet4_elem *ip1,
68 69
			   const struct hash_ipportnet4_elem *ip2,
			   u32 *multi)
70 71 72 73 74 75 76 77
{
	return ip1->ip == ip2->ip &&
	       ip1->ip2 == ip2->ip2 &&
	       ip1->cidr == ip2->cidr &&
	       ip1->port == ip2->port &&
	       ip1->proto == ip2->proto;
}

78 79
static inline int
hash_ipportnet4_do_data_match(const struct hash_ipportnet4_elem *elem)
80
{
81
	return elem->nomatch ? -ENOTEMPTY : 1;
82 83 84
}

static inline void
85
hash_ipportnet4_data_set_flags(struct hash_ipportnet4_elem *elem, u32 flags)
86
{
87
	elem->nomatch = !!((flags >> 16) & IPSET_FLAG_NOMATCH);
88 89
}

90
static inline void
91
hash_ipportnet4_data_reset_flags(struct hash_ipportnet4_elem *elem, u8 *flags)
92
{
93
	swap(*flags, elem->nomatch);
94 95
}

96 97 98 99
static inline void
hash_ipportnet4_data_netmask(struct hash_ipportnet4_elem *elem, u8 cidr)
{
	elem->ip2 &= ip_set_netmask(cidr);
100
	elem->cidr = cidr - 1;
101 102 103 104 105 106
}

static bool
hash_ipportnet4_data_list(struct sk_buff *skb,
			  const struct hash_ipportnet4_elem *data)
{
107 108
	u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0;

D
David S. Miller 已提交
109 110 111 112 113 114 115 116
	if (nla_put_ipaddr4(skb, IPSET_ATTR_IP, data->ip) ||
	    nla_put_ipaddr4(skb, IPSET_ATTR_IP2, data->ip2) ||
	    nla_put_net16(skb, IPSET_ATTR_PORT, data->port) ||
	    nla_put_u8(skb, IPSET_ATTR_CIDR2, data->cidr + 1) ||
	    nla_put_u8(skb, IPSET_ATTR_PROTO, data->proto) ||
	    (flags &&
	     nla_put_net32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags))))
		goto nla_put_failure;
117 118 119 120 121 122
	return 0;

nla_put_failure:
	return 1;
}

123 124 125
static inline void
hash_ipportnet4_data_next(struct hash_ipportnet4_elem *next,
			  const struct hash_ipportnet4_elem *d)
126
{
127 128 129
	next->ip = d->ip;
	next->port = d->port;
	next->ip2 = d->ip2;
130 131
}

132
#define MTYPE		hash_ipportnet4
133
#define HOST_MASK	32
134
#include "ip_set_hash_gen.h"
135

136 137
static int
hash_ipportnet4_kadt(struct ip_set *set, const struct sk_buff *skb,
138
		     const struct xt_action_param *par,
139
		     enum ipset_adt adt, struct ip_set_adt_opt *opt)
140
{
141
	const struct hash_ipportnet *h = set->data;
142
	ipset_adtfn adtfn = set->variant->adt[adt];
143
	struct hash_ipportnet4_elem e = {
144
		.cidr = IP_SET_INIT_CIDR(h->nets[0].cidr[0], HOST_MASK) - 1,
145
	};
146
	struct ip_set_ext ext = IP_SET_INIT_KEXT(skb, opt, set);
147 148

	if (adt == IPSET_TEST)
149
		e.cidr = HOST_MASK - 1;
150

151
	if (!ip_set_get_ip4_port(skb, opt->flags & IPSET_DIM_TWO_SRC,
152
				 &e.port, &e.proto))
153 154
		return -EINVAL;

155 156 157
	ip4addrptr(skb, opt->flags & IPSET_DIM_ONE_SRC, &e.ip);
	ip4addrptr(skb, opt->flags & IPSET_DIM_THREE_SRC, &e.ip2);
	e.ip2 &= ip_set_netmask(e.cidr + 1);
158

159
	return adtfn(set, &e, &ext, &opt->ext, opt->cmdflags);
160 161 162 163
}

static int
hash_ipportnet4_uadt(struct ip_set *set, struct nlattr *tb[],
164
		     enum ipset_adt adt, u32 *lineno, u32 flags, bool retried)
165
{
166
	const struct hash_ipportnet *h = set->data;
167
	ipset_adtfn adtfn = set->variant->adt[adt];
168
	struct hash_ipportnet4_elem e = { .cidr = HOST_MASK - 1 };
169
	struct ip_set_ext ext = IP_SET_INIT_UEXT(set);
170 171
	u32 ip = 0, ip_to = 0, p = 0, port, port_to;
	u32 ip2_from = 0, ip2_to = 0, ip2_last, ip2;
172
	bool with_ports = false;
173
	u8 cidr;
174 175 176 177 178
	int ret;

	if (unlikely(!tb[IPSET_ATTR_IP] || !tb[IPSET_ATTR_IP2] ||
		     !ip_set_attr_netorder(tb, IPSET_ATTR_PORT) ||
		     !ip_set_optattr_netorder(tb, IPSET_ATTR_PORT_TO) ||
179
		     !ip_set_optattr_netorder(tb, IPSET_ATTR_TIMEOUT) ||
180 181
		     !ip_set_optattr_netorder(tb, IPSET_ATTR_CADT_FLAGS) ||
		     !ip_set_optattr_netorder(tb, IPSET_ATTR_PACKETS) ||
182 183 184 185
		     !ip_set_optattr_netorder(tb, IPSET_ATTR_BYTES) ||
		     !ip_set_optattr_netorder(tb, IPSET_ATTR_SKBMARK) ||
		     !ip_set_optattr_netorder(tb, IPSET_ATTR_SKBPRIO) ||
		     !ip_set_optattr_netorder(tb, IPSET_ATTR_SKBQUEUE)))
186 187 188 189 190
		return -IPSET_ERR_PROTOCOL;

	if (tb[IPSET_ATTR_LINENO])
		*lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);

191 192 193 194 195
	ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP], &ip);
	if (ret)
		return ret;

	ret = ip_set_get_extensions(set, tb, &ext);
196 197 198
	if (ret)
		return ret;

199
	ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP2], &ip2_from);
200 201 202
	if (ret)
		return ret;

203
	if (tb[IPSET_ATTR_CIDR2]) {
204 205
		cidr = nla_get_u8(tb[IPSET_ATTR_CIDR2]);
		if (!cidr || cidr > HOST_MASK)
206
			return -IPSET_ERR_INVALID_CIDR;
207
		e.cidr = cidr - 1;
208
	}
209

210
	e.port = nla_get_be16(tb[IPSET_ATTR_PORT]);
211 212

	if (tb[IPSET_ATTR_PROTO]) {
213 214
		e.proto = nla_get_u8(tb[IPSET_ATTR_PROTO]);
		with_ports = ip_set_proto_with_ports(e.proto);
215

216
		if (e.proto == 0)
217 218 219 220
			return -IPSET_ERR_INVALID_PROTO;
	} else
		return -IPSET_ERR_MISSING_PROTO;

221 222
	if (!(with_ports || e.proto == IPPROTO_ICMP))
		e.port = 0;
223

224
	if (tb[IPSET_ATTR_CADT_FLAGS]) {
225 226
		u32 cadt_flags = ip_set_get_h32(tb[IPSET_ATTR_CADT_FLAGS]);
		if (cadt_flags & IPSET_FLAG_NOMATCH)
227
			flags |= (IPSET_FLAG_NOMATCH << 16);
228 229
	}

230
	with_ports = with_ports && tb[IPSET_ATTR_PORT_TO];
231
	if (adt == IPSET_TEST ||
232 233
	    !(tb[IPSET_ATTR_CIDR] || tb[IPSET_ATTR_IP_TO] || with_ports ||
	      tb[IPSET_ATTR_IP2_TO])) {
234 235 236
		e.ip = htonl(ip);
		e.ip2 = htonl(ip2_from & ip_set_hostmask(e.cidr + 1));
		ret = adtfn(set, &e, &ext, &ext, flags);
237
		return ip_set_enomatch(ret, flags, adt, set) ? -ret :
238
		       ip_set_eexist(ret, flags) ? 0 : ret;
239 240
	}

241
	ip_to = ip;
242 243 244 245 246 247 248
	if (tb[IPSET_ATTR_IP_TO]) {
		ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP_TO], &ip_to);
		if (ret)
			return ret;
		if (ip > ip_to)
			swap(ip, ip_to);
	} else if (tb[IPSET_ATTR_CIDR]) {
249
		cidr = nla_get_u8(tb[IPSET_ATTR_CIDR]);
250

251
		if (!cidr || cidr > 32)
252
			return -IPSET_ERR_INVALID_CIDR;
253
		ip_set_mask_from_to(ip, ip_to, cidr);
254
	}
255

256
	port_to = port = ntohs(e.port);
257
	if (tb[IPSET_ATTR_PORT_TO]) {
258 259 260
		port_to = ip_set_get_h16(tb[IPSET_ATTR_PORT_TO]);
		if (port > port_to)
			swap(port, port_to);
261
	}
262 263

	ip2_to = ip2_from;
264 265 266 267 268 269 270 271
	if (tb[IPSET_ATTR_IP2_TO]) {
		ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP2_TO], &ip2_to);
		if (ret)
			return ret;
		if (ip2_from > ip2_to)
			swap(ip2_from, ip2_to);
		if (ip2_from + UINT_MAX == ip2_to)
			return -IPSET_ERR_HASH_RANGE;
272 273
	} else
		ip_set_mask_from_to(ip2_from, ip2_to, e.cidr + 1);
274

275
	if (retried)
276
		ip = ntohl(h->next.ip);
277
	for (; !before(ip_to, ip); ip++) {
278
		e.ip = htonl(ip);
279 280
		p = retried && ip == ntohl(h->next.ip) ? ntohs(h->next.port)
						       : port;
281
		for (; p <= port_to; p++) {
282
			e.port = htons(p);
283 284 285
			ip2 = retried &&
			      ip == ntohl(h->next.ip) &&
			      p == ntohs(h->next.port)
286
				? ntohl(h->next.ip2) : ip2_from;
287
			while (!after(ip2, ip2_to)) {
288
				e.ip2 = htonl(ip2);
289
				ip2_last = ip_set_range_to_cidr(ip2, ip2_to,
290
								&cidr);
291 292
				e.cidr = cidr - 1;
				ret = adtfn(set, &e, &ext, &ext, flags);
293 294 295 296 297 298 299

				if (ret && !ip_set_eexist(ret, flags))
					return ret;
				else
					ret = 0;
				ip2 = ip2_last + 1;
			}
300
		}
301
	}
302 303 304
	return ret;
}

305
/* IPv6 variant */
306 307 308 309 310

struct hash_ipportnet6_elem {
	union nf_inet_addr ip;
	union nf_inet_addr ip2;
	__be16 port;
311 312
	u8 cidr:7;
	u8 nomatch:1;
313 314 315
	u8 proto;
};

316 317
/* Common functions */

318 319
static inline bool
hash_ipportnet6_data_equal(const struct hash_ipportnet6_elem *ip1,
320 321
			   const struct hash_ipportnet6_elem *ip2,
			   u32 *multi)
322
{
323 324
	return ipv6_addr_equal(&ip1->ip.in6, &ip2->ip.in6) &&
	       ipv6_addr_equal(&ip1->ip2.in6, &ip2->ip2.in6) &&
325 326 327 328 329
	       ip1->cidr == ip2->cidr &&
	       ip1->port == ip2->port &&
	       ip1->proto == ip2->proto;
}

330 331
static inline int
hash_ipportnet6_do_data_match(const struct hash_ipportnet6_elem *elem)
332
{
333
	return elem->nomatch ? -ENOTEMPTY : 1;
334 335
}

336
static inline void
337
hash_ipportnet6_data_set_flags(struct hash_ipportnet6_elem *elem, u32 flags)
338
{
339
	elem->nomatch = !!((flags >> 16) & IPSET_FLAG_NOMATCH);
340 341
}

342
static inline void
343
hash_ipportnet6_data_reset_flags(struct hash_ipportnet6_elem *elem, u8 *flags)
344
{
345
	swap(*flags, elem->nomatch);
346 347 348 349 350 351
}

static inline void
hash_ipportnet6_data_netmask(struct hash_ipportnet6_elem *elem, u8 cidr)
{
	ip6_netmask(&elem->ip2, cidr);
352
	elem->cidr = cidr - 1;
353 354 355 356 357 358
}

static bool
hash_ipportnet6_data_list(struct sk_buff *skb,
			  const struct hash_ipportnet6_elem *data)
{
359 360
	u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0;

D
David S. Miller 已提交
361 362 363 364 365 366 367 368
	if (nla_put_ipaddr6(skb, IPSET_ATTR_IP, &data->ip.in6) ||
	    nla_put_ipaddr6(skb, IPSET_ATTR_IP2, &data->ip2.in6) ||
	    nla_put_net16(skb, IPSET_ATTR_PORT, data->port) ||
	    nla_put_u8(skb, IPSET_ATTR_CIDR2, data->cidr + 1) ||
	    nla_put_u8(skb, IPSET_ATTR_PROTO, data->proto) ||
	    (flags &&
	     nla_put_net32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags))))
		goto nla_put_failure;
369 370 371 372 373 374
	return 0;

nla_put_failure:
	return 1;
}

375 376 377
static inline void
hash_ipportnet6_data_next(struct hash_ipportnet4_elem *next,
			  const struct hash_ipportnet6_elem *d)
378
{
379
	next->port = d->port;
380 381
}

382
#undef MTYPE
383 384
#undef HOST_MASK

385
#define MTYPE		hash_ipportnet6
386
#define HOST_MASK	128
387 388
#define IP_SET_EMIT_CREATE
#include "ip_set_hash_gen.h"
389

390 391
static int
hash_ipportnet6_kadt(struct ip_set *set, const struct sk_buff *skb,
392
		     const struct xt_action_param *par,
393
		     enum ipset_adt adt, struct ip_set_adt_opt *opt)
394
{
395
	const struct hash_ipportnet *h = set->data;
396
	ipset_adtfn adtfn = set->variant->adt[adt];
397
	struct hash_ipportnet6_elem e = {
398
		.cidr = IP_SET_INIT_CIDR(h->nets[0].cidr[0], HOST_MASK) - 1,
399
	};
400
	struct ip_set_ext ext = IP_SET_INIT_KEXT(skb, opt, set);
401 402

	if (adt == IPSET_TEST)
403
		e.cidr = HOST_MASK - 1;
404

405
	if (!ip_set_get_ip6_port(skb, opt->flags & IPSET_DIM_TWO_SRC,
406
				 &e.port, &e.proto))
407 408
		return -EINVAL;

409 410 411
	ip6addrptr(skb, opt->flags & IPSET_DIM_ONE_SRC, &e.ip.in6);
	ip6addrptr(skb, opt->flags & IPSET_DIM_THREE_SRC, &e.ip2.in6);
	ip6_netmask(&e.ip2, e.cidr + 1);
412

413
	return adtfn(set, &e, &ext, &opt->ext, opt->cmdflags);
414 415 416 417
}

static int
hash_ipportnet6_uadt(struct ip_set *set, struct nlattr *tb[],
418
		     enum ipset_adt adt, u32 *lineno, u32 flags, bool retried)
419
{
420
	const struct hash_ipportnet *h = set->data;
421
	ipset_adtfn adtfn = set->variant->adt[adt];
422
	struct hash_ipportnet6_elem e = { .cidr = HOST_MASK - 1 };
423
	struct ip_set_ext ext = IP_SET_INIT_UEXT(set);
424
	u32 port, port_to;
425
	bool with_ports = false;
426
	u8 cidr;
427 428 429 430 431 432
	int ret;

	if (unlikely(!tb[IPSET_ATTR_IP] || !tb[IPSET_ATTR_IP2] ||
		     !ip_set_attr_netorder(tb, IPSET_ATTR_PORT) ||
		     !ip_set_optattr_netorder(tb, IPSET_ATTR_PORT_TO) ||
		     !ip_set_optattr_netorder(tb, IPSET_ATTR_TIMEOUT) ||
433
		     !ip_set_optattr_netorder(tb, IPSET_ATTR_CADT_FLAGS) ||
434 435
		     !ip_set_optattr_netorder(tb, IPSET_ATTR_PACKETS) ||
		     !ip_set_optattr_netorder(tb, IPSET_ATTR_BYTES) ||
436 437 438
		     !ip_set_optattr_netorder(tb, IPSET_ATTR_SKBMARK) ||
		     !ip_set_optattr_netorder(tb, IPSET_ATTR_SKBPRIO) ||
		     !ip_set_optattr_netorder(tb, IPSET_ATTR_SKBQUEUE) ||
439 440 441
		     tb[IPSET_ATTR_IP_TO] ||
		     tb[IPSET_ATTR_CIDR]))
		return -IPSET_ERR_PROTOCOL;
442 443
	if (unlikely(tb[IPSET_ATTR_IP_TO]))
		return -IPSET_ERR_HASH_RANGE_UNSUPPORTED;
444 445 446 447

	if (tb[IPSET_ATTR_LINENO])
		*lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);

448 449 450 451 452
	ret = ip_set_get_ipaddr6(tb[IPSET_ATTR_IP], &e.ip);
	if (ret)
		return ret;

	ret = ip_set_get_extensions(set, tb, &ext);
453 454 455
	if (ret)
		return ret;

456
	ret = ip_set_get_ipaddr6(tb[IPSET_ATTR_IP2], &e.ip2);
457 458 459
	if (ret)
		return ret;

460 461 462 463
	if (tb[IPSET_ATTR_CIDR2]) {
		cidr = nla_get_u8(tb[IPSET_ATTR_CIDR2]);
		if (!cidr || cidr > HOST_MASK)
			return -IPSET_ERR_INVALID_CIDR;
464
		e.cidr = cidr - 1;
465
	}
466

467
	ip6_netmask(&e.ip2, e.cidr + 1);
468

469
	e.port = nla_get_be16(tb[IPSET_ATTR_PORT]);
470 471

	if (tb[IPSET_ATTR_PROTO]) {
472 473
		e.proto = nla_get_u8(tb[IPSET_ATTR_PROTO]);
		with_ports = ip_set_proto_with_ports(e.proto);
474

475
		if (e.proto == 0)
476 477 478 479
			return -IPSET_ERR_INVALID_PROTO;
	} else
		return -IPSET_ERR_MISSING_PROTO;

480 481
	if (!(with_ports || e.proto == IPPROTO_ICMPV6))
		e.port = 0;
482

483
	if (tb[IPSET_ATTR_CADT_FLAGS]) {
484 485
		u32 cadt_flags = ip_set_get_h32(tb[IPSET_ATTR_CADT_FLAGS]);
		if (cadt_flags & IPSET_FLAG_NOMATCH)
486
			flags |= (IPSET_FLAG_NOMATCH << 16);
487 488
	}

489
	if (adt == IPSET_TEST || !with_ports || !tb[IPSET_ATTR_PORT_TO]) {
490
		ret = adtfn(set, &e, &ext, &ext, flags);
491
		return ip_set_enomatch(ret, flags, adt, set) ? -ret :
492
		       ip_set_eexist(ret, flags) ? 0 : ret;
493 494
	}

495
	port = ntohs(e.port);
496 497 498 499
	port_to = ip_set_get_h16(tb[IPSET_ATTR_PORT_TO]);
	if (port > port_to)
		swap(port, port_to);

500
	if (retried)
501
		port = ntohs(h->next.port);
502
	for (; port <= port_to; port++) {
503 504
		e.port = htons(port);
		ret = adtfn(set, &e, &ext, &ext, flags);
505 506 507 508 509 510 511 512 513 514 515 516

		if (ret && !ip_set_eexist(ret, flags))
			return ret;
		else
			ret = 0;
	}
	return ret;
}

static struct ip_set_type hash_ipportnet_type __read_mostly = {
	.name		= "hash:ip,port,net",
	.protocol	= IPSET_PROTOCOL,
517 518
	.features	= IPSET_TYPE_IP | IPSET_TYPE_PORT | IPSET_TYPE_IP2 |
			  IPSET_TYPE_NOMATCH,
519
	.dimension	= IPSET_DIM_THREE,
520
	.family		= NFPROTO_UNSPEC,
521 522
	.revision_min	= IPSET_TYPE_REV_MIN,
	.revision_max	= IPSET_TYPE_REV_MAX,
523 524 525 526 527 528 529
	.create		= hash_ipportnet_create,
	.create_policy	= {
		[IPSET_ATTR_HASHSIZE]	= { .type = NLA_U32 },
		[IPSET_ATTR_MAXELEM]	= { .type = NLA_U32 },
		[IPSET_ATTR_PROBES]	= { .type = NLA_U8 },
		[IPSET_ATTR_RESIZE]	= { .type = NLA_U8  },
		[IPSET_ATTR_TIMEOUT]	= { .type = NLA_U32 },
530
		[IPSET_ATTR_CADT_FLAGS]	= { .type = NLA_U32 },
531 532 533 534 535
	},
	.adt_policy	= {
		[IPSET_ATTR_IP]		= { .type = NLA_NESTED },
		[IPSET_ATTR_IP_TO]	= { .type = NLA_NESTED },
		[IPSET_ATTR_IP2]	= { .type = NLA_NESTED },
536
		[IPSET_ATTR_IP2_TO]	= { .type = NLA_NESTED },
537 538 539 540 541
		[IPSET_ATTR_PORT]	= { .type = NLA_U16 },
		[IPSET_ATTR_PORT_TO]	= { .type = NLA_U16 },
		[IPSET_ATTR_CIDR]	= { .type = NLA_U8 },
		[IPSET_ATTR_CIDR2]	= { .type = NLA_U8 },
		[IPSET_ATTR_PROTO]	= { .type = NLA_U8 },
542
		[IPSET_ATTR_CADT_FLAGS]	= { .type = NLA_U32 },
543 544
		[IPSET_ATTR_TIMEOUT]	= { .type = NLA_U32 },
		[IPSET_ATTR_LINENO]	= { .type = NLA_U32 },
545 546
		[IPSET_ATTR_BYTES]	= { .type = NLA_U64 },
		[IPSET_ATTR_PACKETS]	= { .type = NLA_U64 },
547
		[IPSET_ATTR_COMMENT]	= { .type = NLA_NUL_STRING },
548 549 550
		[IPSET_ATTR_SKBMARK]	= { .type = NLA_U64 },
		[IPSET_ATTR_SKBPRIO]	= { .type = NLA_U32 },
		[IPSET_ATTR_SKBQUEUE]	= { .type = NLA_U16 },
551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568
	},
	.me		= THIS_MODULE,
};

static int __init
hash_ipportnet_init(void)
{
	return ip_set_type_register(&hash_ipportnet_type);
}

static void __exit
hash_ipportnet_fini(void)
{
	ip_set_type_unregister(&hash_ipportnet_type);
}

module_init(hash_ipportnet_init);
module_exit(hash_ipportnet_fini);