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 98F9345DA7; Tue, 26 Nov 2024 09:35:19 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5F9244025F; Tue, 26 Nov 2024 09:35:19 +0100 (CET) Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2059.outbound.protection.outlook.com [40.107.212.59]) by mails.dpdk.org (Postfix) with ESMTP id B6B55400EF for ; Tue, 26 Nov 2024 09:35:18 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=usuUngCGI5jlSZsgkZmBBuJPeRm1iiPpzuS95O8Ot/lvLiAV7Hg0ObsnyHP9S/3SvlwWvZ1p/kSi+XoAazhmpkyv252ia3LKFUGs5IqPK+XOBcVIVaJ/qpysDWnqe4MCiASMAZfHX4DKp4qPTl0AEcVNDIYwn79SAWiSEnLecRMEeowNBDmNhUuW3jHq/01zCkW2+BXpc5ok/KYz5azsJ4l8+k9KRuF2edYixQCen31SEI9OnfkCWf9hlG+0kTO8QZDZEsGQPKSPODG5fPioAtolT2Do2MJd2H009q1RTYeBLZeTNQAZKuhheJgs1gKJPWnC5s6ge0t3M04i/mBHAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=9NYVZqHVud9Awohhy8bLogLx0XiENz7qbDHQ5p6Zx1Q=; b=MWu5royOlglyIVnUd1D6McC/ky9r5T2Y3HJcBqAqB9DDCNRh7pJpt4cOqVGWNrCisUuJM0eVr+RRPfh62UNk1LG7sNH28jmvV+83CJ3b/MPWCd//D3B7wTWWWW7Sl9MMeRIObuX22083j+yBH9Vj8MVbwD2Q+4nJUuWXUxK/RssP4CzVx6UsYYLGT3txc5oyIrP4sNrOCa7sODBEEUgDW+FeVSfYdSmLmaeJ7HwQBNlU0PdLg4v2ED41GdgonTOn9R+XYcPFD8Dm9LXOCEbLE3sE5MZuMXnvpR2LERAhmp9KhomLDrNRr/jWcOL+YcDzgAy2cpWVWCs4yip8cEqOcw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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=9NYVZqHVud9Awohhy8bLogLx0XiENz7qbDHQ5p6Zx1Q=; b=sPQH5gsx6tVh7SCO1xuiQxkIqREGc+pR/jfS59rGJLiTlgk5ZXLZbePbF9r/zST1M804qO1H0hBLEppnvANizlqxMtSAQqCsPfT9UioHOsayjaQmo0n2XZaP4h/riaJH/k674wy/c+3lHRE9ZhxcPiBEvUbsIi3eku5pzB8ziqX0qAVpzwSrYMN/MHpfofPcz0+w6suj3H+npQ+qLkte2944GOS22L6nH1VWU99XOLBz0KsMme289pclQhbh0HbjGBAbDPvwXpFdYCy5sVYwK7cPXi+Z65kh9WAI4JsjmAsiJ3oFs21xGluLh6itOYRFFRw4d4vw8wf7udb3smREkg== Received: from MN0PR03CA0023.namprd03.prod.outlook.com (2603:10b6:208:52f::22) by LV8PR12MB9181.namprd12.prod.outlook.com (2603:10b6:408:18d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.21; Tue, 26 Nov 2024 08:35:14 +0000 Received: from BL02EPF00021F6B.namprd02.prod.outlook.com (2603:10b6:208:52f:cafe::9d) by MN0PR03CA0023.outlook.office365.com (2603:10b6:208:52f::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8182.21 via Frontend Transport; Tue, 26 Nov 2024 08:35:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BL02EPF00021F6B.mail.protection.outlook.com (10.167.249.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.12 via Frontend Transport; Tue, 26 Nov 2024 08:35:13 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 26 Nov 2024 00:34:57 -0800 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.1544.4; Tue, 26 Nov 2024 00:34:55 -0800 From: Bing Zhao To: , , , CC: , , , Subject: [PATCH v2] net/mlx5: fix the leak of action data list Date: Tue, 26 Nov 2024 10:34:40 +0200 Message-ID: <20241126083440.307609-1-bingz@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241118065259.250538-1-bingz@nvidia.com> References: <20241118065259.250538-1-bingz@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF00021F6B:EE_|LV8PR12MB9181:EE_ X-MS-Office365-Filtering-Correlation-Id: e09998bf-f6f4-420b-6dfd-08dd0df53f8a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?9GoW2TtAzC1D3uQJCTi+WXQxbe1F4v93beTatmHo6jqrSr9Qyt+5NjfTnDzX?= =?us-ascii?Q?FhAWmGY1vPbLw3jzX8DbytrK++0gtOiq3RoAJelfjmHrBJCDgB8dgsA+IZiw?= =?us-ascii?Q?kx6COjG0ZgdaDKUcQB7HW4O0nPd788J0509Li/S3jtYRksgjsx2nNTSjS43t?= =?us-ascii?Q?r0ncqfUoDfaf2vxOVpqVkKm+38aGxa3ANu27QKZCWvErXe/sr/G6QoD/NsRw?= =?us-ascii?Q?S8uqhqntExEaquSagnTfuTEqIQgh8DeRrbe7vQtrCYchrTl3xtiCVMd6GwXz?= =?us-ascii?Q?fs5sXCH11ydujQ8HYa4D1ioBAFQujYctvq0xTTxYVvYM4+cEqo4XRT0AuftT?= =?us-ascii?Q?du9a1EanVhfCa0hjEf8KrtruM3GuD3UG5819WWfSZWHKzr5wbs8kRXNdlCuW?= =?us-ascii?Q?AHZsXxO3y7XY5SCY4570mwUAbJZ4iF/u4uHEoOxGZjzixbCT3qCyPyC4ILdR?= =?us-ascii?Q?3OdXLV+infKK2yTnwdiQ0TgEzkdxy3u6voS9ThI5GsnGY7Whoh/c8eHOpKqA?= =?us-ascii?Q?qFtWgFuy7IZnLCaMEeBiR2ZsjZP5dhHUGVvthmJhKyso/uWmteosiebXEHhx?= =?us-ascii?Q?afvrvHCyfVI8TG/RASMA7xexIqDDyGpPV72u4HIANvSxqyOa3J3f+kyqcc3E?= =?us-ascii?Q?MnL4HLGAlRm8fea9MDkFdN1L3vPcKXk1ZMxY33pmqlekMp9Dz2HfFJ6mLZtZ?= =?us-ascii?Q?7FPbKtyIjZIcRXsBM9/LNOxA0Pqt1+LNuskqzWHQLp9Rx1EJmq3DWIyB69BZ?= =?us-ascii?Q?EHO+Sq/A9dv85HlOjcTmEwJeCgWFZc4GnVgjJy81E5wFmvtNSEsfBW5e95Jy?= =?us-ascii?Q?jIodsp/+Z7YYg0I4XR9+zN7cFDQW7KKCKFiEQIDX10yj3cNGi62pS9rcZTaI?= =?us-ascii?Q?FotZIUbj+SQ/58F9Ck5w3ockfIWjNH7QQO3D+r0BFDGA3YETTHWayM79OmS+?= =?us-ascii?Q?54VUWWB1QsNYf9ONzCS6dXDCdVXmwOrSYSFgGb4pYqX6OqZZw6JFkTuVH7Dv?= =?us-ascii?Q?KXx3m8P9oSza+G9jh+Bgwy1RSd1hocGnDYyaHsRzIuy//D2WE7/JXEYEXFNj?= =?us-ascii?Q?yXn0Q1XiFJ2X2TFckDWp/FzgNC/gGpvQn72c3j0TFgya+j90PJrWl2vm8tkL?= =?us-ascii?Q?Gkb5/0vXCOIHX17GIelG4r24P3zy3AC9Llt2cOyZQeOBaXePKdCbJ/IOp10v?= =?us-ascii?Q?tjtmcdLiHv7BXEg+qB3r4bWtf8y22XholERE6CbH+TUkctPVxPJTMkkb7IS0?= =?us-ascii?Q?wgia5JwA2QwNY2BeAbEmaCkwzwQqYJMpkbAHYPCynZSG1+3cxGK90WVkYyAk?= =?us-ascii?Q?durssAdbGkL+vqKtIkZ088lWxRVP47MVhongxPBau7zuHpyS1LNr6BBNtkX+?= =?us-ascii?Q?6krDwdF9IDRz8W5eUgZsvt/7O2qfbBtPHYzVu65G/oNyiRlz+RbmmcXb58qe?= =?us-ascii?Q?mAZzvRRsW0Wtekaf1LGZhUc7rxtapvT7?= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230040)(1800799024)(36860700013)(376014)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Nov 2024 08:35:13.8632 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e09998bf-f6f4-420b-6dfd-08dd0df53f8a 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.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF00021F6B.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9181 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 In the actions construction for HWS non-template API, the `masks` parameter is always set to NULL and all the actions will be translated in the "construct" stage as non-fixed ones. In the stage of translating actions template, the actions data would be allocated from the pool and managed in a list. The list would be released when destroying the template with the actions. In the NT2HWS implementation, the temporary template was freed directly and the actions will be destroyed with the flow rule deletion. No other rule would use this list anymore. The actions data in the list should be freed when the actions construction is done. Fixes: ff4064d5b1fe ("net/mlx5: support bulk actions in non-template flow") Cc: mkashani@nvidia.com Signed-off-by: Bing Zhao Acked-by: Dariusz Sosnowski --- v2: update the commit log --- drivers/net/mlx5/mlx5_flow_hw.c | 63 ++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 24 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index 50dbaa27ab..7233ac46c4 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -966,18 +966,15 @@ __flow_hw_actions_release(struct rte_eth_dev *dev, struct mlx5_hw_actions *acts) } /** - * Destroy DR actions created by action template. - * - * For DR actions created during table creation's action translate. - * Need to destroy the DR action when destroying the table. + * Release the action data back into the pool without destory any action. * * @param[in] dev * Pointer to the rte_eth_dev structure. * @param[in] acts * Pointer to the template HW steering DR actions. */ -static void -__flow_hw_action_template_destroy(struct rte_eth_dev *dev, struct mlx5_hw_actions *acts) +static inline void +__flow_hw_act_data_flush(struct rte_eth_dev *dev, struct mlx5_hw_actions *acts) { struct mlx5_priv *priv = dev->data->dev_private; struct mlx5_action_construct_data *data; @@ -987,7 +984,23 @@ __flow_hw_action_template_destroy(struct rte_eth_dev *dev, struct mlx5_hw_action LIST_REMOVE(data, next); mlx5_ipool_free(priv->acts_ipool, data->idx); } +} +/* + * Destroy DR actions created by action template. + * + * For DR actions created during table creation's action translate. + * Need to destroy the DR action when destroying the table. + * + * @param[in] dev + * Pointer to the rte_eth_dev structure. + * @param[in] acts + * Pointer to the template HW steering DR actions. + */ +static void +__flow_hw_action_template_destroy(struct rte_eth_dev *dev, struct mlx5_hw_actions *acts) +{ + __flow_hw_act_data_flush(dev, acts); __flow_hw_actions_release(dev, acts); } @@ -13492,14 +13505,14 @@ flow_nta_build_template_mask(const struct rte_flow_action actions[], static int flow_hw_translate_flow_actions(struct rte_eth_dev *dev, - const struct rte_flow_attr *attr, - const struct rte_flow_action actions[], - struct rte_flow_hw *flow, - struct mlx5_flow_hw_action_params *ap, - struct mlx5_hw_actions *hw_acts, - uint64_t item_flags, uint64_t action_flags, - bool external, - struct rte_flow_error *error) + const struct rte_flow_attr *attr, + const struct rte_flow_action actions[], + struct rte_flow_hw *flow, + struct mlx5_flow_hw_action_params *ap, + struct mlx5_hw_actions *hw_acts, + uint64_t item_flags, uint64_t action_flags, + bool external, + struct rte_flow_error *error) { int ret = 0; uint32_t src_group = 0; @@ -13542,7 +13555,7 @@ flow_hw_translate_flow_actions(struct rte_eth_dev *dev, table = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*table), 0, SOCKET_ID_ANY); if (!table) return rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_ACTION, - actions, "Failed to allocate dummy table"); + actions, "Failed to allocate dummy table"); at = __flow_hw_actions_template_create(dev, &template_attr, actions, masks, true, error); if (!at) { ret = -rte_errno; @@ -13556,27 +13569,29 @@ flow_hw_translate_flow_actions(struct rte_eth_dev *dev, memcpy(&table->cfg.attr.flow_attr, attr, sizeof(*attr)); table->ats[0].action_template = at; ret = __flow_hw_translate_actions_template(dev, &table->cfg, hw_acts, at, - &table->mpctx, true, error); + &table->mpctx, true, error); if (ret) goto end; /* handle bulk actions register. */ ret = flow_hw_encap_decap_resource_register(dev, table, hw_acts, flow, error); if (ret) - goto clean_up; + goto end; ret = flow_hw_modify_hdr_resource_register(dev, table, hw_acts, flow, error); if (ret) - goto clean_up; + goto end; table->ats[0].acts = *hw_acts; ret = flow_hw_actions_construct(dev, flow, ap, - &table->ats[0], item_flags, table, - actions, hw_acts->rule_acts, 0, error); + &table->ats[0], item_flags, table, + actions, hw_acts->rule_acts, 0, error); if (ret) - goto clean_up; + goto end; goto end; -clean_up: - /* Make sure that there is no garbage in the actions. */ - __flow_hw_action_template_destroy(dev, hw_acts); end: + if (ret) + /* Make sure that there is no garbage in the actions. */ + __flow_hw_action_template_destroy(dev, hw_acts); + else + __flow_hw_act_data_flush(dev, hw_acts); if (table) mlx5_free(table); if (at) -- 2.34.1