From patchwork Thu Feb 23 22:32:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Tu X-Patchwork-Id: 1747202 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=N2g8w6MZ; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PN79B6gDMz2466 for ; Fri, 24 Feb 2023 09:33:49 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1pVK9f-0001Sx-F0; Thu, 23 Feb 2023 22:33:35 +0000 Received: from mail-dm6nam04on2065.outbound.protection.outlook.com ([40.107.102.65] helo=NAM04-DM6-obe.outbound.protection.outlook.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1pVK9a-0001Sj-Oz for kernel-team@lists.ubuntu.com; Thu, 23 Feb 2023 22:33:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O+qBYF/YMpsU38qI/ugVWurzjXMiifhACGi7JuZSfpRd/YtSvcfTNJAIx1D6w8rfCSkJ/+/knE8tmVeFu4MIeVQpMSAxlm3xuT7DY3hZ634+URTjZlac447QVGsOM8btLTPBL1bkTyToehTYy70lPa0zNUJS+A4SAigWw7/AvXTzp8i91fRd4MLcXei/lY8w4q7tWa6N42QVnptQMsxJb9n6/5tAJoodyiy61olNrq6somIKfmJZIOT3sYb5p6jI+78dZPlOW/OMETEtN1VMscUC7XJuq1DjA4IL1TmfPpSuwyDGef9kiCiRG1FSo/3r6wNwrxob14orjJNvo5Xf1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wOtiyqh4AQW9LEoW9SOhrvlZN4P5JBVgMXFaNDhFuwY=; b=BFZzoD7mur66f+ceaGpX07Dojs6Ktf2ZM/NvSMYfzUNfV/Sbav37iYzG7OgwXJqayJF/dTq0kSQV6sURp6YKaoFNyoWIEKvsU04SBXqEoRsYhw4SIQ8VPBYkAorwczGuxLh8EqpgM4bMsWjCcrPvZ3NRwDJCZuO5tq41e/1/p2GDK5bkvM3xG6dZqKQDabVXpxZpSitQYrW3TBaBzKlXhOW39YwFxN5TzbAmDX+OoRnLc5trKykn6BA27CjLf7cmpvXckXzGx8rwK77LY3ffDMkvPmV84Ux78k4PyHTHdO9PufXI1/fq1ssuLvPI8a8CCriDZXIVmliFWkgeHJ91gQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none (sender ip is 216.228.118.233) smtp.rcpttodomain=lists.ubuntu.com smtp.mailfrom=sw-mtx-003.mtx.labs.mlnx; dmarc=fail (p=reject sp=reject pct=100) action=oreject header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wOtiyqh4AQW9LEoW9SOhrvlZN4P5JBVgMXFaNDhFuwY=; b=N2g8w6MZP+x7c+6r+gbXHRkts7M72RUK4b19QC7rEleMxD42+i4esaLCZCHvlORrULAueyeAFyAuIQBOjBII4mU2eMq8EhhTwDpPvsgSThx2Wmgf3QfEQSpsC7UwZBk2684IXCTyWEk2knfsCFX0tW10gd3gdKsxSUFxtXmhwM53QjmhUbwcaCBmKsFm5GxR2paL9X3Um1ZADum4WxRk/DlkY24zrLXx7VicNeE1kHhiWpKFi3gTx7X4lqUaA2n3Lfi4KrdDSsGIX1u32sJnYTdCO/mKq8THn2+F2no+B2L5fZcPsWkMFqDS4Yci6b9KojH+KBsITiB1ujhoKJBi8Q== Received: from SJ0PR03CA0134.namprd03.prod.outlook.com (2603:10b6:a03:33c::19) by CY8PR12MB7121.namprd12.prod.outlook.com (2603:10b6:930:62::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.21; Thu, 23 Feb 2023 22:33:28 +0000 Received: from CO1PEPF00001A5E.namprd05.prod.outlook.com (2603:10b6:a03:33c:cafe::db) by SJ0PR03CA0134.outlook.office365.com (2603:10b6:a03:33c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.21 via Frontend Transport; Thu, 23 Feb 2023 22:33:27 +0000 X-MS-Exchange-Authentication-Results: spf=none (sender IP is 216.228.118.233) smtp.mailfrom=sw-mtx-003.mtx.labs.mlnx; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=nvidia.com; Received-SPF: None (protection.outlook.com: sw-mtx-003.mtx.labs.mlnx does not designate permitted sender hosts) Received: from mail.nvidia.com (216.228.118.233) by CO1PEPF00001A5E.mail.protection.outlook.com (10.167.241.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.14 via Frontend Transport; Thu, 23 Feb 2023 22:33:27 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 23 Feb 2023 14:32:56 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 23 Feb 2023 14:32:56 -0800 Received: from mtl123.mtl.labs.mlnx (10.127.8.10) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36 via Frontend Transport; Thu, 23 Feb 2023 14:32:55 -0800 Received: from sw-mtx-003.mtx.labs.mlnx (sw-mtx-003.mtx.labs.mlnx [10.9.151.14]) by mtl123.mtl.labs.mlnx (8.14.4/8.14.4) with ESMTP id 31NMWrsg006593; Fri, 24 Feb 2023 00:32:53 +0200 Received: from sw-mtx-003.mtx.labs.mlnx (localhost [127.0.0.1]) by sw-mtx-003.mtx.labs.mlnx (8.15.2/8.15.2/Debian-22ubuntu3) with ESMTP id 31NMWrEr1321627; Fri, 24 Feb 2023 00:32:53 +0200 Received: (from root@localhost) by sw-mtx-003.mtx.labs.mlnx (8.15.2/8.15.2/Submit) id 31NMWrR51321626; Fri, 24 Feb 2023 00:32:53 +0200 From: William Tu To: Subject: [SRU][F:linux-bluefield][PATCH v2 1/2] netfilter: conntrack: add nf_ct_acct_add() Date: Fri, 24 Feb 2023 00:32:50 +0200 Message-ID: <20230223223251.1321608-2-witu@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230223223251.1321608-1-witu@nvidia.com> References: <20230223223251.1321608-1-witu@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF00001A5E:EE_|CY8PR12MB7121:EE_ X-MS-Office365-Filtering-Correlation-Id: 54ee65ca-6ce8-4ea2-2f91-08db15edfb91 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vyFeA5JTwbkDeP3PbyVUNMS6YpATTgbr7rrqbTPDBgIpHt1aTTsbaFym0u4+EQgunX6d7zTz4euO0YatCCFCJBbS9nzTlKK+OC5PRIhixTHkA+EydDb0YbfgR0+2Jd1aMyrEE7Me8MJALdrW30/goSPyVaBBIC7q5PGOh+X0uQKTEUW0+OL1KZmG1WwCETvxU8M8YkOR9Gb+IurOIF2XUbc6DFZhKCiLKPVHD3WpUV/jF2EkzO+3Sh3hGKeeLhjBoLUVT6EIKdrt0iXaqjPP7iYuqUbOXsQ2owNRZ1PHWKQJZu3iWZcY8BMOyi+qePtdjQXq8hdumcy2l5uw0UL2RQv8JTIhzZCFR5afGGcvzD2PsRQtgz1W68yjfS8NIZZ4yY4QtPThlGq3f6Ep2EKx3SiMd3tS4WugQsFqNtxEMNPwBy8/tLnCX+Eou+k50m7UVmDrXzh3y46FdeKwDCQRW5e4zu8xUjyNFgIjndUfFDVTnotsWxlwQPtSz4Bsd+OZCT5vtGkM17WQqptgozt+IS39gNZqVPyQFJJ+ythWB/4Bofj2tPfK+SZSmUQq4mhbAh+ELem3+yhedwnHvl4qUq80jHR/5S0hTLPGX0DQz5pp1k8x+I51x2akr8loFTYj0KpT4sSv3GSGIBohC5NQYQh43x3lFXx/La5nXuzex3IMGsZQ+EV8CU1QmzQGtEG5F6NuzYt62gVYD5ZJGifptPKM6Wq2TMkSLXnF+E+OjE+pQ74hwTaQ0vY5nHW4qlhL X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230025)(4636009)(136003)(376002)(346002)(396003)(39860400002)(451199018)(46966006)(40470700004)(40460700003)(36756003)(5660300002)(83380400001)(47076005)(40480700001)(35950700001)(8936002)(336012)(82310400005)(107886003)(42882007)(966005)(498600001)(2616005)(1076003)(26005)(4326008)(83170400001)(70586007)(356005)(70206006)(8676002)(54906003)(7636003)(82740400003)(2906002)(41300700001)(6916009)(42186006)(316002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2023 22:33:27.1960 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 54ee65ca-6ce8-4ea2-2f91-08db15edfb91 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF00001A5E.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7121 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: bodong@nvidia.com, vlad@nvidia.com, dann.frazier@canonical.com Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: wenxu BugLink: https://bugs.launchpad.net/bugs/2008136 Add nf_ct_acct_add function to update the conntrack counter with packets and bytes. Signed-off-by: wenxu Signed-off-by: Pablo Neira Ayuso (cherry picked from commit 9312eabab4a68348af5b4482cc7cc6f151ff1c3f) Signed-off-by: William Tu --- include/net/netfilter/nf_conntrack_acct.h | 11 ++++++++++- net/netfilter/nf_conntrack_core.c | 7 ++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/net/netfilter/nf_conntrack_acct.h b/include/net/netfilter/nf_conntrack_acct.h index df198c51244a..7f44a771530e 100644 --- a/include/net/netfilter/nf_conntrack_acct.h +++ b/include/net/netfilter/nf_conntrack_acct.h @@ -65,7 +65,16 @@ static inline void nf_ct_set_acct(struct net *net, bool enable) #endif } -void nf_ct_acct_update(struct nf_conn *ct, u32 dir, unsigned int bytes); +void nf_ct_acct_add(struct nf_conn *ct, u32 dir, unsigned int packets, + unsigned int bytes); + +static inline void nf_ct_acct_update(struct nf_conn *ct, u32 dir, + unsigned int bytes) +{ +#if IS_ENABLED(CONFIG_NF_CONNTRACK) + nf_ct_acct_add(ct, dir, 1, bytes); +#endif +} void nf_conntrack_acct_pernet_init(struct net *net); diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index 8ff545f4f50d..9130b70935af 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c @@ -865,7 +865,8 @@ nf_conntrack_hash_check_insert(struct nf_conn *ct) } EXPORT_SYMBOL_GPL(nf_conntrack_hash_check_insert); -void nf_ct_acct_update(struct nf_conn *ct, u32 dir, unsigned int bytes) +void nf_ct_acct_add(struct nf_conn *ct, u32 dir, unsigned int packets, + unsigned int bytes) { struct nf_conn_acct *acct; @@ -873,11 +874,11 @@ void nf_ct_acct_update(struct nf_conn *ct, u32 dir, unsigned int bytes) if (acct) { struct nf_conn_counter *counter = acct->counter; - atomic64_inc(&counter[dir].packets); + atomic64_add(packets, &counter[dir].packets); atomic64_add(bytes, &counter[dir].bytes); } } -EXPORT_SYMBOL_GPL(nf_ct_acct_update); +EXPORT_SYMBOL_GPL(nf_ct_acct_add); static void nf_ct_acct_merge(struct nf_conn *ct, enum ip_conntrack_info ctinfo, const struct nf_conn *loser_ct)