[iproute2] netem: Fail cleanly if user input is wrong

Submitted by Vijay Subramanian on Jan. 20, 2012, 5:50 p.m.

Details

Message ID 1327081825-6448-1-git-send-email-subramanian.vijay@gmail.com
State Accepted
Delegated to: stephen hemminger
Headers show

Commit Message

Vijay Subramanian Jan. 20, 2012, 5:50 p.m.
(Resending patch since it looks like my earlier mail did not make it to
netdev). 

netem reordering requires that the delay parameter be given. Currently, if no
delay is given, tc prints the error message but still installs the qdisc. Fix
this by printing the usage and failing cleanly.

Signed-off-by: Vijay Subramanian <subramanian.vijay@gmail.com>
---
 tc/q_netem.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Comments

stephen hemminger Jan. 20, 2012, 7:22 p.m.
On Fri, 20 Jan 2012 09:50:25 -0800
Vijay Subramanian <subramanian.vijay@gmail.com> wrote:

> (Resending patch since it looks like my earlier mail did not make it to
> netdev). 
> 
> netem reordering requires that the delay parameter be given. Currently, if no
> delay is given, tc prints the error message but still installs the qdisc. Fix
> this by printing the usage and failing cleanly.
> 
> Signed-off-by: Vijay Subramanian <subramanian.vijay@gmail.com>
> ---
>  tc/q_netem.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/tc/q_netem.c b/tc/q_netem.c
> index b1fd452..23164d9 100644
> --- a/tc/q_netem.c
> +++ b/tc/q_netem.c
> @@ -395,6 +395,8 @@ static int netem_parse_opt(struct qdisc_util *qu, int argc, char **argv,
>  	if (reorder.probability) {
>  		if (opt.latency == 0) {
>  			fprintf(stderr, "reordering not possible without specifying some delay\n");
> +			explain();
> +			return -1;
>  		}
>  		if (opt.gap == 0)
>  			opt.gap = 1;

Applied
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch hide | download patch | download mbox

diff --git a/tc/q_netem.c b/tc/q_netem.c
index b1fd452..23164d9 100644
--- a/tc/q_netem.c
+++ b/tc/q_netem.c
@@ -395,6 +395,8 @@  static int netem_parse_opt(struct qdisc_util *qu, int argc, char **argv,
 	if (reorder.probability) {
 		if (opt.latency == 0) {
 			fprintf(stderr, "reordering not possible without specifying some delay\n");
+			explain();
+			return -1;
 		}
 		if (opt.gap == 0)
 			opt.gap = 1;