diff options
author | Eric Dumazet <edumazet@google.com> | 2012-11-05 11:40:49 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-11-06 19:06:29 -0500 |
commit | 196d97f6b1a5d44be17f12e5adba36368915ba52 (patch) | |
tree | 2e512f8271b19ba3d15dcb370ff0015eb110329e /net/sched | |
parent | bd473da35bc21a0004b8ad35c19e0c8b53b03f36 (diff) |
htb: fix two bugs
Commit 56b765b79e9 (htb: improved accuracy at high rates)
introduced two bugs :
1) one bstats_update() was inadvertently removed from
htb_dequeue_tree(), breaking statistics/rate estimation.
2) Missing qdisc_put_rtab() calls in htb_change_class(),
leaking kernel memory, now struct htb_class no longer
retains pointers to qdisc_rate_table structs.
Since only rate is used, dont use qdisc_get_rtab() calls
copying data we ignore anyway.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Vimalkumar <j.vimal@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched')
-rw-r--r-- | net/sched/sch_htb.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c index 32a80977cf54..d2922c0ef57a 100644 --- a/net/sched/sch_htb.c +++ b/net/sched/sch_htb.c | |||
@@ -879,6 +879,7 @@ next: | |||
879 | } while (cl != start); | 879 | } while (cl != start); |
880 | 880 | ||
881 | if (likely(skb != NULL)) { | 881 | if (likely(skb != NULL)) { |
882 | bstats_update(&cl->bstats, skb); | ||
882 | cl->un.leaf.deficit[level] -= qdisc_pkt_len(skb); | 883 | cl->un.leaf.deficit[level] -= qdisc_pkt_len(skb); |
883 | if (cl->un.leaf.deficit[level] < 0) { | 884 | if (cl->un.leaf.deficit[level] < 0) { |
884 | cl->un.leaf.deficit[level] += cl->quantum; | 885 | cl->un.leaf.deficit[level] += cl->quantum; |
@@ -1355,7 +1356,6 @@ static int htb_change_class(struct Qdisc *sch, u32 classid, | |||
1355 | struct htb_sched *q = qdisc_priv(sch); | 1356 | struct htb_sched *q = qdisc_priv(sch); |
1356 | struct htb_class *cl = (struct htb_class *)*arg, *parent; | 1357 | struct htb_class *cl = (struct htb_class *)*arg, *parent; |
1357 | struct nlattr *opt = tca[TCA_OPTIONS]; | 1358 | struct nlattr *opt = tca[TCA_OPTIONS]; |
1358 | struct qdisc_rate_table *rtab = NULL, *ctab = NULL; | ||
1359 | struct nlattr *tb[__TCA_HTB_MAX]; | 1359 | struct nlattr *tb[__TCA_HTB_MAX]; |
1360 | struct tc_htb_opt *hopt; | 1360 | struct tc_htb_opt *hopt; |
1361 | 1361 | ||
@@ -1374,10 +1374,7 @@ static int htb_change_class(struct Qdisc *sch, u32 classid, | |||
1374 | parent = parentid == TC_H_ROOT ? NULL : htb_find(parentid, sch); | 1374 | parent = parentid == TC_H_ROOT ? NULL : htb_find(parentid, sch); |
1375 | 1375 | ||
1376 | hopt = nla_data(tb[TCA_HTB_PARMS]); | 1376 | hopt = nla_data(tb[TCA_HTB_PARMS]); |
1377 | 1377 | if (!hopt->rate.rate || !hopt->ceil.rate) | |
1378 | rtab = qdisc_get_rtab(&hopt->rate, tb[TCA_HTB_RTAB]); | ||
1379 | ctab = qdisc_get_rtab(&hopt->ceil, tb[TCA_HTB_CTAB]); | ||
1380 | if (!rtab || !ctab) | ||
1381 | goto failure; | 1378 | goto failure; |
1382 | 1379 | ||
1383 | if (!cl) { /* new class */ | 1380 | if (!cl) { /* new class */ |
@@ -1487,7 +1484,7 @@ static int htb_change_class(struct Qdisc *sch, u32 classid, | |||
1487 | * is really leaf before changing cl->un.leaf ! | 1484 | * is really leaf before changing cl->un.leaf ! |
1488 | */ | 1485 | */ |
1489 | if (!cl->level) { | 1486 | if (!cl->level) { |
1490 | cl->quantum = rtab->rate.rate / q->rate2quantum; | 1487 | cl->quantum = hopt->rate.rate / q->rate2quantum; |
1491 | if (!hopt->quantum && cl->quantum < 1000) { | 1488 | if (!hopt->quantum && cl->quantum < 1000) { |
1492 | pr_warning( | 1489 | pr_warning( |
1493 | "HTB: quantum of class %X is small. Consider r2q change.\n", | 1490 | "HTB: quantum of class %X is small. Consider r2q change.\n", |
@@ -1509,8 +1506,8 @@ static int htb_change_class(struct Qdisc *sch, u32 classid, | |||
1509 | cl->buffer = hopt->buffer; | 1506 | cl->buffer = hopt->buffer; |
1510 | cl->cbuffer = hopt->cbuffer; | 1507 | cl->cbuffer = hopt->cbuffer; |
1511 | 1508 | ||
1512 | cl->rate.rate_bps = (u64)rtab->rate.rate << 3; | 1509 | cl->rate.rate_bps = (u64)hopt->rate.rate << 3; |
1513 | cl->ceil.rate_bps = (u64)ctab->rate.rate << 3; | 1510 | cl->ceil.rate_bps = (u64)hopt->ceil.rate << 3; |
1514 | 1511 | ||
1515 | htb_precompute_ratedata(&cl->rate); | 1512 | htb_precompute_ratedata(&cl->rate); |
1516 | htb_precompute_ratedata(&cl->ceil); | 1513 | htb_precompute_ratedata(&cl->ceil); |
@@ -1526,10 +1523,6 @@ static int htb_change_class(struct Qdisc *sch, u32 classid, | |||
1526 | return 0; | 1523 | return 0; |
1527 | 1524 | ||
1528 | failure: | 1525 | failure: |
1529 | if (rtab) | ||
1530 | qdisc_put_rtab(rtab); | ||
1531 | if (ctab) | ||
1532 | qdisc_put_rtab(ctab); | ||
1533 | return err; | 1526 | return err; |
1534 | } | 1527 | } |
1535 | 1528 | ||