DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] app/testpmd: fix RSS key
@ 2020-12-30  5:29 Zhang,Alvin
  0 siblings, 0 replies; 4+ messages in thread
From: Zhang,Alvin @ 2020-12-30  5:29 UTC (permalink / raw)
  To: orika; +Cc: dev, Alvin Zhang, stable

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(-)

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:
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] app/testpmd: fix RSS key
  2021-01-19 19:14 ` Ferruh Yigit
@ 2021-01-21  9:35   ` Zhang, AlvinX
  0 siblings, 0 replies; 4+ messages in thread
From: Zhang, AlvinX @ 2021-01-21  9:35 UTC (permalink / raw)
  To: Yigit, Ferruh; +Cc: dev, stable

Hi Ferruh,

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

Alvin

> -----Original Message-----
> From: Ferruh Yigit <ferruh.yigit@intel.com>
> Sent: Wednesday, January 20, 2021 3:15 AM
> To: Zhang, AlvinX <alvinx.zhang@intel.com>
> Cc: dev@dpdk.org; stable@dpdk.org
> Subject: Re: [PATCH] app/testpmd: fix RSS key
> 
> On 1/18/2021 8:59 AM, Zhang,Alvin wrote:
> > 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.
> >
> 
> Can you please put the rte_flow command that enables reproducing this defect,
> it may help in the future?
> 
> > 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(-)
> >
> > 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)),
> 
> 
> +1, it is required to write the address, and I confirm this enables
> +getting
> 'key' value to the PMD.
> 
> >   			     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;
> 
> 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?
> 
> > +
> > +		*(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:
> >


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] app/testpmd: fix RSS key
  2021-01-18  8:59 Zhang,Alvin
@ 2021-01-19 19:14 ` Ferruh Yigit
  2021-01-21  9:35   ` Zhang, AlvinX
  0 siblings, 1 reply; 4+ messages in thread
From: Ferruh Yigit @ 2021-01-19 19:14 UTC (permalink / raw)
  To: Zhang,Alvin; +Cc: dev, stable

On 1/18/2021 8:59 AM, Zhang,Alvin wrote:
> 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.
> 

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

> 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(-)
> 
> 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)),


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

>   			     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;

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?

> +
> +		*(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:
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [dpdk-dev] [PATCH] app/testpmd: fix RSS key
@ 2021-01-18  8:59 Zhang,Alvin
  2021-01-19 19:14 ` Ferruh Yigit
  0 siblings, 1 reply; 4+ messages in thread
From: Zhang,Alvin @ 2021-01-18  8:59 UTC (permalink / raw)
  To: ferruh.yigit; +Cc: dev, Alvin Zhang, stable

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(-)

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:
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-01-21  9:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-30  5:29 [dpdk-dev] [PATCH] app/testpmd: fix RSS key Zhang,Alvin
2021-01-18  8:59 Zhang,Alvin
2021-01-19 19:14 ` Ferruh Yigit
2021-01-21  9:35   ` Zhang, AlvinX

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git