Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1640770pxy; Mon, 2 Aug 2021 06:53:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQhvzpxCX5CbpUgR6sK93MOov3iL+8whyh11FvmO0QtAOX5AIbEnEfOVvLPplg+UhtDUtp X-Received: by 2002:a92:874f:: with SMTP id d15mr183411ilm.294.1627912415339; Mon, 02 Aug 2021 06:53:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627912415; cv=none; d=google.com; s=arc-20160816; b=L+mX7KGC5QWcgEvM7LKcoZrlPPrSeMG4XdnCiT75zzrw4fwesgInIy6uKXkACuExvx EZgmIijTCjNkfvQIehIieXYT5g6F1eLgiLxx2ZwvaSLpEvwy97zz5P9s/uJGO7h3Jofk nXsKHGHGmFK/Q1+GLPbQJrLyrMKWwsHFWI6eVfIwlQtlP8H9LrJZGqw4ZQtxy5y2SW27 PVfwfGM+8w1O7TZuwtApgyAB+EUE+DCgsGIoHqs73lWAfZKEZptLPwXSOUqdZujKcIeP PZ1fcpVnB8Jfh3V26MGQmwHJKwfUAmOhkStx3XLBaSKpTovRAKKZafTHkXBmLppkkCk3 6wlw== 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=u4uXXpSxuDq28gLOGPmuI5g2/jV96E046zYFm4pC9bU=; b=QbFWqE+vXBS0FuH921jlQf3Jpx9EH275YFbFkETnEV8cnvzhs/9tRLVuvfdqW1RAro Po6LTBqmqFQ/2WOoPoxCBJz7SZuuzHiItVqkAM59gIhWkmC+uICJDbMfAFmNS/N8PTct SMbd7h8RrOjq8Yv4rmpXdgyj64Hw5G4MHik5+DCMF7fYKNlWIE7v9b4EOb+4s7o5+5dQ DOSpiQKoSeDcq/jFvvWvoKkDlcGHugq4q4SoWOdB7S9RBJUcGAM0+TWf1cRfIuGEReCS VCENwiF+xwiKYyCSCeuthx2pfK7fkE2hoClIsYD4PSlG9yKI385xLufMqDH4j5kHBNSy XkzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GRoh7Xzr; 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 a16si11998064ioc.54.2021.08.02.06.53.23; Mon, 02 Aug 2021 06:53:35 -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=GRoh7Xzr; 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 S234972AbhHBNvu (ORCPT + 99 others); Mon, 2 Aug 2021 09:51:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:57094 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233979AbhHBNrr (ORCPT ); Mon, 2 Aug 2021 09:47:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A78EF61104; Mon, 2 Aug 2021 13:47:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627912050; bh=bGwZJDrafhoBL3FL+deMOlcQZuvPztcf6tCHmH7Spco=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GRoh7XzrkcKnIcSS3VN7EglpdM3mxm/IJM+ZbItbj9ai66336g4B7OQQJ7AaqxO9E 3rJAFlaX6MRpDNH71SU1PHN9gwfN4JNrd7muZvTlrrxcfEK22//7Hl30ZzNBXcfDES bl7seVsV4vUUd8F/Tu4Bf7+3JnBIuC+QQMNO1yBc= 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.9 25/32] netfilter: conntrack: adjust stop timestamp to real expiry value Date: Mon, 2 Aug 2021 15:44:45 +0200 Message-Id: <20210802134333.716493568@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210802134332.931915241@linuxfoundation.org> References: <20210802134332.931915241@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 ddd90a3820d3..d03f06717844 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c @@ -491,8 +491,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