Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 1 | /* Copyright (C) 2003-2013 Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 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 bitmap:port type */ |
| 9 | |
| 10 | #include <linux/module.h> |
| 11 | #include <linux/ip.h> |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 12 | #include <linux/skbuff.h> |
| 13 | #include <linux/errno.h> |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 14 | #include <linux/netlink.h> |
| 15 | #include <linux/jiffies.h> |
| 16 | #include <linux/timer.h> |
| 17 | #include <net/netlink.h> |
| 18 | |
| 19 | #include <linux/netfilter/ipset/ip_set.h> |
| 20 | #include <linux/netfilter/ipset/ip_set_bitmap.h> |
| 21 | #include <linux/netfilter/ipset/ip_set_getport.h> |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 22 | |
Jozsef Kadlecsik | 35b8dcf | 2013-04-30 23:02:43 +0200 | [diff] [blame] | 23 | #define IPSET_TYPE_REV_MIN 0 |
Oliver Smith | b90cb8b | 2013-09-22 20:56:32 +0200 | [diff] [blame] | 24 | /* 1 Counter support added */ |
| 25 | #define IPSET_TYPE_REV_MAX 2 /* Comment support added */ |
Jozsef Kadlecsik | 10111a6 | 2012-09-21 21:59:32 +0200 | [diff] [blame] | 26 | |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 27 | MODULE_LICENSE("GPL"); |
| 28 | MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>"); |
Jozsef Kadlecsik | 35b8dcf | 2013-04-30 23:02:43 +0200 | [diff] [blame] | 29 | IP_SET_MODULE_DESC("bitmap:port", IPSET_TYPE_REV_MIN, IPSET_TYPE_REV_MAX); |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 30 | MODULE_ALIAS("ip_set_bitmap:port"); |
| 31 | |
Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 32 | #define MTYPE bitmap_port |
| 33 | |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 34 | /* Type structure */ |
| 35 | struct bitmap_port { |
| 36 | void *members; /* the set members */ |
Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 37 | void *extensions; /* data extensions */ |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 38 | u16 first_port; /* host byte order, included in range */ |
| 39 | u16 last_port; /* host byte order, included in range */ |
Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 40 | u32 elements; /* number of max elements in the set */ |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 41 | size_t memsize; /* members size */ |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 42 | struct timer_list gc; /* garbage collection */ |
| 43 | }; |
| 44 | |
Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 45 | /* ADT structure for generic function args */ |
| 46 | struct bitmap_port_adt_elem { |
| 47 | u16 id; |
| 48 | }; |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 49 | |
Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 50 | static inline u16 |
| 51 | port_to_id(const struct bitmap_port *m, u16 port) |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 52 | { |
Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 53 | return port - m->first_port; |
| 54 | } |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 55 | |
Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 56 | /* Common functions */ |
| 57 | |
| 58 | static inline int |
| 59 | bitmap_port_do_test(const struct bitmap_port_adt_elem *e, |
Jozsef Kadlecsik | ca134ce | 2013-09-07 00:10:07 +0200 | [diff] [blame] | 60 | const struct bitmap_port *map, size_t dsize) |
Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 61 | { |
| 62 | return !!test_bit(e->id, map->members); |
| 63 | } |
| 64 | |
| 65 | static inline int |
Jozsef Kadlecsik | ca134ce | 2013-09-07 00:10:07 +0200 | [diff] [blame] | 66 | bitmap_port_gc_test(u16 id, const struct bitmap_port *map, size_t dsize) |
Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 67 | { |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 68 | return !!test_bit(id, map->members); |
| 69 | } |
| 70 | |
Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 71 | static inline int |
| 72 | bitmap_port_do_add(const struct bitmap_port_adt_elem *e, |
Jozsef Kadlecsik | ca134ce | 2013-09-07 00:10:07 +0200 | [diff] [blame] | 73 | struct bitmap_port *map, u32 flags, size_t dsize) |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 74 | { |
Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 75 | return !!test_and_set_bit(e->id, map->members); |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 76 | } |
| 77 | |
Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 78 | static inline int |
| 79 | bitmap_port_do_del(const struct bitmap_port_adt_elem *e, |
| 80 | struct bitmap_port *map) |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 81 | { |
Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 82 | return !test_and_clear_bit(e->id, map->members); |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 83 | } |
| 84 | |
Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 85 | static inline int |
Jozsef Kadlecsik | ca134ce | 2013-09-07 00:10:07 +0200 | [diff] [blame] | 86 | bitmap_port_do_list(struct sk_buff *skb, const struct bitmap_port *map, u32 id, |
| 87 | size_t dsize) |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 88 | { |
Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 89 | return nla_put_net16(skb, IPSET_ATTR_PORT, |
| 90 | htons(map->first_port + id)); |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 91 | } |
| 92 | |
Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 93 | static inline int |
| 94 | bitmap_port_do_head(struct sk_buff *skb, const struct bitmap_port *map) |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 95 | { |
Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 96 | return nla_put_net16(skb, IPSET_ATTR_PORT, htons(map->first_port)) || |
| 97 | nla_put_net16(skb, IPSET_ATTR_PORT_TO, htons(map->last_port)); |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | static int |
| 101 | bitmap_port_kadt(struct ip_set *set, const struct sk_buff *skb, |
Jozsef Kadlecsik | b66554c | 2011-06-16 18:56:47 +0200 | [diff] [blame] | 102 | const struct xt_action_param *par, |
Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 103 | enum ipset_adt adt, struct ip_set_adt_opt *opt) |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 104 | { |
| 105 | struct bitmap_port *map = set->data; |
| 106 | ipset_adtfn adtfn = set->variant->adt[adt]; |
Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 107 | struct bitmap_port_adt_elem e = {}; |
Jozsef Kadlecsik | ca134ce | 2013-09-07 00:10:07 +0200 | [diff] [blame] | 108 | struct ip_set_ext ext = IP_SET_INIT_KEXT(skb, opt, set); |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 109 | __be16 __port; |
| 110 | u16 port = 0; |
| 111 | |
Jozsef Kadlecsik | ac8cc92 | 2011-06-16 18:42:40 +0200 | [diff] [blame] | 112 | if (!ip_set_get_ip_port(skb, opt->family, |
| 113 | opt->flags & IPSET_DIM_ONE_SRC, &__port)) |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 114 | return -EINVAL; |
| 115 | |
| 116 | port = ntohs(__port); |
| 117 | |
| 118 | if (port < map->first_port || port > map->last_port) |
| 119 | return -IPSET_ERR_BITMAP_RANGE; |
| 120 | |
Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 121 | e.id = port_to_id(map, port); |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 122 | |
Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 123 | return adtfn(set, &e, &ext, &opt->ext, opt->cmdflags); |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | static int |
| 127 | bitmap_port_uadt(struct ip_set *set, struct nlattr *tb[], |
Jozsef Kadlecsik | 3d14b17 | 2011-06-16 18:49:17 +0200 | [diff] [blame] | 128 | enum ipset_adt adt, u32 *lineno, u32 flags, bool retried) |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 129 | { |
| 130 | struct bitmap_port *map = set->data; |
| 131 | ipset_adtfn adtfn = set->variant->adt[adt]; |
Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 132 | struct bitmap_port_adt_elem e = {}; |
Jozsef Kadlecsik | ca134ce | 2013-09-07 00:10:07 +0200 | [diff] [blame] | 133 | struct ip_set_ext ext = IP_SET_INIT_UEXT(set); |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 134 | u32 port; /* wraparound */ |
Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 135 | u16 port_to; |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 136 | int ret = 0; |
| 137 | |
| 138 | if (unlikely(!ip_set_attr_netorder(tb, IPSET_ATTR_PORT) || |
| 139 | !ip_set_optattr_netorder(tb, IPSET_ATTR_PORT_TO) || |
Jozsef Kadlecsik | f48d19d | 2013-04-08 23:10:22 +0200 | [diff] [blame] | 140 | !ip_set_optattr_netorder(tb, IPSET_ATTR_TIMEOUT) || |
| 141 | !ip_set_optattr_netorder(tb, IPSET_ATTR_PACKETS) || |
| 142 | !ip_set_optattr_netorder(tb, IPSET_ATTR_BYTES))) |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 143 | return -IPSET_ERR_PROTOCOL; |
| 144 | |
| 145 | if (tb[IPSET_ATTR_LINENO]) |
| 146 | *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]); |
| 147 | |
| 148 | port = ip_set_get_h16(tb[IPSET_ATTR_PORT]); |
| 149 | if (port < map->first_port || port > map->last_port) |
| 150 | return -IPSET_ERR_BITMAP_RANGE; |
Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 151 | ret = ip_set_get_extensions(set, tb, &ext); |
| 152 | if (ret) |
| 153 | return ret; |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 154 | |
| 155 | if (adt == IPSET_TEST) { |
Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 156 | e.id = port_to_id(map, port); |
| 157 | return adtfn(set, &e, &ext, &ext, flags); |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | if (tb[IPSET_ATTR_PORT_TO]) { |
| 161 | port_to = ip_set_get_h16(tb[IPSET_ATTR_PORT_TO]); |
| 162 | if (port > port_to) { |
| 163 | swap(port, port_to); |
| 164 | if (port < map->first_port) |
| 165 | return -IPSET_ERR_BITMAP_RANGE; |
| 166 | } |
| 167 | } else |
| 168 | port_to = port; |
| 169 | |
| 170 | if (port_to > map->last_port) |
| 171 | return -IPSET_ERR_BITMAP_RANGE; |
| 172 | |
| 173 | for (; port <= port_to; port++) { |
Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 174 | e.id = port_to_id(map, port); |
| 175 | ret = adtfn(set, &e, &ext, &ext, flags); |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 176 | |
| 177 | if (ret && !ip_set_eexist(ret, flags)) |
| 178 | return ret; |
| 179 | else |
| 180 | ret = 0; |
| 181 | } |
| 182 | return ret; |
| 183 | } |
| 184 | |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 185 | static bool |
| 186 | bitmap_port_same_set(const struct ip_set *a, const struct ip_set *b) |
| 187 | { |
| 188 | const struct bitmap_port *x = a->data; |
| 189 | const struct bitmap_port *y = b->data; |
| 190 | |
| 191 | return x->first_port == y->first_port && |
| 192 | x->last_port == y->last_port && |
Jozsef Kadlecsik | ca134ce | 2013-09-07 00:10:07 +0200 | [diff] [blame] | 193 | a->timeout == b->timeout && |
Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 194 | a->extensions == b->extensions; |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 195 | } |
| 196 | |
Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 197 | /* Plain variant */ |
| 198 | |
| 199 | struct bitmap_port_elem { |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 200 | }; |
| 201 | |
Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 202 | #include "ip_set_bitmap_gen.h" |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 203 | |
| 204 | /* Create bitmap:ip type of sets */ |
| 205 | |
| 206 | static bool |
| 207 | init_map_port(struct ip_set *set, struct bitmap_port *map, |
| 208 | u16 first_port, u16 last_port) |
| 209 | { |
| 210 | map->members = ip_set_alloc(map->memsize); |
| 211 | if (!map->members) |
| 212 | return false; |
Jozsef Kadlecsik | ca134ce | 2013-09-07 00:10:07 +0200 | [diff] [blame] | 213 | if (set->dsize) { |
| 214 | map->extensions = ip_set_alloc(set->dsize * map->elements); |
Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 215 | if (!map->extensions) { |
| 216 | kfree(map->members); |
| 217 | return false; |
| 218 | } |
| 219 | } |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 220 | map->first_port = first_port; |
| 221 | map->last_port = last_port; |
Jozsef Kadlecsik | ca134ce | 2013-09-07 00:10:07 +0200 | [diff] [blame] | 222 | set->timeout = IPSET_NO_TIMEOUT; |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 223 | |
| 224 | set->data = map; |
Jan Engelhardt | c15f1c8 | 2012-02-14 00:24:10 +0100 | [diff] [blame] | 225 | set->family = NFPROTO_UNSPEC; |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 226 | |
| 227 | return true; |
| 228 | } |
| 229 | |
| 230 | static int |
Vitaly Lavrov | 1785e8f | 2013-09-30 17:07:02 +0200 | [diff] [blame] | 231 | bitmap_port_create(struct net *net, struct ip_set *set, struct nlattr *tb[], |
| 232 | u32 flags) |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 233 | { |
| 234 | struct bitmap_port *map; |
| 235 | u16 first_port, last_port; |
| 236 | |
| 237 | if (unlikely(!ip_set_attr_netorder(tb, IPSET_ATTR_PORT) || |
| 238 | !ip_set_attr_netorder(tb, IPSET_ATTR_PORT_TO) || |
Jozsef Kadlecsik | f48d19d | 2013-04-08 23:10:22 +0200 | [diff] [blame] | 239 | !ip_set_optattr_netorder(tb, IPSET_ATTR_TIMEOUT) || |
| 240 | !ip_set_optattr_netorder(tb, IPSET_ATTR_CADT_FLAGS))) |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 241 | return -IPSET_ERR_PROTOCOL; |
| 242 | |
| 243 | first_port = ip_set_get_h16(tb[IPSET_ATTR_PORT]); |
| 244 | last_port = ip_set_get_h16(tb[IPSET_ATTR_PORT_TO]); |
| 245 | if (first_port > last_port) { |
| 246 | u16 tmp = first_port; |
| 247 | |
| 248 | first_port = last_port; |
| 249 | last_port = tmp; |
| 250 | } |
| 251 | |
| 252 | map = kzalloc(sizeof(*map), GFP_KERNEL); |
| 253 | if (!map) |
| 254 | return -ENOMEM; |
| 255 | |
Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 256 | map->elements = last_port - first_port + 1; |
Jozsef Kadlecsik | dc476e7 | 2013-10-18 14:03:41 +0200 | [diff] [blame] | 257 | map->memsize = bitmap_bytes(0, map->elements); |
Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 258 | set->variant = &bitmap_port; |
Jozsef Kadlecsik | 03c8b23 | 2013-09-07 00:43:52 +0200 | [diff] [blame] | 259 | set->dsize = ip_set_elem_len(set, tb, 0); |
| 260 | if (!init_map_port(set, map, first_port, last_port)) { |
| 261 | kfree(map); |
| 262 | return -ENOMEM; |
| 263 | } |
| 264 | if (tb[IPSET_ATTR_TIMEOUT]) { |
Jozsef Kadlecsik | ca134ce | 2013-09-07 00:10:07 +0200 | [diff] [blame] | 265 | set->timeout = ip_set_timeout_uget(tb[IPSET_ATTR_TIMEOUT]); |
Jozsef Kadlecsik | b0da390 | 2013-04-27 14:37:01 +0200 | [diff] [blame] | 266 | bitmap_port_gc_init(set, bitmap_port_gc); |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 267 | } |
| 268 | return 0; |
| 269 | } |
| 270 | |
| 271 | static struct ip_set_type bitmap_port_type = { |
| 272 | .name = "bitmap:port", |
| 273 | .protocol = IPSET_PROTOCOL, |
| 274 | .features = IPSET_TYPE_PORT, |
| 275 | .dimension = IPSET_DIM_ONE, |
Jan Engelhardt | c15f1c8 | 2012-02-14 00:24:10 +0100 | [diff] [blame] | 276 | .family = NFPROTO_UNSPEC, |
Jozsef Kadlecsik | 35b8dcf | 2013-04-30 23:02:43 +0200 | [diff] [blame] | 277 | .revision_min = IPSET_TYPE_REV_MIN, |
| 278 | .revision_max = IPSET_TYPE_REV_MAX, |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 279 | .create = bitmap_port_create, |
| 280 | .create_policy = { |
| 281 | [IPSET_ATTR_PORT] = { .type = NLA_U16 }, |
| 282 | [IPSET_ATTR_PORT_TO] = { .type = NLA_U16 }, |
| 283 | [IPSET_ATTR_TIMEOUT] = { .type = NLA_U32 }, |
Jozsef Kadlecsik | f48d19d | 2013-04-08 23:10:22 +0200 | [diff] [blame] | 284 | [IPSET_ATTR_CADT_FLAGS] = { .type = NLA_U32 }, |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 285 | }, |
| 286 | .adt_policy = { |
| 287 | [IPSET_ATTR_PORT] = { .type = NLA_U16 }, |
| 288 | [IPSET_ATTR_PORT_TO] = { .type = NLA_U16 }, |
| 289 | [IPSET_ATTR_TIMEOUT] = { .type = NLA_U32 }, |
| 290 | [IPSET_ATTR_LINENO] = { .type = NLA_U32 }, |
Jozsef Kadlecsik | f48d19d | 2013-04-08 23:10:22 +0200 | [diff] [blame] | 291 | [IPSET_ATTR_BYTES] = { .type = NLA_U64 }, |
| 292 | [IPSET_ATTR_PACKETS] = { .type = NLA_U64 }, |
Oliver Smith | b90cb8b | 2013-09-22 20:56:32 +0200 | [diff] [blame] | 293 | [IPSET_ATTR_COMMENT] = { .type = NLA_NUL_STRING }, |
Jozsef Kadlecsik | 5432619 | 2011-02-01 15:37:04 +0100 | [diff] [blame] | 294 | }, |
| 295 | .me = THIS_MODULE, |
| 296 | }; |
| 297 | |
| 298 | static int __init |
| 299 | bitmap_port_init(void) |
| 300 | { |
| 301 | return ip_set_type_register(&bitmap_port_type); |
| 302 | } |
| 303 | |
| 304 | static void __exit |
| 305 | bitmap_port_fini(void) |
| 306 | { |
| 307 | ip_set_type_unregister(&bitmap_port_type); |
| 308 | } |
| 309 | |
| 310 | module_init(bitmap_port_init); |
| 311 | module_exit(bitmap_port_fini); |