Skip to contentSkip to conversation

app/testpmd: fix RSS key

PATCH Superseded Zhang,Alvin 3 participants 6 messages Jan 18, 2021 – Jan 22, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 app/testpmd: fix RSS key

From: Alvin Zhang <[email protected]>

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")
---
 app/test-pmd/cmdline_flow.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)
app/test-pmd/cmdline_flow.c +13 -11
index 585cab9..6eb46d3 100644
@@ -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:
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 10 lines · Zhang,Alvin

From: Alvin Zhang <[email protected]>

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.

Can you please put the rte_flow command that enables reproducing this defect, it may help in the future?

Quoted 13 lines
Fixes 1848b117cca1 ("app/testpmd: fix RSS key for flow API RSS rule")
---
  app/test-pmd/cmdline_flow.c | 24 +++++++++++++-----------
  1 file changed, 13 insertions(+), 11 deletions(-)
app/test-pmd/cmdline_flow.c +0 -0
index 585cab9..6eb46d3 100644

app/test-pmd/cmdline_flow.c static int comp_set_sample_index(struct context *, const struct token *, · line 3409

Quoted 8 lines
app/test-pmd/cmdline_flow.c +4 -1
@@ -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)),

+1, it is required to write the address, and I confirm this enables getting 'key' value to the PMD.

Quoted 7 lines
app/test-pmd/cmdline_flow.c +0 -0
  			     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);

