]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
netfilter: conntrack: disable 0 value for conntrack_max setting
authorFlorian Westphal <fw@strlen.de>
Sun, 21 Sep 2025 15:45:30 +0000 (17:45 +0200)
committerFlorian Westphal <fw@strlen.de>
Thu, 30 Oct 2025 11:52:45 +0000 (12:52 +0100)
Undocumented 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.

Signed-off-by: Florian Westphal <fw@strlen.de>
net/netfilter/nf_conntrack_core.c
net/netfilter/nf_conntrack_standalone.c

index 344f88295976d728727d67fb0e24070ba527497b..0b95f226f2111636870d971b9eb24b02396a49e3 100644 (file)
@@ -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;
index 708b79380f047f32aa8e6047c52c807b4019f2b9..207b240b14e5dd8704c0a723ea268a7bf90fcc9c 100644 (file)
@@ -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,
        },
 };