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 6327F42B1C for ; Tue, 16 May 2023 07:44:04 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4EA6042D4E; Tue, 16 May 2023 07:44:04 +0200 (CEST) Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2060.outbound.protection.outlook.com [40.107.95.60]) by mails.dpdk.org (Postfix) with ESMTP id 2051E42D3A; Tue, 16 May 2023 07:44:01 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JcRHnaJ3l2q3ySl2TjYeMguF2ahd2aOoNcI5JoIFUKhjhzo52tY70re6MQmF8+87Y/AUKcOSRJx/kw6SwcE628pPIPPRe5UJSBUkPF88QGUMDM5GGLqmA68ErPoGCpGpIoAw3fj3yzxEla5GM1sg+hGMZVCIrF4y4sLQWTS9yKjjMfPfLuuekfqmbEu2jzgbXD8WVN45j97qVWBPxpfxaZeh5I6lK65t6BvyzXDMtVLw1fZ79KJXFDk+LfgvRkLzYB+JQsSQm7gzIPClkLX8ryG3B1mMtM77WJ9ym0zUOOg6OzsMMHBs8NJQn/V+3rgCZGtNMdOgESyCMuBvfuOb8g== 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=u1hlRUWm/ZUI9VMX6+snKuvZLjunGZV518Q2PXYOUEU=; b=M/q0lJS/a+9R4E7wbWR4x75C6sK9MpijQX8+Q6C2QRvRILZhJRSg05z+ae/esRGwbnCI/LzfePmNMldIA0hUnm03IvkkZkBvQFqEmNIN6e0Apd2KAkmVM7Sh0eHWgVZv5CHZis3b2pYBcWnrjhbRL5QAejLm93AXLsrrYekp4P6FqWyCcvU6P8ysr8mz2PkLyHfWUM4klVOPzGrzQzrXYWmF10yDr+MEkWjK+J9AiWJZIIuiFdanSR18gB5Wh84PQmemwjsMxzczD87KLAJ20CRTJ1QCi5TdFsdmEUsd3rWYEKC4q+cbOftb/Hr8XAPKVGx4JRe3tGoWAElnt/vqwQ== 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 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=u1hlRUWm/ZUI9VMX6+snKuvZLjunGZV518Q2PXYOUEU=; b=l0F8gYfTHlpLNZ0+rMtL5iAaFD0wAC7mSqrgQrKNobC2FxIIJTl1QyPLdQfTyRB9hqezHVL1uGpbyq3i58sUB0e1eMGqwpSru1WiuxBpqbl74PSavexWgipHC07k5FXYUS9P2KhM4a2tfhUg+POj81rZZf1bRB63wxjdNPkoENZdcKMgDE5fUocRFYLJOddLKiEAMfh5FAjz1PBAgOpb6/wJmSw4MXpuKSymvrGY+ZKJwfPxS66iYtZNYqfRW1L4XvVyJ5SYx5P6WdBuaFqYyeoSKubVpaaTEtyeABSqFAg1C2X6yVlxZO2ty9Q1+Nv4d9qjnUGZloRBNgKsJhbn7Q== Received: from MW4PR03CA0193.namprd03.prod.outlook.com (2603:10b6:303:b8::18) by BL3PR12MB6620.namprd12.prod.outlook.com (2603:10b6:208:38f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.32; Tue, 16 May 2023 05:43:58 +0000 Received: from CO1NAM11FT052.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b8:cafe::17) by MW4PR03CA0193.outlook.office365.com (2603:10b6:303:b8::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.30 via Frontend Transport; Tue, 16 May 2023 05:43:58 +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 CO1NAM11FT052.mail.protection.outlook.com (10.13.174.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.15 via Frontend Transport; Tue, 16 May 2023 05:43:58 +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.5; Mon, 15 May 2023 22:43:45 -0700 Received: from nvidia.com (10.126.230.37) 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.37; Mon, 15 May 2023 22:43:43 -0700 From: Rongwei Liu To: , , , , CC: Subject: [PATCH v1 1/2] net/mlx5: disallow duplicated tag index in pattern template Date: Tue, 16 May 2023 08:43:28 +0300 Message-ID: <20230516054329.1397016-2-rongweil@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230516054329.1397016-1-rongweil@nvidia.com> References: <20230516054329.1397016-1-rongweil@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.37] 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: CO1NAM11FT052:EE_|BL3PR12MB6620:EE_ X-MS-Office365-Filtering-Correlation-Id: aa703c16-bf9c-4eb5-bdd0-08db55d08b43 X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FdFfmzlpbN2NIhmUp9GXdrLicDiN5IDLMhdthJaII95krFtN3j3NRgZvgby+WnZxngeGcp/86Rii6oVdFaWaHtWdk1ctSohoKf2dFDu0nzRKPjCNSDn0pm1ILeorfCCLihI9TJS+be6ml6RF7kSXx5tSVK9rmkl8+wco4NEgAqfBXFUxZDZG8xV31r1KaD+ajn9Q8RlzPCzRAggmrXraMwj3jsIQ/w4QuGBpiuePsROcLBmZs6QxWGPKVtCLJ/79nCFS0Q9w3NuNaykzkPLEfEmU6a7K7iExlgCOLm9l7BbOZ3L71mf4lyhUo7ausHPG++fK4+exRgNCVYpdgr21NpSBCCq+z1USfCUjk9IoBU0oZ2VjeDGausjwpyXn5Ivh8eDn82iIvoWOpOn201LJh8VimQ6EOvDbPCKvr4P1i1z6LSPxWiEV5DcnP8mN4TNeTgmoldY/5LbO5mWtAaDFIYZjhlaoO5aBVGvCU1AnBIZkMwpYfrBITIxDJ/Ve7CQOHPiIMU36Y3/3bW4uKq772dIL9j+IbB1aTTo9zIelFA4v14fE+7DBswBwKzVUriv3/t/0hDz1CoUk9IsaZp/cKTz1ZsUZRh8YMVy8VCPaL98E0Q0lY5q3fi7ccea6YUahkUhyxWLcalrts+6W12RxMeG3sDa1rf5qW75RL6TfTFCEtAkCMxr/EMsECjcRE7dLr4PqFO9WTwOCatIpzoX+RMrUEcbrEeV6rg33gtfZx3SXep7rUSf0UxgQZmT8m+fu 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:(13230028)(4636009)(376002)(39860400002)(346002)(396003)(136003)(451199021)(46966006)(36840700001)(40470700004)(82740400003)(82310400005)(7636003)(356005)(478600001)(55016003)(336012)(426003)(40480700001)(2616005)(47076005)(83380400001)(36860700001)(1076003)(26005)(16526019)(6286002)(40460700003)(36756003)(6666004)(7696005)(186003)(41300700001)(316002)(70206006)(70586007)(4326008)(86362001)(8676002)(8936002)(5660300002)(2906002)(110136005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 May 2023 05:43:58.0150 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aa703c16-bf9c-4eb5-bdd0-08db55d08b43 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: CO1NAM11FT052.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR12MB6620 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Duplicated tag index in pattern template will most likely cause matching failures such as "template tag index is 0 data mask 0xff / tag index is 0 data mask 0xffff / end" If the upper layer application needs to match the same tag twice with different masks, it should be consolidated into one rte_item with the desired mask. "template tag index is 0 data mask 0xff / tag index is 0 data mask 0xff00 / end" should be present as "template tag index is 0 data mask 0xffff / end" Cc: stable@dpdk.org Signed-off-by: Rongwei Liu Acked-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_flow_hw.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index 7e0ee8d883..78011584eb 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -4831,8 +4831,9 @@ flow_hw_pattern_validate(struct rte_eth_dev *dev, struct rte_flow_error *error) { struct mlx5_priv *priv = dev->data->dev_private; - int i; + int i, tag_idx; bool items_end = false; + uint32_t tag_bitmap = 0; if (!attr->ingress && !attr->egress && !attr->transfer) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR, NULL, @@ -4874,16 +4875,26 @@ flow_hw_pattern_validate(struct rte_eth_dev *dev, switch (type) { case RTE_FLOW_ITEM_TYPE_TAG: { - int reg; const struct rte_flow_item_tag *tag = (const struct rte_flow_item_tag *)items[i].spec; - reg = flow_hw_get_reg_id(RTE_FLOW_ITEM_TYPE_TAG, tag->index); - if (reg == REG_NON) + if (tag == NULL) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "Tag spec is NULL"); + tag_idx = flow_hw_get_reg_id(RTE_FLOW_ITEM_TYPE_TAG, tag->index); + if (tag_idx == REG_NON) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "Unsupported tag index"); + if (tag_bitmap & (1 << tag_idx)) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + NULL, + "Duplicated tag index"); + tag_bitmap |= 1 << tag_idx; break; } case MLX5_RTE_FLOW_ITEM_TYPE_TAG: @@ -4897,6 +4908,12 @@ flow_hw_pattern_validate(struct rte_eth_dev *dev, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "Unsupported internal tag index"); + if (tag_bitmap & (1 << tag->index)) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + NULL, + "Duplicated tag index"); + tag_bitmap |= 1 << tag->index; break; } case RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT: -- 2.27.0