Skip to contentSkip to conversation

app/flow-perf: report invalid parameters

PATCH New Raslan Darawsheh 3 participants 4 messages Nov 11, 2021 – Nov 17, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 app/flow-perf: report invalid parameters

Currently, there is no check if an invalid parameter is passed to the application.
for example:

	./dpdk-test-flow-perf -a 01:00.0 -- --invalid

This validate that all strings are part of the known options.

Fixes 3344cf2e3001 ("app/flow-perf: add flow performance skeleton")
---
 app/test-flow-perf/main.c | 7 +++++++
 1 file changed, 7 insertions(+)
app/test-flow-perf/main.c +7 -0
index c1477b14a1..7453cf2b78 100644
@@ -885,6 +885,13 @@ args_parse(int argc, char **argv)
 			break;
 		}
 	}
+
+	if (opt_idx != argc) {
+		usage(argv[0]);
+		rte_exit(EXIT_FAILURE,
+			 "Incorrect command line %s\n", argv[opt_idx]);
+	}
+
 	if (rules_count % rules_batch != 0) {
 		rte_exit(EXIT_FAILURE,
 			 "rules_count %% rules_batch should be 0\n");
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/1 app/flow-perf: add missing default option

Currently, if an invalid parameter is passed to the application it will cause a crash due to missing default in options.

For example:

        ./dpdk-test-flow-perf -a 01:00.0 -- --invalid

This adds missing default for options, and prints the invalid option.

Fixes 3344cf2e3001 ("app/flow-perf: add flow performance skeleton")
---
 app/test-flow-perf/main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
app/test-flow-perf/main.c +2 -1
index 2b612aa32c..11f1ee0e1e 100644
@@ -715,6 +715,7 @@ args_parse(int argc, char **argv)
 		{ "policy-mtr",                 1, 0, 0 },
 		{ "meter-profile",              1, 0, 0 },
 		{ "packet-mode",                0, 0, 0 },
+		{ 0, 0, 0, 0 },
 	};
 
 	RTE_ETH_FOREACH_DEV(i)
@@ -951,7 +952,7 @@ args_parse(int argc, char **argv)
 		default:
 			usage(argv[0]);
 			rte_exit(EXIT_FAILURE, "Invalid option: %s\n",
-					argv[optind]);
+					argv[optind - 1]);
 			break;
 		}
 	}
Signature · 1 line
2.25.1
Acked-by on v2 1/1
#2 lore raw

RE: [PATCH v2] app/flow-perf: add missing default option

Hi,

Quoted 13 lines

-----Original Message-----
From: Raslan Darawsheh <[email protected]>
Sent: Tuesday, November 16, 2021 4:12 PM
To: [email protected]
Cc: Wisam Monther <[email protected]>; [email protected]
Subject: [PATCH v2] app/flow-perf: add missing default option

Currently, if an invalid parameter is passed to the application it will cause a crash due to missing default in options.

For example:

        ./dpdk-test-flow-perf -a 01:00.0 -- --invalid
Quoted 7 lines

This adds missing default for options, and prints the invalid option.

Fixes 3344cf2e3001 ("app/flow-perf: add flow performance skeleton")

BRs,
Wisam Jaddo

#3 lore raw

Re: [PATCH v2] app/flow-perf: add missing default option

Quoted 6 lines
Quoted 6 lines

Currently, if an invalid parameter is passed to the application it will cause a crash due to missing default in options.

For example:

        ./dpdk-test-flow-perf -a 01:00.0 -- --invalid
Quoted 8 lines
Quoted 7 lines

This adds missing default for options, and prints the invalid option.

Fixes 3344cf2e3001 ("app/flow-perf: add flow performance skeleton")

Applied with title "fix parsing of invalid option", thanks.