DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] app/testpmd: fix auto completion for indirect list action
@ 2024-03-18  9:21 Shani Peretz
  2024-03-19 14:51 ` Ferruh Yigit
  0 siblings, 1 reply; 8+ messages in thread
From: Shani Peretz @ 2024-03-18  9:21 UTC (permalink / raw)
  To: dev
  Cc: shperetz, mkashani, Ori Kam, Aman Singh, Yuying Zhang, Gregory Etelson

In the process of auto completion of a command in testpmd,
the parser splits the command into tokens, where each token
represents an argument and defines a parsing function.
The parsing function of the indirect_list action argument was returning
before having the opportunity to handle the argument.

The fix ensures that the function appropriately handles
the argument before finishing.

Fixes: 72a3dec7126f ("ethdev: add indirect flow list action")

Signed-off-by: Shani Peretz <shperetz@nvidia.com>
---
 app/test-pmd/cmdline_flow.c | 46 ++++++++++++++++++++-----------------
 1 file changed, 25 insertions(+), 21 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index fd6c51f72d..60ee9337cf 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -7839,11 +7839,13 @@ static const struct token token_list[] = {
 		.type = "UNSIGNED",
 		.help = "unsigned integer value",
 		.call = parse_indlst_id2ptr,
+		.comp = comp_none,
 	},
 	[INDIRECT_LIST_ACTION_ID2PTR_CONF] = {
 		.type = "UNSIGNED",
 		.help = "unsigned integer value",
 		.call = parse_indlst_id2ptr,
+		.comp = comp_none,
 	},
 	[ACTION_SHARED_INDIRECT] = {
 		.name = "shared_indirect",
@@ -11912,34 +11914,36 @@ parse_indlst_id2ptr(struct context *ctx, const struct token *token,
 	uint32_t id;
 	int ret;
 
-	if (!action)
-		return -1;
 	ctx->objdata = 0;
 	ctx->object = &id;
 	ctx->objmask = NULL;
 	ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
+	ctx->object = action;
 	if (ret != (int)len)
 		return ret;
-	ctx->object = action;
-	action_conf = (void *)(uintptr_t)action->conf;
-	action_conf->conf = NULL;
-	switch (ctx->curr) {
-	case INDIRECT_LIST_ACTION_ID2PTR_HANDLE:
-	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);
-			return -1;
+
+	/* set handle and conf */
+	if (action) {
+		action_conf = (void *)(uintptr_t)action->conf;
+		action_conf->conf = NULL;
+		switch (ctx->curr) {
+		case INDIRECT_LIST_ACTION_ID2PTR_HANDLE:
+		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);
+				return -1;
+			}
+			break;
+		case INDIRECT_LIST_ACTION_ID2PTR_CONF:
+			indlst_conf = indirect_action_list_conf_get(id);
+			if (!indlst_conf)
+				return -1;
+			action_conf->conf = (const void **)indlst_conf->conf;
+			break;
+		default:
+			break;
 		}
-		break;
-	case INDIRECT_LIST_ACTION_ID2PTR_CONF:
-		indlst_conf = indirect_action_list_conf_get(id);
-		if (!indlst_conf)
-			return -1;
-		action_conf->conf = (const void **)indlst_conf->conf;
-		break;
-	default:
-		break;
 	}
 	return ret;
 }
-- 
2.34.1


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

end of thread, other threads:[~2024-03-23 10:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-18  9:21 [PATCH] app/testpmd: fix auto completion for indirect list action Shani Peretz
2024-03-19 14:51 ` Ferruh Yigit
2024-03-19 15:29   ` Ferruh Yigit
2024-03-19 17:43     ` Ferruh Yigit
2024-03-20  6:06     ` Gregory Etelson
2024-03-20 10:08       ` Ferruh Yigit
2024-03-20 20:25         ` Patrick Robb
2024-03-23 10:09         ` Gregory Etelson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).