Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp858633pxb; Tue, 1 Feb 2022 11:54:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJwBN5rpwde/xh+oJ62zYyplhxKixCOZjJc0cqUmd4SxMIDDdl6oZdzWS6Qh+JgYUg2I9eNv X-Received: by 2002:a17:902:bd03:: with SMTP id p3mr9905802pls.50.1643745278629; Tue, 01 Feb 2022 11:54:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643745278; cv=none; d=google.com; s=arc-20160816; b=NfzasFaTtY3IMjW0tL7Os0OWSPKJGj4HVYzI5naRpdvTE2BVnxGDTJFZuflouq59v5 FtCgTQ01OB5pJ7s/jDFsyKf6ZHAIBGF4H3qky0GnQqc3qmNU4hpyeQ9F3nN+MLQWawQM dyXNWRJ51M+hQBCXu/F/t+6cPjuxIf1ys1NNodi5wSG6uoKN9M/WthhSqZ04n4hg8hzI 7rkV2pZxnya1ZpeQSCY7YVN/CDUIZrodYtccMYlNi4wt8takmBat8bApHWgEEXqdWx+p UNRqBNvuA9Zn8SetviS9xVN5ADvtzG4Wk5XvaPLVs3wnVyEFpMgQ8KZOz0FQlUbTQrD1 9PTA== 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=0LNO4ZgR6SxTDNl48rTkJFtl1J/2rheQV6izlgvPgoI=; b=RlCoSJFI9EwEZHEGzAO/dapq8LOv0f6gKBP/oBv5WxNdqNbV7SsUUE6iRcqNoDv++l Yk9feXMoYDl7rkrCDnxMrV2RiZ6V39khLjekE2UJ9W6p4XwlTxn1IL9vgHYAUPlF8CQ0 miBzkHWKnSOwO2ZpBdanTjvO7WF1yVoPEFbXfPR0TSxqTsp8n0Sk1z0F3lLcu9RlzdfT 4Ev1W0JjNAoeukOkdNwNtNl9p51rr/xchd0Kif9tFXkPEKdmBeIEV3OKCzo1cJ8FhS4x tM1AY7nfjDyTFBzDSJ70Au4Q6vlFJXrg8kY7hG/D4ljhioMGL2GeysU0GkYco6t2HFAr Gjbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nyYXYujc; 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 y36si20598828pga.623.2022.02.01.11.54.26; Tue, 01 Feb 2022 11:54:38 -0800 (PST) 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=nyYXYujc; 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 S1358745AbiAaLEi (ORCPT + 99 others); Mon, 31 Jan 2022 06:04:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358873AbiAaLB4 (ORCPT ); Mon, 31 Jan 2022 06:01:56 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E642C061757; Mon, 31 Jan 2022 03:00:17 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 48FDFB82A69; Mon, 31 Jan 2022 11:00:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68276C340E8; Mon, 31 Jan 2022 11:00:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643626815; bh=zlA4dr6EEzG4yI4mNFgUJEXAqyTrvPkR0P4A7MTyLSU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nyYXYujc/EMLk4fP1ZABTcvYJ+JWg8IXS0arr1JfeWG6WVzaTz+6ovvrLpq8xgwKa lxAkMSxUqdqTPugTblDl8vZKHjJmaMeU/BoLDczRtUYgZ+TzQlvh4fEbQHwqORU0Z3 29PQOa4LbSdStDpDXQuRqhRPwFCh5Yv7YklS97qw= 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.4 49/64] netfilter: conntrack: dont increment invalid counter on NF_REPEAT Date: Mon, 31 Jan 2022 11:56:34 +0100 Message-Id: <20220131105217.335272096@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220131105215.644174521@linuxfoundation.org> References: <20220131105215.644174521@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 830af2eba40327abec64325a5b08b1e85c37a2e0 ] The packet isn't invalid, REPEAT means we're trying again after cleaning out a stale connection, e.g. via tcp tracker. This caused increases of invalid stat counter in a test case involving frequent connection reuse, even though no packet is actually invalid. Fixes: 56a62e2218f5 ("netfilter: conntrack: fix NF_REPEAT handling") Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nf_conntrack_core.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index 4bcc36e4b2ef0..d9b6f2001d006 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c @@ -1709,15 +1709,17 @@ repeat: pr_debug("nf_conntrack_in: Can't track with proto module\n"); nf_conntrack_put(&ct->ct_general); skb->_nfct = 0; - NF_CT_STAT_INC_ATOMIC(state->net, invalid); - if (ret == -NF_DROP) - NF_CT_STAT_INC_ATOMIC(state->net, drop); /* Special case: TCP tracker reports an attempt to reopen a * closed/aborted connection. We have to go back and create a * fresh conntrack. */ if (ret == -NF_REPEAT) goto repeat; + + NF_CT_STAT_INC_ATOMIC(state->net, invalid); + if (ret == -NF_DROP) + NF_CT_STAT_INC_ATOMIC(state->net, drop); + ret = -ret; goto out; } -- 2.34.1