The support makes possible to specify the timeout value for the SET target and a flag to reset the timeout for already existing entries.
Unified · Split
| @@ -217,6 +217,15 @@ struct ip_set; · 216 unmodified lines | |||
| 217 | typedef int (*ipset_adtfn)(struct ip_set *set, void *value, | 217 | typedef int (*ipset_adtfn)(struct ip_set *set, void *value, |
| 218 | u32 timeout, u32 flags); | 218 | u32 timeout, u32 flags); |
| 219 | 219 | ||
| 220 | /* Kernel API function options */ | ||
| 221 | struct ip_set_adt_opt { | ||
| 222 | u8 family; /* Actual protocol family */ | ||
| 223 | u8 dim; /* Dimension of match/target */ | ||
| 224 | u8 flags; /* Direction and negation flags */ | ||
| 225 | u32 cmdflags; /* Command-like flags */ | ||
| 226 | u32 timeout; /* Timeout value */ | ||
| 227 | }; | ||
| 228 | |||
| 220 | /* Set type, variant-specific part */ | 229 | /* Set type, variant-specific part */ |
| 221 | struct ip_set_type_variant { | 230 | struct ip_set_type_variant { |
| 222 | /* Kernelspace: test/add/del entries | 231 | /* Kernelspace: test/add/del entries |
| @@ -224,7 +233,7 @@ struct ip_set_type_variant { · 1 unmodified line | |||
| 224 | * zero for no match/success to add/delete | 233 | * zero for no match/success to add/delete |
| 225 | * positive for matching element */ | 234 | * positive for matching element */ |
| 226 | int (*kadt)(struct ip_set *set, const struct sk_buff * skb, | 235 | int (*kadt)(struct ip_set *set, const struct sk_buff * skb, |
| 227 | enum ipset_adt adt, u8 pf, u8 dim, u8 flags); | 236 | enum ipset_adt adt, const struct ip_set_adt_opt *opt); |
| 228 | 237 | ||
| 229 | /* Userspace: test/add/del entries | 238 | /* Userspace: test/add/del entries |
| 230 | * returns negative error code, | 239 | * returns negative error code, |
| @@ -314,12 +323,13 @@ extern ip_set_id_t ip_set_nfnl_get_byindex(ip_set_id_t index); · 83 unmodified lines | |||
| 314 | extern void ip_set_nfnl_put(ip_set_id_t index); | 323 | extern void ip_set_nfnl_put(ip_set_id_t index); |
| 315 | 324 | ||
| 316 | /* API for iptables set match, and SET target */ | 325 | /* API for iptables set match, and SET target */ |
| 326 | |||
| 317 | extern int ip_set_add(ip_set_id_t id, const struct sk_buff *skb, | 327 | extern int ip_set_add(ip_set_id_t id, const struct sk_buff *skb, |
| 318 | u8 family, u8 dim, u8 flags); | 328 | const struct ip_set_adt_opt *opt); |
| 319 | extern int ip_set_del(ip_set_id_t id, const struct sk_buff *skb, | 329 | extern int ip_set_del(ip_set_id_t id, const struct sk_buff *skb, |
| 320 | u8 family, u8 dim, u8 flags); | 330 | const struct ip_set_adt_opt *opt); |
| 321 | extern int ip_set_test(ip_set_id_t id, const struct sk_buff *skb, | 331 | extern int ip_set_test(ip_set_id_t id, const struct sk_buff *skb, |
| 322 | u8 family, u8 dim, u8 flags); | 332 | const struct ip_set_adt_opt *opt); |
| 323 | 333 | ||
| 324 | /* Utility functions */ | 334 | /* Utility functions */ |
| 325 | extern void * ip_set_alloc(size_t size); | 335 | extern void * ip_set_alloc(size_t size); |
| @@ -586,7 +586,7 @@ nla_put_failure: · 585 unmodified lines | |||
| 586 | 586 | ||
| 587 | static int | 587 | static int |
| 588 | type_pf_kadt(struct ip_set *set, const struct sk_buff * skb, | 588 | type_pf_kadt(struct ip_set *set, const struct sk_buff * skb, |
| 589 | enum ipset_adt adt, u8 pf, u8 dim, u8 flags); | 589 | enum ipset_adt adt, const struct ip_set_adt_opt *opt); |
| 590 | static int | 590 | static int |
| 591 | type_pf_uadt(struct ip_set *set, struct nlattr *tb[], | 591 | type_pf_uadt(struct ip_set *set, struct nlattr *tb[], |
| 592 | enum ipset_adt adt, u32 *lineno, u32 flags); | 592 | enum ipset_adt adt, u32 *lineno, u32 flags); |
| @@ -22,6 +22,9 @@ · 21 unmodified lines | |||
| 22 | 22 | ||
| 23 | #define with_timeout(timeout) ((timeout) != IPSET_NO_TIMEOUT) | 23 | #define with_timeout(timeout) ((timeout) != IPSET_NO_TIMEOUT) |
| 24 | 24 | ||
| 25 | #define opt_timeout(opt, map) \ | ||
| 26 | (with_timeout((opt)->timeout) ? (opt)->timeout : (map)->timeout) | ||
| 27 | |||
| 25 | static inline unsigned int | 28 | static inline unsigned int |
| 26 | ip_set_timeout_uget(struct nlattr *tb) | 29 | ip_set_timeout_uget(struct nlattr *tb) |
| 27 | { | 30 | { |
| @@ -35,7 +35,7 @@ struct xt_set_info_target_v0 { · 34 unmodified lines | |||
| 35 | struct xt_set_info_v0 del_set; | 35 | struct xt_set_info_v0 del_set; |
| 36 | }; | 36 | }; |
| 37 | 37 | ||
| 38 | /* Revision 1: current interface to netfilter/iptables */ | 38 | /* Revision 1 match and target */ |
| 39 | 39 | ||
| 40 | struct xt_set_info { | 40 | struct xt_set_info { |
| 41 | ip_set_id_t index; | 41 | ip_set_id_t index; |
| @@ -44,13 +44,22 @@ struct xt_set_info { · 2 unmodified lines | |||
| 44 | }; | 44 | }; |
| 45 | 45 | ||
| 46 | /* match and target infos */ | 46 | /* match and target infos */ |
| 47 | struct xt_set_info_match { | 47 | struct xt_set_info_match_v1 { |
| 48 | struct xt_set_info match_set; | 48 | struct xt_set_info match_set; |
| 49 | }; | 49 | }; |
| 50 | 50 | ||
| 51 | struct xt_set_info_target { | 51 | struct xt_set_info_target_v1 { |
| 52 | struct xt_set_info add_set; | 52 | struct xt_set_info add_set; |
| 53 | struct xt_set_info del_set; | 53 | struct xt_set_info del_set; |
| 54 | }; | 54 | }; |
| 55 | 55 | ||
| 56 | /* Revision 2 target */ | ||
| 57 | |||
| 58 | struct xt_set_info_target_v2 { | ||
| 59 | struct xt_set_info add_set; | ||
| 60 | struct xt_set_info del_set; | ||
| 61 | u32 flags; | ||
| 62 | u32 timeout; | ||
| 63 | }; | ||
| 64 | |||
| 56 | #endif /*_XT_SET_H*/ | 65 | #endif /*_XT_SET_H*/ |
| @@ -219,19 +219,19 @@ nla_put_failure: · 218 unmodified lines | |||
| 219 | 219 | ||
| 220 | static int | 220 | static int |
| 221 | bitmap_ip_kadt(struct ip_set *set, const struct sk_buff *skb, | 221 | bitmap_ip_kadt(struct ip_set *set, const struct sk_buff *skb, |
| 222 | enum ipset_adt adt, u8 pf, u8 dim, u8 flags) | 222 | enum ipset_adt adt, const struct ip_set_adt_opt *opt) |
| 223 | { | 223 | { |
| 224 | struct bitmap_ip *map = set->data; | 224 | struct bitmap_ip *map = set->data; |
| 225 | ipset_adtfn adtfn = set->variant->adt[adt]; | 225 | ipset_adtfn adtfn = set->variant->adt[adt]; |
| 226 | u32 ip; | 226 | u32 ip; |
| 227 | 227 | ||
| 228 | ip = ntohl(ip4addr(skb, flags & IPSET_DIM_ONE_SRC)); | 228 | ip = ntohl(ip4addr(skb, opt->flags & IPSET_DIM_ONE_SRC)); |
| 229 | if (ip < map->first_ip || ip > map->last_ip) | 229 | if (ip < map->first_ip || ip > map->last_ip) |
| 230 | return -IPSET_ERR_BITMAP_RANGE; | 230 | return -IPSET_ERR_BITMAP_RANGE; |
| 231 | 231 | ||
| 232 | ip = ip_to_id(map, ip); | 232 | ip = ip_to_id(map, ip); |
| 233 | 233 | ||
| 234 | return adtfn(set, &ip, map->timeout, flags); | 234 | return adtfn(set, &ip, opt_timeout(opt, map), opt->cmdflags); |
| 235 | } | 235 | } |
| 236 | 236 | ||
| 237 | static int | 237 | static int |
| @@ -338,17 +338,17 @@ nla_put_failure: · 337 unmodified lines | |||
| 338 | 338 | ||
| 339 | static int | 339 | static int |
| 340 | bitmap_ipmac_kadt(struct ip_set *set, const struct sk_buff *skb, | 340 | bitmap_ipmac_kadt(struct ip_set *set, const struct sk_buff *skb, |
| 341 | enum ipset_adt adt, u8 pf, u8 dim, u8 flags) | 341 | enum ipset_adt adt, const struct ip_set_adt_opt *opt) |
| 342 | { | 342 | { |
| 343 | struct bitmap_ipmac *map = set->data; | 343 | struct bitmap_ipmac *map = set->data; |
| 344 | ipset_adtfn adtfn = set->variant->adt[adt]; | 344 | ipset_adtfn adtfn = set->variant->adt[adt]; |
| 345 | struct ipmac data; | 345 | struct ipmac data; |
| 346 | 346 | ||
| 347 | /* MAC can be src only */ | 347 | /* MAC can be src only */ |
| 348 | if (!(flags & IPSET_DIM_TWO_SRC)) | 348 | if (!(opt->flags & IPSET_DIM_TWO_SRC)) |
| 349 | return 0; | 349 | return 0; |
| 350 | 350 | ||
| 351 | data.id = ntohl(ip4addr(skb, flags & IPSET_DIM_ONE_SRC)); | 351 | data.id = ntohl(ip4addr(skb, opt->flags & IPSET_DIM_ONE_SRC)); |
| 352 | if (data.id < map->first_ip || data.id > map->last_ip) | 352 | if (data.id < map->first_ip || data.id > map->last_ip) |
| 353 | return -IPSET_ERR_BITMAP_RANGE; | 353 | return -IPSET_ERR_BITMAP_RANGE; |
| 354 | 354 | ||
| @@ -360,7 +360,7 @@ bitmap_ipmac_kadt(struct ip_set *set, const struct sk_buff *skb, · 5 unmodified lines | |||
| 360 | data.id -= map->first_ip; | 360 | data.id -= map->first_ip; |
| 361 | data.ether = eth_hdr(skb)->h_source; | 361 | data.ether = eth_hdr(skb)->h_source; |
| 362 | 362 | ||
| 363 | return adtfn(set, &data, map->timeout, flags); | 363 | return adtfn(set, &data, opt_timeout(opt, map), opt->cmdflags); |
| 364 | } | 364 | } |
| 365 | 365 | ||
| 366 | static int | 366 | static int |
| @@ -208,14 +208,15 @@ nla_put_failure: · 207 unmodified lines | |||
| 208 | 208 | ||
| 209 | static int | 209 | static int |
| 210 | bitmap_port_kadt(struct ip_set *set, const struct sk_buff *skb, | 210 | bitmap_port_kadt(struct ip_set *set, const struct sk_buff *skb, |
| 211 | enum ipset_adt adt, u8 pf, u8 dim, u8 flags) | 211 | enum ipset_adt adt, const struct ip_set_adt_opt *opt) |
| 212 | { | 212 | { |
| 213 | struct bitmap_port *map = set->data; | 213 | struct bitmap_port *map = set->data; |
| 214 | ipset_adtfn adtfn = set->variant->adt[adt]; | 214 | ipset_adtfn adtfn = set->variant->adt[adt]; |
| 215 | __be16 __port; | 215 | __be16 __port; |
| 216 | u16 port = 0; | 216 | u16 port = 0; |
| 217 | 217 | ||
| 218 | if (!ip_set_get_ip_port(skb, pf, flags & IPSET_DIM_ONE_SRC, &__port)) | 218 | if (!ip_set_get_ip_port(skb, opt->family, |
| 219 | opt->flags & IPSET_DIM_ONE_SRC, &__port)) | ||
| 219 | return -EINVAL; | 220 | return -EINVAL; |
| 220 | 221 | ||
| 221 | port = ntohs(__port); | 222 | port = ntohs(__port); |
| @@ -225,7 +226,7 @@ bitmap_port_kadt(struct ip_set *set, const struct sk_buff *skb, · 3 unmodified lines | |||
| 225 | 226 | ||
| 226 | port -= map->first_port; | 227 | port -= map->first_port; |
| 227 | 228 | ||
| 228 | return adtfn(set, &port, map->timeout, flags); | 229 | return adtfn(set, &port, opt_timeout(opt, map), opt->cmdflags); |
| 229 | } | 230 | } |
| 230 | 231 | ||
| 231 | static int | 232 | static int |
| @@ -325,7 +325,7 @@ __ip_set_put(ip_set_id_t index) · 324 unmodified lines | |||
| 325 | 325 | ||
| 326 | int | 326 | int |
| 327 | ip_set_test(ip_set_id_t index, const struct sk_buff *skb, | 327 | ip_set_test(ip_set_id_t index, const struct sk_buff *skb, |
| 328 | u8 family, u8 dim, u8 flags) | 328 | const struct ip_set_adt_opt *opt) |
| 329 | { | 329 | { |
| 330 | struct ip_set *set = ip_set_list[index]; | 330 | struct ip_set *set = ip_set_list[index]; |
| 331 | int ret = 0; | 331 | int ret = 0; |
| @@ -333,19 +333,19 @@ ip_set_test(ip_set_id_t index, const struct sk_buff *skb, · 1 unmodified line | |||
| 333 | BUG_ON(set == NULL); | 333 | BUG_ON(set == NULL); |
| 334 | pr_debug("set %s, index %u\n", set->name, index); | 334 | pr_debug("set %s, index %u\n", set->name, index); |
| 335 | 335 | ||
| 336 | if (dim < set->type->dimension || | 336 | if (opt->dim < set->type->dimension || |
| 337 | !(family == set->family || set->family == AF_UNSPEC)) | 337 | !(opt->family == set->family || set->family == AF_UNSPEC)) |
| 338 | return 0; | 338 | return 0; |
| 339 | 339 | ||
| 340 | read_lock_bh(&set->lock); | 340 | read_lock_bh(&set->lock); |
| 341 | ret = set->variant->kadt(set, skb, IPSET_TEST, family, dim, flags); | 341 | ret = set->variant->kadt(set, skb, IPSET_TEST, opt); |
| 342 | read_unlock_bh(&set->lock); | 342 | read_unlock_bh(&set->lock); |
| 343 | 343 | ||
| 344 | if (ret == -EAGAIN) { | 344 | if (ret == -EAGAIN) { |
| 345 | /* Type requests element to be completed */ | 345 | /* Type requests element to be completed */ |
| 346 | pr_debug("element must be competed, ADD is triggered\n"); | 346 | pr_debug("element must be competed, ADD is triggered\n"); |
| 347 | write_lock_bh(&set->lock); | 347 | write_lock_bh(&set->lock); |
| 348 | set->variant->kadt(set, skb, IPSET_ADD, family, dim, flags); | 348 | set->variant->kadt(set, skb, IPSET_ADD, opt); |
| 349 | write_unlock_bh(&set->lock); | 349 | write_unlock_bh(&set->lock); |
| 350 | ret = 1; | 350 | ret = 1; |
| 351 | } | 351 | } |
| @@ -357,7 +357,7 @@ EXPORT_SYMBOL_GPL(ip_set_test); · 5 unmodified lines | |||
| 357 | 357 | ||
| 358 | int | 358 | int |
| 359 | ip_set_add(ip_set_id_t index, const struct sk_buff *skb, | 359 | ip_set_add(ip_set_id_t index, const struct sk_buff *skb, |
| 360 | u8 family, u8 dim, u8 flags) | 360 | const struct ip_set_adt_opt *opt) |
| 361 | { | 361 | { |
| 362 | struct ip_set *set = ip_set_list[index]; | 362 | struct ip_set *set = ip_set_list[index]; |
| 363 | int ret; | 363 | int ret; |
| @@ -365,12 +365,12 @@ ip_set_add(ip_set_id_t index, const struct sk_buff *skb, · 1 unmodified line | |||
| 365 | BUG_ON(set == NULL); | 365 | BUG_ON(set == NULL); |
| 366 | pr_debug("set %s, index %u\n", set->name, index); | 366 | pr_debug("set %s, index %u\n", set->name, index); |
| 367 | 367 | ||
| 368 | if (dim < set->type->dimension || | 368 | if (opt->dim < set->type->dimension || |
| 369 | !(family == set->family || set->family == AF_UNSPEC)) | 369 | !(opt->family == set->family || set->family == AF_UNSPEC)) |
| 370 | return 0; | 370 | return 0; |
| 371 | 371 | ||
| 372 | write_lock_bh(&set->lock); | 372 | write_lock_bh(&set->lock); |
| 373 | ret = set->variant->kadt(set, skb, IPSET_ADD, family, dim, flags); | 373 | ret = set->variant->kadt(set, skb, IPSET_ADD, opt); |
| 374 | write_unlock_bh(&set->lock); | 374 | write_unlock_bh(&set->lock); |
| 375 | 375 | ||
| 376 | return ret; | 376 | return ret; |
| @@ -379,7 +379,7 @@ EXPORT_SYMBOL_GPL(ip_set_add); · 2 unmodified lines | |||
| 379 | 379 | ||
| 380 | int | 380 | int |
| 381 | ip_set_del(ip_set_id_t index, const struct sk_buff *skb, | 381 | ip_set_del(ip_set_id_t index, const struct sk_buff *skb, |
| 382 | u8 family, u8 dim, u8 flags) | 382 | const struct ip_set_adt_opt *opt) |
| 383 | { | 383 | { |
| 384 | struct ip_set *set = ip_set_list[index]; | 384 | struct ip_set *set = ip_set_list[index]; |
| 385 | int ret = 0; | 385 | int ret = 0; |
| @@ -387,12 +387,12 @@ ip_set_del(ip_set_id_t index, const struct sk_buff *skb, · 1 unmodified line | |||
| 387 | BUG_ON(set == NULL); | 387 | BUG_ON(set == NULL); |
| 388 | pr_debug("set %s, index %u\n", set->name, index); | 388 | pr_debug("set %s, index %u\n", set->name, index); |
| 389 | 389 | ||
| 390 | if (dim < set->type->dimension || | 390 | if (opt->dim < set->type->dimension || |
| 391 | !(family == set->family || set->family == AF_UNSPEC)) | 391 | !(opt->family == set->family || set->family == AF_UNSPEC)) |
| 392 | return 0; | 392 | return 0; |
| 393 | 393 | ||
| 394 | write_lock_bh(&set->lock); | 394 | write_lock_bh(&set->lock); |
| 395 | ret = set->variant->kadt(set, skb, IPSET_DEL, family, dim, flags); | 395 | ret = set->variant->kadt(set, skb, IPSET_DEL, opt); |
| 396 | write_unlock_bh(&set->lock); | 396 | write_unlock_bh(&set->lock); |
| 397 | 397 | ||
| 398 | return ret; | 398 | return ret; |
| @@ -110,18 +110,18 @@ nla_put_failure: · 109 unmodified lines | |||
| 110 | 110 | ||
| 111 | static int | 111 | static int |
| 112 | hash_ip4_kadt(struct ip_set *set, const struct sk_buff *skb, | 112 | hash_ip4_kadt(struct ip_set *set, const struct sk_buff *skb, |
| 113 | enum ipset_adt adt, u8 pf, u8 dim, u8 flags) | 113 | enum ipset_adt adt, const struct ip_set_adt_opt *opt) |
| 114 | { | 114 | { |
| 115 | const struct ip_set_hash *h = set->data; | 115 | const struct ip_set_hash *h = set->data; |
| 116 | ipset_adtfn adtfn = set->variant->adt[adt]; | 116 | ipset_adtfn adtfn = set->variant->adt[adt]; |
| 117 | __be32 ip; | 117 | __be32 ip; |
| 118 | 118 | ||
| 119 | ip4addrptr(skb, flags & IPSET_DIM_ONE_SRC, &ip); | 119 | ip4addrptr(skb, opt->flags & IPSET_DIM_ONE_SRC, &ip); |
| 120 | ip &= ip_set_netmask(h->netmask); | 120 | ip &= ip_set_netmask(h->netmask); |
| 121 | if (ip == 0) | 121 | if (ip == 0) |
| 122 | return -EINVAL; | 122 | return -EINVAL; |
| 123 | 123 | ||
| 124 | return adtfn(set, &ip, h->timeout, flags); | 124 | return adtfn(set, &ip, opt_timeout(opt, h), opt->cmdflags); |
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | static int | 127 | static int |
| @@ -283,18 +283,18 @@ nla_put_failure: · 155 unmodified lines | |||
| 283 | 283 | ||
| 284 | static int | 284 | static int |
| 285 | hash_ip6_kadt(struct ip_set *set, const struct sk_buff *skb, | 285 | hash_ip6_kadt(struct ip_set *set, const struct sk_buff *skb, |
| 286 | enum ipset_adt adt, u8 pf, u8 dim, u8 flags) | 286 | enum ipset_adt adt, const struct ip_set_adt_opt *opt) |
| 287 | { | 287 | { |
| 288 | const struct ip_set_hash *h = set->data; | 288 | const struct ip_set_hash *h = set->data; |
| 289 | ipset_adtfn adtfn = set->variant->adt[adt]; | 289 | ipset_adtfn adtfn = set->variant->adt[adt]; |
| 290 | union nf_inet_addr ip; | 290 | union nf_inet_addr ip; |
| 291 | 291 | ||
| 292 | ip6addrptr(skb, flags & IPSET_DIM_ONE_SRC, &ip.in6); | 292 | ip6addrptr(skb, opt->flags & IPSET_DIM_ONE_SRC, &ip.in6); |
| 293 | ip6_netmask(&ip, h->netmask); | 293 | ip6_netmask(&ip, h->netmask); |
| 294 | if (ipv6_addr_any(&ip.in6)) | 294 | if (ipv6_addr_any(&ip.in6)) |
| 295 | return -EINVAL; | 295 | return -EINVAL; |
| 296 | 296 | ||
| 297 | return adtfn(set, &ip, h->timeout, flags); | 297 | return adtfn(set, &ip, opt_timeout(opt, h), opt->cmdflags); |
| 298 | } | 298 | } |
| 299 | 299 | ||
| 300 | static const struct nla_policy hash_ip6_adt_policy[IPSET_ATTR_ADT_MAX + 1] = { | 300 | static const struct nla_policy hash_ip6_adt_policy[IPSET_ATTR_ADT_MAX + 1] = { |
| @@ -126,19 +126,19 @@ nla_put_failure: · 125 unmodified lines | |||
| 126 | 126 | ||
| 127 | static int | 127 | static int |
| 128 | hash_ipport4_kadt(struct ip_set *set, const struct sk_buff *skb, | 128 | hash_ipport4_kadt(struct ip_set *set, const struct sk_buff *skb, |
| 129 | enum ipset_adt adt, u8 pf, u8 dim, u8 flags) | 129 | enum ipset_adt adt, const struct ip_set_adt_opt *opt) |
| 130 | { | 130 | { |
| 131 | const struct ip_set_hash *h = set->data; | 131 | const struct ip_set_hash *h = set->data; |
| 132 | ipset_adtfn adtfn = set->variant->adt[adt]; | 132 | ipset_adtfn adtfn = set->variant->adt[adt]; |
| 133 | struct hash_ipport4_elem data = { }; | 133 | struct hash_ipport4_elem data = { }; |
| 134 | 134 | ||
| 135 | if (!ip_set_get_ip4_port(skb, flags & IPSET_DIM_TWO_SRC, | 135 | if (!ip_set_get_ip4_port(skb, opt->flags & IPSET_DIM_TWO_SRC, |
| 136 | &data.port, &data.proto)) | 136 | &data.port, &data.proto)) |
| 137 | return -EINVAL; | 137 | return -EINVAL; |
| 138 | 138 | ||
| 139 | ip4addrptr(skb, flags & IPSET_DIM_ONE_SRC, &data.ip); | 139 | ip4addrptr(skb, opt->flags & IPSET_DIM_ONE_SRC, &data.ip); |
| 140 | 140 | ||
| 141 | return adtfn(set, &data, h->timeout, flags); | 141 | return adtfn(set, &data, opt_timeout(opt, h), opt->cmdflags); |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | static int | 144 | static int |
| @@ -330,19 +330,19 @@ nla_put_failure: · 185 unmodified lines | |||
| 330 | 330 | ||
| 331 | static int | 331 | static int |
| 332 | hash_ipport6_kadt(struct ip_set *set, const struct sk_buff *skb, | 332 | hash_ipport6_kadt(struct ip_set *set, const struct sk_buff *skb, |
| 333 | enum ipset_adt adt, u8 pf, u8 dim, u8 flags) | 333 | enum ipset_adt adt, const struct ip_set_adt_opt *opt) |
| 334 | { | 334 | { |
| 335 | const struct ip_set_hash *h = set->data; | 335 | const struct ip_set_hash *h = set->data; |
| 336 | ipset_adtfn adtfn = set->variant->adt[adt]; | 336 | ipset_adtfn adtfn = set->variant->adt[adt]; |
| 337 | struct hash_ipport6_elem data = { }; | 337 | struct hash_ipport6_elem data = { }; |
| 338 | 338 | ||
| 339 | if (!ip_set_get_ip6_port(skb, flags & IPSET_DIM_TWO_SRC, | 339 | if (!ip_set_get_ip6_port(skb, opt->flags & IPSET_DIM_TWO_SRC, |
| 340 | &data.port, &data.proto)) | 340 | &data.port, &data.proto)) |
| 341 | return -EINVAL; | 341 | return -EINVAL; |
| 342 | 342 | ||
| 343 | ip6addrptr(skb, flags & IPSET_DIM_ONE_SRC, &data.ip.in6); | 343 | ip6addrptr(skb, opt->flags & IPSET_DIM_ONE_SRC, &data.ip.in6); |
| 344 | 344 | ||
| 345 | return adtfn(set, &data, h->timeout, flags); | 345 | return adtfn(set, &data, opt_timeout(opt, h), opt->cmdflags); |
| 346 | } | 346 | } |
| 347 | 347 | ||
| 348 | static int | 348 | static int |
| @@ -129,20 +129,20 @@ nla_put_failure: · 128 unmodified lines | |||
| 129 | 129 | ||
| 130 | static int | 130 | static int |
| 131 | hash_ipportip4_kadt(struct ip_set *set, const struct sk_buff *skb, | 131 | hash_ipportip4_kadt(struct ip_set *set, const struct sk_buff *skb, |
| 132 | enum ipset_adt adt, u8 pf, u8 dim, u8 flags) | 132 | enum ipset_adt adt, const struct ip_set_adt_opt *opt) |
| 133 | { | 133 | { |
| 134 | const struct ip_set_hash *h = set->data; | 134 | const struct ip_set_hash *h = set->data; |
| 135 | ipset_adtfn adtfn = set->variant->adt[adt]; | 135 | ipset_adtfn adtfn = set->variant->adt[adt]; |
| 136 | struct hash_ipportip4_elem data = { }; | 136 | struct hash_ipportip4_elem data = { }; |
| 137 | 137 | ||
| 138 | if (!ip_set_get_ip4_port(skb, flags & IPSET_DIM_TWO_SRC, | 138 | if (!ip_set_get_ip4_port(skb, opt->flags & IPSET_DIM_TWO_SRC, |
| 139 | &data.port, &data.proto)) | 139 | &data.port, &data.proto)) |
| 140 | return -EINVAL; | 140 | return -EINVAL; |
| 141 | 141 | ||
| 142 | ip4addrptr(skb, flags & IPSET_DIM_ONE_SRC, &data.ip); | 142 | ip4addrptr(skb, opt->flags & IPSET_DIM_ONE_SRC, &data.ip); |
| 143 | ip4addrptr(skb, flags & IPSET_DIM_THREE_SRC, &data.ip2); | 143 | ip4addrptr(skb, opt->flags & IPSET_DIM_THREE_SRC, &data.ip2); |
| 144 | 144 | ||
| 145 | return adtfn(set, &data, h->timeout, flags); | 145 | return adtfn(set, &data, opt_timeout(opt, h), opt->cmdflags); |
| 146 | } | 146 | } |
| 147 | 147 | ||
| 148 | static int | 148 | static int |
| @@ -343,20 +343,20 @@ nla_put_failure: · 194 unmodified lines | |||
| 343 | 343 | ||
| 344 | static int | 344 | static int |
| 345 | hash_ipportip6_kadt(struct ip_set *set, const struct sk_buff *skb, | 345 | hash_ipportip6_kadt(struct ip_set *set, const struct sk_buff *skb, |
| 346 | enum ipset_adt adt, u8 pf, u8 dim, u8 flags) | 346 | enum ipset_adt adt, const struct ip_set_adt_opt *opt) |
| 347 | { | 347 | { |
| 348 | const struct ip_set_hash *h = set->data; | 348 | const struct ip_set_hash *h = set->data; |
| 349 | ipset_adtfn adtfn = set->variant->adt[adt]; | 349 | ipset_adtfn adtfn = set->variant->adt[adt]; |
| 350 | struct hash_ipportip6_elem data = { }; | 350 | struct hash_ipportip6_elem data = { }; |
| 351 | 351 | ||
| 352 | if (!ip_set_get_ip6_port(skb, flags & IPSET_DIM_TWO_SRC, | 352 | if (!ip_set_get_ip6_port(skb, opt->flags & IPSET_DIM_TWO_SRC, |
| 353 | &data.port, &data.proto)) | 353 | &data.port, &data.proto)) |
| 354 | return -EINVAL; | 354 | return -EINVAL; |
| 355 | 355 | ||
| 356 | ip6addrptr(skb, flags & IPSET_DIM_ONE_SRC, &data.ip.in6); | 356 | ip6addrptr(skb, opt->flags & IPSET_DIM_ONE_SRC, &data.ip.in6); |
| 357 | ip6addrptr(skb, flags & IPSET_DIM_THREE_SRC, &data.ip2.in6); | 357 | ip6addrptr(skb, opt->flags & IPSET_DIM_THREE_SRC, &data.ip2.in6); |
| 358 | 358 | ||
| 359 | return adtfn(set, &data, h->timeout, flags); | 359 | return adtfn(set, &data, opt_timeout(opt, h), opt->cmdflags); |
| 360 | } | 360 | } |
| 361 | 361 | ||
| 362 | static int | 362 | static int |
| @@ -142,7 +142,7 @@ nla_put_failure: · 141 unmodified lines | |||
| 142 | 142 | ||
| 143 | static int | 143 | static int |
| 144 | hash_ipportnet4_kadt(struct ip_set *set, const struct sk_buff *skb, | 144 | hash_ipportnet4_kadt(struct ip_set *set, const struct sk_buff *skb, |
| 145 | enum ipset_adt adt, u8 pf, u8 dim, u8 flags) | 145 | enum ipset_adt adt, const struct ip_set_adt_opt *opt) |
| 146 | { | 146 | { |
| 147 | const struct ip_set_hash *h = set->data; | 147 | const struct ip_set_hash *h = set->data; |
| 148 | ipset_adtfn adtfn = set->variant->adt[adt]; | 148 | ipset_adtfn adtfn = set->variant->adt[adt]; |
| @@ -154,15 +154,15 @@ hash_ipportnet4_kadt(struct ip_set *set, const struct sk_buff *skb, · 5 unmodified lines | |||
| 154 | if (adt == IPSET_TEST) | 154 | if (adt == IPSET_TEST) |
| 155 | data.cidr = HOST_MASK; | 155 | data.cidr = HOST_MASK; |
| 156 | 156 | ||
| 157 | if (!ip_set_get_ip4_port(skb, flags & IPSET_DIM_TWO_SRC, | 157 | if (!ip_set_get_ip4_port(skb, opt->flags & IPSET_DIM_TWO_SRC, |
| 158 | &data.port, &data.proto)) | 158 | &data.port, &data.proto)) |
| 159 | return -EINVAL; | 159 | return -EINVAL; |
| 160 | 160 | ||
| 161 | ip4addrptr(skb, flags & IPSET_DIM_ONE_SRC, &data.ip); | 161 | ip4addrptr(skb, opt->flags & IPSET_DIM_ONE_SRC, &data.ip); |
| 162 | ip4addrptr(skb, flags & IPSET_DIM_THREE_SRC, &data.ip2); | 162 | ip4addrptr(skb, opt->flags & IPSET_DIM_THREE_SRC, &data.ip2); |
| 163 | data.ip2 &= ip_set_netmask(data.cidr); | 163 | data.ip2 &= ip_set_netmask(data.cidr); |
| 164 | 164 | ||
| 165 | return adtfn(set, &data, h->timeout, flags); | 165 | return adtfn(set, &data, opt_timeout(opt, h), opt->cmdflags); |
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | static int | 168 | static int |
| @@ -390,7 +390,7 @@ nla_put_failure: · 221 unmodified lines | |||
| 390 | 390 | ||
| 391 | static int | 391 | static int |
| 392 | hash_ipportnet6_kadt(struct ip_set *set, const struct sk_buff *skb, | 392 | hash_ipportnet6_kadt(struct ip_set *set, const struct sk_buff *skb, |
| 393 | enum ipset_adt adt, u8 pf, u8 dim, u8 flags) | 393 | enum ipset_adt adt, const struct ip_set_adt_opt *opt) |
| 394 | { | 394 | { |
| 395 | const struct ip_set_hash *h = set->data; | 395 | const struct ip_set_hash *h = set->data; |
| 396 | ipset_adtfn adtfn = set->variant->adt[adt]; | 396 | ipset_adtfn adtfn = set->variant->adt[adt]; |
| @@ -402,15 +402,15 @@ hash_ipportnet6_kadt(struct ip_set *set, const struct sk_buff *skb, · 5 unmodified lines | |||
| 402 | if (adt == IPSET_TEST) | 402 | if (adt == IPSET_TEST) |
| 403 | data.cidr = HOST_MASK; | 403 | data.cidr = HOST_MASK; |
| 404 | 404 | ||
| 405 | if (!ip_set_get_ip6_port(skb, flags & IPSET_DIM_TWO_SRC, | 405 | if (!ip_set_get_ip6_port(skb, opt->flags & IPSET_DIM_TWO_SRC, |
| 406 | &data.port, &data.proto)) | 406 | &data.port, &data.proto)) |
| 407 | return -EINVAL; | 407 | return -EINVAL; |
| 408 | 408 | ||
| 409 | ip6addrptr(skb, flags & IPSET_DIM_ONE_SRC, &data.ip.in6); | 409 | ip6addrptr(skb, opt->flags & IPSET_DIM_ONE_SRC, &data.ip.in6); |
| 410 | ip6addrptr(skb, flags & IPSET_DIM_THREE_SRC, &data.ip2.in6); | 410 | ip6addrptr(skb, opt->flags & IPSET_DIM_THREE_SRC, &data.ip2.in6); |
| 411 | ip6_netmask(&data.ip2, data.cidr); | 411 | ip6_netmask(&data.ip2, data.cidr); |
| 412 | 412 | ||
| 413 | return adtfn(set, &data, h->timeout, flags); | 413 | return adtfn(set, &data, opt_timeout(opt, h), opt->cmdflags); |
| 414 | } | 414 | } |
| 415 | 415 | ||
| 416 | static int | 416 | static int |
| @@ -127,7 +127,7 @@ nla_put_failure: · 126 unmodified lines | |||
| 127 | 127 | ||
| 128 | static int | 128 | static int |
| 129 | hash_net4_kadt(struct ip_set *set, const struct sk_buff *skb, | 129 | hash_net4_kadt(struct ip_set *set, const struct sk_buff *skb, |
| 130 | enum ipset_adt adt, u8 pf, u8 dim, u8 flags) | 130 | enum ipset_adt adt, const struct ip_set_adt_opt *opt) |
| 131 | { | 131 | { |
| 132 | const struct ip_set_hash *h = set->data; | 132 | const struct ip_set_hash *h = set->data; |
| 133 | ipset_adtfn adtfn = set->variant->adt[adt]; | 133 | ipset_adtfn adtfn = set->variant->adt[adt]; |
| @@ -138,10 +138,10 @@ hash_net4_kadt(struct ip_set *set, const struct sk_buff *skb, · 4 unmodified lines | |||
| 138 | if (adt == IPSET_TEST) | 138 | if (adt == IPSET_TEST) |
| 139 | data.cidr = HOST_MASK; | 139 | data.cidr = HOST_MASK; |
| 140 | 140 | ||
| 141 | ip4addrptr(skb, flags & IPSET_DIM_ONE_SRC, &data.ip); | 141 | ip4addrptr(skb, opt->flags & IPSET_DIM_ONE_SRC, &data.ip); |
| 142 | data.ip &= ip_set_netmask(data.cidr); | 142 | data.ip &= ip_set_netmask(data.cidr); |
| 143 | 143 | ||
| 144 | return adtfn(set, &data, h->timeout, flags); | 144 | return adtfn(set, &data, opt_timeout(opt, h), opt->cmdflags); |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | static int | 147 | static int |
| @@ -292,7 +292,7 @@ nla_put_failure: · 144 unmodified lines | |||
| 292 | 292 | ||
| 293 | static int | 293 | static int |
| 294 | hash_net6_kadt(struct ip_set *set, const struct sk_buff *skb, | 294 | hash_net6_kadt(struct ip_set *set, const struct sk_buff *skb, |
| 295 | enum ipset_adt adt, u8 pf, u8 dim, u8 flags) | 295 | enum ipset_adt adt, const struct ip_set_adt_opt *opt) |
| 296 | { | 296 | { |
| 297 | const struct ip_set_hash *h = set->data; | 297 | const struct ip_set_hash *h = set->data; |
| 298 | ipset_adtfn adtfn = set->variant->adt[adt]; | 298 | ipset_adtfn adtfn = set->variant->adt[adt]; |
| @@ -303,10 +303,10 @@ hash_net6_kadt(struct ip_set *set, const struct sk_buff *skb, · 4 unmodified lines | |||
| 303 | if (adt == IPSET_TEST) | 303 | if (adt == IPSET_TEST) |
| 304 | data.cidr = HOST_MASK; | 304 | data.cidr = HOST_MASK; |
| 305 | 305 | ||
| 306 | ip6addrptr(skb, flags & IPSET_DIM_ONE_SRC, &data.ip.in6); | 306 | ip6addrptr(skb, opt->flags & IPSET_DIM_ONE_SRC, &data.ip.in6); |
| 307 | ip6_netmask(&data.ip, data.cidr); | 307 | ip6_netmask(&data.ip, data.cidr); |
| 308 | 308 | ||
| 309 | return adtfn(set, &data, h->timeout, flags); | 309 | return adtfn(set, &data, opt_timeout(opt, h), opt->cmdflags); |
| 310 | } | 310 | } |
| 311 | 311 | ||
| 312 | static int | 312 | static int |
| @@ -139,7 +139,7 @@ nla_put_failure: · 138 unmodified lines | |||
| 139 | 139 | ||
| 140 | static int | 140 | static int |
| 141 | hash_netport4_kadt(struct ip_set *set, const struct sk_buff *skb, | 141 | hash_netport4_kadt(struct ip_set *set, const struct sk_buff *skb, |
| 142 | enum ipset_adt adt, u8 pf, u8 dim, u8 flags) | 142 | enum ipset_adt adt, const struct ip_set_adt_opt *opt) |
| 143 | { | 143 | { |
| 144 | const struct ip_set_hash *h = set->data; | 144 | const struct ip_set_hash *h = set->data; |
| 145 | ipset_adtfn adtfn = set->variant->adt[adt]; | 145 | ipset_adtfn adtfn = set->variant->adt[adt]; |
| @@ -151,14 +151,14 @@ hash_netport4_kadt(struct ip_set *set, const struct sk_buff *skb, · 5 unmodified lines | |||
| 151 | if (adt == IPSET_TEST) | 151 | if (adt == IPSET_TEST) |
| 152 | data.cidr = HOST_MASK; | 152 | data.cidr = HOST_MASK; |
| 153 | 153 | ||
| 154 | if (!ip_set_get_ip4_port(skb, flags & IPSET_DIM_TWO_SRC, | 154 | if (!ip_set_get_ip4_port(skb, opt->flags & IPSET_DIM_TWO_SRC, |
| 155 | &data.port, &data.proto)) | 155 | &data.port, &data.proto)) |
| 156 | return -EINVAL; | 156 | return -EINVAL; |
| 157 | 157 | ||
| 158 | ip4addrptr(skb, flags & IPSET_DIM_ONE_SRC, &data.ip); | 158 | ip4addrptr(skb, opt->flags & IPSET_DIM_ONE_SRC, &data.ip); |
| 159 | data.ip &= ip_set_netmask(data.cidr); | 159 | data.ip &= ip_set_netmask(data.cidr); |
| 160 | 160 | ||
| 161 | return adtfn(set, &data, h->timeout, flags); | 161 | return adtfn(set, &data, opt_timeout(opt, h), opt->cmdflags); |
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | static int | 164 | static int |
| @@ -352,7 +352,7 @@ nla_put_failure: · 187 unmodified lines | |||
| 352 | 352 | ||
| 353 | static int | 353 | static int |
| 354 | hash_netport6_kadt(struct ip_set *set, const struct sk_buff *skb, | 354 | hash_netport6_kadt(struct ip_set *set, const struct sk_buff *skb, |
| 355 | enum ipset_adt adt, u8 pf, u8 dim, u8 flags) | 355 | enum ipset_adt adt, const struct ip_set_adt_opt *opt) |
| 356 | { | 356 | { |
| 357 | const struct ip_set_hash *h = set->data; | 357 | const struct ip_set_hash *h = set->data; |
| 358 | ipset_adtfn adtfn = set->variant->adt[adt]; | 358 | ipset_adtfn adtfn = set->variant->adt[adt]; |
| @@ -364,14 +364,14 @@ hash_netport6_kadt(struct ip_set *set, const struct sk_buff *skb, · 5 unmodified lines | |||
| 364 | if (adt == IPSET_TEST) | 364 | if (adt == IPSET_TEST) |
| 365 | data.cidr = HOST_MASK; | 365 | data.cidr = HOST_MASK; |
| 366 | 366 | ||
| 367 | if (!ip_set_get_ip6_port(skb, flags & IPSET_DIM_TWO_SRC, | 367 | if (!ip_set_get_ip6_port(skb, opt->flags & IPSET_DIM_TWO_SRC, |
| 368 | &data.port, &data.proto)) | 368 | &data.port, &data.proto)) |
| 369 | return -EINVAL; | 369 | return -EINVAL; |
| 370 | 370 | ||
| 371 | ip6addrptr(skb, flags & IPSET_DIM_ONE_SRC, &data.ip.in6); | 371 | ip6addrptr(skb, opt->flags & IPSET_DIM_ONE_SRC, &data.ip.in6); |
| 372 | ip6_netmask(&data.ip, data.cidr); | 372 | ip6_netmask(&data.ip, data.cidr); |
| 373 | 373 | ||
| 374 | return adtfn(set, &data, h->timeout, flags); | 374 | return adtfn(set, &data, opt_timeout(opt, h), opt->cmdflags); |
| 375 | } | 375 | } |
| 376 | 376 | ||
| 377 | static int | 377 | static int |
| @@ -72,7 +72,7 @@ list_set_expired(const struct list_set *map, u32 id) · 71 unmodified lines | |||
| 72 | 72 | ||
| 73 | static int | 73 | static int |
| 74 | list_set_kadt(struct ip_set *set, const struct sk_buff *skb, | 74 | list_set_kadt(struct ip_set *set, const struct sk_buff *skb, |
| 75 | enum ipset_adt adt, u8 pf, u8 dim, u8 flags) | 75 | enum ipset_adt adt, const struct ip_set_adt_opt *opt) |
| 76 | { | 76 | { |
| 77 | struct list_set *map = set->data; | 77 | struct list_set *map = set->data; |
| 78 | struct set_elem *elem; | 78 | struct set_elem *elem; |
| @@ -87,17 +87,17 @@ list_set_kadt(struct ip_set *set, const struct sk_buff *skb, · 8 unmodified lines | |||
| 87 | continue; | 87 | continue; |
| 88 | switch (adt) { | 88 | switch (adt) { |
| 89 | case IPSET_TEST: | 89 | case IPSET_TEST: |
| 90 | ret = ip_set_test(elem->id, skb, pf, dim, flags); | 90 | ret = ip_set_test(elem->id, skb, opt); |
| 91 | if (ret > 0) | 91 | if (ret > 0) |
| 92 | return ret; | 92 | return ret; |
| 93 | break; | 93 | break; |
| 94 | case IPSET_ADD: | 94 | case IPSET_ADD: |
| 95 | ret = ip_set_add(elem->id, skb, pf, dim, flags); | 95 | ret = ip_set_add(elem->id, skb, opt); |
| 96 | if (ret == 0) | 96 | if (ret == 0) |
| 97 | return ret; | 97 | return ret; |
| 98 | break; | 98 | break; |
| 99 | case IPSET_DEL: | 99 | case IPSET_DEL: |
| 100 | ret = ip_set_del(elem->id, skb, pf, dim, flags); | 100 | ret = ip_set_del(elem->id, skb, opt); |
| 101 | if (ret == 0) | 101 | if (ret == 0) |
| 102 | return ret; | 102 | return ret; |
| 103 | break; | 103 | break; |
| @@ -29,23 +29,32 @@ MODULE_ALIAS("ip6t_SET"); · 28 unmodified lines | |||
| 29 | 29 | ||
| 30 | static inline int | 30 | static inline int |
| 31 | match_set(ip_set_id_t index, const struct sk_buff *skb, | 31 | match_set(ip_set_id_t index, const struct sk_buff *skb, |
| 32 | u8 pf, u8 dim, u8 flags, int inv) | 32 | const struct ip_set_adt_opt *opt, int inv) |
| 33 | { | 33 | { |
| 34 | if (ip_set_test(index, skb, pf, dim, flags)) | 34 | if (ip_set_test(index, skb, opt)) |
| 35 | inv = !inv; | 35 | inv = !inv; |
| 36 | return inv; | 36 | return inv; |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | #define ADT_OPT(n, f, d, fs, cfs, t) \ | ||
| 40 | const struct ip_set_adt_opt n = { \ | ||
| 41 | .family = f, \ | ||
| 42 | .dim = d, \ | ||
| 43 | .flags = fs, \ | ||
| 44 | .cmdflags = cfs, \ | ||
| 45 | .timeout = t, \ | ||
| 46 | } | ||
| 47 | |||
| 39 | /* Revision 0 interface: backward compatible with netfilter/iptables */ | 48 | /* Revision 0 interface: backward compatible with netfilter/iptables */ |
| 40 | 49 | ||
| 41 | static bool | 50 | static bool |
| 42 | set_match_v0(const struct sk_buff *skb, struct xt_action_param *par) | 51 | set_match_v0(const struct sk_buff *skb, struct xt_action_param *par) |
| 43 | { | 52 | { |
| 44 | const struct xt_set_info_match_v0 *info = par->matchinfo; | 53 | const struct xt_set_info_match_v0 *info = par->matchinfo; |
| 54 | ADT_OPT(opt, par->family, info->match_set.u.compat.dim, | ||
| 55 | info->match_set.u.compat.flags, 0, UINT_MAX); | ||
| 45 | 56 | ||
| 46 | return match_set(info->match_set.index, skb, par->family, | 57 | return match_set(info->match_set.index, skb, &opt, |
| 47 | info->match_set.u.compat.dim, | ||
| 48 | info->match_set.u.compat.flags, | ||
| 49 | info->match_set.u.compat.flags & IPSET_INV_MATCH); | 58 | info->match_set.u.compat.flags & IPSET_INV_MATCH); |
| 50 | } | 59 | } |
| 51 | 60 | ||
| @@ -103,15 +112,15 @@ static unsigned int · 51 unmodified lines | |||
| 103 | set_target_v0(struct sk_buff *skb, const struct xt_action_param *par) | 112 | set_target_v0(struct sk_buff *skb, const struct xt_action_param *par) |
| 104 | { | 113 | { |
| 105 | const struct xt_set_info_target_v0 *info = par->targinfo; | 114 | const struct xt_set_info_target_v0 *info = par->targinfo; |
| 115 | ADT_OPT(add_opt, par->family, info->add_set.u.compat.dim, | ||
| 116 | info->add_set.u.compat.flags, 0, UINT_MAX); | ||
| 117 | ADT_OPT(del_opt, par->family, info->del_set.u.compat.dim, | ||
| 118 | info->del_set.u.compat.flags, 0, UINT_MAX); | ||
| 106 | 119 | ||
| 107 | if (info->add_set.index != IPSET_INVALID_ID) | 120 | if (info->add_set.index != IPSET_INVALID_ID) |
| 108 | ip_set_add(info->add_set.index, skb, par->family, | 121 | ip_set_add(info->add_set.index, skb, &add_opt); |
| 109 | info->add_set.u.compat.dim, | ||
| 110 | info->add_set.u.compat.flags); | ||
| 111 | if (info->del_set.index != IPSET_INVALID_ID) | 122 | if (info->del_set.index != IPSET_INVALID_ID) |
| 112 | ip_set_del(info->del_set.index, skb, par->family, | 123 | ip_set_del(info->del_set.index, skb, &del_opt); |
| 113 | info->del_set.u.compat.dim, | ||
| 114 | info->del_set.u.compat.flags); | ||
| 115 | 124 | ||
| 116 | return XT_CONTINUE; | 125 | return XT_CONTINUE; |
| 117 | } | 126 | } |
| @@ -170,23 +179,23 @@ set_target_v0_destroy(const struct xt_tgdtor_param *par) · 52 unmodified lines | |||
| 170 | ip_set_nfnl_put(info->del_set.index); | 179 | ip_set_nfnl_put(info->del_set.index); |
| 171 | } | 180 | } |
| 172 | 181 | ||
| 173 | /* Revision 1: current interface to netfilter/iptables */ | 182 | /* Revision 1 match and target */ |
| 174 | 183 | ||
| 175 | static bool | 184 | static bool |
| 176 | set_match(const struct sk_buff *skb, struct xt_action_param *par) | 185 | set_match_v1(const struct sk_buff *skb, struct xt_action_param *par) |
| 177 | { | 186 | { |
| 178 | const struct xt_set_info_match *info = par->matchinfo; | 187 | const struct xt_set_info_match_v1 *info = par->matchinfo; |
| 188 | ADT_OPT(opt, par->family, info->match_set.dim, | ||
| 189 | info->match_set.flags, 0, UINT_MAX); | ||
| 179 | 190 | ||
| 180 | return match_set(info->match_set.index, skb, par->family, | 191 | return match_set(info->match_set.index, skb, &opt, |
| 181 | info->match_set.dim, | ||
| 182 | info->match_set.flags, | ||
| 183 | info->match_set.flags & IPSET_INV_MATCH); | 192 | info->match_set.flags & IPSET_INV_MATCH); |
| 184 | } | 193 | } |
| 185 | 194 | ||
| 186 | static int | 195 | static int |
| 187 | set_match_checkentry(const struct xt_mtchk_param *par) | 196 | set_match_v1_checkentry(const struct xt_mtchk_param *par) |
| 188 | { | 197 | { |
| 189 | struct xt_set_info_match *info = par->matchinfo; | 198 | struct xt_set_info_match_v1 *info = par->matchinfo; |
| 190 | ip_set_id_t index; | 199 | ip_set_id_t index; |
| 191 | 200 | ||
| 192 | index = ip_set_nfnl_get_byindex(info->match_set.index); | 201 | index = ip_set_nfnl_get_byindex(info->match_set.index); |
| @@ -207,36 +216,34 @@ set_match_checkentry(const struct xt_mtchk_param *par) · 14 unmodified lines | |||
| 207 | } | 216 | } |
| 208 | 217 | ||
| 209 | static void | 218 | static void |
| 210 | set_match_destroy(const struct xt_mtdtor_param *par) | 219 | set_match_v1_destroy(const struct xt_mtdtor_param *par) |
| 211 | { | 220 | { |
| 212 | struct xt_set_info_match *info = par->matchinfo; | 221 | struct xt_set_info_match_v1 *info = par->matchinfo; |
| 213 | 222 | ||
| 214 | ip_set_nfnl_put(info->match_set.index); | 223 | ip_set_nfnl_put(info->match_set.index); |
| 215 | } | 224 | } |
| 216 | 225 | ||
| 217 | static unsigned int | 226 | static unsigned int |
| 218 | set_target(struct sk_buff *skb, const struct xt_action_param *par) | 227 | set_target_v1(struct sk_buff *skb, const struct xt_action_param *par) |
| 219 | { | 228 | { |
| 220 | const struct xt_set_info_target *info = par->targinfo; | 229 | const struct xt_set_info_target_v1 *info = par->targinfo; |
| 230 | ADT_OPT(add_opt, par->family, info->add_set.dim, | ||
| 231 | info->add_set.flags, 0, UINT_MAX); | ||
| 232 | ADT_OPT(del_opt, par->family, info->del_set.dim, | ||
| 233 | info->del_set.flags, 0, UINT_MAX); | ||
| 221 | 234 | ||
| 222 | if (info->add_set.index != IPSET_INVALID_ID) | 235 | if (info->add_set.index != IPSET_INVALID_ID) |
| 223 | ip_set_add(info->add_set.index, | 236 | ip_set_add(info->add_set.index, skb, &add_opt); |
| 224 | skb, par->family, | ||
| 225 | info->add_set.dim, | ||
| 226 | info->add_set.flags); | ||
| 227 | if (info->del_set.index != IPSET_INVALID_ID) | 237 | if (info->del_set.index != IPSET_INVALID_ID) |
| 228 | ip_set_del(info->del_set.index, | 238 | ip_set_del(info->del_set.index, skb, &del_opt); |
| 229 | skb, par->family, | ||
| 230 | info->del_set.dim, | ||
| 231 | info->del_set.flags); | ||
| 232 | 239 | ||
| 233 | return XT_CONTINUE; | 240 | return XT_CONTINUE; |
| 234 | } | 241 | } |
| 235 | 242 | ||
| 236 | static int | 243 | static int |
| 237 | set_target_checkentry(const struct xt_tgchk_param *par) | 244 | set_target_v1_checkentry(const struct xt_tgchk_param *par) |
| 238 | { | 245 | { |
| 239 | const struct xt_set_info_target *info = par->targinfo; | 246 | const struct xt_set_info_target_v1 *info = par->targinfo; |
| 240 | ip_set_id_t index; | 247 | ip_set_id_t index; |
| 241 | 248 | ||
| 242 | if (info->add_set.index != IPSET_INVALID_ID) { | 249 | if (info->add_set.index != IPSET_INVALID_ID) { |
| @@ -273,9 +280,9 @@ set_target_checkentry(const struct xt_tgchk_param *par) · 30 unmodified lines | |||
| 273 | } | 280 | } |
| 274 | 281 | ||
| 275 | static void | 282 | static void |
| 276 | set_target_destroy(const struct xt_tgdtor_param *par) | 283 | set_target_v1_destroy(const struct xt_tgdtor_param *par) |
| 277 | { | 284 | { |
| 278 | const struct xt_set_info_target *info = par->targinfo; | 285 | const struct xt_set_info_target_v1 *info = par->targinfo; |
| 279 | 286 | ||
| 280 | if (info->add_set.index != IPSET_INVALID_ID) | 287 | if (info->add_set.index != IPSET_INVALID_ID) |
| 281 | ip_set_nfnl_put(info->add_set.index); | 288 | ip_set_nfnl_put(info->add_set.index); |
| @@ -283,6 +290,28 @@ set_target_destroy(const struct xt_tgdtor_param *par) · 1 unmodified line | |||
| 283 | ip_set_nfnl_put(info->del_set.index); | 290 | ip_set_nfnl_put(info->del_set.index); |
| 284 | } | 291 | } |
| 285 | 292 | ||
| 293 | /* Revision 2 target */ | ||
| 294 | |||
| 295 | static unsigned int | ||
| 296 | set_target_v2(struct sk_buff *skb, const struct xt_action_param *par) | ||
| 297 | { | ||
| 298 | const struct xt_set_info_target_v2 *info = par->targinfo; | ||
| 299 | ADT_OPT(add_opt, par->family, info->add_set.dim, | ||
| 300 | info->add_set.flags, info->flags, info->timeout); | ||
| 301 | ADT_OPT(del_opt, par->family, info->del_set.dim, | ||
| 302 | info->del_set.flags, 0, UINT_MAX); | ||
| 303 | |||
| 304 | if (info->add_set.index != IPSET_INVALID_ID) | ||
| 305 | ip_set_add(info->add_set.index, skb, &add_opt); | ||
| 306 | if (info->del_set.index != IPSET_INVALID_ID) | ||
| 307 | ip_set_del(info->del_set.index, skb, &del_opt); | ||
| 308 | |||
| 309 | return XT_CONTINUE; | ||
| 310 | } | ||
| 311 | |||
| 312 | #define set_target_v2_checkentry set_target_v1_checkentry | ||
| 313 | #define set_target_v2_destroy set_target_v1_destroy | ||
| 314 | |||
| 286 | static struct xt_match set_matches[] __read_mostly = { | 315 | static struct xt_match set_matches[] __read_mostly = { |
| 287 | { | 316 | { |
| 288 | .name = "set", | 317 | .name = "set", |
| @@ -298,20 +327,20 @@ static struct xt_match set_matches[] __read_mostly = { · 9 unmodified lines | |||
| 298 | .name = "set", | 327 | .name = "set", |
| 299 | .family = NFPROTO_IPV4, | 328 | .family = NFPROTO_IPV4, |
| 300 | .revision = 1, | 329 | .revision = 1, |
| 301 | .match = set_match, | 330 | .match = set_match_v1, |
| 302 | .matchsize = sizeof(struct xt_set_info_match), | 331 | .matchsize = sizeof(struct xt_set_info_match_v1), |
| 303 | .checkentry = set_match_checkentry, | 332 | .checkentry = set_match_v1_checkentry, |
| 304 | .destroy = set_match_destroy, | 333 | .destroy = set_match_v1_destroy, |
| 305 | .me = THIS_MODULE | 334 | .me = THIS_MODULE |
| 306 | }, | 335 | }, |
| 307 | { | 336 | { |
| 308 | .name = "set", | 337 | .name = "set", |
| 309 | .family = NFPROTO_IPV6, | 338 | .family = NFPROTO_IPV6, |
| 310 | .revision = 1, | 339 | .revision = 1, |
| 311 | .match = set_match, | 340 | .match = set_match_v1, |
| 312 | .matchsize = sizeof(struct xt_set_info_match), | 341 | .matchsize = sizeof(struct xt_set_info_match_v1), |
| 313 | .checkentry = set_match_checkentry, | 342 | .checkentry = set_match_v1_checkentry, |
| 314 | .destroy = set_match_destroy, | 343 | .destroy = set_match_v1_destroy, |
| 315 | .me = THIS_MODULE | 344 | .me = THIS_MODULE |
| 316 | }, | 345 | }, |
| 317 | }; | 346 | }; |
| @@ -331,20 +360,40 @@ static struct xt_target set_targets[] __read_mostly = { · 13 unmodified lines | |||
| 331 | .name = "SET", | 360 | .name = "SET", |
| 332 | .revision = 1, | 361 | .revision = 1, |
| 333 | .family = NFPROTO_IPV4, | 362 | .family = NFPROTO_IPV4, |
| 334 | .target = set_target, | 363 | .target = set_target_v1, |
| 335 | .targetsize = sizeof(struct xt_set_info_target), | 364 | .targetsize = sizeof(struct xt_set_info_target_v1), |
| 336 | .checkentry = set_target_checkentry, | 365 | .checkentry = set_target_v1_checkentry, |
| 337 | .destroy = set_target_destroy, | 366 | .destroy = set_target_v1_destroy, |
| 338 | .me = THIS_MODULE | 367 | .me = THIS_MODULE |
| 339 | }, | 368 | }, |
| 340 | { | 369 | { |
| 341 | .name = "SET", | 370 | .name = "SET", |
| 342 | .revision = 1, | 371 | .revision = 1, |
| 343 | .family = NFPROTO_IPV6, | 372 | .family = NFPROTO_IPV6, |
| 344 | .target = set_target, | 373 | .target = set_target_v1, |
| 345 | .targetsize = sizeof(struct xt_set_info_target), | 374 | .targetsize = sizeof(struct xt_set_info_target_v1), |
| 346 | .checkentry = set_target_checkentry, | 375 | .checkentry = set_target_v1_checkentry, |
| 347 | .destroy = set_target_destroy, | 376 | .destroy = set_target_v1_destroy, |
| 377 | .me = THIS_MODULE | ||
| 378 | }, | ||
| 379 | { | ||
| 380 | .name = "SET", | ||
| 381 | .revision = 2, | ||
| 382 | .family = NFPROTO_IPV4, | ||
| 383 | .target = set_target_v2, | ||
| 384 | .targetsize = sizeof(struct xt_set_info_target_v2), | ||
| 385 | .checkentry = set_target_v2_checkentry, | ||
| 386 | .destroy = set_target_v2_destroy, | ||
| 387 | .me = THIS_MODULE | ||
| 388 | }, | ||
| 389 | { | ||
| 390 | .name = "SET", | ||
| 391 | .revision = 2, | ||
| 392 | .family = NFPROTO_IPV6, | ||
| 393 | .target = set_target_v2, | ||
| 394 | .targetsize = sizeof(struct xt_set_info_target_v2), | ||
| 395 | .checkentry = set_target_v2_checkentry, | ||
| 396 | .destroy = set_target_v2_destroy, | ||
| 348 | .me = THIS_MODULE | 397 | .me = THIS_MODULE |
| 349 | }, | 398 | }, |
| 350 | }; | 399 | }; |