aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/sch_tbf.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sched/sch_tbf.c')
-rw-r--r--net/sched/sch_tbf.c49
1 files changed, 25 insertions, 24 deletions
diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
index d88fea9d6b61..6c4ad7e677b3 100644
--- a/net/sched/sch_tbf.c
+++ b/net/sched/sch_tbf.c
@@ -245,20 +245,21 @@ static void tbf_reset(struct Qdisc* sch)
245static struct Qdisc *tbf_create_dflt_qdisc(struct Qdisc *sch, u32 limit) 245static struct Qdisc *tbf_create_dflt_qdisc(struct Qdisc *sch, u32 limit)
246{ 246{
247 struct Qdisc *q; 247 struct Qdisc *q;
248 struct rtattr *rta; 248 struct nlattr *nla;
249 int ret; 249 int ret;
250 250
251 q = qdisc_create_dflt(sch->dev, &bfifo_qdisc_ops, 251 q = qdisc_create_dflt(sch->dev, &bfifo_qdisc_ops,
252 TC_H_MAKE(sch->handle, 1)); 252 TC_H_MAKE(sch->handle, 1));
253 if (q) { 253 if (q) {
254 rta = kmalloc(RTA_LENGTH(sizeof(struct tc_fifo_qopt)), GFP_KERNEL); 254 nla = kmalloc(nla_attr_size(sizeof(struct tc_fifo_qopt)),
255 if (rta) { 255 GFP_KERNEL);
256 rta->rta_type = RTM_NEWQDISC; 256 if (nla) {
257 rta->rta_len = RTA_LENGTH(sizeof(struct tc_fifo_qopt)); 257 nla->nla_type = RTM_NEWQDISC;
258 ((struct tc_fifo_qopt *)RTA_DATA(rta))->limit = limit; 258 nla->nla_len = nla_attr_size(sizeof(struct tc_fifo_qopt));
259 ((struct tc_fifo_qopt *)nla_data(nla))->limit = limit;
259 260
260 ret = q->ops->change(q, rta); 261 ret = q->ops->change(q, nla);
261 kfree(rta); 262 kfree(nla);
262 263
263 if (ret == 0) 264 if (ret == 0)
264 return q; 265 return q;
@@ -269,30 +270,30 @@ static struct Qdisc *tbf_create_dflt_qdisc(struct Qdisc *sch, u32 limit)
269 return NULL; 270 return NULL;
270} 271}
271 272
272static int tbf_change(struct Qdisc* sch, struct rtattr *opt) 273static int tbf_change(struct Qdisc* sch, struct nlattr *opt)
273{ 274{
274 int err = -EINVAL; 275 int err = -EINVAL;
275 struct tbf_sched_data *q = qdisc_priv(sch); 276 struct tbf_sched_data *q = qdisc_priv(sch);
276 struct rtattr *tb[TCA_TBF_PTAB]; 277 struct nlattr *tb[TCA_TBF_PTAB + 1];
277 struct tc_tbf_qopt *qopt; 278 struct tc_tbf_qopt *qopt;
278 struct qdisc_rate_table *rtab = NULL; 279 struct qdisc_rate_table *rtab = NULL;
279 struct qdisc_rate_table *ptab = NULL; 280 struct qdisc_rate_table *ptab = NULL;
280 struct Qdisc *child = NULL; 281 struct Qdisc *child = NULL;
281 int max_size,n; 282 int max_size,n;
282 283
283 if (rtattr_parse_nested(tb, TCA_TBF_PTAB, opt) || 284 if (nla_parse_nested(tb, TCA_TBF_PTAB, opt, NULL) ||
284 tb[TCA_TBF_PARMS-1] == NULL || 285 tb[TCA_TBF_PARMS] == NULL ||
285 RTA_PAYLOAD(tb[TCA_TBF_PARMS-1]) < sizeof(*qopt)) 286 nla_len(tb[TCA_TBF_PARMS]) < sizeof(*qopt))
286 goto done; 287 goto done;
287 288
288 qopt = RTA_DATA(tb[TCA_TBF_PARMS-1]); 289 qopt = nla_data(tb[TCA_TBF_PARMS]);
289 rtab = qdisc_get_rtab(&qopt->rate, tb[TCA_TBF_RTAB-1]); 290 rtab = qdisc_get_rtab(&qopt->rate, tb[TCA_TBF_RTAB]);
290 if (rtab == NULL) 291 if (rtab == NULL)
291 goto done; 292 goto done;
292 293
293 if (qopt->peakrate.rate) { 294 if (qopt->peakrate.rate) {
294 if (qopt->peakrate.rate > qopt->rate.rate) 295 if (qopt->peakrate.rate > qopt->rate.rate)
295 ptab = qdisc_get_rtab(&qopt->peakrate, tb[TCA_TBF_PTAB-1]); 296 ptab = qdisc_get_rtab(&qopt->peakrate, tb[TCA_TBF_PTAB]);
296 if (ptab == NULL) 297 if (ptab == NULL)
297 goto done; 298 goto done;
298 } 299 }
@@ -339,7 +340,7 @@ done:
339 return err; 340 return err;
340} 341}
341 342
342static int tbf_init(struct Qdisc* sch, struct rtattr *opt) 343static int tbf_init(struct Qdisc* sch, struct nlattr *opt)
343{ 344{
344 struct tbf_sched_data *q = qdisc_priv(sch); 345 struct tbf_sched_data *q = qdisc_priv(sch);
345 346
@@ -371,11 +372,11 @@ static int tbf_dump(struct Qdisc *sch, struct sk_buff *skb)
371{ 372{
372 struct tbf_sched_data *q = qdisc_priv(sch); 373 struct tbf_sched_data *q = qdisc_priv(sch);
373 unsigned char *b = skb_tail_pointer(skb); 374 unsigned char *b = skb_tail_pointer(skb);
374 struct rtattr *rta; 375 struct nlattr *nla;
375 struct tc_tbf_qopt opt; 376 struct tc_tbf_qopt opt;
376 377
377 rta = (struct rtattr*)b; 378 nla = (struct nlattr*)b;
378 RTA_PUT(skb, TCA_OPTIONS, 0, NULL); 379 NLA_PUT(skb, TCA_OPTIONS, 0, NULL);
379 380
380 opt.limit = q->limit; 381 opt.limit = q->limit;
381 opt.rate = q->R_tab->rate; 382 opt.rate = q->R_tab->rate;
@@ -385,12 +386,12 @@ static int tbf_dump(struct Qdisc *sch, struct sk_buff *skb)
385 memset(&opt.peakrate, 0, sizeof(opt.peakrate)); 386 memset(&opt.peakrate, 0, sizeof(opt.peakrate));
386 opt.mtu = q->mtu; 387 opt.mtu = q->mtu;
387 opt.buffer = q->buffer; 388 opt.buffer = q->buffer;
388 RTA_PUT(skb, TCA_TBF_PARMS, sizeof(opt), &opt); 389 NLA_PUT(skb, TCA_TBF_PARMS, sizeof(opt), &opt);
389 rta->rta_len = skb_tail_pointer(skb) - b; 390 nla->nla_len = skb_tail_pointer(skb) - b;
390 391
391 return skb->len; 392 return skb->len;
392 393
393rtattr_failure: 394nla_put_failure:
394 nlmsg_trim(skb, b); 395 nlmsg_trim(skb, b);
395 return -1; 396 return -1;
396} 397}
@@ -442,7 +443,7 @@ static void tbf_put(struct Qdisc *sch, unsigned long arg)
442} 443}
443 444
444static int tbf_change_class(struct Qdisc *sch, u32 classid, u32 parentid, 445static int tbf_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
445 struct rtattr **tca, unsigned long *arg) 446 struct nlattr **tca, unsigned long *arg)
446{ 447{
447 return -ENOSYS; 448 return -ENOSYS;
448} 449}