diff options
Diffstat (limited to 'net/sched/sch_tbf.c')
-rw-r--r-- | net/sched/sch_tbf.c | 42 |
1 files changed, 9 insertions, 33 deletions
diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c index 0b7d78f59d8c..b296672f7632 100644 --- a/net/sched/sch_tbf.c +++ b/net/sched/sch_tbf.c | |||
@@ -123,7 +123,7 @@ static int tbf_enqueue(struct sk_buff *skb, struct Qdisc* sch) | |||
123 | struct tbf_sched_data *q = qdisc_priv(sch); | 123 | struct tbf_sched_data *q = qdisc_priv(sch); |
124 | int ret; | 124 | int ret; |
125 | 125 | ||
126 | if (skb->len > q->max_size) { | 126 | if (qdisc_pkt_len(skb) > q->max_size) { |
127 | sch->qstats.drops++; | 127 | sch->qstats.drops++; |
128 | #ifdef CONFIG_NET_CLS_ACT | 128 | #ifdef CONFIG_NET_CLS_ACT |
129 | if (sch->reshape_fail == NULL || sch->reshape_fail(skb, sch)) | 129 | if (sch->reshape_fail == NULL || sch->reshape_fail(skb, sch)) |
@@ -133,13 +133,14 @@ static int tbf_enqueue(struct sk_buff *skb, struct Qdisc* sch) | |||
133 | return NET_XMIT_DROP; | 133 | return NET_XMIT_DROP; |
134 | } | 134 | } |
135 | 135 | ||
136 | if ((ret = q->qdisc->enqueue(skb, q->qdisc)) != 0) { | 136 | ret = qdisc_enqueue(skb, q->qdisc); |
137 | if (ret != 0) { | ||
137 | sch->qstats.drops++; | 138 | sch->qstats.drops++; |
138 | return ret; | 139 | return ret; |
139 | } | 140 | } |
140 | 141 | ||
141 | sch->q.qlen++; | 142 | sch->q.qlen++; |
142 | sch->bstats.bytes += skb->len; | 143 | sch->bstats.bytes += qdisc_pkt_len(skb); |
143 | sch->bstats.packets++; | 144 | sch->bstats.packets++; |
144 | return 0; | 145 | return 0; |
145 | } | 146 | } |
@@ -180,7 +181,7 @@ static struct sk_buff *tbf_dequeue(struct Qdisc* sch) | |||
180 | psched_time_t now; | 181 | psched_time_t now; |
181 | long toks; | 182 | long toks; |
182 | long ptoks = 0; | 183 | long ptoks = 0; |
183 | unsigned int len = skb->len; | 184 | unsigned int len = qdisc_pkt_len(skb); |
184 | 185 | ||
185 | now = psched_get_time(); | 186 | now = psched_get_time(); |
186 | toks = psched_tdiff_bounded(now, q->t_c, q->buffer); | 187 | toks = psched_tdiff_bounded(now, q->t_c, q->buffer); |
@@ -242,34 +243,6 @@ static void tbf_reset(struct Qdisc* sch) | |||
242 | qdisc_watchdog_cancel(&q->watchdog); | 243 | qdisc_watchdog_cancel(&q->watchdog); |
243 | } | 244 | } |
244 | 245 | ||
245 | static struct Qdisc *tbf_create_dflt_qdisc(struct Qdisc *sch, u32 limit) | ||
246 | { | ||
247 | struct Qdisc *q; | ||
248 | struct nlattr *nla; | ||
249 | int ret; | ||
250 | |||
251 | q = qdisc_create_dflt(sch->dev, &bfifo_qdisc_ops, | ||
252 | TC_H_MAKE(sch->handle, 1)); | ||
253 | if (q) { | ||
254 | nla = kmalloc(nla_attr_size(sizeof(struct tc_fifo_qopt)), | ||
255 | GFP_KERNEL); | ||
256 | if (nla) { | ||
257 | nla->nla_type = RTM_NEWQDISC; | ||
258 | nla->nla_len = nla_attr_size(sizeof(struct tc_fifo_qopt)); | ||
259 | ((struct tc_fifo_qopt *)nla_data(nla))->limit = limit; | ||
260 | |||
261 | ret = q->ops->change(q, nla); | ||
262 | kfree(nla); | ||
263 | |||
264 | if (ret == 0) | ||
265 | return q; | ||
266 | } | ||
267 | qdisc_destroy(q); | ||
268 | } | ||
269 | |||
270 | return NULL; | ||
271 | } | ||
272 | |||
273 | static const struct nla_policy tbf_policy[TCA_TBF_MAX + 1] = { | 246 | static const struct nla_policy tbf_policy[TCA_TBF_MAX + 1] = { |
274 | [TCA_TBF_PARMS] = { .len = sizeof(struct tc_tbf_qopt) }, | 247 | [TCA_TBF_PARMS] = { .len = sizeof(struct tc_tbf_qopt) }, |
275 | [TCA_TBF_RTAB] = { .type = NLA_BINARY, .len = TC_RTAB_SIZE }, | 248 | [TCA_TBF_RTAB] = { .type = NLA_BINARY, .len = TC_RTAB_SIZE }, |
@@ -322,8 +295,11 @@ static int tbf_change(struct Qdisc* sch, struct nlattr *opt) | |||
322 | goto done; | 295 | goto done; |
323 | 296 | ||
324 | if (qopt->limit > 0) { | 297 | if (qopt->limit > 0) { |
325 | if ((child = tbf_create_dflt_qdisc(sch, qopt->limit)) == NULL) | 298 | child = fifo_create_dflt(sch, &bfifo_qdisc_ops, qopt->limit); |
299 | if (IS_ERR(child)) { | ||
300 | err = PTR_ERR(child); | ||
326 | goto done; | 301 | goto done; |
302 | } | ||
327 | } | 303 | } |
328 | 304 | ||
329 | sch_tree_lock(sch); | 305 | sch_tree_lock(sch); |