Merge tag 'driver-core-4.6-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git...
[deliverable/linux.git] / include / linux / netfilter / ipset / ip_set.h
CommitLineData
a7b4f989
JK
1/* Copyright (C) 2000-2002 Joakim Axelsson <gozem@linux.nu>
2 * Patrick Schaaf <bof@bof.de>
3 * Martin Josefsson <gandalf@wlug.westbo.se>
075e64c0 4 * Copyright (C) 2003-2013 Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
a7b4f989
JK
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
a8201414
DH
10#ifndef _IP_SET_H
11#define _IP_SET_H
a7b4f989 12
ae8ded1c
JE
13#include <linux/ip.h>
14#include <linux/ipv6.h>
15#include <linux/netlink.h>
16#include <linux/netfilter.h>
17#include <linux/netfilter/x_tables.h>
10111a6e 18#include <linux/stringify.h>
ae8ded1c
JE
19#include <linux/vmalloc.h>
20#include <net/netlink.h>
a8201414 21#include <uapi/linux/netfilter/ipset/ip_set.h>
ae8ded1c 22
10111a6e
JK
23#define _IP_SET_MODULE_DESC(a, b, c) \
24 MODULE_DESCRIPTION(a " type of IP sets, revisions " b "-" c)
25#define IP_SET_MODULE_DESC(a, b, c) \
26 _IP_SET_MODULE_DESC(a, __stringify(b), __stringify(c))
27
a7b4f989
JK
28/* Set features */
29enum ip_set_feature {
30 IPSET_TYPE_IP_FLAG = 0,
31 IPSET_TYPE_IP = (1 << IPSET_TYPE_IP_FLAG),
32 IPSET_TYPE_PORT_FLAG = 1,
33 IPSET_TYPE_PORT = (1 << IPSET_TYPE_PORT_FLAG),
34 IPSET_TYPE_MAC_FLAG = 2,
35 IPSET_TYPE_MAC = (1 << IPSET_TYPE_MAC_FLAG),
36 IPSET_TYPE_IP2_FLAG = 3,
37 IPSET_TYPE_IP2 = (1 << IPSET_TYPE_IP2_FLAG),
38 IPSET_TYPE_NAME_FLAG = 4,
39 IPSET_TYPE_NAME = (1 << IPSET_TYPE_NAME_FLAG),
e385357a
JK
40 IPSET_TYPE_IFACE_FLAG = 5,
41 IPSET_TYPE_IFACE = (1 << IPSET_TYPE_IFACE_FLAG),
3b02b56c
VD
42 IPSET_TYPE_MARK_FLAG = 6,
43 IPSET_TYPE_MARK = (1 << IPSET_TYPE_MARK_FLAG),
44 IPSET_TYPE_NOMATCH_FLAG = 7,
3e0304a5 45 IPSET_TYPE_NOMATCH = (1 << IPSET_TYPE_NOMATCH_FLAG),
a7b4f989
JK
46 /* Strictly speaking not a feature, but a flag for dumping:
47 * this settype must be dumped last */
3b02b56c 48 IPSET_DUMP_LAST_FLAG = 8,
a7b4f989
JK
49 IPSET_DUMP_LAST = (1 << IPSET_DUMP_LAST_FLAG),
50};
51
075e64c0
JK
52/* Set extensions */
53enum ip_set_extension {
40cd63bf 54 IPSET_EXT_BIT_TIMEOUT = 0,
075e64c0 55 IPSET_EXT_TIMEOUT = (1 << IPSET_EXT_BIT_TIMEOUT),
40cd63bf 56 IPSET_EXT_BIT_COUNTER = 1,
34d666d4 57 IPSET_EXT_COUNTER = (1 << IPSET_EXT_BIT_COUNTER),
68b63f08
OS
58 IPSET_EXT_BIT_COMMENT = 2,
59 IPSET_EXT_COMMENT = (1 << IPSET_EXT_BIT_COMMENT),
0e9871e3
AD
60 IPSET_EXT_BIT_SKBINFO = 3,
61 IPSET_EXT_SKBINFO = (1 << IPSET_EXT_BIT_SKBINFO),
40cd63bf
JK
62 /* Mark set with an extension which needs to call destroy */
63 IPSET_EXT_BIT_DESTROY = 7,
64 IPSET_EXT_DESTROY = (1 << IPSET_EXT_BIT_DESTROY),
075e64c0
JK
65};
66
075e64c0 67#define SET_WITH_TIMEOUT(s) ((s)->extensions & IPSET_EXT_TIMEOUT)
34d666d4 68#define SET_WITH_COUNTER(s) ((s)->extensions & IPSET_EXT_COUNTER)
68b63f08 69#define SET_WITH_COMMENT(s) ((s)->extensions & IPSET_EXT_COMMENT)
0e9871e3 70#define SET_WITH_SKBINFO(s) ((s)->extensions & IPSET_EXT_SKBINFO)
07cf8f5a 71#define SET_WITH_FORCEADD(s) ((s)->flags & IPSET_CREATE_FLAG_FORCEADD)
075e64c0 72
f925f705
JK
73/* Extension id, in size order */
74enum ip_set_ext_id {
75 IPSET_EXT_ID_COUNTER = 0,
76 IPSET_EXT_ID_TIMEOUT,
0e9871e3 77 IPSET_EXT_ID_SKBINFO,
68b63f08 78 IPSET_EXT_ID_COMMENT,
f925f705
JK
79 IPSET_EXT_ID_MAX,
80};
81
03c8b234
JK
82/* Extension type */
83struct ip_set_ext_type {
40cd63bf
JK
84 /* Destroy extension private data (can be NULL) */
85 void (*destroy)(void *ext);
03c8b234
JK
86 enum ip_set_extension type;
87 enum ipset_cadt_flags flag;
88 /* Size and minimal alignment */
89 u8 len;
90 u8 align;
91};
92
93extern const struct ip_set_ext_type ip_set_extensions[];
94
075e64c0 95struct ip_set_ext {
34d666d4
JK
96 u64 packets;
97 u64 bytes;
f925f705 98 u32 timeout;
0e9871e3
AD
99 u32 skbmark;
100 u32 skbmarkmask;
101 u32 skbprio;
102 u16 skbqueue;
68b63f08 103 char *comment;
075e64c0
JK
104};
105
ca134ce8
JK
106struct ip_set_counter {
107 atomic64_t bytes;
108 atomic64_t packets;
109};
110
b57b2d1f
JK
111struct ip_set_comment_rcu {
112 struct rcu_head rcu;
113 char str[0];
114};
115
68b63f08 116struct ip_set_comment {
b57b2d1f 117 struct ip_set_comment_rcu __rcu *c;
68b63f08 118};
40cd63bf 119
0e9871e3
AD
120struct ip_set_skbinfo {
121 u32 skbmark;
122 u32 skbmarkmask;
123 u32 skbprio;
124 u16 skbqueue;
125};
126
68b63f08 127struct ip_set;
40cd63bf 128
ca134ce8 129#define ext_timeout(e, s) \
275e2bc0 130((unsigned long *)(((void *)(e)) + (s)->offset[IPSET_EXT_ID_TIMEOUT]))
ca134ce8 131#define ext_counter(e, s) \
275e2bc0 132((struct ip_set_counter *)(((void *)(e)) + (s)->offset[IPSET_EXT_ID_COUNTER]))
68b63f08 133#define ext_comment(e, s) \
275e2bc0 134((struct ip_set_comment *)(((void *)(e)) + (s)->offset[IPSET_EXT_ID_COMMENT]))
0e9871e3 135#define ext_skbinfo(e, s) \
275e2bc0 136((struct ip_set_skbinfo *)(((void *)(e)) + (s)->offset[IPSET_EXT_ID_SKBINFO]))
ca134ce8 137
5416219e 138typedef int (*ipset_adtfn)(struct ip_set *set, void *value,
075e64c0 139 const struct ip_set_ext *ext,
6e01781d 140 struct ip_set_ext *mext, u32 cmdflags);
a7b4f989 141
ac8cc925
JK
142/* Kernel API function options */
143struct ip_set_adt_opt {
144 u8 family; /* Actual protocol family */
145 u8 dim; /* Dimension of match/target */
146 u8 flags; /* Direction and negation flags */
147 u32 cmdflags; /* Command-like flags */
075e64c0 148 struct ip_set_ext ext; /* Extensions */
ac8cc925
JK
149};
150
a7b4f989
JK
151/* Set type, variant-specific part */
152struct ip_set_type_variant {
153 /* Kernelspace: test/add/del entries
154 * returns negative error code,
155 * zero for no match/success to add/delete
156 * positive for matching element */
3ace95c0 157 int (*kadt)(struct ip_set *set, const struct sk_buff *skb,
b66554cf 158 const struct xt_action_param *par,
075e64c0 159 enum ipset_adt adt, struct ip_set_adt_opt *opt);
a7b4f989
JK
160
161 /* Userspace: test/add/del entries
162 * returns negative error code,
163 * zero for no match/success to add/delete
164 * positive for matching element */
165 int (*uadt)(struct ip_set *set, struct nlattr *tb[],
3d14b171 166 enum ipset_adt adt, u32 *lineno, u32 flags, bool retried);
a7b4f989
JK
167
168 /* Low level add/del/test functions */
169 ipset_adtfn adt[IPSET_ADT_MAX];
170
171 /* When adding entries and set is full, try to resize the set */
172 int (*resize)(struct ip_set *set, bool retried);
173 /* Destroy the set */
174 void (*destroy)(struct ip_set *set);
175 /* Flush the elements */
176 void (*flush)(struct ip_set *set);
177 /* Expire entries before listing */
178 void (*expire)(struct ip_set *set);
179 /* List set header data */
180 int (*head)(struct ip_set *set, struct sk_buff *skb);
181 /* List elements */
182 int (*list)(const struct ip_set *set, struct sk_buff *skb,
183 struct netlink_callback *cb);
c4c99783
JK
184 /* Keep listing private when resizing runs parallel */
185 void (*uref)(struct ip_set *set, struct netlink_callback *cb,
186 bool start);
a7b4f989
JK
187
188 /* Return true if "b" set is the same as "a"
189 * according to the create set parameters */
190 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
191};
192
193/* The core set type structure */
194struct ip_set_type {
195 struct list_head list;
196
197 /* Typename */
198 char name[IPSET_MAXNAMELEN];
199 /* Protocol version */
200 u8 protocol;
a7b4f989
JK
201 /* Set type dimension */
202 u8 dimension;
c15f1c83
JE
203 /*
204 * Supported family: may be NFPROTO_UNSPEC for both
205 * NFPROTO_IPV4/NFPROTO_IPV6.
206 */
a7b4f989 207 u8 family;
f1e00b39
JK
208 /* Type revisions */
209 u8 revision_min, revision_max;
3b02b56c
VD
210 /* Set features to control swapping */
211 u16 features;
a7b4f989
JK
212
213 /* Create set */
1785e8f4
VL
214 int (*create)(struct net *net, struct ip_set *set,
215 struct nlattr *tb[], u32 flags);
a7b4f989
JK
216
217 /* Attribute policies */
218 const struct nla_policy create_policy[IPSET_ATTR_CREATE_MAX + 1];
219 const struct nla_policy adt_policy[IPSET_ATTR_ADT_MAX + 1];
220
221 /* Set this to THIS_MODULE if you are a module, otherwise NULL */
222 struct module *me;
223};
224
225/* register and unregister set type */
226extern int ip_set_type_register(struct ip_set_type *set_type);
227extern void ip_set_type_unregister(struct ip_set_type *set_type);
228
229/* A generic IP set */
230struct ip_set {
231 /* The name of the set */
232 char name[IPSET_MAXNAMELEN];
233 /* Lock protecting the set data */
b57b2d1f 234 spinlock_t lock;
a7b4f989 235 /* References to the set */
2f9f28b2 236 u32 ref;
596cf3fe
VP
237 /* References to the set for netlink events like dump,
238 * ref can be swapped out by ip_set_swap
239 */
240 u32 ref_netlink;
a7b4f989
JK
241 /* The core set type */
242 struct ip_set_type *type;
243 /* The type variant doing the real job */
244 const struct ip_set_type_variant *variant;
245 /* The actual INET family of the set */
246 u8 family;
f1e00b39
JK
247 /* The type revision */
248 u8 revision;
075e64c0
JK
249 /* Extensions */
250 u8 extensions;
af284ece
JK
251 /* Create flags */
252 u8 flags;
ca134ce8
JK
253 /* Default timeout value, if enabled */
254 u32 timeout;
255 /* Element data size */
256 size_t dsize;
257 /* Offsets to extensions in elements */
258 size_t offset[IPSET_EXT_ID_MAX];
a7b4f989
JK
259 /* The type specific data */
260 void *data;
261};
262
68b63f08
OS
263static inline void
264ip_set_ext_destroy(struct ip_set *set, void *data)
265{
266 /* Check that the extension is enabled for the set and
267 * call it's destroy function for its extension part in data.
268 */
269 if (SET_WITH_COMMENT(set))
270 ip_set_extensions[IPSET_EXT_ID_COMMENT].destroy(
271 ext_comment(data, set));
272}
273
274static inline int
275ip_set_put_flags(struct sk_buff *skb, struct ip_set *set)
276{
277 u32 cadt_flags = 0;
278
279 if (SET_WITH_TIMEOUT(set))
280 if (unlikely(nla_put_net32(skb, IPSET_ATTR_TIMEOUT,
281 htonl(set->timeout))))
282 return -EMSGSIZE;
283 if (SET_WITH_COUNTER(set))
284 cadt_flags |= IPSET_FLAG_WITH_COUNTERS;
285 if (SET_WITH_COMMENT(set))
286 cadt_flags |= IPSET_FLAG_WITH_COMMENT;
0e9871e3
AD
287 if (SET_WITH_SKBINFO(set))
288 cadt_flags |= IPSET_FLAG_WITH_SKBINFO;
07cf8f5a
JH
289 if (SET_WITH_FORCEADD(set))
290 cadt_flags |= IPSET_FLAG_WITH_FORCEADD;
68b63f08
OS
291
292 if (!cadt_flags)
293 return 0;
294 return nla_put_net32(skb, IPSET_ATTR_CADT_FLAGS, htonl(cadt_flags));
295}
296
34d666d4
JK
297static inline void
298ip_set_add_bytes(u64 bytes, struct ip_set_counter *counter)
299{
300 atomic64_add((long long)bytes, &(counter)->bytes);
301}
302
303static inline void
304ip_set_add_packets(u64 packets, struct ip_set_counter *counter)
305{
306 atomic64_add((long long)packets, &(counter)->packets);
307}
308
309static inline u64
310ip_set_get_bytes(const struct ip_set_counter *counter)
311{
312 return (u64)atomic64_read(&(counter)->bytes);
313}
314
315static inline u64
316ip_set_get_packets(const struct ip_set_counter *counter)
317{
318 return (u64)atomic64_read(&(counter)->packets);
319}
320
321static inline void
322ip_set_update_counter(struct ip_set_counter *counter,
323 const struct ip_set_ext *ext,
324 struct ip_set_ext *mext, u32 flags)
325{
6e01781d
JK
326 if (ext->packets != ULLONG_MAX &&
327 !(flags & IPSET_FLAG_SKIP_COUNTER_UPDATE)) {
34d666d4
JK
328 ip_set_add_bytes(ext->bytes, counter);
329 ip_set_add_packets(ext->packets, counter);
330 }
6e01781d
JK
331 if (flags & IPSET_FLAG_MATCH_COUNTERS) {
332 mext->packets = ip_set_get_packets(counter);
333 mext->bytes = ip_set_get_bytes(counter);
334 }
34d666d4
JK
335}
336
0e9871e3
AD
337static inline void
338ip_set_get_skbinfo(struct ip_set_skbinfo *skbinfo,
339 const struct ip_set_ext *ext,
340 struct ip_set_ext *mext, u32 flags)
341{
342 mext->skbmark = skbinfo->skbmark;
343 mext->skbmarkmask = skbinfo->skbmarkmask;
344 mext->skbprio = skbinfo->skbprio;
345 mext->skbqueue = skbinfo->skbqueue;
346}
347static inline bool
348ip_set_put_skbinfo(struct sk_buff *skb, struct ip_set_skbinfo *skbinfo)
349{
aef96193
JK
350 /* Send nonzero parameters only */
351 return ((skbinfo->skbmark || skbinfo->skbmarkmask) &&
352 nla_put_net64(skb, IPSET_ATTR_SKBMARK,
353 cpu_to_be64((u64)skbinfo->skbmark << 32 |
354 skbinfo->skbmarkmask))) ||
355 (skbinfo->skbprio &&
ca0f6a5c 356 nla_put_net32(skb, IPSET_ATTR_SKBPRIO,
aef96193
JK
357 cpu_to_be32(skbinfo->skbprio))) ||
358 (skbinfo->skbqueue &&
ca0f6a5c 359 nla_put_net16(skb, IPSET_ATTR_SKBQUEUE,
aef96193 360 cpu_to_be16(skbinfo->skbqueue)));
0e9871e3
AD
361}
362
363static inline void
364ip_set_init_skbinfo(struct ip_set_skbinfo *skbinfo,
365 const struct ip_set_ext *ext)
366{
367 skbinfo->skbmark = ext->skbmark;
368 skbinfo->skbmarkmask = ext->skbmarkmask;
369 skbinfo->skbprio = ext->skbprio;
370 skbinfo->skbqueue = ext->skbqueue;
371}
372
34d666d4
JK
373static inline bool
374ip_set_put_counter(struct sk_buff *skb, struct ip_set_counter *counter)
375{
376 return nla_put_net64(skb, IPSET_ATTR_BYTES,
377 cpu_to_be64(ip_set_get_bytes(counter))) ||
378 nla_put_net64(skb, IPSET_ATTR_PACKETS,
379 cpu_to_be64(ip_set_get_packets(counter)));
380}
381
382static inline void
383ip_set_init_counter(struct ip_set_counter *counter,
384 const struct ip_set_ext *ext)
385{
386 if (ext->bytes != ULLONG_MAX)
387 atomic64_set(&(counter)->bytes, (long long)(ext->bytes));
388 if (ext->packets != ULLONG_MAX)
389 atomic64_set(&(counter)->packets, (long long)(ext->packets));
390}
391
93302880
JK
392/* Netlink CB args */
393enum {
c4c99783
JK
394 IPSET_CB_NET = 0, /* net namespace */
395 IPSET_CB_DUMP, /* dump single set/all sets */
396 IPSET_CB_INDEX, /* set index */
397 IPSET_CB_PRIVATE, /* set private data */
398 IPSET_CB_ARG0, /* type specific */
93302880 399 IPSET_CB_ARG1,
93302880
JK
400};
401
a7b4f989 402/* register and unregister set references */
1785e8f4
VL
403extern ip_set_id_t ip_set_get_byname(struct net *net,
404 const char *name, struct ip_set **set);
405extern void ip_set_put_byindex(struct net *net, ip_set_id_t index);
406extern const char *ip_set_name_byindex(struct net *net, ip_set_id_t index);
1785e8f4
VL
407extern ip_set_id_t ip_set_nfnl_get_byindex(struct net *net, ip_set_id_t index);
408extern void ip_set_nfnl_put(struct net *net, ip_set_id_t index);
a7b4f989
JK
409
410/* API for iptables set match, and SET target */
ac8cc925 411
a7b4f989 412extern int ip_set_add(ip_set_id_t id, const struct sk_buff *skb,
b66554cf 413 const struct xt_action_param *par,
075e64c0 414 struct ip_set_adt_opt *opt);
a7b4f989 415extern int ip_set_del(ip_set_id_t id, const struct sk_buff *skb,
b66554cf 416 const struct xt_action_param *par,
075e64c0 417 struct ip_set_adt_opt *opt);
a7b4f989 418extern int ip_set_test(ip_set_id_t id, const struct sk_buff *skb,
b66554cf 419 const struct xt_action_param *par,
075e64c0 420 struct ip_set_adt_opt *opt);
a7b4f989
JK
421
422/* Utility functions */
15b4d93f 423extern void *ip_set_alloc(size_t size);
a7b4f989
JK
424extern void ip_set_free(void *members);
425extern int ip_set_get_ipaddr4(struct nlattr *nla, __be32 *ipaddr);
426extern int ip_set_get_ipaddr6(struct nlattr *nla, union nf_inet_addr *ipaddr);
03c8b234 427extern size_t ip_set_elem_len(struct ip_set *set, struct nlattr *tb[],
95ad1f4a 428 size_t len, size_t align);
075e64c0
JK
429extern int ip_set_get_extensions(struct ip_set *set, struct nlattr *tb[],
430 struct ip_set_ext *ext);
a7b4f989
JK
431
432static inline int
433ip_set_get_hostipaddr4(struct nlattr *nla, u32 *ipaddr)
434{
435 __be32 ip;
436 int ret = ip_set_get_ipaddr4(nla, &ip);
15b4d93f 437
a7b4f989
JK
438 if (ret)
439 return ret;
440 *ipaddr = ntohl(ip);
441 return 0;
442}
443
444/* Ignore IPSET_ERR_EXIST errors if asked to do so? */
445static inline bool
446ip_set_eexist(int ret, u32 flags)
447{
448 return ret == -IPSET_ERR_EXIST && (flags & IPSET_FLAG_EXIST);
449}
450
43c56e59
JK
451/* Match elements marked with nomatch */
452static inline bool
0f1799ba 453ip_set_enomatch(int ret, u32 flags, enum ipset_adt adt, struct ip_set *set)
43c56e59
JK
454{
455 return adt == IPSET_TEST &&
0f1799ba
JK
456 (set->type->features & IPSET_TYPE_NOMATCH) &&
457 ((flags >> 16) & IPSET_FLAG_NOMATCH) &&
458 (ret > 0 || ret == -ENOTEMPTY);
43c56e59
JK
459}
460
a7b4f989
JK
461/* Check the NLA_F_NET_BYTEORDER flag */
462static inline bool
463ip_set_attr_netorder(struct nlattr *tb[], int type)
464{
465 return tb[type] && (tb[type]->nla_type & NLA_F_NET_BYTEORDER);
466}
467
468static inline bool
469ip_set_optattr_netorder(struct nlattr *tb[], int type)
470{
471 return !tb[type] || (tb[type]->nla_type & NLA_F_NET_BYTEORDER);
472}
473
474/* Useful converters */
475static inline u32
476ip_set_get_h32(const struct nlattr *attr)
477{
478 return ntohl(nla_get_be32(attr));
479}
480
481static inline u16
482ip_set_get_h16(const struct nlattr *attr)
483{
484 return ntohs(nla_get_be16(attr));
485}
486
487#define ipset_nest_start(skb, attr) nla_nest_start(skb, attr | NLA_F_NESTED)
488#define ipset_nest_end(skb, start) nla_nest_end(skb, start)
489
7cf7899d
DM
490static inline int nla_put_ipaddr4(struct sk_buff *skb, int type, __be32 ipaddr)
491{
492 struct nlattr *__nested = ipset_nest_start(skb, type);
493 int ret;
494
495 if (!__nested)
496 return -EMSGSIZE;
930345ea 497 ret = nla_put_in_addr(skb, IPSET_ATTR_IPADDR_IPV4, ipaddr);
7cf7899d
DM
498 if (!ret)
499 ipset_nest_end(skb, __nested);
500 return ret;
501}
502
3ace95c0
JK
503static inline int nla_put_ipaddr6(struct sk_buff *skb, int type,
504 const struct in6_addr *ipaddrptr)
7cf7899d
DM
505{
506 struct nlattr *__nested = ipset_nest_start(skb, type);
507 int ret;
508
509 if (!__nested)
510 return -EMSGSIZE;
930345ea 511 ret = nla_put_in6_addr(skb, IPSET_ATTR_IPADDR_IPV6, ipaddrptr);
7cf7899d
DM
512 if (!ret)
513 ipset_nest_end(skb, __nested);
514 return ret;
515}
a7b4f989
JK
516
517/* Get address from skbuff */
518static inline __be32
519ip4addr(const struct sk_buff *skb, bool src)
520{
521 return src ? ip_hdr(skb)->saddr : ip_hdr(skb)->daddr;
522}
523
524static inline void
525ip4addrptr(const struct sk_buff *skb, bool src, __be32 *addr)
526{
527 *addr = src ? ip_hdr(skb)->saddr : ip_hdr(skb)->daddr;
528}
529
530static inline void
531ip6addrptr(const struct sk_buff *skb, bool src, struct in6_addr *addr)
532{
533 memcpy(addr, src ? &ipv6_hdr(skb)->saddr : &ipv6_hdr(skb)->daddr,
534 sizeof(*addr));
535}
536
537/* Calculate the bytes required to store the inclusive range of a-b */
538static inline int
539bitmap_bytes(u32 a, u32 b)
540{
541 return 4 * ((((b - a + 8) / 8) + 3) / 4);
542}
543
075e64c0 544#include <linux/netfilter/ipset/ip_set_timeout.h>
68b63f08 545#include <linux/netfilter/ipset/ip_set_comment.h>
075e64c0 546
a3b1c1eb 547int
3fd986b3 548ip_set_put_extensions(struct sk_buff *skb, const struct ip_set *set,
a3b1c1eb 549 const void *e, bool active);
3fd986b3 550
ca134ce8 551#define IP_SET_INIT_KEXT(skb, opt, set) \
34d666d4 552 { .bytes = (skb)->len, .packets = 1, \
ca134ce8 553 .timeout = ip_set_adt_opt_timeout(opt, set) }
075e64c0 554
ca134ce8 555#define IP_SET_INIT_UEXT(set) \
34d666d4 556 { .bytes = ULLONG_MAX, .packets = ULLONG_MAX, \
ca134ce8 557 .timeout = (set)->timeout }
075e64c0 558
35b8dcf8
JK
559#define IPSET_CONCAT(a, b) a##b
560#define IPSET_TOKEN(a, b) IPSET_CONCAT(a, b)
561
a7b4f989 562#endif /*_IP_SET_H */
This page took 0.433785 seconds and 5 git commands to generate.