Skip to content

Commit c05955e

Browse files
author
Herton R. Krzesinski
committed
Merge: netfilter: nf_tables: Support resetting state in rules and set elements
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/2864 Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1925492 Upstream Status: all upstream in linus.git Rule resetting code is in patch 2, it requires patch 1 as preliminary work. Set element resetting code is in patch 6. It is useable by itself, but caused some context conflicts. Backporting patches 3 and 4 avoids those, both are useful and rather simple. Patch 5 is a fixup of patch 4. Signed-off-by: Phil Sutter <psutter@redhat.com> Approved-by: Florian Westphal <fwestpha@redhat.com> Approved-by: Guillaume Nault <gnault@redhat.com> Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
2 parents 39a0b86 + 7c45d32 commit c05955e

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

+317
-108
lines changed

include/net/netfilter/nf_tables.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ static inline void *nft_expr_priv(const struct nft_expr *expr)
360360
int nft_expr_clone(struct nft_expr *dst, struct nft_expr *src);
361361
void nft_expr_destroy(const struct nft_ctx *ctx, struct nft_expr *expr);
362362
int nft_expr_dump(struct sk_buff *skb, unsigned int attr,
363-
const struct nft_expr *expr);
363+
const struct nft_expr *expr, bool reset);
364364

365365
struct nft_set_ext;
366366

@@ -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);

include/uapi/linux/netfilter/nf_tables.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,15 @@ enum nft_verdicts {
9797
* @NFT_MSG_NEWFLOWTABLE: add new flow table (enum nft_flowtable_attributes)
9898
* @NFT_MSG_GETFLOWTABLE: get flow table (enum nft_flowtable_attributes)
9999
* @NFT_MSG_DELFLOWTABLE: delete flow table (enum nft_flowtable_attributes)
100+
* @NFT_MSG_GETRULE_RESET: get rules and reset stateful expressions (enum nft_obj_attributes)
101+
* @NFT_MSG_DESTROYTABLE: destroy a table (enum nft_table_attributes)
102+
* @NFT_MSG_DESTROYCHAIN: destroy a chain (enum nft_chain_attributes)
103+
* @NFT_MSG_DESTROYRULE: destroy a rule (enum nft_rule_attributes)
104+
* @NFT_MSG_DESTROYSET: destroy a set (enum nft_set_attributes)
105+
* @NFT_MSG_DESTROYSETELEM: destroy a set element (enum nft_set_elem_attributes)
106+
* @NFT_MSG_DESTROYOBJ: destroy a stateful object (enum nft_object_attributes)
107+
* @NFT_MSG_DESTROYFLOWTABLE: destroy flow table (enum nft_flowtable_attributes)
108+
* @NFT_MSG_GETSETELEM_RESET: get set elements and reset attached stateful expressions (enum nft_set_elem_attributes)
100109
*/
101110
enum nf_tables_msg_types {
102111
NFT_MSG_NEWTABLE,
@@ -124,6 +133,15 @@ enum nf_tables_msg_types {
124133
NFT_MSG_NEWFLOWTABLE,
125134
NFT_MSG_GETFLOWTABLE,
126135
NFT_MSG_DELFLOWTABLE,
136+
NFT_MSG_GETRULE_RESET,
137+
NFT_MSG_DESTROYTABLE,
138+
NFT_MSG_DESTROYCHAIN,
139+
NFT_MSG_DESTROYRULE,
140+
NFT_MSG_DESTROYSET,
141+
NFT_MSG_DESTROYSETELEM,
142+
NFT_MSG_DESTROYOBJ,
143+
NFT_MSG_DESTROYFLOWTABLE,
144+
NFT_MSG_GETSETELEM_RESET,
127145
NFT_MSG_MAX,
128146
};
129147

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

0 commit comments

Comments
 (0)