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 0EA4943BA9; Fri, 23 Feb 2024 15:24:12 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7FCBF427D8; Fri, 23 Feb 2024 15:24:08 +0100 (CET) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2072.outbound.protection.outlook.com [40.107.243.72]) by mails.dpdk.org (Postfix) with ESMTP id A4AFA427D8; Fri, 23 Feb 2024 15:24:07 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ARkdxzdt61hNSg3RpwUzZq/98liYMdNPAua0aLKWrmL+c+XH/Nfv7D6PgCAVSKo62ydV7vVPWJc21e6YTpSKLH7sEwcVXAEtBURwI8aBJCtVFqgiwSFS8AnX8Z+FPXeuVtccRSEYC0kNiL+TKcniAKSOlDzHPF7xzlLarU9tMk1eRbFQW6VYCgSNm/ol0h3l9PvCRDk1XQqaQxv0LJJap53hcHFJDaiOG7d7j3FUN/orye/4iaeSdQ7B2zW3MBlI0Dy98Wn+ZjCYnFveaWMLBmNH6QP5iqvHCgAWXwz45Ej0srU+cOEiwvwEJPXu19WNQpLr91LHAQ3CdnB7x7r+hA== 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=M4sQbaS/1Vomins1z9qRsi0hg1FfRGaT9TRAiH3ylYc=; b=NPdUJnpd0FBN/ZvXBKzSO+yWLozIrKjWM0dtjPBBnSJf/MCHqmcE/YL78xZ3Wt/JFKrEN9POSGDJttmqSJb0sU/RqQiF+iBADe6HdfCXeadoS2hsHJvL/hThzP4XSGgAUZfMb/QkJLioUeSw6JVIdoqJqvLMKqa7cZ/MaM9t9S/OMDPxaJGECCMw0KbEvcFIheXrDu6dIGy5RSafuC5IyPzQqaqy8cE0CSq1lXyWZJyaj9LukIwoFfpJl7Om9LNtM0wMLvNNRdRTgLtZwWoz8Y7ntRgLp4fI9X8DKZEYwzu4Oa4dt2grsjoZi3blOdrCDfMvfxatsGzI+3tmI6/E+g== 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=M4sQbaS/1Vomins1z9qRsi0hg1FfRGaT9TRAiH3ylYc=; b=LkDPPmMMXs8o5wlBMy7hniBV+fSGtUfSQr2/gklvhYWQ1aBHmt27zDyxephXaP2odqWHuGCgEGHiPCUmdvrRc73+svS0mf77DnEEWxs/6mDhvAhWgMFD9rV0iFAiFWHmroFyy6fiU+waL0jqAxMp30eg6kk3jogkU8oWt0uSShr+gLMop1Y02oUVjZlRkYEfJ43D+avL2J+p0Ej94wyXY5zxAMVP7hEKQx71DS6VLsFuXHx5ywPulaoCmKd86xkTrsFBiLoWUKdUNH72Q9OhzCzbfkXgxWkvRQdbAxNpm4JgE7tjarAGOwNY8TfBv3mM4jEpg9OjHF0f3Ol6m7wGUg== Received: from DS7PR03CA0079.namprd03.prod.outlook.com (2603:10b6:5:3bb::24) by SA1PR12MB7319.namprd12.prod.outlook.com (2603:10b6:806:2b5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.24; Fri, 23 Feb 2024 14:24:04 +0000 Received: from DS3PEPF000099E0.namprd04.prod.outlook.com (2603:10b6:5:3bb:cafe::7f) by DS7PR03CA0079.outlook.office365.com (2603:10b6:5:3bb::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.45 via Frontend Transport; Fri, 23 Feb 2024 14:24:04 +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 DS3PEPF000099E0.mail.protection.outlook.com (10.167.17.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.25 via Frontend Transport; Fri, 23 Feb 2024 14:24:04 +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; Fri, 23 Feb 2024 06:23:42 -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.1258.12; Fri, 23 Feb 2024 06:23:39 -0800 From: Dariusz Sosnowski To: Viacheslav Ovsiienko , Ori Kam , Suanming Mou , Matan Azrad CC: , Subject: [PATCH v2 2/4] net/mlx5: fix connection tracking action validation Date: Fri, 23 Feb 2024 16:23:18 +0200 Message-ID: <20240223142320.49470-3-dsosnowski@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240223142320.49470-1-dsosnowski@nvidia.com> References: <20240221100145.8234-1-dsosnowski@nvidia.com> <20240223142320.49470-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: DS3PEPF000099E0:EE_|SA1PR12MB7319:EE_ X-MS-Office365-Filtering-Correlation-Id: 1cc2b65f-fb29-4505-de9e-08dc347b1687 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QbEmLN/mNySl41VBxU+PnoC9OvVDZyupJP4/N4FlHhD2jEHnb+r1TZY74r6aCKCxj1TaL7gNoyzT9r9j6Bj+NP149/uupbximULU8YkL1enVUwUY+oXJEIMGZbOY+X+3IeLoS/hHxkErwLUO2Eku7mCTArCMtvpKKXUYPBjN4yvWlSTHAawjfJYDWO2Itk0cyR2hou7mJ5X3mwxwOb6l/NY3AlV5oF8+wdz2v+DyExc2yrqYnkmzk4Y9KA+i28YDgPSMPJR5yzd9hSZIgzfd0+OLwsA7t5UgZnh4H5fcVnOy75i79kdH4kTmE7tT6aUpbz/tsMU6XL6ZIvAbg484L7t4nqOTfkB0ArxoV/QIe29dfShijPNzpXPu4PUd+njmlKCH++yWUbohmgQDwW0kdkVyH6aS9ZbVwkoJSlUcRHE7TEybHD9kd4DNwaUn+MhVzFJo8EalnM2YLoK3tuD+OwS6WW8aDEm+jumfe0pdYPNWOZGWKlnMcIXXFl9/jYUQ98TFwZXifyqN6QYnoTf5w/blIgJEVmkMheiFh+qE7K0eVIEV9pnCFDfedFsIDGXui5DB5WGV656fWOOBFVDukVOw6NYX7oltx6XqID4fu9cxv75dYlavWFQcS1lHHQvYKMM5EsRSebkrpc9WPOdqas8kzvlMibznxhPOyhrfOtQ= 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)(36860700004)(40470700004)(46966006); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2024 14:24:04.0892 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1cc2b65f-fb29-4505-de9e-08dc347b1687 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: DS3PEPF000099E0.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7319 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 23a2388320..c78ef1f616 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -13861,6 +13861,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, @@ -16558,6 +16565,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 bcf43f5457..366a6956d2 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -10048,6 +10048,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.34.1