DPDK patches and discussions
 help / color / mirror / Atom feed
From: Matan Azrad <matan@mellanox.com>
To: Jingjing Wu <jingjing.wu@intel.com>,
	Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v2 2/2] ethdev: fix flow rule copy functions
Date: Mon, 24 Jul 2017 16:47:33 +0300	[thread overview]
Message-ID: <1500904053-4543-3-git-send-email-matan@mellanox.com> (raw)
In-Reply-To: <1500904053-4543-1-git-send-email-matan@mellanox.com>

The corrupted code checks only RAW flow item type special case for
returning its size but doesn't deal with any other flow item type
and returns 0 for all the others.

This bug leaves the flow descriptor empty for non RAW types.

The fix takes the correct size to any regular types from appropriate
array.

The same issue, with a similar fix, is in flow action size method
which deals only with RSS special type.

This bug was already present in the original code taken from testpmd.

Fixes: bae73ebad91c ("ethdev: add flow rule copy function")

Signed-off-by: Matan Azrad <matan@mellanox.com>
---
 lib/librte_ether/rte_flow.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c
index 884e4f6..2001fbb 100644
--- a/lib/librte_ether/rte_flow.c
+++ b/lib/librte_ether/rte_flow.c
@@ -248,8 +248,10 @@ struct rte_flow *
 flow_item_spec_size(const struct rte_flow_item *item,
 		    size_t *size, size_t *pad)
 {
-	if (!item->spec)
+	if (!item->spec) {
+		*size = 0;
 		goto empty;
+	}
 	switch (item->type) {
 		union {
 			const struct rte_flow_item_raw *raw;
@@ -262,10 +264,10 @@ struct rte_flow *
 			spec.raw->length * sizeof(*spec.raw->pattern);
 		break;
 	default:
-empty:
-		*size = 0;
+		*size = rte_flow_desc_item[item->type].size;
 		break;
 	}
+empty:
 	*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;
 }
 
@@ -274,8 +276,10 @@ struct rte_flow *
 flow_action_conf_size(const struct rte_flow_action *action,
 		      size_t *size, size_t *pad)
 {
-	if (!action->conf)
+	if (!action->conf) {
+		*size = 0;
 		goto empty;
+	}
 	switch (action->type) {
 		union {
 			const struct rte_flow_action_rss *rss;
@@ -288,10 +292,10 @@ struct rte_flow *
 			conf.rss->num * sizeof(*conf.rss->queue);
 		break;
 	default:
-empty:
-		*size = 0;
+		*size = rte_flow_desc_action[action->type].size;
 		break;
 	}
+empty:
 	*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;
 }
 
-- 
1.8.3.1

  parent reply	other threads:[~2017-07-24 13:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-24  7:10 [dpdk-dev] [PATCH 0/2] fix flow rules " Matan Azrad
2017-07-24  7:10 ` [dpdk-dev] [PATCH 1/2] app/testpmd: fix flow rule " Matan Azrad
2017-07-24  7:10 ` [dpdk-dev] [PATCH 2/2] ethdev: " Matan Azrad
2017-07-24 13:47 ` [dpdk-dev] [PATCH v2 0/2] fix flow rules " Matan Azrad
2017-07-24 13:47   ` [dpdk-dev] [PATCH v2 1/2] app/testpmd: fix flow rule " Matan Azrad
2017-07-24 13:47   ` Matan Azrad [this message]
2017-07-31 12:10   ` [dpdk-dev] [PATCH v2 0/2] fix flow rules " 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=1500904053-4543-3-git-send-email-matan@mellanox.com \
    --to=matan@mellanox.com \
    --cc=adrien.mazarguil@6wind.com \
    --cc=dev@dpdk.org \
    --cc=jingjing.wu@intel.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).