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 26A4845C9B; Mon, 18 Nov 2024 07:53:36 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BA8304065C; Mon, 18 Nov 2024 07:53:35 +0100 (CET) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2047.outbound.protection.outlook.com [40.107.237.47]) by mails.dpdk.org (Postfix) with ESMTP id F36BE4029C for ; Mon, 18 Nov 2024 07:53:33 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hY//6nDrVO18fxhzMSHKs0v8jdRku9rruD5E+IHSqsXBO0aEHUYwfkBVUql7edfTQIps3uXpq2qYNILtTFZHBoYSBc0U0ykZhZfSnZqsHfN59u6eMped1LOLWbdddlNQ/Ly0U+lpVCbetJWcZNnkTOSNwwBNflkL+v1Fw31A4IYzRPMOBkODBto1aEK46qkVh41YQh+4VvBgoLjbHX3roHDfKnMdycildTmcDc3tHIdssGcBEeQI+AWMZtk9LRXeTS/T5A9MZarxsZvirJgzAmTvqnUZ1gaEtrNuwO+KQcnXqX24xJKUVOJChNsAa+ntTw01YnGgF5DHyKLQU0NSqw== 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=JQdJ911cDw0FA4aEBcFgnStes8c6s+DbFVXlS/1uEW8=; b=Uj+4ou2uEv7meovX3ywTQl9UqPBhMrshRjxJ+GnoMY56QjpLuZHcPTpcQtnX/jMqV+yYJqVaDotfpP8SKzx6NjPBj+8/FNYhotg0gjWtrQsUNFWuN7RGq7Sr+aIi8yUE96LLmAJd7drS2TXRWxZv204ktgwimkWFqcfYMTRvBhQ9vrQ8q6isSYSz0zi7Dtu+08R+mAH58tX/G5ZOC9ABK6Lbhb0UPRtPbv4NoFwgDXDV6GnUZCBZzS/6y7KlBZKS1MjAw/8lT8I8Zaqy2+7yq5H61oSCwoRwGkNv9NbtGtXpSRNqsmpCcOdMhbY22C5oOUFL+KYCeT8rZMFcwBsPOw== 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=JQdJ911cDw0FA4aEBcFgnStes8c6s+DbFVXlS/1uEW8=; b=UyTGHlhpXt9h5+W+LkEMjOBkJI1AOPuqPmRyh7RBUUV5RBaHRR4kY8O/QiwHqjJc97pnVmXprP2pFhn27XTbJYQkqzok73enjAeMGOnz2dyVZyzYEpvMpd3eIOAr1BXvtlgekxXnn0A5auNz3FaZhGajwrZRfyo+pPof9G2XmtwXAn8Ienq3T1Khac/wnSM1i9H9BAbEs+akWZ1vWD3fkVFuEeOFnmCoMT9Id1DT1V0SQlwHemR1oqa9qlgu1/Kun/WiLjl7kkwZz7vU8UsWrR5MZGt88YD7SfkK4sBaYAWEwa6s7DcvDNRoyLiXC5N8mYji14wayT/v657eqN36AA== Received: from BL1PR13CA0328.namprd13.prod.outlook.com (2603:10b6:208:2c1::33) by PH7PR12MB5855.namprd12.prod.outlook.com (2603:10b6:510:1d6::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.20; Mon, 18 Nov 2024 06:53:31 +0000 Received: from BN1PEPF00004683.namprd03.prod.outlook.com (2603:10b6:208:2c1:cafe::d8) by BL1PR13CA0328.outlook.office365.com (2603:10b6:208:2c1::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.13 via Frontend Transport; Mon, 18 Nov 2024 06:53:30 +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 BN1PEPF00004683.mail.protection.outlook.com (10.167.243.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 06:53:30 +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.1544.4; Sun, 17 Nov 2024 22:53:17 -0800 Received: from nvidia.com (10.126.230.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; Sun, 17 Nov 2024 22:53:15 -0800 From: Bing Zhao To: , , , CC: , , , Subject: [PATCH] net/mlx5: fix the leak of action data list Date: Mon, 18 Nov 2024 08:52:59 +0200 Message-ID: <20241118065259.250538-1-bingz@nvidia.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1PEPF00004683:EE_|PH7PR12MB5855:EE_ X-MS-Office365-Filtering-Correlation-Id: 9414a127-627f-4a7d-1f9b-08dd079db668 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?HHecRaDpFZwYm1fhFvAH5JwK6JW0/+LasgYrIajoY2Fh4lSdMMaBKXZOQLv1?= =?us-ascii?Q?Fw3Ozy0Qy2a+5rFihKNhPJNeVRr7Y7VcclADQ93+oUBKgUmgqgnB3Z/7Ff8C?= =?us-ascii?Q?RGZfYnAhEN4GDcpjMnV/eqZk34nex0/uEHGw/sgrXkThp6HMVfJB+ySsLimq?= =?us-ascii?Q?U37bsxFzS98jZ4vj4Ff7iOA34nJpULJ7GbbQUXB64TB0F5xw/kIqha1XFFRY?= =?us-ascii?Q?eAeuL1ZRsc6VHNEGfXxKaomKz/5kCnsRFlV8NS7MxrBFGPGXaBWVBaEcgB/n?= =?us-ascii?Q?NDDSj7BxtgiMPA5bB8kTWRPeSwUzBZiTeV3DCYTlM4mqNcyE2IkQcYKXyaSs?= =?us-ascii?Q?GfbNN67T79jT6sZ2WjMM79ZmrsL8LB3GQloLCdkbasSPooiL/6zOzipaaZo+?= =?us-ascii?Q?HUlm9/4TVqNU1RZIqqBjxa5b5ZACg1XyO+AFkS7iQ4tTWLwoXkT8vomVVSJY?= =?us-ascii?Q?ekpAue7gCvYEJPDgoUj6c/vgFJ+Xm7WNXRE2lT7LpnWvE2E7uj+WWaKjvfFt?= =?us-ascii?Q?OcwkZ2J/t5ldDTXnG8RTAuh8hulLtqniaYSW/YkdHdFXWyK+6Kx/IE1p8SJv?= =?us-ascii?Q?sqIryG8mmZpuPSdQcqVnCBGa5Vf13N8XwYGQ+a3y3GslVSUZwVl5MerORm77?= =?us-ascii?Q?yjRwxNGJCyn0WYcEr77jcR6kdEVWhAJsRdLAogaYCgrXdebzk6VyVdPjg/Il?= =?us-ascii?Q?h215tVl1FkSZ5iJXAszSEsCMTUBhqS7YNBN2CQgy4NjERqbKpQ6sgu3jS0yT?= =?us-ascii?Q?2Uq4oOSa1Vqx/2u/KtvNgWY0VBRjNfT1rRMzjpESYjp0sbJxoj/TQwHVp3WD?= =?us-ascii?Q?2Y+0Uc4S4jLfIyU5+x7YZGGEO9+IsESOUuosa5mAr8VkYF+JMSZl9Bem8eol?= =?us-ascii?Q?Xs9F89M0d/t2DbXh9NrukAWAw1bX8X+Qa2QCcxolHpqQCxw0Ytp4mQmawTQh?= =?us-ascii?Q?72g062v6+ms4c6h9j/kjxGBie+/4JV4xJUFzPH/0cFgGrHt9JX/SPOaB9MdR?= =?us-ascii?Q?Lbbm9yzT46KR4dgikvsS0EcCrZhuzurYCfMdp4BXBsmJR4Jcu5VvTh6vnYkd?= =?us-ascii?Q?DRuM6eFYId47fvHsbzro+tr9iI0jZTis+YrpREnmWa+KcYPPjncmo/D+8Y3n?= =?us-ascii?Q?AzuTGbrUryUa+pPmA2moUTZ7laB9fpSa6g+a37tABKsxbwe3y+Cnxi9OjDaa?= =?us-ascii?Q?iu1Ipo+MVOHMi+hreBO60FSz7qyJUcxCn+uNrPtcYjjf/vTbCLOnqYynifg7?= =?us-ascii?Q?WG10l9cFw8htbNOvRDpfYHV4H0MY8DqTN+JUL1bSAYcETJpFCtFqFrk2ftx5?= =?us-ascii?Q?8EImVdf93FaXN8PdmRCQXoS7UPsLjjXMVWOnIlQnu8y2AUkwQyqZexa5hBXf?= =?us-ascii?Q?yQlM3Ux7ZqMher5NylB509AkLO2CLggGgJUHoqcmVErhXVJGAQ=3D=3D?= 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:(13230040)(1800799024)(36860700013)(376014)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 06:53:30.5984 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9414a127-627f-4a7d-1f9b-08dd079db668 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: BN1PEPF00004683.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5855 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 of NT2HWS, 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 --- 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