patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH] app/testpmd: report invalid command line parameter
@ 2019-11-17 17:10 David Marchand
  2019-11-17 17:12 ` David Marchand
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: David Marchand @ 2019-11-17 17:10 UTC (permalink / raw)
  To: dev
  Cc: thomas, ferruh.yigit, stable, Wenzhuo Lu, Jingjing Wu, Bernard Iremonger

We currently do not check that a non option string has been passed to
testpmd.

Example:
$ ./master/app/testpmd --no-huge -m 512 --vdev net_null0 \
	--vdev net_null1 -- -i nb-cores=2 --total-num-mbuf 2048
[...]
testpmd> show config fwd
io packet forwarding - ports=2 - cores=1 - streams=2 - NUMA support
enabled, MP allocation mode: native
Logical Core 1 (socket 0) forwards packets on 2 streams:
  RX P=0/Q=0 (socket 0) -> TX P=1/Q=0 (socket 0) peer=02:00:00:00:00:01
  RX P=1/Q=0 (socket 0) -> TX P=0/Q=0 (socket 0) peer=02:00:00:00:00:00

Here nb-cores=2 is just ignored, while the (probably sleepy) user did not
notice this.

Validate that all strings passed to testpmd are part of a known option.

After this patch:
$ ./master/app/testpmd --no-huge -m 512 --vdev net_null0 \
	--vdev net_null1 -- -i -nb-cores=2 --total-num-mbuf 2048
[...]
Invalid parameter: nb-cores=2
EAL: Error - exiting with code: 1
  Cause: Command line incorrect

While at it, when passing an unknown option, print the string that gets
refused by getopt_long to help the user.

Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
This seems a bit dangerous to take this kind of change.
Some "working fine" scripts might now report failures from testpmd because
of garbage in the command line.

Sending the patch anyway to see what others think about it.

---
 app/test-pmd/parameters.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index deca7a6828..2e7a504415 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -1363,12 +1363,19 @@ launch_args_parse(int argc, char** argv)
 			break;
 		default:
 			usage(argv[0]);
+			printf("Invalid option: %s\n", argv[optind]);
 			rte_exit(EXIT_FAILURE,
 				 "Command line is incomplete or incorrect\n");
 			break;
 		}
 	}
 
+	if (optind != argc) {
+		usage(argv[0]);
+		printf("Invalid parameter: %s\n", argv[optind]);
+		rte_exit(EXIT_FAILURE, "Command line is incorrect\n");
+	}
+
 	/* Set offload configuration from command line parameters. */
 	rx_mode.offloads = rx_offloads;
 	tx_mode.offloads = tx_offloads;
-- 
2.23.0


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

* Re: [dpdk-stable] [PATCH] app/testpmd: report invalid command line parameter
  2019-11-17 17:10 [dpdk-stable] [PATCH] app/testpmd: report invalid command line parameter David Marchand
@ 2019-11-17 17:12 ` David Marchand
  2019-11-18 10:37 ` Ferruh Yigit
  2019-11-18 15:37 ` [dpdk-stable] [PATCH v2] " David Marchand
  2 siblings, 0 replies; 7+ messages in thread
From: David Marchand @ 2019-11-17 17:12 UTC (permalink / raw)
  To: dev
  Cc: Thomas Monjalon, Yigit, Ferruh, dpdk stable, Wenzhuo Lu,
	Jingjing Wu, Bernard Iremonger

On Sun, Nov 17, 2019 at 6:10 PM David Marchand
<david.marchand@redhat.com> wrote:
> After this patch:
> $ ./master/app/testpmd --no-huge -m 512 --vdev net_null0 \
>         --vdev net_null1 -- -i -nb-cores=2 --total-num-mbuf 2048

Sorry wrong example, s/-nb-cores/nb-cores/

> [...]
> Invalid parameter: nb-cores=2
> EAL: Error - exiting with code: 1
>   Cause: Command line incorrect

But the output was correct.


-- 
David Marchand


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

