[dpdk-dev,v2,1/2] app/testpmd: fix flow rule copy functions

Message ID 1500904053-4543-2-git-send-email-matan@mellanox.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Matan Azrad July 24, 2017, 1:47 p.m. UTC
  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.

Fixes: 99457e8fb8ce ("app/testpmd: implement basic support for flow API")
Cc: stable@dpdk.org

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

Patch

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index ee6644d..3ae3e1c 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -954,8 +954,10 @@  struct rss_type_info {
 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;
@@ -967,10 +969,10 @@  struct rss_type_info {
 			spec.raw->length * sizeof(*spec.raw->pattern);
 		break;
 	default:
-empty:
-		*size = 0;
+		*size = flow_item[item->type].size;
 		break;
 	}
+empty:
 	*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;
 }
 
@@ -1005,8 +1007,10 @@  struct rss_type_info {
 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;
@@ -1018,10 +1022,10 @@  struct rss_type_info {
 			conf.rss->num * sizeof(*conf.rss->queue);
 		break;
 	default:
-empty:
-		*size = 0;
+		*size = flow_action[action->type].size;
 		break;
 	}
+empty:
 	*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;
 }