DPDK patches and discussions
 help / color / mirror / Atom feed
From: Gregory Etelson <getelson@nvidia.com>
To: <dev@dpdk.org>, <getelson@nvidia.com>, <viacheslavo@nvidia.com>
Cc: <ferruh.yigit@intel.com>, Ori Kam <orika@nvidia.com>,
	Thomas Monjalon <thomas@monjalon.net>,
	Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Subject: [dpdk-dev] [PATCH v2] ethdev: fix variable length flow elements support
Date: Thu, 4 Nov 2021 13:27:21 +0200	[thread overview]
Message-ID: <20211104112721.4025-1-getelson@nvidia.com> (raw)
In-Reply-To: <20211026090554.9128-1-getelson@nvidia.com>

RTE flow API defines two flow elements types - common and PMD private.
Common RTE flow types are defined in rte_flow.h while PMD private
types exists inside specific PMD only. Application can create a flow
rule with PMD private items or actions. RTE flow API restricts
private PMD types to negative values.

Current implementation tried to use negative PMD private item type
value as index in the rte_flow_desc_item[] array.

The patch allows access to rte_flow_desc_item[] and
rte_flow_desc_action[] arrays to non-private PMD types only.

Fixes: 6cf72047332b ("ethdev: support flow elements with variable length")
Signed-off-by: Gregory Etelson <getelson@nvidia.com>
---
v2: Update the patch comment.
---
 lib/ethdev/rte_flow.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c
index d268784532..a93f68abbc 100644
--- a/lib/ethdev/rte_flow.c
+++ b/lib/ethdev/rte_flow.c
@@ -54,11 +54,13 @@ rte_flow_conv_copy(void *buf, const void *data, const size_t size,
 	/**
 	 * Allow PMD private flow item
 	 */
-	size_t sz = type >= 0 ? desc[type].size : sizeof(void *);
+	bool rte_type = type >= 0;
+
+	size_t sz = rte_type ? desc[type].size : sizeof(void *);
 	if (buf == NULL || data == NULL)
 		return 0;
 	rte_memcpy(buf, data, (size > sz ? sz : size));
-	if (desc[type].desc_fn)
+	if (rte_type && desc[type].desc_fn)
 		sz += desc[type].desc_fn(size > 0 ? buf : NULL, data);
 	return sz;
 }
-- 
2.33.1


  parent reply	other threads:[~2021-11-04 11:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-26  9:05 [dpdk-dev] [PATCH] " Gregory Etelson
2021-11-03 21:04 ` Ferruh Yigit
2021-11-04  5:33   ` Gregory Etelson
2021-11-04  9:10     ` Ferruh Yigit
2021-11-04  9:20       ` Gregory Etelson
2021-11-04 11:27 ` Gregory Etelson [this message]
2021-11-04 12:46   ` [dpdk-dev] [PATCH v2] " Ferruh Yigit

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=20211104112721.4025-1-getelson@nvidia.com \
    --to=getelson@nvidia.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=orika@nvidia.com \
    --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).