All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] netfilter: conntrack: fix reading nf_conntrack_buckets
@ 2021-01-08 11:44 Jesper Dangaard Brouer
  2021-01-08 11:54 ` Florian Westphal
  2021-01-10  8:39 ` Pablo Neira Ayuso
  0 siblings, 2 replies; 3+ messages in thread
From: Jesper Dangaard Brouer @ 2021-01-08 11:44 UTC (permalink / raw)
  To: Pablo Neira Ayuso, netfilter-devel
  Cc: Jesper Dangaard Brouer, Florian Westphal, netdev

The old way of changing the conntrack hashsize runtime was through changing
the module param via file /sys/module/nf_conntrack/parameters/hashsize. This
was extended to sysctl change in commit 3183ab8997a4 ("netfilter: conntrack:
allow increasing bucket size via sysctl too").

The commit introduced second "user" variable nf_conntrack_htable_size_user
which shadow actual variable nf_conntrack_htable_size. When hashsize is
changed via module param this "user" variable isn't updated. This results in
sysctl net/netfilter/nf_conntrack_buckets shows the wrong value when users
update via the old way.

This patch fix the issue by always updating "user" variable when reading the
proc file. This will take care of changes to the actual variable without
sysctl need to be aware.

Fixes: 3183ab8997a4 ("netfilter: conntrack: allow increasing bucket size via sysctl too")
Reported-by: Yoel Caspersen <yoel@kviknet.dk>
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
---
 net/netfilter/nf_conntrack_standalone.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
index 46c5557c1fec..0ee702d374b0 100644
--- a/net/netfilter/nf_conntrack_standalone.c
+++ b/net/netfilter/nf_conntrack_standalone.c
@@ -523,6 +523,9 @@ nf_conntrack_hash_sysctl(struct ctl_table *table, int write,
 {
 	int ret;
 
+	/* module_param hashsize could have changed value */
+	nf_conntrack_htable_size_user = nf_conntrack_htable_size;
+
 	ret = proc_dointvec(table, write, buffer, lenp, ppos);
 	if (ret < 0 || !write)
 		return ret;



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] netfilter: conntrack: fix reading nf_conntrack_buckets
  2021-01-08 11:44 [PATCH net] netfilter: conntrack: fix reading nf_conntrack_buckets Jesper Dangaard Brouer
@ 2021-01-08 11:54 ` Florian Westphal
  2021-01-10  8:39 ` Pablo Neira Ayuso
  1 sibling, 0 replies; 3+ messages in thread
From: Florian Westphal @ 2021-01-08 11:54 UTC (permalink / raw)
  To: Jesper Dangaard Brouer
  Cc: Pablo Neira Ayuso, netfilter-devel, Florian Westphal, netdev

Jesper Dangaard Brouer <brouer@redhat.com> wrote:
> The old way of changing the conntrack hashsize runtime was through changing
> the module param via file /sys/module/nf_conntrack/parameters/hashsize. This
> was extended to sysctl change in commit 3183ab8997a4 ("netfilter: conntrack:
> allow increasing bucket size via sysctl too").
> 
> The commit introduced second "user" variable nf_conntrack_htable_size_user
> which shadow actual variable nf_conntrack_htable_size. When hashsize is
> changed via module param this "user" variable isn't updated. This results in
> sysctl net/netfilter/nf_conntrack_buckets shows the wrong value when users
> update via the old way.

Oh, right!

Acked-by: Florian Westphal <fw@strlen.de>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] netfilter: conntrack: fix reading nf_conntrack_buckets
  2021-01-08 11:44 [PATCH net] netfilter: conntrack: fix reading nf_conntrack_buckets Jesper Dangaard Brouer
  2021-01-08 11:54 ` Florian Westphal
@ 2021-01-10  8:39 ` Pablo Neira Ayuso
  1 sibling, 0 replies; 3+ messages in thread
From: Pablo Neira Ayuso @ 2021-01-10  8:39 UTC (permalink / raw)
  To: Jesper Dangaard Brouer; +Cc: netfilter-devel, Florian Westphal, netdev

On Fri, Jan 08, 2021 at 12:44:33PM +0100, Jesper Dangaard Brouer wrote:
> The old way of changing the conntrack hashsize runtime was through changing
> the module param via file /sys/module/nf_conntrack/parameters/hashsize. This
> was extended to sysctl change in commit 3183ab8997a4 ("netfilter: conntrack:
> allow increasing bucket size via sysctl too").
> 
> The commit introduced second "user" variable nf_conntrack_htable_size_user
> which shadow actual variable nf_conntrack_htable_size. When hashsize is
> changed via module param this "user" variable isn't updated. This results in
> sysctl net/netfilter/nf_conntrack_buckets shows the wrong value when users
> update via the old way.
> 
> This patch fix the issue by always updating "user" variable when reading the
> proc file. This will take care of changes to the actual variable without
> sysctl need to be aware.

Applied, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-01-10  8:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-08 11:44 [PATCH net] netfilter: conntrack: fix reading nf_conntrack_buckets Jesper Dangaard Brouer
2021-01-08 11:54 ` Florian Westphal
2021-01-10  8:39 ` Pablo Neira Ayuso

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.