DPDK patches and discussions
 help / color / mirror / Atom feed
From: Hemant Agrawal <hemant.agrawal@nxp.com>
To: dev@dpdk.org
Cc: ferruh.yigit@intel.com, Vanshika Shukla <vanshika.shukla@nxp.com>
Subject: [dpdk-dev] [PATCH 6/7] net/dpaa2: add input validation
Date: Mon, 19 Jul 2021 19:29:16 +0530	[thread overview]
Message-ID: <20210719135917.26241-7-hemant.agrawal@nxp.com> (raw)
In-Reply-To: <20210719135917.26241-1-hemant.agrawal@nxp.com>

From: Vanshika Shukla <vanshika.shukla@nxp.com>

This patch adds validation of the port id for
rte_pmd_dpaa2_set_custom_hash API to check if the
port is a valid DPAA2 port. Also handles some
edge cases in the rte_pmd_dpaa2_mux_flow_create API.

Signed-off-by: Vanshika Shukla <vanshika.shukla@nxp.com>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/net/dpaa2/base/dpaa2_hw_dpni.c | 11 +++++++++++
 drivers/net/dpaa2/dpaa2_ethdev.c       |  4 ++--
 drivers/net/dpaa2/dpaa2_ethdev.h       |  1 +
 drivers/net/dpaa2/dpaa2_mux.c          |  3 +++
 4 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/net/dpaa2/base/dpaa2_hw_dpni.c b/drivers/net/dpaa2/base/dpaa2_hw_dpni.c
index b901b4342f..641e7027f1 100644
--- a/drivers/net/dpaa2/base/dpaa2_hw_dpni.c
+++ b/drivers/net/dpaa2/base/dpaa2_hw_dpni.c
@@ -41,6 +41,17 @@ rte_pmd_dpaa2_set_custom_hash(uint16_t port_id,
 	void *p_params;
 	int ret, tc_index = 0;
 
+	if (!rte_eth_dev_is_valid_port(port_id)) {
+		DPAA2_PMD_WARN("Invalid port id %u", port_id);
+		return -EINVAL;
+	}
+
+	if (strcmp(eth_dev->device->driver->name,
+			RTE_STR(NET_DPAA2_PMD_DRIVER_NAME))) {
+		DPAA2_PMD_WARN("Not a valid dpaa2 port");
+		return -EINVAL;
+	}
+
 	p_params = rte_zmalloc(
 		NULL, DIST_PARAM_IOVA_SIZE, RTE_CACHE_LINE_SIZE);
 	if (!p_params) {
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index d892819a7e..c12169578e 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -2905,8 +2905,8 @@ static struct rte_dpaa2_driver rte_dpaa2_pmd = {
 	.remove = rte_dpaa2_remove,
 };
 
-RTE_PMD_REGISTER_DPAA2(net_dpaa2, rte_dpaa2_pmd);
-RTE_PMD_REGISTER_PARAM_STRING(net_dpaa2,
+RTE_PMD_REGISTER_DPAA2(NET_DPAA2_PMD_DRIVER_NAME, rte_dpaa2_pmd);
+RTE_PMD_REGISTER_PARAM_STRING(NET_DPAA2_PMD_DRIVER_NAME,
 		DRIVER_LOOPBACK_MODE "=<int> "
 		DRIVER_NO_PREFETCH_MODE "=<int>"
 		DRIVER_TX_CONF "=<int>"
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.h b/drivers/net/dpaa2/dpaa2_ethdev.h
index 7b76ca7b2d..b9c729f6cd 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.h
+++ b/drivers/net/dpaa2/dpaa2_ethdev.h
@@ -19,6 +19,7 @@
 
 #define DPAA2_MIN_RX_BUF_SIZE 512
 #define DPAA2_MAX_RX_PKT_LEN  10240 /*WRIOP support*/
+#define NET_DPAA2_PMD_DRIVER_NAME net_dpaa2
 
 #define MAX_TCS			DPNI_MAX_TC
 #define MAX_RX_QUEUES		128
diff --git a/drivers/net/dpaa2/dpaa2_mux.c b/drivers/net/dpaa2/dpaa2_mux.c
index 811f417491..d347f4df51 100644
--- a/drivers/net/dpaa2/dpaa2_mux.c
+++ b/drivers/net/dpaa2/dpaa2_mux.c
@@ -68,6 +68,9 @@ rte_pmd_dpaa2_mux_flow_create(uint32_t dpdmux_id,
 	int ret;
 	static int i;
 
+	if (!pattern || !actions || !pattern[0] || !actions[0])
+		return NULL;
+
 	/* Find the DPDMUX from dpdmux_id in our list */
 	dpdmux_dev = get_dpdmux_from_id(dpdmux_id);
 	if (!dpdmux_dev) {
-- 
2.17.1


  parent reply	other threads:[~2021-07-19 14:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-19 13:59 [dpdk-dev] [PATCH 0/7] NXP DPAAx fixes and improvements Hemant Agrawal
2021-07-19 13:59 ` [dpdk-dev] [PATCH 1/7] bus/dpaa: fix to use right type of memory free Hemant Agrawal
2021-07-19 13:59 ` [dpdk-dev] [PATCH 2/7] net/dpaa: fix headroom in VSP case Hemant Agrawal
2021-07-19 13:59 ` [dpdk-dev] [PATCH 3/7] bus/dpaa: reduce syscall usages Hemant Agrawal
2021-07-19 13:59 ` [dpdk-dev] [PATCH 4/7] net/dpaa: add check for parsing default Rx queue Hemant Agrawal
2021-07-19 13:59 ` [dpdk-dev] [PATCH 5/7] net/dpaa2: add per thread init PMD API Hemant Agrawal
2021-09-09  7:09   ` Hemant Agrawal
2021-07-19 13:59 ` Hemant Agrawal [this message]
2021-07-19 13:59 ` [dpdk-dev] [PATCH 7/7] doc: remove SDK info form individual dev guides Hemant Agrawal
2021-07-23 18:34 ` [dpdk-dev] [PATCH 0/7] NXP DPAAx fixes and improvements Thomas Monjalon

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=20210719135917.26241-7-hemant.agrawal@nxp.com \
    --to=hemant.agrawal@nxp.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=vanshika.shukla@nxp.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).