Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1643691pxy; Mon, 2 Aug 2021 06:58:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvub/gw4aNPToGqeauVuX07nU55osDku1wbxnQHcuKX2jD5J7i8gFz9HOMeTjBMYfYIZy1 X-Received: by 2002:a92:190f:: with SMTP id 15mr16574ilz.45.1627912702903; Mon, 02 Aug 2021 06:58:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627912702; cv=none; d=google.com; s=arc-20160816; b=db3Rhlr3keTjva9OiB2rrMfr7jkZ88fVPHACcXxuGQDvnPu+zdqGjdkSegqDOqgGTC AGMzeq/oRsaaAWA9wiVhYm63/aC1qhZNO3RgMizGca5bmMoNvIvVzQyAT1qMAuTmfKtz GjNeldGX7EeQ4Qbc91d/i+LNkqm9AotH+0UQjLi7+MSrWMMfdgo9s0GTh82Q/cd2AIwG /lnza6JIgeRqQQIRgWNPGdhmXX8cHWHEN4einmaYOpDvdwWkipRXCX8l6qs0ZBqkfWTW vhyxb5p9eAVx5av/VpjDQSlPMvGgzGTq/VlyOIPjqavMQRlng2lD8MH2qvpuXbqdDQ0m 7SwQ== 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=sG1SBZcla4aGNpdml0Jq6oP/xEaOhu3kqKf55g24hc4=; b=vIe7Bf/+HwY6iry3IbmCD9p++VtArNPSlsdx7j4hU8dZ5x9tDX/svor9dMAhx64oDv sbp9ireLTKA3TsIsrP2tB2smeZqlbuzRMI3AiiBVuolOEu7vskiiCFfjLzCss7WL1Gf8 6SH+j3eWuEqaqwiCRaQL2zAhB+y4M4kX0+UjFp1M4jc1YIOGcdBA+00re3I5bOqhywwl T7kDCbkFSsFXHG3yFlX8gokDaLBkVSIoIMXvpLDoHMinRauDhu1hD24Z2msJAQFuax2w 3dwYVtgG0oVHSfh2AnSO7Nc7TR5P4nrS9ozmNmGE1fDxbDR6E5bUjT83UwVXoL5OxBrG 6Z3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sdyyl23g; 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 d21si708969jam.9.2021.08.02.06.58.11; Mon, 02 Aug 2021 06:58:22 -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=sdyyl23g; 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 S235900AbhHBN4L (ORCPT + 99 others); Mon, 2 Aug 2021 09:56:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:60854 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234853AbhHBNuv (ORCPT ); Mon, 2 Aug 2021 09:50:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E2EB4610FD; Mon, 2 Aug 2021 13:50:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627912230; bh=8emaHppUL/0BfGTf1x1Cvm0PKcYxfJ4rhTRJG6q+I2w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sdyyl23gFjh4+Y4OHWOPIAPU0PrShDVuySjgYbokOHtPHWpQwNKiQOs8wodblXnCB nYLzkUPFclVKWr2Cl117mdBEBz6RF4rW94pnMEMFWRk6znYc9PWvSY5CsOVi7u581D Qr9D9vWDGn5pDHPtQvAzfVyvJpYx6rrHF9BYlQXA= 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 4.19 16/30] netfilter: conntrack: adjust stop timestamp to real expiry value Date: Mon, 2 Aug 2021 15:44:54 +0200 Message-Id: <20210802134334.592916600@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210802134334.081433902@linuxfoundation.org> References: <20210802134334.081433902@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 1dceda3c0e75..c5590d36b775 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c @@ -630,8 +630,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