]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
Fixed 'tc qdisc show' for tbf when latency<0
authorSergey V. Lobanov <sergey@lobanov.in>
Sat, 10 May 2014 23:01:14 +0000 (03:01 +0400)
committerStephen Hemminger <stephen@networkplumber.org>
Thu, 29 May 2014 00:08:16 +0000 (17:08 -0700)
When limit<burst latency becomes <0, for example:
 # tc qdisc add dev eth0 root handle 1: tbf limit 100K burst 256K rate 256kbit
 # tc qdisc show
 qdisc tbf 1: dev eth0 root refcnt 2 rate 256Kbit burst 256Kb lat 4290.0s

If latency<0 there is no reason to show it. Limit will be printed instead of
latency when latency<0:
 # tc qdisc show
 qdisc tbf 1: dev eth0 root refcnt 2 rate 256Kbit burst 256Kb limit 100Kb

Signed-off-by: Sergey V. Lobanov <sergey@lobanov.in>
tc/q_tbf.c

index f3022b65f76a9e8f1741781a7a372cd334e57789..2d56331100d87bbaaca60d8f2b0ff631212f60cc 100644 (file)
@@ -302,16 +302,16 @@ static int tbf_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
                }
        }
 
-       if (show_raw)
-               fprintf(f, "limit %s ", sprint_size(qopt->limit, b1));
-
        latency = TIME_UNITS_PER_SEC*(qopt->limit/(double)rate64) - tc_core_tick2time(qopt->buffer);
        if (prate64) {
                double lat2 = TIME_UNITS_PER_SEC*(qopt->limit/(double)prate64) - tc_core_tick2time(qopt->mtu);
                if (lat2 > latency)
                        latency = lat2;
        }
-       fprintf(f, "lat %s ", sprint_time(latency, b1));
+       if (latency >= 0.0)
+               fprintf(f, "lat %s ", sprint_time(latency, b1));
+       if (show_raw || latency < 0.0)
+               fprintf(f, "limit %s ", sprint_size(qopt->limit, b1));
 
        if (qopt->rate.overhead) {
                fprintf(f, "overhead %d", qopt->rate.overhead);