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 9F12F43C06; Tue, 27 Feb 2024 14:53:14 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6255942E71; Tue, 27 Feb 2024 14:53:12 +0100 (CET) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2079.outbound.protection.outlook.com [40.107.92.79]) by mails.dpdk.org (Postfix) with ESMTP id 61FE940ED2; Tue, 27 Feb 2024 14:53:11 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iP0nA4EY7ByqBEJNe1JmLF0p+j6biHwIHvdh1MA/Al1WahgkNZtpoHRSf+csRVEIRO8byHLSDeoy/ch3qTOe/1SLV3rSOkRi3lQBd6L9UChGS4Et2F1RLVFkj2zBRtyQLzqf9e1GZbRbjvl4Q/uBaFCnhBZOmHYhzghICLG+zAiFv+ND2JPs0gU1nY5e9fMFtqOM9j/Uowni2j1cTdPFQLTjRhxKVnhdbRz7WVbyiWUKDIo5A5TZy0u8dDqdEVrJJb+QvZ1hpFzNvTHVWAWNAq8Xogce/AuNj7p6IqsnLBP5Fwlnppcb9cZEiRb5IaK8Gh0RaWa3wEtx8gh0JmvTdA== 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=atYGsA66Evd3rxLtfOBzP0J9rw3eDpH4khS0lu2yUQc=; b=EfzHwqO/gsUfPHqNmJZPJXqf5/e5hm96Hij/5MPynCPpkv6cEa/+XQ0VXSUS3kB9ABwbBeduFWJsYr2G33xuntNJiU0udqA/YyvtlDAB9ydmj7tYrMtF3Tv++jYUounjbRIsRKsslupDhwPtFmWrKHBjCJ11pPmKlvDVF4wEPKGzFEzSigz+hjsCAhXSg9GUkpyefy/Y2DmhZDfKj496ZiwZED4E8ZM7WdWroLDZU/cWID7UNxtpiaYODKjeMDbwJGiLRa3bKIbJ63UiK6jfHV02NseTt0HnhBKgEl20lRTzpTMbIpxjAb934Sq0EA3uFcuRMGCJ2aCpcwLadA8+eQ== 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=atYGsA66Evd3rxLtfOBzP0J9rw3eDpH4khS0lu2yUQc=; b=dznfCbmHNtt/CHqIjDbJC7U4HlVB+zRJsh3AxNLmC4PTAHc54J0W1U4/6YZYGLSroPbTUVV/X6p4lHviNEnnkkoE3cH74yLKKjy+n8v2wPUhHNlNz8yN0ByK8WQDCPlS/MvfLgcJOf32+ucSOWH03np1h60DsupRjEe5fad+7UH+ccmipuaNTz2rq0GsMCbwoXp99UL0gqzIOHjrjVMBIi8i7lm6aS2pkkcRY99qJSSooHPBkwlMnkRhjUaWmZd18/PeE8TdAD3XautaYAdl2yNnegntGd9BfG7QyFrswXN7+SfE5tqTiaQQi74vx/ScqMr6pj6viRJgdhG9SLmlSA== Received: from BN7PR06CA0067.namprd06.prod.outlook.com (2603:10b6:408:34::44) by MN2PR12MB4485.namprd12.prod.outlook.com (2603:10b6:208:269::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.36; Tue, 27 Feb 2024 13:53:07 +0000 Received: from BN3PEPF0000B078.namprd04.prod.outlook.com (2603:10b6:408:34:cafe::e1) by BN7PR06CA0067.outlook.office365.com (2603:10b6:408:34::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.49 via Frontend Transport; Tue, 27 Feb 2024 13:53:07 +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 BN3PEPF0000B078.mail.protection.outlook.com (10.167.243.123) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.25 via Frontend Transport; Tue, 27 Feb 2024 13:53:07 +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.986.41; Tue, 27 Feb 2024 05:52:46 -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.1258.12; Tue, 27 Feb 2024 05:52:43 -0800 From: Dariusz Sosnowski To: Viacheslav Ovsiienko , Ori Kam , Suanming Mou , Matan Azrad CC: , Subject: [PATCH v3 2/4] net/mlx5: fix connection tracking action validation Date: Tue, 27 Feb 2024 15:52:22 +0200 Message-ID: <20240227135224.20066-3-dsosnowski@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240227135224.20066-1-dsosnowski@nvidia.com> References: <20240223142320.49470-1-dsosnowski@nvidia.com> <20240227135224.20066-1-dsosnowski@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.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: BN3PEPF0000B078:EE_|MN2PR12MB4485:EE_ X-MS-Office365-Filtering-Correlation-Id: 6cd9747f-e102-4226-4cd7-08dc379b6d9d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jFEeHODiN2mHSe4t+/a6VHjPy6pmIFFJE9TgEi//kbtAeszipNm6Gp9wRxgGHlcY0/grIXb2+kdhTPqG0/ZbljEKzQJ7xyNNecIJ2ZZfKYnwC2VkN71aUVRdSnoBeDyCbV1AjTFA+dCf6FRDY03LNVlxbTM4fRHqCiKdeg6xY4XfxDIZX3Z900Jm6mvrrGTuWZfAXgpHDW7VvjnimAfCGMTRn/t0yuW5xvsd381mxykITmLcDD59xKdwUChavn2Lz4Wl4CWeU9O9qyTTgRHzd784BVnjabMop55oKWbQUfLIdfAl4vq1VcX3YcbkltKAqPvY7NyhtRzVynOfda4vtnY09Uml6+0fvci8leqTyqaqYCF2D0T1WL3NgGFAh88ySI7H5GONcqqVebFW2P3Pj9XXKEvDbk/WSKVPzm/PVkgVGibkirSO8kNcyKh/KmTPPjaMGXevwuA584ijTGic8/ZIRpMRVh9REtPH/6b9toT0p1eUkPR5zeK9W2Pww7ceUz2p0jduvk4Y598Tih2gXwLHDDlUlwSR6ZoOerIC+SW/fLHQFdoYW/DOwdeRH0adeL9sxPx6oJsfPgz2WtQFPU/Q8Qcr48k6t3h2rdmxT4U2zJd4dlJYor2jJJfBLeaeTKAg1gtLqvekeE0rrjhLkUj/6IFYQ5NEMbgr9d0Ks84QavqKitajK5OkM0GjFa3ygiFJ4djDXzGJoRGx16bIS/PaTd75Ydl57hX0THVDxWTWWbcadqWxQsxl25D0GkhJ 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:(13230031)(36860700004)(82310400014); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Feb 2024 13:53:07.6220 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6cd9747f-e102-4226-4cd7-08dc379b6d9d 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: BN3PEPF0000B078.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4485 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 mlx5 PMD, handles to indirect connection tracking flow actions are encoded as 32-bit unsigned integers, where port ID is stored in bits 28-25. Because of this, connection tracking flow actions cannot be created on ports with IDs higher than 15. This patch adds missing validation. Fixes: 463170a7c934 ("net/mlx5: support connection tracking with HWS") Cc: stable@dpdk.org Signed-off-by: Dariusz Sosnowski Acked-by: Ori Kam --- drivers/net/mlx5/mlx5_flow_dv.c | 9 +++++++++ drivers/net/mlx5/mlx5_flow_hw.c | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 75a8a223ab..ddf19e9a51 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -13889,6 +13889,13 @@ flow_dv_translate_create_conntrack(struct rte_eth_dev *dev, return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, NULL, "Connection is not supported"); + if (dev->data->port_id >= MLX5_INDIRECT_ACT_CT_MAX_PORT) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "CT supports port indexes up to " + RTE_STR(MLX5_ACTION_CTX_CT_MAX_PORT)); + return 0; + } idx = flow_dv_aso_ct_alloc(dev, error); if (!idx) return rte_flow_error_set(error, rte_errno, @@ -16586,6 +16593,8 @@ flow_dv_action_create(struct rte_eth_dev *dev, case RTE_FLOW_ACTION_TYPE_CONNTRACK: ret = flow_dv_translate_create_conntrack(dev, action->conf, err); + if (!ret) + break; idx = MLX5_INDIRECT_ACT_CT_GEN_IDX(PORT_ID(priv), ret); break; default: diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index 2a1281732a..a8e2c9cc9e 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -10344,6 +10344,13 @@ flow_hw_conntrack_create(struct rte_eth_dev *dev, uint32_t queue, "CT is not enabled"); return 0; } + if (dev->data->port_id >= MLX5_INDIRECT_ACT_CT_MAX_PORT) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "CT supports port indexes up to " + RTE_STR(MLX5_ACTION_CTX_CT_MAX_PORT)); + return 0; + } ct = mlx5_ipool_zmalloc(pool->cts, &ct_idx); if (!ct) { rte_flow_error_set(error, rte_errno, -- 2.25.1