]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
tc/netem: fix loss state display and p14 parsing
authorJay Vosburgh <jay.vosburgh@canonical.com>
Fri, 9 May 2014 02:02:20 +0000 (19:02 -0700)
committerStephen Hemminger <stephen@networkplumber.org>
Fri, 9 May 2014 19:06:58 +0000 (12:06 -0700)
The display of the entire netem loss state is shown as if it
were gemodel state, as the loss state information is assigned to the
wrong pointer.  Correct this by assigning the loss state to the correct
pointer.

Additionally, attempting to set netem loss state will result in
random values in the p14 state probability because the option value
passed to the kernel by tc netem is not parsed or initialized.  Fix this
by supplying a default value of 0 for p14 and parsing the p14 value if
one is supplied.

Signed-off-by: Jay Vosburgh <jay.vosburgh@canonical.com>
tc/q_netem.c

index 946007c50e6449ca39d4bd39214718c5c983eb19..c83e301ecae3c30939f7bcd87934be25bea76e27 100644 (file)
@@ -263,6 +263,7 @@ static int netem_parse_opt(struct qdisc_util *qu, int argc, char **argv,
                                set_percent(&gimodel.p31, 1. - p13);
                                set_percent(&gimodel.p32, 0);
                                set_percent(&gimodel.p23, 1.);
+                               set_percent(&gimodel.p14, 0);
                                loss_type = NETEM_LOSS_GI;
 
                                if (!NEXT_IS_NUMBER())
@@ -288,6 +289,13 @@ static int netem_parse_opt(struct qdisc_util *qu, int argc, char **argv,
                                        explain1("loss p23");
                                        return -1;
                                }
+                               if (!NEXT_IS_NUMBER())
+                                       continue;
+                               NEXT_ARG();
+                               if (get_percent(&gimodel.p14, *argv)) {
+                                       explain1("loss p14");
+                                       return -1;
+                               }
 
                        } else if (!strcmp(*argv, "gemodel")) {
                                NEXT_ARG();
@@ -569,7 +577,7 @@ static int netem_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
 
                        parse_rtattr_nested(lb, NETEM_LOSS_MAX, tb[TCA_NETEM_LOSS]);
                        if (lb[NETEM_LOSS_GI])
-                               gemodel = RTA_DATA(lb[NETEM_LOSS_GI]);
+                               gimodel = RTA_DATA(lb[NETEM_LOSS_GI]);
                        if (lb[NETEM_LOSS_GE])
                                gemodel = RTA_DATA(lb[NETEM_LOSS_GE]);
                }