Skip to content

Commit b66554c

Browse files
Jozsef Kadlecsikkaber
authored andcommitted
netfilter: ipset: add xt_action_param to the variant level kadt functions, ipset API change
With the change the sets can use any parameter available for the match and target extensions, like input/output interface. It's required for the hash:net,iface set type. Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> Signed-off-by: Patrick McHardy <kaber@trash.net>
1 parent e6146e8 commit b66554c

14 files changed

Lines changed: 43 additions & 16 deletions

‎include/linux/netfilter/ipset/ip_set.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ enum ipset_adt {
170170
#include <linux/ipv6.h>
171171
#include <linux/netlink.h>
172172
#include <linux/netfilter.h>
173+
#include <linux/netfilter/x_tables.h>
173174
#include <linux/vmalloc.h>
174175
#include <net/netlink.h>
175176

@@ -238,6 +239,7 @@ struct ip_set_type_variant {
238239
* zero for no match/success to add/delete
239240
* positive for matching element */
240241
int (*kadt)(struct ip_set *set, const struct sk_buff * skb,
242+
const struct xt_action_param *par,
241243
enum ipset_adt adt, const struct ip_set_adt_opt *opt);
242244

243245
/* Userspace: test/add/del entries
@@ -332,10 +334,13 @@ extern void ip_set_nfnl_put(ip_set_id_t index);
332334
/* API for iptables set match, and SET target */
333335

334336
extern int ip_set_add(ip_set_id_t id, const struct sk_buff *skb,
337+
const struct xt_action_param *par,
335338
const struct ip_set_adt_opt *opt);
336339
extern int ip_set_del(ip_set_id_t id, const struct sk_buff *skb,
340+
const struct xt_action_param *par,
337341
const struct ip_set_adt_opt *opt);
338342
extern int ip_set_test(ip_set_id_t id, const struct sk_buff *skb,
343+
const struct xt_action_param *par,
339344
const struct ip_set_adt_opt *opt);
340345

341346
/* Utility functions */

‎include/linux/netfilter/ipset/ip_set_ahash.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,7 @@ type_pf_list(const struct ip_set *set,
599599

600600
static int
601601
type_pf_kadt(struct ip_set *set, const struct sk_buff * skb,
602+
const struct xt_action_param *par,
602603
enum ipset_adt adt, const struct ip_set_adt_opt *opt);
603604
static int
604605
type_pf_uadt(struct ip_set *set, struct nlattr *tb[],

‎net/netfilter/ipset/ip_set_bitmap_ip.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ bitmap_ip_tlist(const struct ip_set *set,
219219

220220
static int
221221
bitmap_ip_kadt(struct ip_set *set, const struct sk_buff *skb,
222+
const struct xt_action_param *par,
222223
enum ipset_adt adt, const struct ip_set_adt_opt *opt)
223224
{
224225
struct bitmap_ip *map = set->data;

‎net/netfilter/ipset/ip_set_bitmap_ipmac.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ bitmap_ipmac_tlist(const struct ip_set *set,
338338

339339
static int
340340
bitmap_ipmac_kadt(struct ip_set *set, const struct sk_buff *skb,
341+
const struct xt_action_param *par,
341342
enum ipset_adt adt, const struct ip_set_adt_opt *opt)
342343
{
343344
struct bitmap_ipmac *map = set->data;

‎net/netfilter/ipset/ip_set_bitmap_port.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ bitmap_port_tlist(const struct ip_set *set,
208208

209209
static int
210210
bitmap_port_kadt(struct ip_set *set, const struct sk_buff *skb,
211+
const struct xt_action_param *par,
211212
enum ipset_adt adt, const struct ip_set_adt_opt *opt)
212213
{
213214
struct bitmap_port *map = set->data;

‎net/netfilter/ipset/ip_set_core.c‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <net/netlink.h>
2222

2323
#include <linux/netfilter.h>
24+
#include <linux/netfilter/x_tables.h>
2425
#include <linux/netfilter/nfnetlink.h>
2526
#include <linux/netfilter/ipset/ip_set.h>
2627

@@ -328,6 +329,7 @@ __ip_set_put(ip_set_id_t index)
328329

329330
int
330331
ip_set_test(ip_set_id_t index, const struct sk_buff *skb,
332+
const struct xt_action_param *par,
331333
const struct ip_set_adt_opt *opt)
332334
{
333335
struct ip_set *set = ip_set_list[index];
@@ -341,14 +343,14 @@ ip_set_test(ip_set_id_t index, const struct sk_buff *skb,
341343
return 0;
342344

343345
read_lock_bh(&set->lock);
344-
ret = set->variant->kadt(set, skb, IPSET_TEST, opt);
346+
ret = set->variant->kadt(set, skb, par, IPSET_TEST, opt);
345347
read_unlock_bh(&set->lock);
346348

347349
if (ret == -EAGAIN) {
348350
/* Type requests element to be completed */
349351
pr_debug("element must be competed, ADD is triggered\n");
350352
write_lock_bh(&set->lock);
351-
set->variant->kadt(set, skb, IPSET_ADD, opt);
353+
set->variant->kadt(set, skb, par, IPSET_ADD, opt);
352354
write_unlock_bh(&set->lock);
353355
ret = 1;
354356
}
@@ -360,6 +362,7 @@ EXPORT_SYMBOL_GPL(ip_set_test);
360362

361363
int
362364
ip_set_add(ip_set_id_t index, const struct sk_buff *skb,
365+
const struct xt_action_param *par,
363366
const struct ip_set_adt_opt *opt)
364367
{
365368
struct ip_set *set = ip_set_list[index];
@@ -373,7 +376,7 @@ ip_set_add(ip_set_id_t index, const struct sk_buff *skb,
373376
return 0;
374377

375378
write_lock_bh(&set->lock);
376-
ret = set->variant->kadt(set, skb, IPSET_ADD, opt);
379+
ret = set->variant->kadt(set, skb, par, IPSET_ADD, opt);
377380
write_unlock_bh(&set->lock);
378381

379382
return ret;
@@ -382,6 +385,7 @@ EXPORT_SYMBOL_GPL(ip_set_add);
382385

383386
int
384387
ip_set_del(ip_set_id_t index, const struct sk_buff *skb,
388+
const struct xt_action_param *par,
385389
const struct ip_set_adt_opt *opt)
386390
{
387391
struct ip_set *set = ip_set_list[index];
@@ -395,7 +399,7 @@ ip_set_del(ip_set_id_t index, const struct sk_buff *skb,
395399
return 0;
396400

397401
write_lock_bh(&set->lock);
398-
ret = set->variant->kadt(set, skb, IPSET_DEL, opt);
402+
ret = set->variant->kadt(set, skb, par, IPSET_DEL, opt);
399403
write_unlock_bh(&set->lock);
400404

401405
return ret;

‎net/netfilter/ipset/ip_set_hash_ip.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ hash_ip4_data_next(struct ip_set_hash *h, const struct hash_ip4_elem *d)
116116

117117
static int
118118
hash_ip4_kadt(struct ip_set *set, const struct sk_buff *skb,
119+
const struct xt_action_param *par,
119120
enum ipset_adt adt, const struct ip_set_adt_opt *opt)
120121
{
121122
const struct ip_set_hash *h = set->data;
@@ -295,6 +296,7 @@ hash_ip6_data_next(struct ip_set_hash *h, const struct hash_ip6_elem *d)
295296

296297
static int
297298
hash_ip6_kadt(struct ip_set *set, const struct sk_buff *skb,
299+
const struct xt_action_param *par,
298300
enum ipset_adt adt, const struct ip_set_adt_opt *opt)
299301
{
300302
const struct ip_set_hash *h = set->data;

‎net/netfilter/ipset/ip_set_hash_ipport.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ hash_ipport4_data_next(struct ip_set_hash *h,
134134

135135
static int
136136
hash_ipport4_kadt(struct ip_set *set, const struct sk_buff *skb,
137+
const struct xt_action_param *par,
137138
enum ipset_adt adt, const struct ip_set_adt_opt *opt)
138139
{
139140
const struct ip_set_hash *h = set->data;
@@ -348,6 +349,7 @@ hash_ipport6_data_next(struct ip_set_hash *h,
348349

349350
static int
350351
hash_ipport6_kadt(struct ip_set *set, const struct sk_buff *skb,
352+
const struct xt_action_param *par,
351353
enum ipset_adt adt, const struct ip_set_adt_opt *opt)
352354
{
353355
const struct ip_set_hash *h = set->data;

‎net/netfilter/ipset/ip_set_hash_ipportip.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ hash_ipportip4_data_next(struct ip_set_hash *h,
137137

138138
static int
139139
hash_ipportip4_kadt(struct ip_set *set, const struct sk_buff *skb,
140+
const struct xt_action_param *par,
140141
enum ipset_adt adt, const struct ip_set_adt_opt *opt)
141142
{
142143
const struct ip_set_hash *h = set->data;
@@ -361,6 +362,7 @@ hash_ipportip6_data_next(struct ip_set_hash *h,
361362

362363
static int
363364
hash_ipportip6_kadt(struct ip_set *set, const struct sk_buff *skb,
365+
const struct xt_action_param *par,
364366
enum ipset_adt adt, const struct ip_set_adt_opt *opt)
365367
{
366368
const struct ip_set_hash *h = set->data;

‎net/netfilter/ipset/ip_set_hash_ipportnet.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ hash_ipportnet4_data_next(struct ip_set_hash *h,
151151

152152
static int
153153
hash_ipportnet4_kadt(struct ip_set *set, const struct sk_buff *skb,
154+
const struct xt_action_param *par,
154155
enum ipset_adt adt, const struct ip_set_adt_opt *opt)
155156
{
156157
const struct ip_set_hash *h = set->data;
@@ -428,6 +429,7 @@ hash_ipportnet6_data_next(struct ip_set_hash *h,
428429

429430
static int
430431
hash_ipportnet6_kadt(struct ip_set *set, const struct sk_buff *skb,
432+
const struct xt_action_param *par,
431433
enum ipset_adt adt, const struct ip_set_adt_opt *opt)
432434
{
433435
const struct ip_set_hash *h = set->data;

0 commit comments

Comments
 (0)