[v2] app/testpmd: fix indirect action list parameters parsing

Message ID 20231109183637.498742-1-getelson@nvidia.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series [v2] app/testpmd: fix indirect action list parameters parsing |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/github-robot: build fail github build: failed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing fail Testing issues
ci/iol-sample-apps-testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS

Commit Message

Gregory Etelson Nov. 9, 2023, 6:36 p.m. UTC
  Indirect actions list arguments parser was configured to place target
number into 64bit value, while the code provided 32bits memory.

The patch updated variable size for translation results.

Fixes: 72a3dec7126f ("ethdev: add indirect flow list action")
Signed-off-by: Gregory Etelson <getelson@nvidia.com>
---
v2: define `id` as uintptr_t
---
 app/test-pmd/cmdline_flow.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
  

Comments

Stephen Hemminger Nov. 9, 2023, 7:41 p.m. UTC | #1
On Thu, 9 Nov 2023 20:36:37 +0200
Gregory Etelson <getelson@nvidia.com> wrote:

> diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
> index 0d521159e9..397f9bc3eb 100644
> --- a/app/test-pmd/cmdline_flow.c
> +++ b/app/test-pmd/cmdline_flow.c
> @@ -11331,7 +11331,7 @@ parse_indlst_id2ptr(struct context *ctx, const struct token *token,
>  	struct rte_flow_action *action = ctx->object;
>  	struct rte_flow_action_indirect_list *action_conf;
>  	const struct indlst_conf *indlst_conf;
> -	uint32_t id;
> +	uintptr_t id;
>  	int ret;
>  
>  	if (!action)
> @@ -11350,7 +11350,8 @@ parse_indlst_id2ptr(struct context *ctx, const struct token *token,
>  	action_conf->handle = (typeof(action_conf->handle))
>  				port_action_handle_get_by_id(ctx->port, id);
>  		if (!action_conf->handle) {
> -			printf("no indirect list handle for id %u\n", id);
> +			printf("no indirect list handle for id %"PRIu64"\n",
> +			       id);

On 32 bit platforms uintptr_t is 32 bits.
Uintptr_t is always a typedef for unsigned long so use %lu here instead.
  
Bruce Richardson Nov. 9, 2023, 8:01 p.m. UTC | #2
On Thu, Nov 09, 2023 at 11:41:37AM -0800, Stephen Hemminger wrote:
> On Thu, 9 Nov 2023 20:36:37 +0200
> Gregory Etelson <getelson@nvidia.com> wrote:
> 
> > diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
> > index 0d521159e9..397f9bc3eb 100644
> > --- a/app/test-pmd/cmdline_flow.c
> > +++ b/app/test-pmd/cmdline_flow.c
> > @@ -11331,7 +11331,7 @@ parse_indlst_id2ptr(struct context *ctx, const struct token *token,
> >  	struct rte_flow_action *action = ctx->object;
> >  	struct rte_flow_action_indirect_list *action_conf;
> >  	const struct indlst_conf *indlst_conf;
> > -	uint32_t id;
> > +	uintptr_t id;
> >  	int ret;
> >  
> >  	if (!action)
> > @@ -11350,7 +11350,8 @@ parse_indlst_id2ptr(struct context *ctx, const struct token *token,
> >  	action_conf->handle = (typeof(action_conf->handle))
> >  				port_action_handle_get_by_id(ctx->port, id);
> >  		if (!action_conf->handle) {
> > -			printf("no indirect list handle for id %u\n", id);
> > +			printf("no indirect list handle for id %"PRIu64"\n",
> > +			       id);
> 
> On 32 bit platforms uintptr_t is 32 bits.
> Uintptr_t is always a typedef for unsigned long so use %lu here instead.

PRIuPTR(and PRIxPTR) is the corresponding define from inttypes.h.

/Bruce
  

Patch

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 0d521159e9..397f9bc3eb 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -11331,7 +11331,7 @@  parse_indlst_id2ptr(struct context *ctx, const struct token *token,
 	struct rte_flow_action *action = ctx->object;
 	struct rte_flow_action_indirect_list *action_conf;
 	const struct indlst_conf *indlst_conf;
-	uint32_t id;
+	uintptr_t id;
 	int ret;
 
 	if (!action)
@@ -11350,7 +11350,8 @@  parse_indlst_id2ptr(struct context *ctx, const struct token *token,
 	action_conf->handle = (typeof(action_conf->handle))
 				port_action_handle_get_by_id(ctx->port, id);
 		if (!action_conf->handle) {
-			printf("no indirect list handle for id %u\n", id);
+			printf("no indirect list handle for id %"PRIu64"\n",
+			       id);
 			return -1;
 		}
 		break;