DPDK patches and discussions
 help / color / mirror / Atom feed
From: Dariusz Sosnowski <dsosnowski@nvidia.com>
To: Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
	Ori Kam <orika@nvidia.com>,  Suanming Mou <suanmingm@nvidia.com>,
	Matan Azrad <matan@nvidia.com>
Cc: <dev@dpdk.org>, <stable@dpdk.org>
Subject: [PATCH 2/4] net/mlx5: fix connection tracking action validation
Date: Wed, 21 Feb 2024 12:01:43 +0200	[thread overview]
Message-ID: <20240221100145.8234-3-dsosnowski@nvidia.com> (raw)
In-Reply-To: <20240221100145.8234-1-dsosnowski@nvidia.com>

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 <dsosnowski@nvidia.com>
Acked-by: Ori Kam <orika@nvidia.com>
---
 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 6fded15d91..0604f92531 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 3bb3a9a178..2f366e9078 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.25.1


  parent reply	other threads:[~2024-02-21 10:02 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-21 10:01 [PATCH 0/4] net/mlx5: connection tracking changes Dariusz Sosnowski
2024-02-21 10:01 ` [PATCH 1/4] net/mlx5: fix conntrack action handle representation Dariusz Sosnowski
2024-02-21 10:01 ` Dariusz Sosnowski [this message]
2024-02-21 10:01 ` [PATCH 3/4] net/mlx5: add cross port CT object sharing Dariusz Sosnowski
2024-02-21 10:01 ` [PATCH 4/4] net/mlx5: remove port from conntrack handle representation Dariusz Sosnowski
2024-02-23 14:23 ` [PATCH v2 0/4] net/mlx5: connection tracking changes Dariusz Sosnowski
2024-02-23 14:23   ` [PATCH v2 1/4] net/mlx5: fix conntrack action handle representation Dariusz Sosnowski
2024-02-23 14:23   ` [PATCH v2 2/4] net/mlx5: fix connection tracking action validation Dariusz Sosnowski
2024-02-23 14:23   ` [PATCH v2 3/4] net/mlx5: add cross port CT object sharing Dariusz Sosnowski
2024-02-23 14:23   ` [PATCH v2 4/4] net/mlx5: remove port from conntrack handle representation Dariusz Sosnowski
2024-02-27 13:52   ` [PATCH v3 0/4] net/mlx5: connection tracking changes Dariusz Sosnowski
2024-02-27 13:52     ` [PATCH v3 1/4] net/mlx5: fix conntrack action handle representation Dariusz Sosnowski
2024-02-27 13:52     ` [PATCH v3 2/4] net/mlx5: fix connection tracking action validation Dariusz Sosnowski
2024-02-27 13:52     ` [PATCH v3 3/4] net/mlx5: add cross port CT object sharing Dariusz Sosnowski
2024-02-27 13:52     ` [PATCH v3 4/4] net/mlx5: remove port from conntrack handle representation Dariusz Sosnowski
2024-02-28 10:12     ` [PATCH v3 0/4] net/mlx5: connection tracking changes 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=20240221100145.8234-3-dsosnowski@nvidia.com \
    --to=dsosnowski@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=matan@nvidia.com \
    --cc=orika@nvidia.com \
    --cc=stable@dpdk.org \
    --cc=suanmingm@nvidia.com \
    --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).