netfilter: updates for net-next
Subsystems (3)
Florian Westphal
maintainercover netfilter: updates for net-next
Hi,
The following patchset contains Netfilter fixes for *net-next*:
1) Convert nf_tables 'nft_set_iter' usage to use C99 struct initialization, from Fernando Fernandez Mancera.
2) Disallow nf_conntrack_max=0. This was an (undocumented) historic inheritance from ip_conntrack (ipv4 only nf_conntrack predecessor). Doing so will simplify future changes to make this pernet-tuneable.
3) Fix a typo in conntrack.h comment, from Weibiao Tu.
Please, pull these changes from:
The following changes since commit ea7d0d60ebc9bddf3ad768557dfa1495bc032bf6:
Merge branch 'add-cn20k-nix-and-npa-contexts' (2025-10-30 10:44:12 +0100)
are available in the Git repository at:
https://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf-next.git tags/nf-next-25-10-30
for you to fetch changes up to 57347d58a4011551e7d0e030f2f12e4d1a28feb6:
netfilter: fix typo in nf_conntrack_l4proto.h comment (2025-10-30 12:52:45 +0100)
----------------------------------------------------------------
netfilter pull request nf-next-25-10-30
----------------------------------------------------------------
Fernando Fernandez Mancera (1):
netfilter: nf_tables: use C99 struct initializer for nft_set_iter
Florian Westphal (1):
netfilter: conntrack: disable 0 value for conntrack_max setting
caivive (Weibiao Tu) (1):
netfilter: fix typo in nf_conntrack_l4proto.h comment
include/net/netfilter/nf_conntrack_l4proto.h | 2 +- net/netfilter/nf_conntrack_core.c | 2 +- net/netfilter/nf_conntrack_standalone.c | 4 ++-- net/netfilter/nf_tables_api.c | 34 +++++++++++++--------------- net/netfilter/nft_lookup.c | 13 ++++------- 5 files changed, 25 insertions(+), 30 deletions(-)
# WARNING: skip 0001-netfilter-nf_tables-use-C99-struct-initializer-for-n.patch, no "Fixes" tag! # WARNING: skip 0002-netfilter-conntrack-disable-0-value-for-conntrack_ma.patch, no "Fixes" tag! # WARNING: skip 0003-netfilter-fix-typo-in-nf_conntrack_l4proto.h-comment.patch, no "Fixes" tag!
Florian Westphal
maintainerPATCH 1/3 netfilter: nf_tables: use C99 struct initializer for nft_set_iter
From: Fernando Fernandez Mancera <[email protected]>
Use C99 struct initializer for nft_set_iter, simplifying the code and preventing future errors due to uninitialized fields if new fields are added to the struct.
--- net/netfilter/nf_tables_api.c | 34 ++++++++++++++++------------------ net/netfilter/nft_lookup.c | 13 +++++-------- 2 files changed, 21 insertions(+), 26 deletions(-)
net/netfilter/nf_tables_api.c +16 -18
@@ -5770,7 +5770,11 @@ int nf_tables_bind_set(const struct nft_ctx *ctx, struct nft_set *set, struct nft_set_binding *binding) {struct nft_set_binding *i; -struct nft_set_iter iter; +struct nft_set_iter iter = { + .genmask =nft_genmask_next (ctx->net), + .type =NFT_ITER_UPDATE , + .fn = nf_tables_bind_check_setelem, + };if (!list_empty (&set->bindings) &&nft_set_is_anonymous (set))return -EBUSY ;
@@ -5785,13 +5789,6 @@ int nf_tables_bind_set(const struct nft_ctx *ctx, struct nft_set *set, goto bind; } - iter.genmask =nft_genmask_next (ctx->net); - iter.type =NFT_ITER_UPDATE ; - iter.skip =0 ; - iter.count =0 ; - iter.err =0 ; - iter.fn = nf_tables_bind_check_setelem; - set->ops->walk (ctx, set, &iter);if (!iter.err) iter.err =nft_set_catchall_bind_check (ctx, set);
@@ -6195,7 +6192,17 @@ static int nf_tables_dump_set(struct sk_buff *skb, struct netlink_callback *cb)struct nftables_pernet *nft_net;struct nft_table *table;struct nft_set *set; -struct nft_set_dump_args args; +struct nft_set_dump_args args = { + .cb = cb, + .skb = skb, + .reset = dump_ctx->reset, + .iter = { + .genmask =nft_genmask_cur (net), + .type =NFT_ITER_READ , + .skip = cb->args[0 ], + .fn = nf_tables_dump_setelem, + }, + };bool set_found = false;struct nlmsghdr *nlh;struct nlattr *nest;
@@ -6246,15 +6253,6 @@ static int nf_tables_dump_set(struct sk_buff *skb, struct netlink_callback *cb)if (nest ==NULL ) goto nla_put_failure; - args.cb = cb; - args.skb = skb; - args.reset = dump_ctx->reset; - args.iter.genmask =nft_genmask_cur (net); - args.iter.type =NFT_ITER_READ ; - args.iter.skip = cb->args[0 ]; - args.iter.count =0 ; - args.iter.err =0 ; - args.iter.fn = nf_tables_dump_setelem; set->ops->walk (&dump_ctx->ctx, set, &args.iter);if (!args.iter.err && args.iter.count == cb->args[0 ])
net/netfilter/nft_lookup.c +5 -8
@@ -246,19 +246,16 @@ static int nft_lookup_validate(const struct nft_ctx *ctx, const struct nft_expr *expr) {const struct nft_lookup *priv =nft_expr_priv (expr); -struct nft_set_iter iter; +struct nft_set_iter iter = { + .genmask =nft_genmask_next (ctx->net), + .type =NFT_ITER_UPDATE , + .fn = nft_setelem_validate, + };if (!(priv->set->flags &NFT_SET_MAP ) || priv->set->dtype !=NFT_DATA_VERDICT )return 0 ; - iter.genmask =nft_genmask_next (ctx->net); - iter.type =NFT_ITER_UPDATE ; - iter.skip =0 ; - iter.count =0 ; - iter.err =0 ; - iter.fn = nft_setelem_validate; - priv->set->ops->walk (ctx, priv->set, &iter);if (!iter.err) iter.err =nft_set_catchall_validate (ctx, priv->set);
Signature · 1 line
2.51.0
Re: [PATCH net-next 1/3] netfilter: nf_tables: use C99 struct initializer for nft_set_iter
This series was applied to netdev/net-next.git (main) by Florian Westphal <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Florian Westphal <[email protected]>:
Quoted 10 lines · On Thu, 30 Oct 2025 13:19:52 +0100 you wrote:
From: Fernando Fernandez Mancera <[email protected]>
Use C99 struct initializer for
nft_set_iter, simplifying the code and preventing future errors due to uninitialized fields if new fields are added to the struct.Signed-off-by Fernando Fernandez Mancera <[email protected]>Signed-off-by Florian Westphal <[email protected]>[...]
Here is the summary with links:
- [net-next,1/3] netfilter: nf_tables: use C99 struct initializer for nft_set_iter
https://git.kernel.org/netdev/net-next/c/320d80eeb222 - [net-next,2/3] netfilter: conntrack: disable 0 value for conntrack_max setting https://git.kernel.org/netdev/net-next/c/2b749f257645 - [net-next,3/3] netfilter: fix typo in nf_conntrack_l4proto.h comment https://git.kernel.org/netdev/net-next/c/57347d58a401
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Florian Westphal
maintainerPATCH 2/3 netfilter: conntrack: disable 0 value for conntrack_max setting
In reply to Florian WestphalUndocumented historical artifact inherited from ip_conntrack. If value is 0, then no limit is applied at all, conntrack table can grow to huge value, only limited by size of conntrack hashes and the kernel-internal upper limit on the hash chain lengths.
This feature makes no sense; users can just set
conntrack_max=2147483647 (INT_MAX).
Disallow a 0 value. This will make it slightly easier to allow per-netns constraints for this value in a future patch.
--- net/netfilter/nf_conntrack_core.c | 2 +- net/netfilter/nf_conntrack_standalone.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
net/netfilter/nf_conntrack_core.c +1 -1
@@ -1668,7 +1668,7 @@ __nf_conntrack_alloc(struct net *net,/* We don't want any race condition at early drop stage */ ct_count =atomic_inc_return (&cnet->count); -if (nf_conntrack_max &&unlikely (ct_count > nf_conntrack_max)) { +if (unlikely (ct_count > nf_conntrack_max)) {if (!early_drop (net, hash)) {if (!conntrack_gc_work.early_drop) conntrack_gc_work.early_drop = true;
net/netfilter/nf_conntrack_standalone.c +2 -2
@@ -648,7 +648,7 @@ static struct ctl_table nf_ct_sysctl_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, + .extra1 = SYSCTL_ONE, .extra2 = SYSCTL_INT_MAX, }, [NF_SYSCTL_CT_COUNT] = {
@@ -929,7 +929,7 @@ static struct ctl_table nf_ct_netfilter_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, + .extra1 = SYSCTL_ONE, .extra2 = SYSCTL_INT_MAX, }, };
Signature · 1 line
2.51.0
Florian Westphal
maintainerPATCH 3/3 netfilter: fix typo in nf_conntrack_l4proto.h comment
In reply to Florian WestphalFrom: "caivive (Weibiao Tu)" <[email protected]>
In the comment for nf_conntrack_l4proto.h, the word "nfnetink" was incorrectly spelled. It has been corrected to "nfnetlink".
Fixes a typo to enhance readability and ensure consistency.
--- include/net/netfilter/nf_conntrack_l4proto.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/net/netfilter/nf_conntrack_l4proto.h +1 -1
@@ -30,7 +30,7 @@ struct nf_conntrack_l4proto {/* called by gc worker if table is full */ bool (*can_early_drop)(const struct nf_conn *ct); -/* convert protoinfo to nfnetink attributes */ +/* convert protoinfo to nfnetlink attributes */ int (*to_nlattr)(struct sk_buff *skb,struct nlattr *nla,struct nf_conn *ct,bool destroy);
Signature · 1 line
2.51.0