app/test-pmd/cmdline_flow.c static int comp_set_sample_index(struct context *, const struct token *, · line 6505

Quoted 10 lines
app/test-pmd/cmdline_flow.c +3 -5
+
  	/* 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;

Above two lines seems only actual change in this function, others are refactoring the assignment.

1) why this check required, I think we can ignore it.
2) What do you think to remove the refactoring to reduce the change to the actual fix?

Quoted 16 lines
app/test-pmd/cmdline_flow.c +6 -5
+
+		*(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:
#2 lore raw

Hi Ferruh,

Thanks for your review.
I will modify the patch in V2.

Alvin

Quoted 92 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, January 20, 2021 3:15 AM
To: Zhang, AlvinX <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] app/testpmd: fix RSS key

Quoted 9 lines · Zhang,Alvin

From: Alvin Zhang <[email protected]>

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.

Can you please put the rte_flow command that enables reproducing this defect, it may help in the future?

app/test-pmd/cmdline_flow.c static int comp_set_sample_index(struct context

Quoted 13 lines
Fixes 1848b117cca1 ("app/testpmd: fix RSS key for flow API RSS rule")
---
  app/test-pmd/cmdline_flow.c | 24 +++++++++++++-----------
  1 file changed, 13 insertions(+), 11 deletions(-)
app/test-pmd/cmdline_flow.c +0 -0
index 585cab9..6eb46d3 100644
@@ -3403,7 +3403,10 @@ static int comp_set_sample_index(struct context

*, const struct token *,

app/test-pmd/cmdline_flow.c static int comp_set_sample_index(struct context *, const struct token *, · line 3409

Quoted 8 lines
app/test-pmd/cmdline_flow.c +4 -1
  		.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)),

+1, it is required to write the address, and I confirm this enables +getting
'key' value to the PMD.

app/test-pmd/cmdline_flow.c static int comp_set_sample_index(struct context *, const struct token *,

Quoted 3 lines
app/test-pmd/cmdline_flow.c +0 -0
  			     ARGS_ENTRY_ARB
  			     (offsetof(struct action_rss_data, conf) +
  			      offsetof(struct rte_flow_action_rss, key_len), @@

-6495,19

Quoted 1 line

+6498,18 @@ static int comp_set_sample_index(struct context *, const

struct token *,

app/test-pmd/cmdline_flow.c static int comp_set_sample_index(struct context *, const struct token *, · line 6505

Quoted 13 lines

if (ctx->objmask)
memset((uint8_t *)ctx->objmask + arg_data->offset,
0xff, hexlen);

app/test-pmd/cmdline_flow.c +3 -5
+
  	/* 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;

Above two lines seems only actual change in this function, others are refactoring the assignment.

1) why this check required, I think we can ignore it.
2) What do you think to remove the refactoring to reduce the change to the actual fix?

Quoted 16 lines
app/test-pmd/cmdline_flow.c +6 -5
+
+		*(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:
#3 lore raw

PATCH v2 1/1 app/testpmd: fix RSS key

In reply to Zhang,Alvin

From: Alvin Zhang <[email protected]>

Since the patch '1848b117' has initialized the variable 'key' in 'struct rte_flow_action_rss' with 'NULL', the PMD cannot get the RSS key now. Details as bellow:

testpmd> flow create 0 ingress pattern eth / ipv4 / end actions
rss types ipv4-other end key 1234567890123456789012345678901234567890FFFFFFFFFFFF123 4567890123456789012345678901234567890FFFFFFFFFFFF queues end / end
Flow rule #1 created
testpmd> show port 0 rss-hash key
RSS functions:
all ipv4-other ip
RSS key:

         4439796BB54C5023B675EA5B124F9F30B8A2C03DDFDC4D02A08C9B3
         34AF64A4C05C6FA343958D8557D99583AE138C92E81150366

This patch sets offset and size of the 'key' variable as the first parameter of the token 'key'. Later, the address of the RSS key will be copied to 'key' variable.

Fixes 1848b117cca1 ("app/testpmd: fix RSS key for flow API RSS rule")
---
 app/test-pmd/cmdline_flow.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
app/test-pmd/cmdline_flow.c +4 -1
index 0618611..067e120 100644
@@ -3541,7 +3541,10 @@ static int comp_set_modify_field_id(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),
Signature · 1 line
1.8.3.1
Tested-by on v2 1/1
#4 lore raw

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Zhang,Alvin
Sent: Thursday, January 21, 2021 5:42 PM
To: Yigit, Ferruh <[email protected]>
Cc: [email protected]; Zhang, AlvinX <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v2] app/testpmd: fix RSS key

From: Alvin Zhang <[email protected]>

Since the patch '1848b117' has initialized the variable 'key' in 'struct rte_flow_action_rss' with 'NULL', the PMD cannot get the RSS key now. Details as bellow:

testpmd> flow create 0 ingress pattern eth / ipv4 / end actions
rss types ipv4-other end key 1234567890123456789012345678901234567890FFFFFFFFFFFF123 4567890123456789012345678901234567890FFFFFFFFFFFF queues end / end
Flow rule #1 created
testpmd> show port 0 rss-hash key
RSS functions:
all ipv4-other ip
RSS key:

         4439796BB54C5023B675EA5B124F9F30B8A2C03DDFDC4D02A08C9B3
         34AF64A4C05C6FA343958D8557D99583AE138C92E81150366

This patch sets offset and size of the 'key' variable as the first parameter of the token 'key'. Later, the address of the RSS key will be copied to 'key' variable.

Fixes 1848b117cca1 ("app/testpmd: fix RSS key for flow API RSS rule")
---
 app/test-pmd/cmdline_flow.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
app/test-pmd/cmdline_flow.c +4 -1
@@ -3541,7 +3541,10 @@ static int comp_set_modify_field_id(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),

--
1.8.3.1

Reviewed-by Applied
#5 lore raw

On 1/22/2021 5:43 AM, Zhou, JunX W wrote:
<...>

Quoted 24 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Zhang,Alvin
Sent: Thursday, January 21, 2021 5:42 PM
To: Yigit, Ferruh <[email protected]>
Cc: [email protected]; Zhang, AlvinX <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v2] app/testpmd: fix RSS key

From: Alvin Zhang <[email protected]>

Since the patch '1848b117' has initialized the variable 'key' in 'struct rte_flow_action_rss' with 'NULL', the PMD cannot get the RSS key now. Details as bellow:

testpmd> flow create 0 ingress pattern eth / ipv4 / end actions
rss types ipv4-other end key 1234567890123456789012345678901234567890FFFFFFFFFFFF123 4567890123456789012345678901234567890FFFFFFFFFFFF queues end / end
Flow rule #1 created
testpmd> show port 0 rss-hash key
RSS functions:
all ipv4-other ip
RSS key:

          4439796BB54C5023B675EA5B124F9F30B8A2C03DDFDC4D02A08C9B3
          34AF64A4C05C6FA343958D8557D99583AE138C92E81150366
Quoted 9 lines

This patch sets offset and size of the 'key' variable as the first parameter of the token 'key'. Later, the address of the RSS key will be copied to 'key' variable.

Fixes 1848b117cca1 ("app/testpmd: fix RSS key for flow API RSS rule")

Applied to dpdk-next-net/main, thanks.