From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B22A843252; Tue, 31 Oct 2023 15:28:09 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5FB354029E; Tue, 31 Oct 2023 15:28:09 +0100 (CET) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2069.outbound.protection.outlook.com [40.107.93.69]) by mails.dpdk.org (Postfix) with ESMTP id 42A8B40284 for ; Tue, 31 Oct 2023 15:28:08 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jLWUHEaa6weL9IXkfJiUGR/y6G0qbJMCEL4MHR9r0JpwdQizXVWpykFExcqhen75+Ch2teDTeRdWevdzUuGRAKneS5xfxHV7ApN9Eu/vMxr3wi4jW0OPpQV0w1Y+LLytspgnQouV/tekk5P91h0V8GlPEEhh2wdFzeyIM9D3cwpw2893EXbcc71hWp7DjA0wXDHO0ltsB8JxXxWHCt+ncbsB6K4wSXW+2pAeiRof2XQ3egaMgs06XHpvJC3OgQQgB5sfgv7+TtN8d6+QSt162i0J/eVxmByfeP8+piRmWsd0/mgOYvEj8aO72VTtV8ctx8hbWmfjkBgX80svrPGFvQ== 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=q3LBPYbgN5D47JeYiqDWQ+4OZLLrLB09GKRt2cNZh78=; b=LKkP9wWhM4PDRtfjbc5S84CC6ljc+2Jeku40/dlUPal/TE7k2vfOUlb0iozrzQRNnU1qp45ENbwoR+brjHY0OqaaEvY+4WagztGMiM0K7hFsJyNbJU1B0eu0iNzDz8lEZ7v67CSfRKqmYnR+vv3G816JVjqUTiOcM9fhYSzEewB8ftrT+0u5qYbAoprU2wT4Fz5PreFSslNPTSZruLCink3J9uFHvBwvQAvcovLtBov1uhBA2eA2qwZzulYHoGZhFvOp5oVWZc72TAo6Hzn8Hix9SoFnhnpHSnXxUke+A/GI8/v8pVMsio9OFSCZniOCunZusOb0OzrM0IpqvV2viw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) 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=q3LBPYbgN5D47JeYiqDWQ+4OZLLrLB09GKRt2cNZh78=; b=gMQm7PAYlNNt9EOP5lPlw3te3IWSgH+g99S2vrWOdRAXft1sld1s889OMxJuhpRytyCGl0mjBr9GvcVmRIttho9Ui1c7nYoaCuD7A09HBiG/Rw5z3cM/Pe0umwxbDOrPkZxwt/9V7Ak5lJO+EyIsAzXQdyAUJdooxWzCekV92CjjCn+rF+167wseK4AxtfpbUn54g6RHsm6izrgE9gTswK4lIwVw57xEViHoQ0ZhqOMeMHJtgI/7/XiJaBGDgGEERt/V5fzxfFWI052AuqzyL26EyLVLu/0s4mY+8JhCS0aEnYw5HaWBVL/CRC6rRUtxVO2Oh0yZDa5QEE6G+OuTEw== Received: from CYXPR02CA0006.namprd02.prod.outlook.com (2603:10b6:930:cf::10) by DM4PR12MB6302.namprd12.prod.outlook.com (2603:10b6:8:a4::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.28; Tue, 31 Oct 2023 14:28:06 +0000 Received: from CY4PEPF0000EDD5.namprd03.prod.outlook.com (2603:10b6:930:cf:cafe::22) by CYXPR02CA0006.outlook.office365.com (2603:10b6:930:cf::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.30 via Frontend Transport; Tue, 31 Oct 2023 14:28:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CY4PEPF0000EDD5.mail.protection.outlook.com (10.167.241.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.19 via Frontend Transport; Tue, 31 Oct 2023 14:28:05 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 31 Oct 2023 07:27:54 -0700 Received: from nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 31 Oct 2023 07:27:51 -0700 From: Dariusz Sosnowski To: Matan Azrad , Viacheslav Ovsiienko , Ori Kam , Suanming Mou , Itamar Gozlan CC: , Raslan Darawsheh Subject: [PATCH 1/8] net/mlx5/hws: fix leak in FT management Date: Tue, 31 Oct 2023 16:27:26 +0200 Message-ID: <20231031142733.2009166-2-dsosnowski@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231031142733.2009166-1-dsosnowski@nvidia.com> References: <20231031142733.2009166-1-dsosnowski@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD5:EE_|DM4PR12MB6302:EE_ X-MS-Office365-Filtering-Correlation-Id: 7cc43abb-dba6-47e9-c616-08dbda1d98ee X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2qprI5+T7Os/uAtvnaPyACA7LuttjqIRMvGLItlLfK3DWtPOOA4ZuASm8EJGXEcBWtu3kyAMJZ8CY7Sytx5PwrQyzd/W6u4VGqI170Drcj0eaqtq0b9AHBHlQy4N//GmSRJm0cmDJ03XBfHDG9fGzgvv/HzZcUgvYhLJC1fpaZ5Wpt3rcEgh5yyhpaA15DOoCwoGFzKDjXf5nCJCJlOn1kgcQFsyYXqrSch50PkxQYxs1EKTia9CJERMmjEhlgkVwDwgkta/q5MDO+ysKsOtTzOZJ4f45Ng3DapWH++jV+clDOdTO2iHFNVVSdRVAiprEoEIlHRdH3RKr9NUf8/A9PG0e5TKISMl925NE6mvZNDuMMe9hHemnC09P2p2mFLhFjS/oNi9UHkrge9tq9GZ9Umu6yLDN7tGs5o6FOuzhbODaBhDlohiL5ly4cVyfYO0Zt6A97P6iBL4gdqt0nnmcWIHl34ybZKGDfL+/2wgJ3GtNg5RiaZlfAKFFeDuEAUI7w9OIIHiWtYkKdRjJKibrclR5lfnZpJbQMJ1hn1Hp4fLgNLmovi/Sl1ug2lm6qE1hbQ2pWzK+H2doVs2qbReapImqTgNd1ADxUwUiNYn1z10zaeIFjrxmkdq/X8HH98KAupvt4zV7smRcyXA8grLOPiX+aIrTbH4gmnQiAOBRDfSGW8o1neBCoxB4mK607+Fes+0KzIj8JLSuPPgZ95A1z5ucNCRTT1woIjNe5kvNYLm9hEEQicNVNcAZN29NSFF X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(396003)(346002)(39860400002)(376002)(136003)(230922051799003)(451199024)(1800799009)(186009)(82310400011)(64100799003)(40470700004)(46966006)(36840700001)(110136005)(2906002)(86362001)(41300700001)(40460700003)(4326008)(8936002)(8676002)(5660300002)(36756003)(478600001)(55016003)(40480700001)(47076005)(7696005)(6666004)(1076003)(107886003)(7636003)(6636002)(54906003)(316002)(16526019)(6286002)(70206006)(26005)(426003)(70586007)(336012)(82740400003)(83380400001)(36860700001)(2616005)(356005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2023 14:28:05.6655 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7cc43abb-dba6-47e9-c616-08dbda1d98ee X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6302 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Itamar Gozlan This commit fixes two leaks in flow table management. The first leak was when the default miss table of a flow table was not reset to the default action when setting a new first matcher. The second leak was caused by a missing free for an RTC in the case of disconnecting the last matcher in a table's matcher list. Fixes: b81f95ca770d ("net/mlx5/hws: support default miss table") Signed-off-by: Itamar Gozlan Acked-by: Viacheslav Ovsiienko --- drivers/net/mlx5/hws/mlx5dr_matcher.c | 41 +++++++-------------------- 1 file changed, 10 insertions(+), 31 deletions(-) diff --git a/drivers/net/mlx5/hws/mlx5dr_matcher.c b/drivers/net/mlx5/hws/mlx5dr_matcher.c index a82c182460..ebe42c44c6 100644 --- a/drivers/net/mlx5/hws/mlx5dr_matcher.c +++ b/drivers/net/mlx5/hws/mlx5dr_matcher.c @@ -253,15 +253,15 @@ static int mlx5dr_matcher_connect(struct mlx5dr_matcher *matcher) goto remove_from_list; } - if (prev) { - /* Reset next miss FT to default (drop refcount) */ - ret = mlx5dr_table_ft_set_default_next_ft(tbl, prev->end_ft); - if (ret) { - DR_LOG(ERR, "Failed to reset matcher ft default miss"); - goto remove_from_list; - } - } else { - /* Update tables missing to current table */ + /* Reset next miss FT to default (drop refcount) */ + ret = mlx5dr_table_ft_set_default_next_ft(tbl, prev ? prev->end_ft : tbl->ft); + if (ret) { + DR_LOG(ERR, "Failed to reset matcher ft default miss"); + goto remove_from_list; + } + + if (!prev) { + /* Update tables missing to current matcher in the table */ ret = mlx5dr_table_update_connected_miss_tables(tbl); if (ret) { DR_LOG(ERR, "Fatal error, failed to update connected miss table"); @@ -276,27 +276,6 @@ static int mlx5dr_matcher_connect(struct mlx5dr_matcher *matcher) return ret; } -static int mlx5dr_last_matcher_disconnect(struct mlx5dr_table *tbl, - struct mlx5dr_devx_obj *prev_ft) -{ - struct mlx5dr_cmd_ft_modify_attr ft_attr = {0}; - - if (tbl->default_miss.miss_tbl) { - /* Connect new last matcher to next miss_tbl if exists */ - return mlx5dr_table_connect_to_miss_table(tbl, - tbl->default_miss.miss_tbl); - } else { - ft_attr.modify_fs = MLX5_IFC_MODIFY_FLOW_TABLE_RTC_ID; - ft_attr.type = tbl->fw_ft_type; - /* Matcher is last, point prev end FT to default miss */ - mlx5dr_cmd_set_attr_connect_miss_tbl(tbl->ctx, - tbl->fw_ft_type, - tbl->type, - &ft_attr); - return mlx5dr_cmd_flow_table_modify(prev_ft, &ft_attr); - } -} - static int mlx5dr_matcher_disconnect(struct mlx5dr_matcher *matcher) { struct mlx5dr_matcher *tmp_matcher, *prev_matcher; @@ -330,7 +309,7 @@ static int mlx5dr_matcher_disconnect(struct mlx5dr_matcher *matcher) goto matcher_reconnect; } } else { - ret = mlx5dr_last_matcher_disconnect(tbl, prev_ft); + ret = mlx5dr_table_connect_to_miss_table(tbl, tbl->default_miss.miss_tbl); if (ret) { DR_LOG(ERR, "Failed to disconnect last matcher"); goto matcher_reconnect; -- 2.25.1