| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * net/sched/sch_htb.c Hierarchical token bucket, feed tree version |
|---|
| 3 | | - * |
|---|
| 4 | | - * This program is free software; you can redistribute it and/or |
|---|
| 5 | | - * modify it under the terms of the GNU General Public License |
|---|
| 6 | | - * as published by the Free Software Foundation; either version |
|---|
| 7 | | - * 2 of the License, or (at your option) any later version. |
|---|
| 8 | 4 | * |
|---|
| 9 | 5 | * Authors: Martin Devera, <devik@cdi.cz> |
|---|
| 10 | 6 | * |
|---|
| .. | .. |
|---|
| 132 | 128 | struct htb_class_inner { |
|---|
| 133 | 129 | struct htb_prio clprio[TC_HTB_NUMPRIO]; |
|---|
| 134 | 130 | } inner; |
|---|
| 135 | | - } un; |
|---|
| 131 | + }; |
|---|
| 136 | 132 | s64 pq_key; |
|---|
| 137 | 133 | |
|---|
| 138 | 134 | int prio_activity; /* for which prios are we active */ |
|---|
| .. | .. |
|---|
| 165 | 161 | |
|---|
| 166 | 162 | /* non shaped skbs; let them go directly thru */ |
|---|
| 167 | 163 | struct qdisc_skb_head direct_queue; |
|---|
| 168 | | - long direct_pkts; |
|---|
| 164 | + u32 direct_pkts; |
|---|
| 165 | + u32 overlimits; |
|---|
| 169 | 166 | |
|---|
| 170 | 167 | struct qdisc_watchdog watchdog; |
|---|
| 171 | 168 | |
|---|
| .. | .. |
|---|
| 242 | 239 | case TC_ACT_STOLEN: |
|---|
| 243 | 240 | case TC_ACT_TRAP: |
|---|
| 244 | 241 | *qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN; |
|---|
| 245 | | - /* fall through */ |
|---|
| 242 | + fallthrough; |
|---|
| 246 | 243 | case TC_ACT_SHOT: |
|---|
| 247 | 244 | return NULL; |
|---|
| 248 | 245 | } |
|---|
| .. | .. |
|---|
| 408 | 405 | while (cl->cmode == HTB_MAY_BORROW && p && mask) { |
|---|
| 409 | 406 | m = mask; |
|---|
| 410 | 407 | while (m) { |
|---|
| 411 | | - int prio = ffz(~m); |
|---|
| 408 | + unsigned int prio = ffz(~m); |
|---|
| 409 | + |
|---|
| 410 | + if (WARN_ON_ONCE(prio >= ARRAY_SIZE(p->inner.clprio))) |
|---|
| 411 | + break; |
|---|
| 412 | 412 | m &= ~(1 << prio); |
|---|
| 413 | 413 | |
|---|
| 414 | | - if (p->un.inner.clprio[prio].feed.rb_node) |
|---|
| 414 | + if (p->inner.clprio[prio].feed.rb_node) |
|---|
| 415 | 415 | /* parent already has its feed in use so that |
|---|
| 416 | 416 | * reset bit in mask as parent is already ok |
|---|
| 417 | 417 | */ |
|---|
| 418 | 418 | mask &= ~(1 << prio); |
|---|
| 419 | 419 | |
|---|
| 420 | | - htb_add_to_id_tree(&p->un.inner.clprio[prio].feed, cl, prio); |
|---|
| 420 | + htb_add_to_id_tree(&p->inner.clprio[prio].feed, cl, prio); |
|---|
| 421 | 421 | } |
|---|
| 422 | 422 | p->prio_activity |= mask; |
|---|
| 423 | 423 | cl = p; |
|---|
| .. | .. |
|---|
| 447 | 447 | int prio = ffz(~m); |
|---|
| 448 | 448 | m &= ~(1 << prio); |
|---|
| 449 | 449 | |
|---|
| 450 | | - if (p->un.inner.clprio[prio].ptr == cl->node + prio) { |
|---|
| 450 | + if (p->inner.clprio[prio].ptr == cl->node + prio) { |
|---|
| 451 | 451 | /* we are removing child which is pointed to from |
|---|
| 452 | 452 | * parent feed - forget the pointer but remember |
|---|
| 453 | 453 | * classid |
|---|
| 454 | 454 | */ |
|---|
| 455 | | - p->un.inner.clprio[prio].last_ptr_id = cl->common.classid; |
|---|
| 456 | | - p->un.inner.clprio[prio].ptr = NULL; |
|---|
| 455 | + p->inner.clprio[prio].last_ptr_id = cl->common.classid; |
|---|
| 456 | + p->inner.clprio[prio].ptr = NULL; |
|---|
| 457 | 457 | } |
|---|
| 458 | 458 | |
|---|
| 459 | 459 | htb_safe_rb_erase(cl->node + prio, |
|---|
| 460 | | - &p->un.inner.clprio[prio].feed); |
|---|
| 460 | + &p->inner.clprio[prio].feed); |
|---|
| 461 | 461 | |
|---|
| 462 | | - if (!p->un.inner.clprio[prio].feed.rb_node) |
|---|
| 462 | + if (!p->inner.clprio[prio].feed.rb_node) |
|---|
| 463 | 463 | mask |= 1 << prio; |
|---|
| 464 | 464 | } |
|---|
| 465 | 465 | |
|---|
| .. | .. |
|---|
| 533 | 533 | if (new_mode == cl->cmode) |
|---|
| 534 | 534 | return; |
|---|
| 535 | 535 | |
|---|
| 536 | | - if (new_mode == HTB_CANT_SEND) |
|---|
| 536 | + if (new_mode == HTB_CANT_SEND) { |
|---|
| 537 | 537 | cl->overlimits++; |
|---|
| 538 | + q->overlimits++; |
|---|
| 539 | + } |
|---|
| 538 | 540 | |
|---|
| 539 | 541 | if (cl->prio_activity) { /* not necessary: speed optimization */ |
|---|
| 540 | 542 | if (cl->cmode != HTB_CANT_SEND) |
|---|
| .. | .. |
|---|
| 555 | 557 | */ |
|---|
| 556 | 558 | static inline void htb_activate(struct htb_sched *q, struct htb_class *cl) |
|---|
| 557 | 559 | { |
|---|
| 558 | | - WARN_ON(cl->level || !cl->un.leaf.q || !cl->un.leaf.q->q.qlen); |
|---|
| 560 | + WARN_ON(cl->level || !cl->leaf.q || !cl->leaf.q->q.qlen); |
|---|
| 559 | 561 | |
|---|
| 560 | 562 | if (!cl->prio_activity) { |
|---|
| 561 | 563 | cl->prio_activity = 1 << cl->prio; |
|---|
| .. | .. |
|---|
| 577 | 579 | cl->prio_activity = 0; |
|---|
| 578 | 580 | } |
|---|
| 579 | 581 | |
|---|
| 580 | | -static void htb_enqueue_tail(struct sk_buff *skb, struct Qdisc *sch, |
|---|
| 581 | | - struct qdisc_skb_head *qh) |
|---|
| 582 | | -{ |
|---|
| 583 | | - struct sk_buff *last = qh->tail; |
|---|
| 584 | | - |
|---|
| 585 | | - if (last) { |
|---|
| 586 | | - skb->next = NULL; |
|---|
| 587 | | - last->next = skb; |
|---|
| 588 | | - qh->tail = skb; |
|---|
| 589 | | - } else { |
|---|
| 590 | | - qh->tail = skb; |
|---|
| 591 | | - qh->head = skb; |
|---|
| 592 | | - } |
|---|
| 593 | | - qh->qlen++; |
|---|
| 594 | | -} |
|---|
| 595 | | - |
|---|
| 596 | 582 | static int htb_enqueue(struct sk_buff *skb, struct Qdisc *sch, |
|---|
| 597 | 583 | struct sk_buff **to_free) |
|---|
| 598 | 584 | { |
|---|
| 599 | | - int uninitialized_var(ret); |
|---|
| 585 | + int ret; |
|---|
| 586 | + unsigned int len = qdisc_pkt_len(skb); |
|---|
| 600 | 587 | struct htb_sched *q = qdisc_priv(sch); |
|---|
| 601 | 588 | struct htb_class *cl = htb_classify(skb, sch, &ret); |
|---|
| 602 | 589 | |
|---|
| 603 | 590 | if (cl == HTB_DIRECT) { |
|---|
| 604 | 591 | /* enqueue to helper queue */ |
|---|
| 605 | 592 | if (q->direct_queue.qlen < q->direct_qlen) { |
|---|
| 606 | | - htb_enqueue_tail(skb, sch, &q->direct_queue); |
|---|
| 593 | + __qdisc_enqueue_tail(skb, &q->direct_queue); |
|---|
| 607 | 594 | q->direct_pkts++; |
|---|
| 608 | 595 | } else { |
|---|
| 609 | 596 | return qdisc_drop(skb, sch, to_free); |
|---|
| .. | .. |
|---|
| 615 | 602 | __qdisc_drop(skb, to_free); |
|---|
| 616 | 603 | return ret; |
|---|
| 617 | 604 | #endif |
|---|
| 618 | | - } else if ((ret = qdisc_enqueue(skb, cl->un.leaf.q, |
|---|
| 605 | + } else if ((ret = qdisc_enqueue(skb, cl->leaf.q, |
|---|
| 619 | 606 | to_free)) != NET_XMIT_SUCCESS) { |
|---|
| 620 | 607 | if (net_xmit_drop_count(ret)) { |
|---|
| 621 | 608 | qdisc_qstats_drop(sch); |
|---|
| .. | .. |
|---|
| 626 | 613 | htb_activate(q, cl); |
|---|
| 627 | 614 | } |
|---|
| 628 | 615 | |
|---|
| 629 | | - qdisc_qstats_backlog_inc(sch, skb); |
|---|
| 616 | + sch->qstats.backlog += len; |
|---|
| 630 | 617 | sch->q.qlen++; |
|---|
| 631 | 618 | return NET_XMIT_SUCCESS; |
|---|
| 632 | 619 | } |
|---|
| .. | .. |
|---|
| 823 | 810 | cl = rb_entry(*sp->pptr, struct htb_class, node[prio]); |
|---|
| 824 | 811 | if (!cl->level) |
|---|
| 825 | 812 | return cl; |
|---|
| 826 | | - clp = &cl->un.inner.clprio[prio]; |
|---|
| 813 | + clp = &cl->inner.clprio[prio]; |
|---|
| 827 | 814 | (++sp)->root = clp->feed.rb_node; |
|---|
| 828 | 815 | sp->pptr = &clp->ptr; |
|---|
| 829 | 816 | sp->pid = &clp->last_ptr_id; |
|---|
| .. | .. |
|---|
| 857 | 844 | * graft operation on the leaf since last dequeue; |
|---|
| 858 | 845 | * simply deactivate and skip such class |
|---|
| 859 | 846 | */ |
|---|
| 860 | | - if (unlikely(cl->un.leaf.q->q.qlen == 0)) { |
|---|
| 847 | + if (unlikely(cl->leaf.q->q.qlen == 0)) { |
|---|
| 861 | 848 | struct htb_class *next; |
|---|
| 862 | 849 | htb_deactivate(q, cl); |
|---|
| 863 | 850 | |
|---|
| .. | .. |
|---|
| 873 | 860 | goto next; |
|---|
| 874 | 861 | } |
|---|
| 875 | 862 | |
|---|
| 876 | | - skb = cl->un.leaf.q->dequeue(cl->un.leaf.q); |
|---|
| 863 | + skb = cl->leaf.q->dequeue(cl->leaf.q); |
|---|
| 877 | 864 | if (likely(skb != NULL)) |
|---|
| 878 | 865 | break; |
|---|
| 879 | 866 | |
|---|
| 880 | | - qdisc_warn_nonwc("htb", cl->un.leaf.q); |
|---|
| 881 | | - htb_next_rb_node(level ? &cl->parent->un.inner.clprio[prio].ptr: |
|---|
| 867 | + qdisc_warn_nonwc("htb", cl->leaf.q); |
|---|
| 868 | + htb_next_rb_node(level ? &cl->parent->inner.clprio[prio].ptr: |
|---|
| 882 | 869 | &q->hlevel[0].hprio[prio].ptr); |
|---|
| 883 | 870 | cl = htb_lookup_leaf(hprio, prio); |
|---|
| 884 | 871 | |
|---|
| .. | .. |
|---|
| 886 | 873 | |
|---|
| 887 | 874 | if (likely(skb != NULL)) { |
|---|
| 888 | 875 | bstats_update(&cl->bstats, skb); |
|---|
| 889 | | - cl->un.leaf.deficit[level] -= qdisc_pkt_len(skb); |
|---|
| 890 | | - if (cl->un.leaf.deficit[level] < 0) { |
|---|
| 891 | | - cl->un.leaf.deficit[level] += cl->quantum; |
|---|
| 892 | | - htb_next_rb_node(level ? &cl->parent->un.inner.clprio[prio].ptr : |
|---|
| 876 | + cl->leaf.deficit[level] -= qdisc_pkt_len(skb); |
|---|
| 877 | + if (cl->leaf.deficit[level] < 0) { |
|---|
| 878 | + cl->leaf.deficit[level] += cl->quantum; |
|---|
| 879 | + htb_next_rb_node(level ? &cl->parent->inner.clprio[prio].ptr : |
|---|
| 893 | 880 | &q->hlevel[0].hprio[prio].ptr); |
|---|
| 894 | 881 | } |
|---|
| 895 | 882 | /* this used to be after charge_class but this constelation |
|---|
| 896 | 883 | * gives us slightly better performance |
|---|
| 897 | 884 | */ |
|---|
| 898 | | - if (!cl->un.leaf.q->q.qlen) |
|---|
| 885 | + if (!cl->leaf.q->q.qlen) |
|---|
| 899 | 886 | htb_deactivate(q, cl); |
|---|
| 900 | 887 | htb_charge_class(q, cl, level, skb); |
|---|
| 901 | 888 | } |
|---|
| .. | .. |
|---|
| 952 | 939 | goto ok; |
|---|
| 953 | 940 | } |
|---|
| 954 | 941 | } |
|---|
| 955 | | - qdisc_qstats_overlimit(sch); |
|---|
| 956 | 942 | if (likely(next_event > q->now)) |
|---|
| 957 | 943 | qdisc_watchdog_schedule_ns(&q->watchdog, next_event); |
|---|
| 958 | 944 | else |
|---|
| .. | .. |
|---|
| 972 | 958 | for (i = 0; i < q->clhash.hashsize; i++) { |
|---|
| 973 | 959 | hlist_for_each_entry(cl, &q->clhash.hash[i], common.hnode) { |
|---|
| 974 | 960 | if (cl->level) |
|---|
| 975 | | - memset(&cl->un.inner, 0, sizeof(cl->un.inner)); |
|---|
| 961 | + memset(&cl->inner, 0, sizeof(cl->inner)); |
|---|
| 976 | 962 | else { |
|---|
| 977 | | - if (cl->un.leaf.q) |
|---|
| 978 | | - qdisc_reset(cl->un.leaf.q); |
|---|
| 963 | + if (cl->leaf.q) |
|---|
| 964 | + qdisc_reset(cl->leaf.q); |
|---|
| 979 | 965 | } |
|---|
| 980 | 966 | cl->prio_activity = 0; |
|---|
| 981 | 967 | cl->cmode = HTB_CAN_SEND; |
|---|
| .. | .. |
|---|
| 983 | 969 | } |
|---|
| 984 | 970 | qdisc_watchdog_cancel(&q->watchdog); |
|---|
| 985 | 971 | __qdisc_reset_queue(&q->direct_queue); |
|---|
| 986 | | - sch->q.qlen = 0; |
|---|
| 987 | | - sch->qstats.backlog = 0; |
|---|
| 988 | 972 | memset(q->hlevel, 0, sizeof(q->hlevel)); |
|---|
| 989 | 973 | memset(q->row_mask, 0, sizeof(q->row_mask)); |
|---|
| 990 | 974 | } |
|---|
| .. | .. |
|---|
| 1027 | 1011 | if (err) |
|---|
| 1028 | 1012 | return err; |
|---|
| 1029 | 1013 | |
|---|
| 1030 | | - err = nla_parse_nested(tb, TCA_HTB_MAX, opt, htb_policy, NULL); |
|---|
| 1014 | + err = nla_parse_nested_deprecated(tb, TCA_HTB_MAX, opt, htb_policy, |
|---|
| 1015 | + NULL); |
|---|
| 1031 | 1016 | if (err < 0) |
|---|
| 1032 | 1017 | return err; |
|---|
| 1033 | 1018 | |
|---|
| .. | .. |
|---|
| 1062 | 1047 | struct nlattr *nest; |
|---|
| 1063 | 1048 | struct tc_htb_glob gopt; |
|---|
| 1064 | 1049 | |
|---|
| 1050 | + sch->qstats.overlimits = q->overlimits; |
|---|
| 1065 | 1051 | /* Its safe to not acquire qdisc lock. As we hold RTNL, |
|---|
| 1066 | 1052 | * no change can happen on the qdisc parameters. |
|---|
| 1067 | 1053 | */ |
|---|
| .. | .. |
|---|
| 1072 | 1058 | gopt.defcls = q->defcls; |
|---|
| 1073 | 1059 | gopt.debug = 0; |
|---|
| 1074 | 1060 | |
|---|
| 1075 | | - nest = nla_nest_start(skb, TCA_OPTIONS); |
|---|
| 1061 | + nest = nla_nest_start_noflag(skb, TCA_OPTIONS); |
|---|
| 1076 | 1062 | if (nest == NULL) |
|---|
| 1077 | 1063 | goto nla_put_failure; |
|---|
| 1078 | 1064 | if (nla_put(skb, TCA_HTB_INIT, sizeof(gopt), &gopt) || |
|---|
| .. | .. |
|---|
| 1098 | 1084 | */ |
|---|
| 1099 | 1085 | tcm->tcm_parent = cl->parent ? cl->parent->common.classid : TC_H_ROOT; |
|---|
| 1100 | 1086 | tcm->tcm_handle = cl->common.classid; |
|---|
| 1101 | | - if (!cl->level && cl->un.leaf.q) |
|---|
| 1102 | | - tcm->tcm_info = cl->un.leaf.q->handle; |
|---|
| 1087 | + if (!cl->level && cl->leaf.q) |
|---|
| 1088 | + tcm->tcm_info = cl->leaf.q->handle; |
|---|
| 1103 | 1089 | |
|---|
| 1104 | | - nest = nla_nest_start(skb, TCA_OPTIONS); |
|---|
| 1090 | + nest = nla_nest_start_noflag(skb, TCA_OPTIONS); |
|---|
| 1105 | 1091 | if (nest == NULL) |
|---|
| 1106 | 1092 | goto nla_put_failure; |
|---|
| 1107 | 1093 | |
|---|
| .. | .. |
|---|
| 1142 | 1128 | }; |
|---|
| 1143 | 1129 | __u32 qlen = 0; |
|---|
| 1144 | 1130 | |
|---|
| 1145 | | - if (!cl->level && cl->un.leaf.q) { |
|---|
| 1146 | | - qlen = cl->un.leaf.q->q.qlen; |
|---|
| 1147 | | - qs.backlog = cl->un.leaf.q->qstats.backlog; |
|---|
| 1148 | | - } |
|---|
| 1131 | + if (!cl->level && cl->leaf.q) |
|---|
| 1132 | + qdisc_qstats_qlen_backlog(cl->leaf.q, &qlen, &qs.backlog); |
|---|
| 1133 | + |
|---|
| 1149 | 1134 | cl->xstats.tokens = clamp_t(s64, PSCHED_NS2TICKS(cl->tokens), |
|---|
| 1150 | 1135 | INT_MIN, INT_MAX); |
|---|
| 1151 | 1136 | cl->xstats.ctokens = clamp_t(s64, PSCHED_NS2TICKS(cl->ctokens), |
|---|
| .. | .. |
|---|
| 1172 | 1157 | cl->common.classid, extack)) == NULL) |
|---|
| 1173 | 1158 | return -ENOBUFS; |
|---|
| 1174 | 1159 | |
|---|
| 1175 | | - *old = qdisc_replace(sch, new, &cl->un.leaf.q); |
|---|
| 1160 | + *old = qdisc_replace(sch, new, &cl->leaf.q); |
|---|
| 1176 | 1161 | return 0; |
|---|
| 1177 | 1162 | } |
|---|
| 1178 | 1163 | |
|---|
| 1179 | 1164 | static struct Qdisc *htb_leaf(struct Qdisc *sch, unsigned long arg) |
|---|
| 1180 | 1165 | { |
|---|
| 1181 | 1166 | struct htb_class *cl = (struct htb_class *)arg; |
|---|
| 1182 | | - return !cl->level ? cl->un.leaf.q : NULL; |
|---|
| 1167 | + return !cl->level ? cl->leaf.q : NULL; |
|---|
| 1183 | 1168 | } |
|---|
| 1184 | 1169 | |
|---|
| 1185 | 1170 | static void htb_qlen_notify(struct Qdisc *sch, unsigned long arg) |
|---|
| .. | .. |
|---|
| 1205 | 1190 | { |
|---|
| 1206 | 1191 | struct htb_class *parent = cl->parent; |
|---|
| 1207 | 1192 | |
|---|
| 1208 | | - WARN_ON(cl->level || !cl->un.leaf.q || cl->prio_activity); |
|---|
| 1193 | + WARN_ON(cl->level || !cl->leaf.q || cl->prio_activity); |
|---|
| 1209 | 1194 | |
|---|
| 1210 | 1195 | if (parent->cmode != HTB_CAN_SEND) |
|---|
| 1211 | 1196 | htb_safe_rb_erase(&parent->pq_node, |
|---|
| 1212 | 1197 | &q->hlevel[parent->level].wait_pq); |
|---|
| 1213 | 1198 | |
|---|
| 1214 | 1199 | parent->level = 0; |
|---|
| 1215 | | - memset(&parent->un.inner, 0, sizeof(parent->un.inner)); |
|---|
| 1216 | | - parent->un.leaf.q = new_q ? new_q : &noop_qdisc; |
|---|
| 1200 | + memset(&parent->inner, 0, sizeof(parent->inner)); |
|---|
| 1201 | + parent->leaf.q = new_q ? new_q : &noop_qdisc; |
|---|
| 1217 | 1202 | parent->tokens = parent->buffer; |
|---|
| 1218 | 1203 | parent->ctokens = parent->cbuffer; |
|---|
| 1219 | 1204 | parent->t_c = ktime_get_ns(); |
|---|
| .. | .. |
|---|
| 1223 | 1208 | static void htb_destroy_class(struct Qdisc *sch, struct htb_class *cl) |
|---|
| 1224 | 1209 | { |
|---|
| 1225 | 1210 | if (!cl->level) { |
|---|
| 1226 | | - WARN_ON(!cl->un.leaf.q); |
|---|
| 1227 | | - qdisc_put(cl->un.leaf.q); |
|---|
| 1211 | + WARN_ON(!cl->leaf.q); |
|---|
| 1212 | + qdisc_put(cl->leaf.q); |
|---|
| 1228 | 1213 | } |
|---|
| 1229 | 1214 | gen_kill_estimator(&cl->rate_est); |
|---|
| 1230 | 1215 | tcf_block_put(cl->block); |
|---|
| .. | .. |
|---|
| 1285 | 1270 | |
|---|
| 1286 | 1271 | sch_tree_lock(sch); |
|---|
| 1287 | 1272 | |
|---|
| 1288 | | - if (!cl->level) { |
|---|
| 1289 | | - unsigned int qlen = cl->un.leaf.q->q.qlen; |
|---|
| 1290 | | - unsigned int backlog = cl->un.leaf.q->qstats.backlog; |
|---|
| 1291 | | - |
|---|
| 1292 | | - qdisc_reset(cl->un.leaf.q); |
|---|
| 1293 | | - qdisc_tree_reduce_backlog(cl->un.leaf.q, qlen, backlog); |
|---|
| 1294 | | - } |
|---|
| 1273 | + if (!cl->level) |
|---|
| 1274 | + qdisc_purge_queue(cl->leaf.q); |
|---|
| 1295 | 1275 | |
|---|
| 1296 | 1276 | /* delete from hash and active; remainder in destroy_class */ |
|---|
| 1297 | 1277 | qdisc_class_hash_remove(&q->clhash, &cl->common); |
|---|
| .. | .. |
|---|
| 1323 | 1303 | struct htb_class *cl = (struct htb_class *)*arg, *parent; |
|---|
| 1324 | 1304 | struct nlattr *opt = tca[TCA_OPTIONS]; |
|---|
| 1325 | 1305 | struct nlattr *tb[TCA_HTB_MAX + 1]; |
|---|
| 1306 | + struct Qdisc *parent_qdisc = NULL; |
|---|
| 1326 | 1307 | struct tc_htb_opt *hopt; |
|---|
| 1327 | 1308 | u64 rate64, ceil64; |
|---|
| 1328 | 1309 | int warn = 0; |
|---|
| .. | .. |
|---|
| 1331 | 1312 | if (!opt) |
|---|
| 1332 | 1313 | goto failure; |
|---|
| 1333 | 1314 | |
|---|
| 1334 | | - err = nla_parse_nested(tb, TCA_HTB_MAX, opt, htb_policy, NULL); |
|---|
| 1315 | + err = nla_parse_nested_deprecated(tb, TCA_HTB_MAX, opt, htb_policy, |
|---|
| 1316 | + NULL); |
|---|
| 1335 | 1317 | if (err < 0) |
|---|
| 1336 | 1318 | goto failure; |
|---|
| 1337 | 1319 | |
|---|
| .. | .. |
|---|
| 1419 | 1401 | classid, NULL); |
|---|
| 1420 | 1402 | sch_tree_lock(sch); |
|---|
| 1421 | 1403 | if (parent && !parent->level) { |
|---|
| 1422 | | - unsigned int qlen = parent->un.leaf.q->q.qlen; |
|---|
| 1423 | | - unsigned int backlog = parent->un.leaf.q->qstats.backlog; |
|---|
| 1424 | | - |
|---|
| 1425 | 1404 | /* turn parent into inner node */ |
|---|
| 1426 | | - qdisc_reset(parent->un.leaf.q); |
|---|
| 1427 | | - qdisc_tree_reduce_backlog(parent->un.leaf.q, qlen, backlog); |
|---|
| 1428 | | - qdisc_put(parent->un.leaf.q); |
|---|
| 1405 | + qdisc_purge_queue(parent->leaf.q); |
|---|
| 1406 | + parent_qdisc = parent->leaf.q; |
|---|
| 1429 | 1407 | if (parent->prio_activity) |
|---|
| 1430 | 1408 | htb_deactivate(q, parent); |
|---|
| 1431 | 1409 | |
|---|
| .. | .. |
|---|
| 1436 | 1414 | } |
|---|
| 1437 | 1415 | parent->level = (parent->parent ? parent->parent->level |
|---|
| 1438 | 1416 | : TC_HTB_MAXDEPTH) - 1; |
|---|
| 1439 | | - memset(&parent->un.inner, 0, sizeof(parent->un.inner)); |
|---|
| 1417 | + memset(&parent->inner, 0, sizeof(parent->inner)); |
|---|
| 1440 | 1418 | } |
|---|
| 1441 | 1419 | /* leaf (we) needs elementary qdisc */ |
|---|
| 1442 | | - cl->un.leaf.q = new_q ? new_q : &noop_qdisc; |
|---|
| 1420 | + cl->leaf.q = new_q ? new_q : &noop_qdisc; |
|---|
| 1443 | 1421 | |
|---|
| 1444 | 1422 | cl->common.classid = classid; |
|---|
| 1445 | 1423 | cl->parent = parent; |
|---|
| .. | .. |
|---|
| 1455 | 1433 | qdisc_class_hash_insert(&q->clhash, &cl->common); |
|---|
| 1456 | 1434 | if (parent) |
|---|
| 1457 | 1435 | parent->children++; |
|---|
| 1458 | | - if (cl->un.leaf.q != &noop_qdisc) |
|---|
| 1459 | | - qdisc_hash_add(cl->un.leaf.q, true); |
|---|
| 1436 | + if (cl->leaf.q != &noop_qdisc) |
|---|
| 1437 | + qdisc_hash_add(cl->leaf.q, true); |
|---|
| 1460 | 1438 | } else { |
|---|
| 1461 | 1439 | if (tca[TCA_RATE]) { |
|---|
| 1462 | 1440 | err = gen_replace_estimator(&cl->bstats, NULL, |
|---|
| .. | .. |
|---|
| 1478 | 1456 | psched_ratecfg_precompute(&cl->ceil, &hopt->ceil, ceil64); |
|---|
| 1479 | 1457 | |
|---|
| 1480 | 1458 | /* it used to be a nasty bug here, we have to check that node |
|---|
| 1481 | | - * is really leaf before changing cl->un.leaf ! |
|---|
| 1459 | + * is really leaf before changing cl->leaf ! |
|---|
| 1482 | 1460 | */ |
|---|
| 1483 | 1461 | if (!cl->level) { |
|---|
| 1484 | 1462 | u64 quantum = cl->rate.rate_bytes_ps; |
|---|
| .. | .. |
|---|
| 1504 | 1482 | cl->cbuffer = PSCHED_TICKS2NS(hopt->cbuffer); |
|---|
| 1505 | 1483 | |
|---|
| 1506 | 1484 | sch_tree_unlock(sch); |
|---|
| 1485 | + qdisc_put(parent_qdisc); |
|---|
| 1507 | 1486 | |
|---|
| 1508 | 1487 | if (warn) |
|---|
| 1509 | 1488 | pr_warn("HTB: quantum of class %X is %s. Consider r2q change.\n", |
|---|