* [PATCH 1/2] net/mlx5: non template - fix validation for GENEVE options
@ 2025-04-27 11:22 Maayan Kashani
2025-04-27 11:22 ` [PATCH 2/2] net/mlx5: fix coverity warning Maayan Kashani
0 siblings, 1 reply; 2+ messages in thread
From: Maayan Kashani @ 2025-04-27 11:22 UTC (permalink / raw)
To: dev
Cc: mkashani, dsosnowski, rasland, stable, Bing Zhao,
Viacheslav Ovsiienko, Ori Kam, Suanming Mou, Matan Azrad,
Gregory Etelson
For non-template API on top of HWS,
geneve options parser is created by the pmd and not by the user,
therefore during validation , the parser is not yet created.
The fix is to ignore the validation of geneve options in
case the rule is a non-template rule.
The parser will be created later during rule create.
Fixes: 80c676259a04 ("net/mlx5: validate HWS template items")
Cc: stable@dpdk.org
Signed-off-by: Maayan Kashani <mkashani@nvidia.com>
Acked-by: Bing Zhao <bingz@nvidia.com>
---
drivers/net/mlx5/mlx5_flow_hw.c | 35 ++++++++++++++++++++++++---------
1 file changed, 26 insertions(+), 9 deletions(-)
diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index 20d38ce4141..09157e30090 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -8475,10 +8475,11 @@ struct mlx5_hw_pattern_validation_ctx {
};
static int
-flow_hw_pattern_validate(struct rte_eth_dev *dev,
+__flow_hw_pattern_validate(struct rte_eth_dev *dev,
const struct rte_flow_pattern_template_attr *attr,
const struct rte_flow_item items[],
uint64_t *item_flags,
+ bool nt_flow,
struct rte_flow_error *error)
{
struct mlx5_priv *priv = dev->data->dev_private;
@@ -8646,10 +8647,16 @@ flow_hw_pattern_validate(struct rte_eth_dev *dev,
case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
{
last_item = MLX5_FLOW_LAYER_GENEVE_OPT;
- ret = mlx5_flow_geneve_tlv_option_validate(priv, item,
- error);
- if (ret < 0)
- return ret;
+ /*
+ * For non template the parser is internally created before
+ * the flow creation.
+ */
+ if (!nt_flow) {
+ ret = mlx5_flow_geneve_tlv_option_validate(priv, item,
+ error);
+ if (ret < 0)
+ return ret;
+ }
break;
}
case RTE_FLOW_ITEM_TYPE_COMPARE:
@@ -8913,6 +8920,16 @@ flow_hw_pattern_validate(struct rte_eth_dev *dev,
return 1 + RTE_PTR_DIFF(item, items) / sizeof(item[0]);
}
+static int
+flow_hw_pattern_validate(struct rte_eth_dev *dev,
+ const struct rte_flow_pattern_template_attr *attr,
+ const struct rte_flow_item items[],
+ uint64_t *item_flags,
+ struct rte_flow_error *error)
+{
+ return __flow_hw_pattern_validate(dev, attr, items, item_flags, false, error);
+}
+
/*
* Verify that the tested flow patterns fits STE size limit in HWS group.
*
@@ -14252,8 +14269,8 @@ static uintptr_t flow_hw_list_create(struct rte_eth_dev *dev,
};
/* Validate application items only */
- ret = flow_hw_pattern_validate(dev, &pattern_template_attr, items,
- &item_flags, error);
+ ret = __flow_hw_pattern_validate(dev, &pattern_template_attr, items,
+ &item_flags, true, error);
if (ret < 0)
return 0;
@@ -15388,8 +15405,8 @@ flow_hw_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
if (external) {
/* Validate application items only */
- ret = flow_hw_pattern_validate(dev, &pattern_template_attr, items,
- &item_flags, error);
+ ret = __flow_hw_pattern_validate(dev, &pattern_template_attr, items,
+ &item_flags, true, error);
if (ret < 0)
return -rte_errno;
}
--
2.21.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 2/2] net/mlx5: fix coverity warning
2025-04-27 11:22 [PATCH 1/2] net/mlx5: non template - fix validation for GENEVE options Maayan Kashani
@ 2025-04-27 11:22 ` Maayan Kashani
0 siblings, 0 replies; 2+ messages in thread
From: Maayan Kashani @ 2025-04-27 11:22 UTC (permalink / raw)
To: dev
Cc: mkashani, dsosnowski, rasland, stable, Bing Zhao,
Viacheslav Ovsiienko, Ori Kam, Suanming Mou, Matan Azrad,
Gregory Etelson
gre_item was dereferenced w/o checking it's value.
added a check to verify if null before using the pointer.
Fixes: 80c676259a04 ("net/mlx5: validate HWS template items")
Cc: stable@dpdk.org
Signed-off-by: Maayan Kashani <mkashani@nvidia.com>
Acked-by: Bing Zhao <bingz@nvidia.com>
---
drivers/net/mlx5/mlx5_flow.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index e2f4bd8cef1..93ee6f75626 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -3333,10 +3333,10 @@ mlx5_flow_validate_item_gre_key(const struct rte_eth_dev *dev,
return rte_flow_error_set(error, ENOTSUP,
RTE_FLOW_ERROR_TYPE_ITEM, item,
"GRE key following a wrong item");
- gre_mask = gre_item->mask;
+ gre_mask = gre_item ? gre_item->mask : NULL;
if (!gre_mask)
gre_mask = &rte_flow_item_gre_mask;
- gre_spec = gre_item->spec;
+ gre_spec = gre_item ? gre_item->spec : NULL;
if (gre_spec && (gre_mask->c_rsvd0_ver & RTE_BE16(0x2000)) &&
!(gre_spec->c_rsvd0_ver & RTE_BE16(0x2000)))
return rte_flow_error_set(error, EINVAL,
@@ -3379,8 +3379,8 @@ mlx5_flow_validate_item_gre_option(struct rte_eth_dev *dev,
const struct rte_flow_item *gre_item,
struct rte_flow_error *error)
{
- const struct rte_flow_item_gre *gre_spec = gre_item->spec;
- const struct rte_flow_item_gre *gre_mask = gre_item->mask;
+ const struct rte_flow_item_gre *gre_spec = gre_item ? gre_item->spec : NULL;
+ const struct rte_flow_item_gre *gre_mask = gre_item ? gre_item->mask : NULL;
const struct rte_flow_item_gre_opt *spec = item->spec;
const struct rte_flow_item_gre_opt *mask = item->mask;
struct mlx5_priv *priv = dev->data->dev_private;
--
2.21.0
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-04-27 11:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-27 11:22 [PATCH 1/2] net/mlx5: non template - fix validation for GENEVE options Maayan Kashani
2025-04-27 11:22 ` [PATCH 2/2] net/mlx5: fix coverity warning Maayan Kashani
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).