Skip to content

Commit 58e207e

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: evict stale entries when user reads /proc/net/nf_conntrack
Fabian reports a possible conntrack memory leak (could not reproduce so far), however, one minor issue can be easily resolved: > cat /proc/net/nf_conntrack | wc -l = 5 > 4 minutes required to clean up the table. We should not report those timed-out entries to the user in first place. And instead of just skipping those timed-out entries while iterating over the table we can also zap them (we already do this during ctnetlink walks, but I forgot about the /proc interface). Fixes: f330a7f ("netfilter: conntrack: get rid of conntrack timer") Reported-by: Fabian Frederick <fabf@skynet.be> Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 11d5f15 commit 58e207e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

net/netfilter/nf_conntrack_standalone.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@ static int ct_seq_show(struct seq_file *s, void *v)
212212
if (unlikely(!atomic_inc_not_zero(&ct->ct_general.use)))
213213
return 0;
214214

215+
if (nf_ct_should_gc(ct)) {
216+
nf_ct_kill(ct);
217+
goto release;
218+
}
219+
215220
/* we only want to print DIR_ORIGINAL */
216221
if (NF_CT_DIRECTION(hash))
217222
goto release;

0 commit comments

Comments
 (0)