netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH nf] netfilter: nf_conntrack: do not skip entries in /proc/net/nf_conntrack
@ 2025-09-24  7:27 Eric Dumazet
  2025-09-24  8:50 ` Florian Westphal
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2025-09-24  7:27 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni, Pablo Neira Ayuso,
	Florian Westphal, Jozsef Kadlecsik
  Cc: netdev, netfilter-devel, coreteam, eric.dumazet, Eric Dumazet

ct_seq_show() has an opportunistic garbage collector :

if (nf_ct_should_gc(ct)) {
    nf_ct_kill(ct);
    goto release;
}

So if one nf_conn is killed there, next time ct_get_next() runs,
we skip the following item in the bucket, even if it should have
been displayed if gc did not take place.

We can decrement st->skip_elems to tell ct_get_next() one of the items
was removed from the chain.

Fixes: 58e207e4983d ("netfilter: evict stale entries when user reads /proc/net/nf_conntrack")
Signed-off-by: Eric Dumazet <edumazet@google.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 1f14ef0436c65fccc8e64956a105d5473e21b55e..708b79380f047f32aa8e6047c52c807b4019f2b9 100644
--- a/net/netfilter/nf_conntrack_standalone.c
+++ b/net/netfilter/nf_conntrack_standalone.c
@@ -317,6 +317,9 @@ static int ct_seq_show(struct seq_file *s, void *v)
 	smp_acquire__after_ctrl_dep();
 
 	if (nf_ct_should_gc(ct)) {
+		struct ct_iter_state *st = s->private;
+
+		st->skip_elems--;
 		nf_ct_kill(ct);
 		goto release;
 	}
-- 
2.51.0.534.gc79095c0ca-goog


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

* Re: [PATCH nf] netfilter: nf_conntrack: do not skip entries in /proc/net/nf_conntrack
  2025-09-24  7:27 [PATCH nf] netfilter: nf_conntrack: do not skip entries in /proc/net/nf_conntrack Eric Dumazet
@ 2025-09-24  8:50 ` Florian Westphal
  0 siblings, 0 replies; 2+ messages in thread
From: Florian Westphal @ 2025-09-24  8:50 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, Pablo Neira Ayuso,
	Jozsef Kadlecsik, netdev, netfilter-devel, coreteam, eric.dumazet

Eric Dumazet <edumazet@google.com> wrote:
> diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
> index 1f14ef0436c65fccc8e64956a105d5473e21b55e..708b79380f047f32aa8e6047c52c807b4019f2b9 100644
> --- a/net/netfilter/nf_conntrack_standalone.c
> +++ b/net/netfilter/nf_conntrack_standalone.c
> @@ -317,6 +317,9 @@ static int ct_seq_show(struct seq_file *s, void *v)
>  	smp_acquire__after_ctrl_dep();
>  
>  	if (nf_ct_should_gc(ct)) {
> +		struct ct_iter_state *st = s->private;
> +
> +		st->skip_elems--;

I'll route this via nf-next, I don't think there is
a need to add it to nf this close to release.

Thanks Eric!

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

end of thread, other threads:[~2025-09-24  8:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-24  7:27 [PATCH nf] netfilter: nf_conntrack: do not skip entries in /proc/net/nf_conntrack Eric Dumazet
2025-09-24  8:50 ` Florian Westphal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).