Skip to content

Commit 55895d0

Browse files
committed
netfilter: nf_tables: Extend nft_expr_ops::dump callback parameters
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1925492 Upstream Status: commit 7d34aa3 Conflicts: * Context changes due to missing expression reduce support * Dropped chunks applying to TCP option stripping, 16byte cmp fast ops and inner header matching commit 7d34aa3 Author: Phil Sutter <phil@nwl.cc> Date: Fri Oct 14 23:45:58 2022 +0200 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 <phil@nwl.cc> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: Phil Sutter <psutter@redhat.com>
1 parent fe25bd4 commit 55895d0

Some content is hidden

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

44 files changed

+104
-59
lines changed

include/net/netfilter/nf_tables.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,8 @@ struct nft_expr_ops {
902902
void (*destroy_clone)(const struct nft_ctx *ctx,
903903
const struct nft_expr *expr);
904904
int (*dump)(struct sk_buff *skb,
905-
const struct nft_expr *expr);
905+
const struct nft_expr *expr,
906+
bool reset);
906907
int (*validate)(const struct nft_ctx *ctx,
907908
const struct nft_expr *expr,
908909
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
@@ -23,10 +23,10 @@ int nft_meta_set_init(const struct nft_ctx *ctx,
2323
const struct nlattr * const tb[]);
2424

2525
int nft_meta_get_dump(struct sk_buff *skb,
26-
const struct nft_expr *expr);
26+
const struct nft_expr *expr, bool reset);
2727

2828
int nft_meta_set_dump(struct sk_buff *skb,
29-
const struct nft_expr *expr);
29+
const struct nft_expr *expr, bool reset);
3030

3131
void nft_meta_get_eval(const struct nft_expr *expr,
3232
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
@@ -2691,7 +2691,7 @@ static int nf_tables_fill_expr_info(struct sk_buff *skb,
26912691
NFTA_EXPR_DATA);
26922692
if (data == NULL)
26932693
goto nla_put_failure;
2694-
if (expr->ops->dump(skb, expr) < 0)
2694+
if (expr->ops->dump(skb, expr, false) < 0)
26952695
goto nla_put_failure;
26962696
nla_nest_end(skb, data);
26972697
}

net/netfilter/nft_bitwise.c

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

233-
static int nft_bitwise_dump(struct sk_buff *skb, const struct nft_expr *expr)
233+
static int nft_bitwise_dump(struct sk_buff *skb,
234+
const struct nft_expr *expr, bool reset)
234235
{
235236
const struct nft_bitwise *priv = nft_expr_priv(expr);
236237
int err = 0;
@@ -344,7 +345,8 @@ static int nft_bitwise_fast_init(const struct nft_ctx *ctx,
344345
}
345346

346347
static int
347-
nft_bitwise_fast_dump(struct sk_buff *skb, const struct nft_expr *expr)
348+
nft_bitwise_fast_dump(struct sk_buff *skb,
349+
const struct nft_expr *expr, bool reset)
348350
{
349351
const struct nft_bitwise_fast_expr *priv = nft_expr_priv(expr);
350352
struct nft_data data;

net/netfilter/nft_byteorder.c

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

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

net/netfilter/nft_cmp.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ static int nft_cmp_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
9696
return 0;
9797
}
9898

99-
static int nft_cmp_dump(struct sk_buff *skb, const struct nft_expr *expr)
99+
static int nft_cmp_dump(struct sk_buff *skb,
100+
const struct nft_expr *expr, bool reset)
100101
{
101102
const struct nft_cmp_expr *priv = nft_expr_priv(expr);
102103

@@ -242,7 +243,8 @@ static int nft_cmp_fast_offload(struct nft_offload_ctx *ctx,
242243
return __nft_cmp_offload(ctx, flow, &cmp);
243244
}
244245

245-
static int nft_cmp_fast_dump(struct sk_buff *skb, const struct nft_expr *expr)
246+
static int nft_cmp_fast_dump(struct sk_buff *skb,
247+
const struct nft_expr *expr, bool reset)
246248
{
247249
const struct nft_cmp_fast_expr *priv = nft_expr_priv(expr);
248250
enum nft_cmp_ops op = priv->inv ? NFT_CMP_NEQ : NFT_CMP_EQ;

0 commit comments

Comments
 (0)