From: Rongwei Liu <rongweil@nvidia.com>
To: <dev@dpdk.org>, <matan@nvidia.com>, <viacheslavo@nvidia.com>,
<orika@nvidia.com>, <thomas@monjalon.net>
Cc: <stable@dpdk.org>
Subject: [PATCH v1 1/2] net/mlx5: disallow duplicated tag index in pattern template
Date: Tue, 16 May 2023 08:43:28 +0300 [thread overview]
Message-ID: <20230516054329.1397016-2-rongweil@nvidia.com> (raw)
In-Reply-To: <20230516054329.1397016-1-rongweil@nvidia.com>
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 <rongweil@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
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
next prev parent reply other threads:[~2023-05-16 5:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-16 5:43 [PATCH v1 0/2] disallow duplicated tag index Rongwei Liu
2023-05-16 5:43 ` Rongwei Liu [this message]
2023-05-17 17:11 ` [PATCH v1 1/2] net/mlx5: disallow duplicated tag index in pattern template Ori Kam
2023-05-16 5:43 ` [PATCH v1 2/2] net/mlx5: fix sws duplicated tag index matching Rongwei Liu
2023-05-24 14:05 ` [PATCH v1 0/2] disallow duplicated tag index Raslan Darawsheh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230516054329.1397016-2-rongweil@nvidia.com \
--to=rongweil@nvidia.com \
--cc=dev@dpdk.org \
--cc=matan@nvidia.com \
--cc=orika@nvidia.com \
--cc=stable@dpdk.org \
--cc=thomas@monjalon.net \
--cc=viacheslavo@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).