Skip to contentSkip to conversation

netfilter: conntrack: adjust stop timestamp to real expiry value

PATCH Applied Florian Westphal 2 participants 2 messages Jul 18, 2021 – Jul 23, 2021

Subsystems (2)
lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 netfilter: conntrack: adjust stop timestamp to real expiry value

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 b87a2f9199ea82 ("netfilter: conntrack: add gc worker to remove timed-out entries")
---
 net/netfilter/nf_conntrack_core.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
net/netfilter/nf_conntrack_core.c +6 -1
index 96ba19fc8155..97274698050b 100644
@@ -662,8 +662,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) {
Signature · 1 line
2.31.1
maintainer Applied
#1 lore raw
Quoted 4 lines · Florian Westphal

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.

Applied, thanks.