Skip to content

Commit 7d34aa3

Browse files
Phil Sutterummakynes
authored andcommitted
netfilter: nf_tables: Extend nft_expr_ops::dump callback parameters
Add a 'reset' flag just like with nft_object_ops::dump. This will be useful to reset "anonymous stateful objects", e.g. simple rule counters. No functional change intended. Signed-off-by: Phil Sutter <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 7394c2d commit 7d34aa3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+110
-62
lines changed

include/net/netfilter/nf_tables.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,8 @@ struct nft_expr_ops {
927927
void (*destroy_clone)(const struct nft_ctx *ctx,
928928
const struct nft_expr *expr);
929929
int (*dump)(struct sk_buff *skb,
930-
const struct nft_expr *expr);
930+
const struct nft_expr *expr,
931+
bool reset);
931932
int (*validate)(const struct nft_ctx *ctx,
932933
const struct nft_expr *expr,
933934
const struct nft_data **data);

include/net/netfilter/nft_fib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ nft_fib_is_loopback(const struct sk_buff *skb, const struct net_device *in)
1818
return skb->pkt_type == PACKET_LOOPBACK || in->flags & IFF_LOOPBACK;
1919
}
2020

21-
int nft_fib_dump(struct sk_buff *skb, const struct nft_expr *expr);
21+
int nft_fib_dump(struct sk_buff *skb, const struct nft_expr *expr, bool reset);
2222
int nft_fib_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
2323
const struct nlattr * const tb[]);
2424
int nft_fib_validate(const struct nft_ctx *ctx, const struct nft_expr *expr,

include/net/netfilter/nft_meta.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ int nft_meta_set_init(const struct nft_ctx *ctx,
2424
const struct nlattr * const tb[]);
2525

2626
int nft_meta_get_dump(struct sk_buff *skb,
27-
const struct nft_expr *expr);
27+
const struct nft_expr *expr, bool reset);
2828

2929
int nft_meta_set_dump(struct sk_buff *skb,
30-
const struct nft_expr *expr);
30+
const struct nft_expr *expr, bool reset);
3131

