app/testpmd: fix auto completion for indirect list action
PATCH 1/1 app/testpmd: fix auto completion for indirect list action
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.
--- app/test-pmd/cmdline_flow.c | 46 ++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 21 deletions(-)
app/test-pmd/cmdline_flow.c +25 -21
@@ -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; }
Signature · 1 line
2.34.1
Quoted 6 lines · Shani Peretz
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 theindirect_listaction argument was returning before having the opportunity to handle the argument.
Hi Shani,
I can see a few other handles follows the updated logic, but to understand more, was the problematic part following:
``` if (!action) return -1; ```
If so why 'action' can be NULL and why need to continue for this case, can you please help me understand?
Also even if 'action' is NULL, function will return output of 'parse_int()', is this expected?
Thanks,
ferruh
Quoted 86 lines
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 <[email protected]>--- app/test-pmd/cmdline_flow.c | 46 ++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 21 deletions(-)app/test-pmd/cmdline_flow.c +25
-21@@ -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; }
Quoted 16 lines · Ferruh Yigit
Quoted 6 lines · Shani Peretz
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 theindirect_listaction argument was returning before having the opportunity to handle the argument.Hi Shani,
I can see a few other handles follows the updated logic, but to understand more, was the problematic part following:
``` if (!action) return -1; ```
Quoted 6 lines
If so why 'action' can be NULL and why need to continue for this case, can you please help me understand?
Also even if 'action' is NULL, function will return output of '
parse_int()', is this expected?
I can verify the fix via debugging,
it seems missing ".comp = comp_none" cause calling handler (parse_indlst_id2ptr), and 'parse_indlst_id2ptr()' needs to be fixed to parse correctly.
I will proceed with patch since it is local to a specific flow command,
BUT overall how can we catch issues like this in the feature, we don't have a good way to test testpmd flow commands.
@Ori, @Gregory, do you have any idea?
cc'ed CI mail list too.
Quoted 24 lines · Ferruh Yigit
Quoted 16 lines · Ferruh Yigit
Quoted 6 lines · Shani Peretz
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 theindirect_listaction argument was returning before having the opportunity to handle the argument.Hi Shani,
I can see a few other handles follows the updated logic, but to understand more, was the problematic part following:
``` if (!action) return -1; ```Quoted 6 lines
If so why 'action' can be NULL and why need to continue for this case, can you please help me understand?
Also even if 'action' is NULL, function will return output of '
parse_int()', is this expected?
Quoted 8 lines
I can verify the fix via debugging,
it seems missing ".comp =
comp_none" cause calling handler (parse_indlst_id2ptr), and 'parse_indlst_id2ptr()' needs to be fixed to parse correctly.I will proceed with patch since it is local to a specific flow command,
Applied to dpdk-next-net/main, thanks.
Hello Ferruh,
Quoted 4 lines
BUT overall how can we catch issues like this in the feature, we don't have a good way to test testpmd flow commands.
@Ori, @Gregory, do you have any idea?
cc'ed CI mail list too.
We have a tool for unit tests based on the testpmd.
The tool details are here: https://drive.google.com/drive/folders/1cHrPwx4fUJ6ibUCtHd4kNKsrmmvQvvOj?usp=drive_link.
There's also a short description here: https://inbox.dpdk.org/ci/[email protected]/
Consider an option when a code patch is accompanied with a short test script that validates that patch functionality. DPDK CI can run the script to verify that the patch functions correctly.
Regards,
Gregory
Quoted 13 lines · Gregory Etelson
Hello Ferruh,
Quoted 4 lines
BUT overall how can we catch issues like this in the feature, we don't have a good way to test testpmd flow commands.
@Ori, @Gregory, do you have any idea?
cc'ed CI mail list too.We have a tool for unit tests based on the testpmd.
The tool details are here:
https://drive.google.com/drive/folders/1cHrPwx4fUJ6ibUCtHd4kNKsrmmvQvvOj?usp=drive_link <https://drive.google.com/drive/folders/1cHrPwx4fUJ6ibUCtHd4kNKsrmmvQvvOj?usp=drive_link>.
There's also a short description here:
https://inbox.dpdk.org/ci/[email protected]/ <https://inbox.dpdk.org/ci/[email protected]/>
Quoted 5 lines
Consider an option when a code patch is accompanied with a short test script that validates that patch functionality.
DPDK CI can run the script to verify that the patch functions correctly.
Thanks Gregory, I missed this proposal, we need something to verify flow APIs, so +1 to the effort.
What is the status of incorporating this feature into dts?
But I guess it won't catch this issue, as it uses full flow commands. This issue is related to the testpmd command parsing code. I wonder if we can find a way to verify testpmd parsing code?
Quoted 15 lines · Ferruh Yigit
Quoted 13 lines · Gregory Etelson
Hello Ferruh,
Quoted 4 lines
BUT overall how can we catch issues like this in the feature, we don't have a good way to test testpmd flow commands.
@Ori, @Gregory, do you have any idea?
cc'ed CI mail list too.We have a tool for unit tests based on the testpmd.
The tool details are here:
https://drive.google.com/drive/folders/1cHrPwx4fUJ6ibUCtHd4kNKsrmmvQvvOj?usp=drive_link <https://drive.google.com/drive/folders/1cHrPwx4fUJ6ibUCtHd4kNKsrmmvQvvOj?usp=drive_link>.
There's also a short description here:
https://inbox.dpdk.org/ci/[email protected]/ <https://inbox.dpdk.org/ci/[email protected]/>
Quoted 3 lines
Quoted 3 lines
Consider an option when a code patch is accompanied with a short test script that validates that patch functionality.
DPDK CI can run the script to verify that the patch functions correctly.
A similar idea has been proposed for DTS. I believe the plan is at the end of 2024 techboard is going to discuss adding this as a requirement for patches affecting certain components in DPDK. So a change related to the new feature must come with an accompanied /dts testsuite addition at the same time.
Quoted 6 lines
Quoted 2 lines
Thanks Gregory, I missed this proposal, we need something to verify flow APIs, so +1 to the effort.
What is the status of incorporating this feature into dts?
The DTS 24.07 roadmap does not include testsuites verifying flow APIs, but if work proceeds at a good pace and there is space for it, we can look at writing something for 24.07. Otherwise it falls to 24.11 or 25.03. Sorry, I know that's pretty far out.
Quoted 6 lines
But I guess it won't catch this issue, as it uses full flow commands. This issue is related to the testpmd command parsing code. I wonder if we can find a way to verify testpmd parsing code?
Hello Ferruh,
Quoted 3 lines
But I guess it won't catch this issue, as it uses full flow commands. This issue is related to the testpmd command parsing code. I wonder if we can find a way to verify testpmd parsing code?
What if flow command validation program breaks a tested command into tokens and then pass each token followed by the TAB key to the controlled testpmd process ? There are 3 possible outputs for the token + TAB sequence:
1. a valid token will trigger meaningful testpmd help ouput that can be matched.
2. invalid token output will fail [1].
3.
invalid token will crash the controlled testpmd process.
I've compiled a small programm to test that idea. Please check it out.
Regards,
Gregory.
commit e4a27c2c2892cfd408b473b18192b30927e4281c
Author: Gregory Etelson <[email protected]> Date: Sat Mar 23 11:38:44 2024 +0200
validate testpmd flow command
Cargo.toml new file +12 -0
@@ -0,0 +1,12 @@ +[package] +name = "testpmd-validate" +version = "0.1.0" +edition = "2021" +rust-version = "1.76.0" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +ssh2 = { version = "0.9.4", features = ["vendored-openssl"] } +time = "0.3.34" +regex = "1.10.4"
src/main.rs new file +128 -0
128 lines not on this page · raw message