Skip to content

Commit

Permalink
netfilter: conntrack: adjust stop timestamp to real expiry value
Browse files Browse the repository at this point in the history
[ Upstream commit 30a56a2 ]

In case the entry is evicted via garbage collection there is
delay between the timeout value and the eviction event.

This adjusts the stop value based on how much time has passed.

Fixes: b87a2f9 ("netfilter: conntrack: add gc worker to remove timed-out entries")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Florian Westphal authored and gregkh committed Aug 4, 2021
1 parent ac038f4 commit 3dbda84
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion net/netfilter/nf_conntrack_core.c
Expand Up @@ -661,8 +661,13 @@ bool nf_ct_delete(struct nf_conn *ct, u32 portid, int report)
return false;

tstamp = nf_conn_tstamp_find(ct);
if (tstamp && tstamp->stop == 0)
if (tstamp) {
s32 timeout = ct->timeout - nfct_time_stamp;

tstamp->stop = ktime_get_real_ns();
if (timeout < 0)
tstamp->stop -= jiffies_to_nsecs(-timeout);
}

if (nf_conntrack_event_report(IPCT_DESTROY, ct,
portid, report) < 0) {
Expand Down

0 comments on commit 3dbda84

Please sign in to comment.