app/pdump: close program if --pdump argument is missing
PATCH 1/1 app/pdump: close program if --pdump argument is missing
--pdump is a mandatory argument in pdump application. It should print usage and exit if --pdump argument is missing. The application is not closing and getting stuck. Made the change to print usage and exit when this argument is missing.
--- app/pdump/main.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
app/pdump/main.c +13 -6
@@ -383,14 +383,17 @@ launch_args_parse(int argc, char **argv, char *prgname) { int opt, ret; int option_index; + bool pdump_flag = false; static struct option long_option[] = { {CMD_LINE_OPT_PDUMP, 1, 0, CMD_LINE_OPT_PDUMP_NUM}, {CMD_LINE_OPT_MULTI, 0, 0, CMD_LINE_OPT_MULTI_NUM}, {NULL, 0, 0, 0} }; - if (argc == 1) + if (argc == 1) { pdump_usage(prgname); + return -1; + } /* Parse command line */ while ((opt = getopt_long(argc, argv, " ",
@@ -402,6 +405,7 @@ launch_args_parse(int argc, char **argv, char *prgname)pdump_usage (prgname);return -1 ; } + pdump_flag = true;break ;case CMD_LINE_OPT_MULTI_NUM : multiple_core_capture =1 ;
@@ -412,6 +416,11 @@ launch_args_parse(int argc, char **argv, char *prgname) } } +if (pdump_flag == false) { +pdump_usage (prgname); +return -1 ; + } +return 0 ; }
@@ -991,11 +1000,9 @@ main(int argc, char **argv) argv += (diag -2 );/* parse app arguments */ -if (argc >1 ) { - ret =launch_args_parse (argc, argv, argp[0 ]); -if (ret <0 ) -rte_exit (EXIT_FAILURE ,"Invalid argument\n" ); - } + ret =launch_args_parse (argc, argv, argp[0 ]); +if (ret <0 ) +rte_exit (EXIT_FAILURE ,"Invalid argument\n" );/* create mempool, ring and vdevs info */ create_mp_ring_vdev ();
Signature · 1 line
2.25.1
Quoted 7 lines · On Wed, 2 Mar 2022 14:26:14 +0500 "usman.tanveer" <[email protected]>…
--pdump is a mandatory argument in pdump application. It should print usage and exit if --pdump argument is missing. The application is not closing and getting stuck. Made the change to print usage and exit when this argument is missing.
Signed-off-by usman.tanveer <[email protected]>
Maybe pdump could just do something sane with no arguments. That is one of the issues I tried to address by rewriting it.
Ideally, existing pdump can be deprecated and removed in 22.11?
The 20.11 release is not coming out till August, in the meantime, this patch can be applied to print help if mandatory argument is not passed.
Quoted 16 lines · Stephen Hemminger
Quoted 7 lines · On Wed, 2 Mar 2022 14:26:14 +0500 "usman.tanveer" <[email protected]>…
--pdump is a mandatory argument in pdump application. It should print usage and exit if --pdump argument is missing. The application is not closing and getting stuck. Made the change to print usage and exit when this argument is missing.
Signed-off-by usman.tanveer <[email protected]>Maybe pdump could just do something sane with no arguments. That is one of the issues I tried to address by rewriting it.
Ideally, existing pdump can be deprecated and removed in 22.11?
PATCH v2 1/1 app/pdump: exit if no device specified
In reply to usman.tanveerSimpler version of earlier patch which had a good idea, was just implemented with more code than necessary.
If no device is specified don't start the capture loop.
--- app/pdump/main.c | 3 +++ 1 file changed, 3 insertions(+)
app/pdump/main.c +3 -0
@@ -915,6 +915,9 @@ dump_packets(void)int i;unsigned int lcore_id =0 ; +if (num_tuples ==0 ) +rte_exit (EXIT_FAILURE ,"No device specified for capture\n" ); +if (!multiple_core_capture) {printf (" core (%u), capture for (%d) tuples\n" ,rte_lcore_id (), num_tuples);
Signature · 1 line
2.39.2
Re: [PATCH v2] app/pdump: exit if no device specified
Quoted 25 lines · Stephen Hemminger
Simpler version of earlier patch which had a good idea, was just implemented with more code than necessary.
If no device is specified don't start the capture loop.Reported-by usman.tanveer <[email protected]>Signed-off-by Stephen Hemminger <[email protected]>--- app/pdump/main.c | 3 +++ 1 file changed, 3 insertions(+)app/pdump/main.c +3
-0@@ -915,6 +915,9 @@ dump_packets(void)int i;unsigned int lcore_id =0 ; +if (num_tuples ==0 ) +rte_exit (EXIT_FAILURE ,"No device specified for capture\n" ); +if (!multiple_core_capture) {printf (" core (%u), capture for (%d) tuples\n" ,rte_lcore_id (), num_tuples);
Thomas Monjalon
AppliedRe: [PATCH v2] app/pdump: exit if no device specified
03/07/2023 08:29, fengchengwen:
Quoted 9 lines
Acked-by Chengwen Feng <[email protected]>Quoted 6 lines · Stephen Hemminger
Simpler version of earlier patch which had a good idea, was just implemented with more code than necessary.
If no device is specified don't start the capture loop.Reported-by usman.tanveer <[email protected]>Signed-off-by Stephen Hemminger <[email protected]>
Applied, thanks.