Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1648977pxy; Mon, 2 Aug 2021 07:04:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPUM8HzBUUR4vZ/7uz9du/IIGnKfj5TVKNPmZxV3KNUy1QM6UNANeZ7mbPOY9q0q3TlML8 X-Received: by 2002:a5d:9b99:: with SMTP id r25mr1061122iom.104.1627913052604; Mon, 02 Aug 2021 07:04:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627913052; cv=none; d=google.com; s=arc-20160816; b=E7Yk0EDWBv++qZ97fhHRR1TwnArjahSKImOVBwN3EV5DelSkbpmgzSFKu5pKifKX6i ILUs7E2nftDKKxKFHVzEdTQHtjUzhnOc4/Q6RzSJhUob1OKxpDYqXQBn1FNCDRgRT8wl AgjAAU/O3f6uCitj/LdTQ8zozwj2CmtsBhk5UOQdVOTCIQlkjdYiNPbqRHtv7fnh4b2P E1JCc/F6p4z2frwl5SUrDe3Ft2ORpYIinAiX5eeqim0JIjlwTvnkR09gDXX3M4ZjAGSU G7/XyZARpb/XIa12qrwuXSPgJ1U40IA8Z3lEMADsvvYiaVBFDXtxhS06IAwHRpej4RzT WdXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FBpKWBSYxWrAoTocjPtqZiWa3v7ybFlfApQpjmu4xPA=; b=vWdgK6PR1AXPU51rNVC4art/AUYsKy1luPKIBV0eE/DcdVXhaHUNze5wjpFqx0yJqQ /5ytn3WpGO0oQ1e69t5B0KiOJBsYyU0+wPloM7qRJ2iH4qyofMTbbCYd4dAHQKrM6gie p4dxIVSKuxwSOF+tbcAy9srxlWszgWogTT1p5p1AoLQF8zOs3HUEqJ72F9PqW+Z86BZ5 rBa/DfhjB83wUEgR5sZKZi6ldwngW3n/WJ1mmL7SF51gUmjdGvxF/GvYkgiUMJL2HYte 9TXPcYnbaEHloZW8C/X2E9CeQgpSK2/CRFkFlAb2+i1Gc4+7V9igygjXO/harYE6c2PH 6NDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CU3VaCpg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e20si14462916iow.6.2021.08.02.07.04.01; Mon, 02 Aug 2021 07:04:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CU3VaCpg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235367AbhHBOCZ (ORCPT + 99 others); Mon, 2 Aug 2021 10:02:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:33012 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235850AbhHBNya (ORCPT ); Mon, 2 Aug 2021 09:54:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6880860F50; Mon, 2 Aug 2021 13:52:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627912373; bh=ZtaFqGVNTbtzbbJC1xi0DYcx1OmZu94B3O9QLS3xKRA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CU3VaCpgpsOZwA/Fhi+G+KKz2RJWAoRw8cn8T1evvhgHRX0BLWsNHNmHow9thgPnK +OtxRkrEyyU7WceYJZHUpk/Ll0kw+bUdWXUNOuRX8p6qY8qqwSXv6KDtQVuaoGLlt7 PtKt24ht1cRufhasAJ0Jj0RoavQGYtkXbDBZ1D0Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florian Westphal , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 5.10 31/67] netfilter: conntrack: adjust stop timestamp to real expiry value Date: Mon, 2 Aug 2021 15:44:54 +0200 Message-Id: <20210802134340.080656722@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210802134339.023067817@linuxfoundation.org> References: <20210802134339.023067817@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Florian Westphal [ Upstream commit 30a56a2b881821625f79837d4d968c679852444e ] 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 Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nf_conntrack_core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index ff0168736f6e..f9f2af26ccb3 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c @@ -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) { -- 2.30.2