* Re: [dpdk-stable] [PATCH] app/testpmd: report invalid command line parameter
  2019-11-17 17:10 [dpdk-stable] [PATCH] app/testpmd: report invalid command line parameter David Marchand
  2019-11-17 17:12 ` David Marchand
@ 2019-11-18 10:37 ` Ferruh Yigit
  2019-11-18 15:37 ` [dpdk-stable] [PATCH v2] " David Marchand
  2 siblings, 0 replies; 7+ messages in thread
From: Ferruh Yigit @ 2019-11-18 10:37 UTC (permalink / raw)
  To: David Marchand, dev
  Cc: thomas, stable, Wenzhuo Lu, Jingjing Wu, Bernard Iremonger

On 11/17/2019 5:10 PM, David Marchand wrote:
> We currently do not check that a non option string has been passed to
> testpmd.
> 
> Example:
> $ ./master/app/testpmd --no-huge -m 512 --vdev net_null0 \
> 	--vdev net_null1 -- -i nb-cores=2 --total-num-mbuf 2048
> [...]
> testpmd> show config fwd
> io packet forwarding - ports=2 - cores=1 - streams=2 - NUMA support
> enabled, MP allocation mode: native
> Logical Core 1 (socket 0) forwards packets on 2 streams:
>   RX P=0/Q=0 (socket 0) -> TX P=1/Q=0 (socket 0) peer=02:00:00:00:00:01
>   RX P=1/Q=0 (socket 0) -> TX P=0/Q=0 (socket 0) peer=02:00:00:00:00:00
> 
> Here nb-cores=2 is just ignored, while the (probably sleepy) user did not
> notice this.
> 
> Validate that all strings passed to testpmd are part of a known option.
> 
> After this patch:
> $ ./master/app/testpmd --no-huge -m 512 --vdev net_null0 \
> 	--vdev net_null1 -- -i -nb-cores=2 --total-num-mbuf 2048
> [...]
> Invalid parameter: nb-cores=2
> EAL: Error - exiting with code: 1
>   Cause: Command line incorrect
> 
> While at it, when passing an unknown option, print the string that gets
> refused by getopt_long to help the user.
> 
> Fixes: af75078fece3 ("first public release")
> Cc: stable@dpdk.org
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
> This seems a bit dangerous to take this kind of change.
> Some "working fine" scripts might now report failures from testpmd because
> of garbage in the command line.
> 
> Sending the patch anyway to see what others think about it.

+1 to the patch, I think better to fail in this case.

Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

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

* [dpdk-stable] [PATCH v2] app/testpmd: report invalid command line parameter
  2019-11-17 17:10 [dpdk-stable] [PATCH] app/testpmd: report invalid command line parameter David Marchand
  2019-11-17 17:12 ` David Marchand
  2019-11-18 10:37 ` Ferruh Yigit
@ 2019-11-18 15:37 ` David Marchand
  2019-11-18 16:18   ` Ferruh Yigit
  2 siblings, 1 reply; 7+ messages in thread
From: David Marchand @ 2019-11-18 15:37 UTC (permalink / raw)
  To: dev
  Cc: thomas, ferruh.yigit, stable, Wenzhuo Lu, Jingjing Wu, Bernard Iremonger

We currently do not check that a non option string has been passed to
testpmd.

Example:
$ ./master/app/testpmd --no-huge -m 512 --vdev net_null0 \
	--vdev net_null1 -- -i nb-cores=2 --total-num-mbuf 2048
[...]
testpmd> show config fwd
io packet forwarding - ports=2 - cores=1 - streams=2 - NUMA support
enabled, MP allocation mode: native
Logical Core 1 (socket 0) forwards packets on 2 streams:
  RX P=0/Q=0 (socket 0) -> TX P=1/Q=0 (socket 0) peer=02:00:00:00:00:01
  RX P=1/Q=0 (socket 0) -> TX P=0/Q=0 (socket 0) peer=02:00:00:00:00:00

Here nb-cores=2 is just ignored, while the (probably sleepy) user did not
notice this.

Validate that all strings passed to testpmd are part of a known option.

After this patch:
$ ./master/app/testpmd --no-huge -m 512 --vdev net_null0 \
	--vdev net_null1 -- -i nb-cores=2 --total-num-mbuf 2048
[...]
Invalid parameter: nb-cores=2
EAL: Error - exiting with code: 1
  Cause: Command line incorrect

While at it, when passing an unknown option, print the string that gets
refused by getopt_long to help the user.

Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
This seems a bit dangerous to take this kind of change this late.
Some "working fine" scripts might now report failures from testpmd because
of garbage in the command line.

Sending the patch anyway to see what others think about it.

Changelog since v1:
- fixed example in commitlog,

---
 app/test-pmd/parameters.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index deca7a6828..2e7a504415 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -1363,12 +1363,19 @@ launch_args_parse(int argc, char** argv)
 			break;
 		default:
 			usage(argv[0]);
+			printf("Invalid option: %s\n", argv[optind]);
 			rte_exit(EXIT_FAILURE,
 				 "Command line is incomplete or incorrect\n");
 			break;
 		}
 	}
 
+	if (optind != argc) {
+		usage(argv[0]);
+		printf("Invalid parameter: %s\n", argv[optind]);
+		rte_exit(EXIT_FAILURE, "Command line is incorrect\n");
+	}
+
 	/* Set offload configuration from command line parameters. */
 	rx_mode.offloads = rx_offloads;
 	tx_mode.offloads = tx_offloads;
-- 
2.23.0


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

* Re: [dpdk-stable] [PATCH v2] app/testpmd: report invalid command line parameter
  2019-11-18 15:37 ` [dpdk-stable] [PATCH v2] " David Marchand
