app/testpmd: fix RSS key

Message ID 20201230052928.19816-1-alvinx.zhang@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series app/testpmd: fix RSS key |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-abi-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS

Commit Message

Alvin Zhang Dec. 30, 2020, 5:29 a.m. UTC
  From: Alvin Zhang <alvinx.zhang@intel.com>

Since the patch '1848b117' has set the value of key in 'struct
rte_flow_action_rss' to NULL, the PMD cannot get the RSS key now.

This patch sets offset and size of the key pointer as the first
parameter of the token 'key' and copies the start address of the
'HEX' data to the location specified by the first parameter of
the token.

Fixes: 1848b117cca1 ("app/testpmd: fix RSS key for flow API RSS rule")
Cc: stable@dpdk.org

Signed-off-by: Alvin Zhang <alvinx.zhang@intel.com>
---
 app/test-pmd/cmdline_flow.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)
  

Patch

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 585cab9..6eb46d3 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -3403,7 +3403,10 @@  static int comp_set_sample_index(struct context *, const struct token *,
 		.name = "key",
 		.help = "RSS hash key",
 		.next = NEXT(action_rss, NEXT_ENTRY(HEX)),
-		.args = ARGS(ARGS_ENTRY_ARB(0, 0),
+		.args = ARGS(ARGS_ENTRY_ARB
+			     (offsetof(struct action_rss_data, conf) +
+			      offsetof(struct rte_flow_action_rss, key),
+			      sizeof(((struct rte_flow_action_rss *)0)->key)),
 			     ARGS_ENTRY_ARB
 			     (offsetof(struct action_rss_data, conf) +
 			      offsetof(struct rte_flow_action_rss, key_len),
@@ -6495,19 +6498,18 @@  static int comp_set_sample_index(struct context *, const struct token *,
 	if (ctx->objmask)
 		memset((uint8_t *)ctx->objmask + arg_data->offset,
 					0xff, hexlen);
+
 	/* Save address if requested. */
 	if (arg_addr->size) {
-		memcpy((uint8_t *)ctx->object + arg_addr->offset,
-		       (void *[]){
-			(uint8_t *)ctx->object + arg_data->offset
-		       },
-		       arg_addr->size);
+		if (arg_addr->size < sizeof(void *))
+			goto error;
+
+		*(void **)((uint8_t *)ctx->object + arg_addr->offset) =
+				(uint8_t *)ctx->object + arg_data->offset;
+
 		if (ctx->objmask)
-			memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
-			       (void *[]){
-				(uint8_t *)ctx->objmask + arg_data->offset
-			       },
-			       arg_addr->size);
+			*(void **)((uint8_t *)ctx->objmask + arg_addr->offset) =
+				(uint8_t *)ctx->objmask + arg_data->offset;
 	}
 	return len;
 error: