Skip to content

Commit 151d799

Browse files
kaberummakynes
authored andcommitted
netfilter: nf_tables: mark stateful expressions
Add a flag to mark stateful expressions. This is used for dynamic expression instanstiation to limit the usable expressions. Strictly speaking only the dynset expression can not be used in order to avoid recursion, but since dynamically instantiating non-stateful expressions will simply create an identical copy, which behaves no differently than the original, this limits to expressions where it actually makes sense to dynamically instantiate them. Signed-off-by: Patrick McHardy <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent f25ad2e commit 151d799

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

include/net/netfilter/nf_tables.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,7 @@ static inline void nft_set_gc_batch_add(struct nft_set_gc_batch *gcb,
583583
* @policy: netlink attribute policy
584584
* @maxattr: highest netlink attribute number
585585
* @family: address family for AF-specific types
586+
* @flags: expression type flags
586587
*/
587588
struct nft_expr_type {
588589
const struct nft_expr_ops *(*select_ops)(const struct nft_ctx *,
@@ -594,8 +595,11 @@ struct nft_expr_type {
594595
const struct nla_policy *policy;
595596
unsigned int maxattr;
596597
u8 family;
598+
u8 flags;
597599
};
598600

601+
#define NFT_EXPR_STATEFUL 0x1
602+
599603
/**
600604
* struct nft_expr_ops - nf_tables expression operations
601605
*

net/netfilter/nft_counter.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ static struct nft_expr_type nft_counter_type __read_mostly = {
9292
.ops = &nft_counter_ops,
9393
.policy = nft_counter_policy,
9494
.maxattr = NFTA_COUNTER_MAX,
95+
.flags = NFT_EXPR_STATEFUL,
9596
.owner = THIS_MODULE,
9697
};
9798

net/netfilter/nft_limit.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ static struct nft_expr_type nft_limit_type __read_mostly = {
9898
.ops = &nft_limit_ops,
9999
.policy = nft_limit_policy,
100100
.maxattr = NFTA_LIMIT_MAX,
101+
.flags = NFT_EXPR_STATEFUL,
101102
.owner = THIS_MODULE,
102103
};
103104

0 commit comments

Comments
 (0)