3232
void nft_meta_get_eval(const struct nft_expr *expr,
3333
struct nft_regs *regs,

include/net/netfilter/nft_reject.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ int nft_reject_init(const struct nft_ctx *ctx,
2222
const struct nft_expr *expr,
2323
const struct nlattr * const tb[]);
2424

25-
int nft_reject_dump(struct sk_buff *skb, const struct nft_expr *expr);
25+
int nft_reject_dump(struct sk_buff *skb,
26+
const struct nft_expr *expr, bool reset);
2627

2728
int nft_reject_icmp_code(u8 code);
2829
int nft_reject_icmpv6_code(u8 code);

net/ipv4/netfilter/nft_dup_ipv4.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ static int nft_dup_ipv4_init(const struct nft_ctx *ctx,
5252
return err;
5353
}
5454

55-
static int nft_dup_ipv4_dump(struct sk_buff *skb, const struct nft_expr *expr)
55+
static int nft_dup_ipv4_dump(struct sk_buff *skb,
56+
const struct nft_expr *expr, bool reset)
5657
{
5758
struct nft_dup_ipv4 *priv = nft_expr_priv(expr);
5859

net/ipv6/netfilter/nft_dup_ipv6.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ static int nft_dup_ipv6_init(const struct nft_ctx *ctx,
5050
return err;
5151
}
5252

53-
static int nft_dup_ipv6_dump(struct sk_buff *skb, const struct nft_expr *expr)
53+
static int nft_dup_ipv6_dump(struct sk_buff *skb,
54+
const struct nft_expr *expr, bool reset)
5455
{
5556
struct nft_dup_ipv6 *priv = nft_expr_priv(expr);
5657

net/netfilter/nf_tables_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2769,7 +2769,7 @@ static int nf_tables_fill_expr_info(struct sk_buff *skb,
27692769
NFTA_EXPR_DATA);
27702770
if (data == NULL)
27712771
goto nla_put_failure;
2772-
if (expr->ops->dump(skb, expr) < 0)
2772+
if (expr->ops->dump(skb, expr, false) < 0)
27732773
goto nla_put_failure;
27742774
nla_nest_end(skb, data);
27752775
}

net/netfilter/nft_bitwise.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ static int nft_bitwise_dump_shift(struct sk_buff *skb,
232232
return 0;
233233
}
234234

235-
static int nft_bitwise_dump(struct sk_buff *skb, const struct nft_expr *expr)
235+
static int nft_bitwise_dump(struct sk_buff *skb,
236+
const struct nft_expr *expr, bool reset)
236237
{
237238
const struct nft_bitwise *priv = nft_expr_priv(expr);
238239
int err = 0;
@@ -393,7 +394,8 @@ static int nft_bitwise_fast_init(const struct nft_ctx *ctx,
393394
}
394395

395396
static int
396-
nft_bitwise_fast_dump(struct sk_buff *skb, const struct nft_expr *expr)
397+
nft_bitwise_fast_dump(struct sk_buff *skb,
398+
const struct nft_expr *expr, bool reset)
397399
{
398400
const struct nft_bitwise_fast_expr *priv = nft_expr_priv(expr);
399401
struct nft_data data;

net/netfilter/nft_byteorder.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ static int nft_byteorder_init(const struct nft_ctx *ctx,
148148
priv->len);
149149
}
150150

151-
static int nft_byteorder_dump(struct sk_buff *skb, const struct nft_expr *expr)
151+
static int nft_byteorder_dump(struct sk_buff *skb,
152+
const struct nft_expr *expr, bool reset)
152153
{
153154
const struct nft_byteorder *priv = nft_expr_priv(expr);
154155

net/netfilter/nft_cmp.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ static int nft_cmp_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
9292
return 0;
9393
}
9494

95-
static int nft_cmp_dump(struct sk_buff *skb, const struct nft_expr *expr)
95+
static int nft_cmp_dump(struct sk_buff *skb,
96+
const struct nft_expr *expr, bool reset)
9697
{
9798
const struct nft_cmp_expr *priv = nft_expr_priv(expr);
9899

@@ -253,7 +254,8 @@ static int nft_cmp_fast_offload(struct nft_offload_ctx *ctx,
253254
return __nft_cmp_offload(ctx, flow, &cmp);
254255
}
255256

256-
static int nft_cmp_fast_dump(struct sk_buff *skb, const struct nft_expr *expr)
257+
static int nft_cmp_fast_dump(struct sk_buff *skb,
258+
const struct nft_expr *expr, bool reset)
257259
{
258260
const struct nft_cmp_fast_expr *priv = nft_expr_priv(expr);
259261
enum nft_cmp_ops op = priv->inv ? NFT_CMP_NEQ : NFT_CMP_EQ;
@@ -347,7 +349,8 @@ static int nft_cmp16_fast_offload(struct nft_offload_ctx *ctx,
347349
return __nft_cmp_offload(ctx, flow, &cmp);
348350
}
349351

350-
static int nft_cmp16_fast_dump(struct sk_buff *skb, const struct nft_expr *expr)
352+
static int nft_cmp16_fast_dump(struct sk_buff *skb,
353+
const struct nft_expr *expr, bool reset)
351354
{
352355
const struct nft_cmp16_fast_expr *priv = nft_expr_priv(expr);
353356
enum nft_cmp_ops op = priv->inv ? NFT_CMP_NEQ : NFT_CMP_EQ;

net/netfilter/nft_compat.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,8 @@ static int nft_extension_dump_info(struct sk_buff *skb, int attr,
324324
return 0;
325325
}
326326

327-
static int nft_target_dump(struct sk_buff *skb, const struct nft_expr *expr)
327+
static int nft_target_dump(struct sk_buff *skb,
328+
const struct nft_expr *expr, bool reset)
328329
{
329330
const struct xt_target *target = expr->ops->data;
330331
void *info = nft_expr_priv(expr);
@@ -572,12 +573,14 @@ static int __nft_match_dump(struct sk_buff *skb, const struct nft_expr *expr,
572573
return -1;
573574
}
574575

575-
static int nft_match_dump(struct sk_buff *skb, const struct nft_expr *expr)
576+
static int nft_match_dump(struct sk_buff *skb,
577+
const struct nft_expr *expr, bool reset)
576578
{
577579
return __nft_match_dump(skb, expr, nft_expr_priv(expr));
578580
}
579581

580-
static int nft_match_large_dump(struct sk_buff *skb, const struct nft_expr *e)
582+
static int nft_match_large_dump(struct sk_buff *skb,
583+
const struct nft_expr *e, bool reset)
581584
{
582585
struct nft_xt_match_priv *priv = nft_expr_priv(e);
583586

net/netfilter/nft_connlimit.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ static void nft_connlimit_eval(const struct nft_expr *expr,
185185
nft_connlimit_do_eval(priv, regs, pkt, NULL);
186186
}
187187

188-
static int nft_connlimit_dump(struct sk_buff *skb, const struct nft_expr *expr)
188+
static int nft_connlimit_dump(struct sk_buff *skb,
189+
const struct nft_expr *expr, bool reset)
189190
{
190191
struct nft_connlimit *priv = nft_expr_priv(expr);
191192

net/netfilter/nft_counter.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ void nft_counter_eval(const struct nft_expr *expr, struct nft_regs *regs,
201201
nft_counter_do_eval(priv, regs, pkt);
202202
}
203203

204-
static int nft_counter_dump(struct sk_buff *skb, const struct nft_expr *expr)
204+
static int nft_counter_dump(struct sk_buff *skb,
205+
const struct nft_expr *expr, bool reset)
205206
{
206207
struct nft_counter_percpu_priv *priv = nft_expr_priv(expr);
207208

net/netfilter/nft_ct.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,8 @@ static void nft_ct_set_destroy(const struct nft_ctx *ctx,
641641
nf_ct_netns_put(ctx->net, ctx->family);
642642
}
643643

644-
static int nft_ct_get_dump(struct sk_buff *skb, const struct nft_expr *expr)
644+
static int nft_ct_get_dump(struct sk_buff *skb,
645+
const struct nft_expr *expr, bool reset)
645646
{
646647
const struct nft_ct *priv = nft_expr_priv(expr);
647648

@@ -703,7 +704,8 @@ static bool nft_ct_get_reduce(struct nft_regs_track *track,
703704
return nft_expr_reduce_bitwise(track, expr);
704705
}
705706

706-
static int nft_ct_set_dump(struct sk_buff *skb, const struct nft_expr *expr)
707+
static int nft_ct_set_dump(struct sk_buff *skb,
708+
const struct nft_expr *expr, bool reset)
707709
{
708710
const struct nft_ct *priv = nft_expr_priv(expr);
709711

net/netfilter/nft_dup_netdev.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ static int nft_dup_netdev_init(const struct nft_ctx *ctx,
4444
sizeof(int));
4545
}
4646

47-
static int nft_dup_netdev_dump(struct sk_buff *skb, const struct nft_expr *expr)
47+
static int nft_dup_netdev_dump(struct sk_buff *skb,
48+
const struct nft_expr *expr, bool reset)
4849
{
4950
struct nft_dup_netdev *priv = nft_expr_priv(expr);
5051

net/netfilter/nft_dynset.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,8 @@ static void nft_dynset_destroy(const struct nft_ctx *ctx,
357357
nf_tables_destroy_set(ctx, priv->set);
358358
}
359359

360-
static int nft_dynset_dump(struct sk_buff *skb, const struct nft_expr *expr)
360+
static int nft_dynset_dump(struct sk_buff *skb,
361+
const struct nft_expr *expr, bool reset)
361362
{
362363
const struct nft_dynset *priv = nft_expr_priv(expr);
363364
u32 flags = priv->invert ? NFT_DYNSET_F_INV : 0;

net/netfilter/nft_exthdr.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,8 @@ static int nft_exthdr_dump_common(struct sk_buff *skb, const struct nft_exthdr *
576576
return -1;
577577
}
578578

579-
static int nft_exthdr_dump(struct sk_buff *skb, const struct nft_expr *expr)
579+
static int nft_exthdr_dump(struct sk_buff *skb,
580+
const struct nft_expr *expr, bool reset)
580581
{
581582
const struct nft_exthdr *priv = nft_expr_priv(expr);
582583

@@ -586,7 +587,8 @@ static int nft_exthdr_dump(struct sk_buff *skb, const struct nft_expr *expr)
586587
return nft_exthdr_dump_common(skb, priv);
587588
}
588589

589-
static int nft_exthdr_dump_set(struct sk_buff *skb, const struct nft_expr *expr)
590+
static int nft_exthdr_dump_set(struct sk_buff *skb,
591+
const struct nft_expr *expr, bool reset)
590592
{
591593
const struct nft_exthdr *priv = nft_expr_priv(expr);
592594

@@ -596,7 +598,8 @@ static int nft_exthdr_dump_set(struct sk_buff *skb, const struct nft_expr *expr)
596598
return nft_exthdr_dump_common(skb, priv);
597599
}
598600

599-
static int nft_exthdr_dump_strip(struct sk_buff *skb, const struct nft_expr *expr)
601+
static int nft_exthdr_dump_strip(struct sk_buff *skb,
602+
const struct nft_expr *expr, bool reset)
600603
{
601604
const struct nft_exthdr *priv = nft_expr_priv(expr);
602605

net/netfilter/nft_fib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ int nft_fib_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
118118
}
119119
EXPORT_SYMBOL_GPL(nft_fib_init);
120120

121-
int nft_fib_dump(struct sk_buff *skb, const struct nft_expr *expr)
121+
int nft_fib_dump(struct sk_buff *skb, const struct nft_expr *expr, bool reset)
122122
{
123123
const struct nft_fib *priv = nft_expr_priv(expr);
124124

net/netfilter/nft_flow_offload.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,8 @@ static void nft_flow_offload_destroy(const struct nft_ctx *ctx,
433433
nf_ct_netns_put(ctx->net, ctx->family);
434434
}
435435

436-
static int nft_flow_offload_dump(struct sk_buff *skb, const struct nft_expr *expr)
436+
static int nft_flow_offload_dump(struct sk_buff *skb,
437+
const struct nft_expr *expr, bool reset)
437438
{
438439
struct nft_flow_offload *priv = nft_expr_priv(expr);
439440

net/netfilter/nft_fwd_netdev.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ static int nft_fwd_netdev_init(const struct nft_ctx *ctx,
5656
sizeof(int));
5757
}
5858

59-
static int nft_fwd_netdev_dump(struct sk_buff *skb, const struct nft_expr *expr)
59+
static int nft_fwd_netdev_dump(struct sk_buff *skb,
60+
const struct nft_expr *expr, bool reset)
6061
{
6162
struct nft_fwd_netdev *priv = nft_expr_priv(expr);
6263

@@ -186,7 +187,8 @@ static int nft_fwd_neigh_init(const struct nft_ctx *ctx,
186187
addr_len);
187188
}
188189

189-
static int nft_fwd_neigh_dump(struct sk_buff *skb, const struct nft_expr *expr)
190+
static int nft_fwd_neigh_dump(struct sk_buff *skb,
191+
const struct nft_expr *expr, bool reset)
190192
{
191193
struct nft_fwd_neigh *priv = nft_expr_priv(expr);
192194

net/netfilter/nft_hash.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ static int nft_symhash_init(const struct nft_ctx *ctx,
139139
}
140140

141141
static int nft_jhash_dump(struct sk_buff *skb,
142-
const struct nft_expr *expr)
142+
const struct nft_expr *expr, bool reset)
143143
{
144144
const struct nft_jhash *priv = nft_expr_priv(expr);
145145

@@ -176,7 +176,7 @@ static bool nft_jhash_reduce(struct nft_regs_track *track,
176176
}
177177

178178
static int nft_symhash_dump(struct sk_buff *skb,
179-
const struct nft_expr *expr)
179+
const struct nft_expr *expr, bool reset)
180180
{
181181
const struct nft_symhash *priv = nft_expr_priv(expr);
182182

net/netfilter/nft_immediate.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ static void nft_immediate_destroy(const struct nft_ctx *ctx,
147147
}
148148
}
149149

150-
static int nft_immediate_dump(struct sk_buff *skb, const struct nft_expr *expr)
150+
static int nft_immediate_dump(struct sk_buff *skb,
151+
const struct nft_expr *expr, bool reset)
151152
{
152153
const struct nft_immediate_expr *priv = nft_expr_priv(expr);
153154

net/netfilter/nft_inner.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,8 @@ static int nft_inner_init(const struct nft_ctx *ctx,
347347
return 0;
348348
}
349349

350-
static int nft_inner_dump(struct sk_buff *skb, const struct nft_expr *expr)
350+
static int nft_inner_dump(struct sk_buff *skb,
351+
const struct nft_expr *expr, bool reset)
351352
{
352353
const struct nft_inner *priv = nft_expr_priv(expr);
353354

net/netfilter/nft_last.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ static void nft_last_eval(const struct nft_expr *expr,
6565
WRITE_ONCE(last->set, 1);
6666
}
6767

68-
static int nft_last_dump(struct sk_buff *skb, const struct nft_expr *expr)
68+
static int nft_last_dump(struct sk_buff *skb,
69+
const struct nft_expr *expr, bool reset)
6970
{
7071
struct nft_last_priv *priv = nft_expr_priv(expr);
7172
struct nft_last *last = priv->last;

net/netfilter/nft_limit.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ static int nft_limit_pkts_init(const struct nft_ctx *ctx,
193193
return 0;
194194
}
195195

196-
static int nft_limit_pkts_dump(struct sk_buff *skb, const struct nft_expr *expr)
196+
static int nft_limit_pkts_dump(struct sk_buff *skb,
197+
const struct nft_expr *expr, bool reset)
197198
{
198199
const struct nft_limit_priv_pkts *priv = nft_expr_priv(expr);
199200

@@ -251,7 +252,7 @@ static int nft_limit_bytes_init(const struct nft_ctx *ctx,
251252
}
252253

253254
static int nft_limit_bytes_dump(struct sk_buff *skb,
254-
const struct nft_expr *expr)
255+
const struct nft_expr *expr, bool reset)
255256
{
256257
const struct nft_limit_priv *priv = nft_expr_priv(expr);
257258

net/netfilter/nft_log.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,8 @@ static void nft_log_destroy(const struct nft_ctx *ctx,
241241
nf_logger_put(ctx->family, li->type);
242242
}
243243

244-
static int nft_log_dump(struct sk_buff *skb, const struct nft_expr *expr)
244+
static int nft_log_dump(struct sk_buff *skb,
245+
const struct nft_expr *expr, bool reset)
245246
{
246247
const struct nft_log *priv = nft_expr_priv(expr);
247248
const struct nf_loginfo *li = &priv->loginfo;

net/netfilter/nft_lookup.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ static void nft_lookup_destroy(const struct nft_ctx *ctx,
178178
nf_tables_destroy_set(ctx, priv->set);
179179
}
180180

181-
static int nft_lookup_dump(struct sk_buff *skb, const struct nft_expr *expr)
181+
static int nft_lookup_dump(struct sk_buff *skb,
182+
const struct nft_expr *expr, bool reset)
182183
{
183184
const struct nft_lookup *priv = nft_expr_priv(expr);
184185
u32 flags = priv->invert ? NFT_LOOKUP_F_INV : 0;

net/netfilter/nft_masq.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ static int nft_masq_init(const struct nft_ctx *ctx,
7373
return nf_ct_netns_get(ctx->net, ctx->family);
7474
}
7575

76-
static int nft_masq_dump(struct sk_buff *skb, const struct nft_expr *expr)
76+
static int nft_masq_dump(struct sk_buff *skb,
77+
const struct nft_expr *expr, bool reset)
7778
{
7879
const struct nft_masq *priv = nft_expr_priv(expr);
7980

0 commit comments

Comments
 (0)