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;

0 commit comments

Comments
 (0)