@ 2019-11-18 16:18   ` Ferruh Yigit
  2019-11-19 19:18     ` Pallavi Kadam
  0 siblings, 1 reply; 7+ messages in thread
From: Ferruh Yigit @ 2019-11-18 16:18 UTC (permalink / raw)
  To: David Marchand, dev
  Cc: thomas, stable, Wenzhuo Lu, Jingjing Wu, Bernard Iremonger,
	Anatoly Burakov, Kadam, Pallavi, Ranjit Menon

On 11/18/2019 3:37 PM, David Marchand wrote:
> We currently do not check that a non option string has been passed to
> testpmd.
> 
> Example:
> $ ./master/app/testpmd --no-huge -m 512 --vdev net_null0 \
> 	--vdev net_null1 -- -i nb-cores=2 --total-num-mbuf 2048
> [...]
> testpmd> show config fwd
> io packet forwarding - ports=2 - cores=1 - streams=2 - NUMA support
> enabled, MP allocation mode: native
> Logical Core 1 (socket 0) forwards packets on 2 streams:
>   RX P=0/Q=0 (socket 0) -> TX P=1/Q=0 (socket 0) peer=02:00:00:00:00:01
>   RX P=1/Q=0 (socket 0) -> TX P=0/Q=0 (socket 0) peer=02:00:00:00:00:00
> 
> Here nb-cores=2 is just ignored, while the (probably sleepy) user did not
> notice this.
> 
> Validate that all strings passed to testpmd are part of a known option.
> 
> After this patch:
> $ ./master/app/testpmd --no-huge -m 512 --vdev net_null0 \
> 	--vdev net_null1 -- -i nb-cores=2 --total-num-mbuf 2048
> [...]
> Invalid parameter: nb-cores=2
> EAL: Error - exiting with code: 1
>   Cause: Command line incorrect
> 
> While at it, when passing an unknown option, print the string that gets
> refused by getopt_long to help the user.
> 
> Fixes: af75078fece3 ("first public release")
> Cc: stable@dpdk.org
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
> ---
> This seems a bit dangerous to take this kind of change this late.
> Some "working fine" scripts might now report failures from testpmd because
> of garbage in the command line.
> 
> Sending the patch anyway to see what others think about it.
> 
> Changelog since v1:
> - fixed example in commitlog,
> 
> ---
>  app/test-pmd/parameters.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
> index deca7a6828..2e7a504415 100644
> --- a/app/test-pmd/parameters.c
> +++ b/app/test-pmd/parameters.c
> @@ -1363,12 +1363,19 @@ launch_args_parse(int argc, char** argv)
>  			break;
>  		default:
>  			usage(argv[0]);
> +			printf("Invalid option: %s\n", argv[optind]);
>  			rte_exit(EXIT_FAILURE,
>  				 "Command line is incomplete or incorrect\n");
>  			break;
>  		}
>  	}
>  
> +	if (optind != argc) {

I hope 'optind' works as expected [1] in Windows too (Anatoly verified the
FreeBSD one).

@Pallavi, @Ranjit, Can you please confirm it?

[1]
https://linux.die.net/man/3/optind
"
If there are no more option characters, getopt() returns -1. Then optind is the
index in argv of the first argv-element that is not an option.
"

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

* Re: [dpdk-stable] [PATCH v2] app/testpmd: report invalid command line parameter
  2019-11-18 16:18   ` Ferruh Yigit
@ 2019-11-19 19:18     ` Pallavi Kadam
  2019-11-20 12:18       ` Ferruh Yigit
  0 siblings, 1 reply; 7+ messages in thread
From: Pallavi Kadam @ 2019-11-19 19:18 UTC (permalink / raw)
  To: Ferruh Yigit, David Marchand, dev
  Cc: thomas, stable, Wenzhuo Lu, Jingjing Wu, Bernard Iremonger,
	Anatoly Burakov, Ranjit Menon


On 11/18/2019 8:18 AM, Ferruh Yigit wrote:
> On 11/18/2019 3:37 PM, David Marchand wrote:
>> We currently do not check that a non option string has been passed to
>> testpmd.
>>
>> Example:
>> $ ./master/app/testpmd --no-huge -m 512 --vdev net_null0 \
>> 	--vdev net_null1 -- -i nb-cores=2 --total-num-mbuf 2048
>> [...]
>> testpmd> show config fwd
>> io packet forwarding - ports=2 - cores=1 - streams=2 - NUMA support
>> enabled, MP allocation mode: native
>> Logical Core 1 (socket 0) forwards packets on 2 streams:
>>    RX P=0/Q=0 (socket 0) -> TX P=1/Q=0 (socket 0) peer=02:00:00:00:00:01
>>    RX P=1/Q=0 (socket 0) -> TX P=0/Q=0 (socket 0) peer=02:00:00:00:00:00
>>
>> Here nb-cores=2 is just ignored, while the (probably sleepy) user did not
>> notice this.
>>
>> Validate that all strings passed to testpmd are part of a known option.
>>
>> After this patch:
>> $ ./master/app/testpmd --no-huge -m 512 --vdev net_null0 \
>> 	--vdev net_null1 -- -i nb-cores=2 --total-num-mbuf 2048
>> [...]
>> Invalid parameter: nb-cores=2
>> EAL: Error - exiting with code: 1
>>    Cause: Command line incorrect
>>
>> While at it, when passing an unknown option, print the string that gets
>> refused by getopt_long to help the user.
>>
>> Fixes: af75078fece3 ("first public release")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: David Marchand <david.marchand@redhat.com>
>> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
>> ---
>> This seems a bit dangerous to take this kind of change this late.
>> Some "working fine" scripts might now report failures from testpmd because
>> of garbage in the command line.
>>
>> Sending the patch anyway to see what others think about it.
>>
>> Changelog since v1:
>> - fixed example in commitlog,
>>
>> ---
>>   app/test-pmd/parameters.c | 7 +++++++
>>   1 file changed, 7 insertions(+)
>>
>> diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
>> index deca7a6828..2e7a504415 100644
>> --- a/app/test-pmd/parameters.c
>> +++ b/app/test-pmd/parameters.c
>> @@ -1363,12 +1363,19 @@ launch_args_parse(int argc, char** argv)
>>   			break;
>>   		default:
>>   			usage(argv[0]);
>> +			printf("Invalid option: %s\n", argv[optind]);
>>   			rte_exit(EXIT_FAILURE,
>>   				 "Command line is incomplete or incorrect\n");
>>   			break;
>>   		}
>>   	}
>>   
>> +	if (optind != argc) {
> I hope 'optind' works as expected [1] in Windows too (Anatoly verified the
> FreeBSD one).
>
> @Pallavi, @Ranjit, Can you please confirm it?
>
> [1]
> https://linux.die.net/man/3/optind
> "
> If there are no more option characters, getopt() returns -1. Then optind is the
> index in argv of the first argv-element that is not an option.
> "

Verified on Windows. So far this change does not affect Windows code.
Also, Windows does not support testpmd app yet.


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

* Re: [dpdk-stable] [PATCH v2] app/testpmd: report invalid command line parameter
  2019-11-19 19:18     ` Pallavi Kadam
@ 2019-11-20 12:18       ` Ferruh Yigit
  0 siblings, 0 replies; 7+ messages in thread
From: Ferruh Yigit @ 2019-11-20 12:18 UTC (permalink / raw)
  To: Pallavi Kadam, David Marchand, dev
  Cc: thomas, stable, Wenzhuo Lu, Jingjing Wu, Bernard Iremonger,
	Anatoly Burakov, Ranjit Menon

On 11/19/2019 7:18 PM, Pallavi Kadam wrote:
> 
> On 11/18/2019 8:18 AM, Ferruh Yigit wrote:
>> On 11/18/2019 3:37 PM, David Marchand wrote:
>>> We currently do not check that a non option string has been passed to
>>> testpmd.
>>>
>>> Example:
>>> $ ./master/app/testpmd --no-huge -m 512 --vdev net_null0 \
>>> 	--vdev net_null1 -- -i nb-cores=2 --total-num-mbuf 2048
>>> [...]
>>> testpmd> show config fwd
>>> io packet forwarding - ports=2 - cores=1 - streams=2 - NUMA support
>>> enabled, MP allocation mode: native
>>> Logical Core 1 (socket 0) forwards packets on 2 streams:
>>>   RX P=0/Q=0 (socket 0) -> TX P=1/Q=0 (socket 0) peer=02:00:00:00:00:01
>>>   RX P=1/Q=0 (socket 0) -> TX P=0/Q=0 (socket 0) peer=02:00:00:00:00:00
>>>
>>> Here nb-cores=2 is just ignored, while the (probably sleepy) user did not
>>> notice this.
>>>
>>> Validate that all strings passed to testpmd are part of a known option.
>>>
>>> After this patch:
>>> $ ./master/app/testpmd --no-huge -m 512 --vdev net_null0 \
>>> 	--vdev net_null1 -- -i nb-cores=2 --total-num-mbuf 2048
>>> [...]
>>> Invalid parameter: nb-cores=2
>>> EAL: Error - exiting with code: 1
>>>   Cause: Command line incorrect
>>>
>>> While at it, when passing an unknown option, print the string that gets
>>> refused by getopt_long to help the user.
>>>
>>> Fixes: af75078fece3 ("first public release")
>>> Cc: stable@dpdk.org
>>>
>>> Signed-off-by: David Marchand <david.marchand@redhat.com>
>>> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
>>> ---
>>> This seems a bit dangerous to take this kind of change this late.
>>> Some "working fine" scripts might now report failures from testpmd because
>>> of garbage in the command line.
>>>
>>> Sending the patch anyway to see what others think about it.
>>>
>>> Changelog since v1:
>>> - fixed example in commitlog,
>>>
>>> ---
>>>  app/test-pmd/parameters.c | 7 +++++++
>>>  1 file changed, 7 insertions(+)
>>>
>>> diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
>>> index deca7a6828..2e7a504415 100644
>>> --- a/app/test-pmd/parameters.c
>>> +++ b/app/test-pmd/parameters.c
>>> @@ -1363,12 +1363,19 @@ launch_args_parse(int argc, char** argv)
>>>  			break;
>>>  		default:
>>>  			usage(argv[0]);
>>> +			printf("Invalid option: %s\n", argv[optind]);
>>>  			rte_exit(EXIT_FAILURE,
>>>  				 "Command line is incomplete or incorrect\n");
>>>  			break;
>>>  		}
>>>  	}
>>>  
>>> +	if (optind != argc) {
>> I hope 'optind' works as expected [1] in Windows too (Anatoly verified the
>> FreeBSD one).
>>
>> @Pallavi, @Ranjit, Can you please confirm it?
>>
>> [1]
>> https://linux.die.net/man/3/optind
>> "
>> If there are no more option characters, getopt() returns -1. Then optind is the
>> index in argv of the first argv-element that is not an option.
>> "
> 
> Verified on Windows. So far this change does not affect Windows code.
> Also, Windows does not support testpmd app yet.
> 

Applied to dpdk-next-net/master, thanks.

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

end of thread, other threads:[~2019-11-20 12:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-17 17:10 [dpdk-stable] [PATCH] app/testpmd: report invalid command line parameter David Marchand
2019-11-17 17:12 ` David Marchand
2019-11-18 10:37 ` Ferruh Yigit
2019-11-18 15:37 ` [dpdk-stable] [PATCH v2] " David Marchand
2019-11-18 16:18   ` Ferruh Yigit
2019-11-19 19:18     ` Pallavi Kadam
2019-11-20 12:18       ` Ferruh Yigit

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ https://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git