]> git.baikalelectronics.ru Git - kernel.git/commitdiff
netfilter: conntrack: adjust stop timestamp to real expiry value
authorFlorian Westphal <fw@strlen.de>
Sun, 18 Jul 2021 16:36:00 +0000 (18:36 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 23 Jul 2021 12:18:03 +0000 (14:18 +0200)
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")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_conntrack_core.c

index 83c52df8587014515eeadc5d87e5fb8623ce4e74..5c03e510675193c1812bb9b8291963d3c35d748b 100644 (file)
@@ -670,8 +670,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) {