diff options
| -rw-r--r-- | include/uapi/linux/pkt_sched.h | 2 | ||||
| -rw-r--r-- | net/sched/sch_tbf.c | 22 |
2 files changed, 20 insertions, 4 deletions
diff --git a/include/uapi/linux/pkt_sched.h b/include/uapi/linux/pkt_sched.h index f2624b549e61..307f293477e8 100644 --- a/include/uapi/linux/pkt_sched.h +++ b/include/uapi/linux/pkt_sched.h | |||
| @@ -171,6 +171,8 @@ enum { | |||
| 171 | TCA_TBF_PARMS, | 171 | TCA_TBF_PARMS, |
| 172 | TCA_TBF_RTAB, | 172 | TCA_TBF_RTAB, |
| 173 | TCA_TBF_PTAB, | 173 | TCA_TBF_PTAB, |
| 174 | TCA_TBF_RATE64, | ||
| 175 | TCA_TBF_PRATE64, | ||
| 174 | __TCA_TBF_MAX, | 176 | __TCA_TBF_MAX, |
| 175 | }; | 177 | }; |
| 176 | 178 | ||
diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c index b0571224f3c9..68f98595819c 100644 --- a/net/sched/sch_tbf.c +++ b/net/sched/sch_tbf.c | |||
| @@ -266,20 +266,23 @@ static const struct nla_policy tbf_policy[TCA_TBF_MAX + 1] = { | |||
| 266 | [TCA_TBF_PARMS] = { .len = sizeof(struct tc_tbf_qopt) }, | 266 | [TCA_TBF_PARMS] = { .len = sizeof(struct tc_tbf_qopt) }, |
| 267 | [TCA_TBF_RTAB] = { .type = NLA_BINARY, .len = TC_RTAB_SIZE }, | 267 | [TCA_TBF_RTAB] = { .type = NLA_BINARY, .len = TC_RTAB_SIZE }, |
| 268 | [TCA_TBF_PTAB] = { .type = NLA_BINARY, .len = TC_RTAB_SIZE }, | 268 | [TCA_TBF_PTAB] = { .type = NLA_BINARY, .len = TC_RTAB_SIZE }, |
| 269 | [TCA_TBF_RATE64] = { .type = NLA_U64 }, | ||
| 270 | [TCA_TBF_PRATE64] = { .type = NLA_U64 }, | ||
| 269 | }; | 271 | }; |
| 270 | 272 | ||
| 271 | static int tbf_change(struct Qdisc *sch, struct nlattr *opt) | 273 | static int tbf_change(struct Qdisc *sch, struct nlattr *opt) |
| 272 | { | 274 | { |
| 273 | int err; | 275 | int err; |
| 274 | struct tbf_sched_data *q = qdisc_priv(sch); | 276 | struct tbf_sched_data *q = qdisc_priv(sch); |
| 275 | struct nlattr *tb[TCA_TBF_PTAB + 1]; | 277 | struct nlattr *tb[TCA_TBF_MAX + 1]; |
| 276 | struct tc_tbf_qopt *qopt; | 278 | struct tc_tbf_qopt *qopt; |
| 277 | struct qdisc_rate_table *rtab = NULL; | 279 | struct qdisc_rate_table *rtab = NULL; |
| 278 | struct qdisc_rate_table *ptab = NULL; | 280 | struct qdisc_rate_table *ptab = NULL; |
| 279 | struct Qdisc *child = NULL; | 281 | struct Qdisc *child = NULL; |
| 280 | int max_size, n; | 282 | int max_size, n; |
| 283 | u64 rate64 = 0, prate64 = 0; | ||
| 281 | 284 | ||
| 282 | err = nla_parse_nested(tb, TCA_TBF_PTAB, opt, tbf_policy); | 285 | err = nla_parse_nested(tb, TCA_TBF_MAX, opt, tbf_policy); |
| 283 | if (err < 0) | 286 | if (err < 0) |
| 284 | return err; | 287 | return err; |
| 285 | 288 | ||
| @@ -341,9 +344,13 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt) | |||
| 341 | q->tokens = q->buffer; | 344 | q->tokens = q->buffer; |
| 342 | q->ptokens = q->mtu; | 345 | q->ptokens = q->mtu; |
| 343 | 346 | ||
| 344 | psched_ratecfg_precompute(&q->rate, &rtab->rate, 0); | 347 | if (tb[TCA_TBF_RATE64]) |
| 348 | rate64 = nla_get_u64(tb[TCA_TBF_RATE64]); | ||
| 349 | psched_ratecfg_precompute(&q->rate, &rtab->rate, rate64); | ||
| 345 | if (ptab) { | 350 | if (ptab) { |
| 346 | psched_ratecfg_precompute(&q->peak, &ptab->rate, 0); | 351 | if (tb[TCA_TBF_PRATE64]) |
| 352 | prate64 = nla_get_u64(tb[TCA_TBF_PRATE64]); | ||
| 353 | psched_ratecfg_precompute(&q->peak, &ptab->rate, prate64); | ||
| 347 | q->peak_present = true; | 354 | q->peak_present = true; |
| 348 | } else { | 355 | } else { |
| 349 | q->peak_present = false; | 356 | q->peak_present = false; |
| @@ -402,6 +409,13 @@ static int tbf_dump(struct Qdisc *sch, struct sk_buff *skb) | |||
| 402 | opt.buffer = PSCHED_NS2TICKS(q->buffer); | 409 | opt.buffer = PSCHED_NS2TICKS(q->buffer); |
| 403 | if (nla_put(skb, TCA_TBF_PARMS, sizeof(opt), &opt)) | 410 | if (nla_put(skb, TCA_TBF_PARMS, sizeof(opt), &opt)) |
| 404 | goto nla_put_failure; | 411 | goto nla_put_failure; |
| 412 | if (q->rate.rate_bytes_ps >= (1ULL << 32) && | ||
| 413 | nla_put_u64(skb, TCA_TBF_RATE64, q->rate.rate_bytes_ps)) | ||
| 414 | goto nla_put_failure; | ||
| 415 | if (q->peak_present && | ||
| 416 | q->peak.rate_bytes_ps >= (1ULL << 32) && | ||
| 417 | nla_put_u64(skb, TCA_TBF_PRATE64, q->peak.rate_bytes_ps)) | ||
| 418 | goto nla_put_failure; | ||
| 405 | 419 | ||
| 406 | nla_nest_end(skb, nest); | 420 | nla_nest_end(skb, nest); |
| 407 | return skb->len; | 421 | return skb->len; |
