sch_gred.c (20fea08b5fb639c4c175b5c74a2bb346c5c5bc2e) sch_gred.c (1e90474c377e92db7262a8968a45c1dd980ca9e5)
1/*
2 * net/sched/sch_gred.c Generic Random Early Detection queue.
3 *
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.

--- 336 unchanged lines hidden (view full) ---

345 }
346}
347
348static inline void gred_destroy_vq(struct gred_sched_data *q)
349{
350 kfree(q);
351}
352
1/*
2 * net/sched/sch_gred.c Generic Random Early Detection queue.
3 *
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.

--- 336 unchanged lines hidden (view full) ---

345 }
346}
347
348static inline void gred_destroy_vq(struct gred_sched_data *q)
349{
350 kfree(q);
351}
352
353static inline int gred_change_table_def(struct Qdisc *sch, struct rtattr *dps)
353static inline int gred_change_table_def(struct Qdisc *sch, struct nlattr *dps)
354{
355 struct gred_sched *table = qdisc_priv(sch);
356 struct tc_gred_sopt *sopt;
357 int i;
358
354{
355 struct gred_sched *table = qdisc_priv(sch);
356 struct tc_gred_sopt *sopt;
357 int i;
358
359 if (dps == NULL || RTA_PAYLOAD(dps) < sizeof(*sopt))
359 if (dps == NULL || nla_len(dps) < sizeof(*sopt))
360 return -EINVAL;
361
360 return -EINVAL;
361
362 sopt = RTA_DATA(dps);
362 sopt = nla_data(dps);
363
364 if (sopt->DPs > MAX_DPs || sopt->DPs == 0 || sopt->def_DP >= sopt->DPs)
365 return -EINVAL;
366
367 sch_tree_lock(sch);
368 table->DPs = sopt->DPs;
369 table->def = sopt->def_DP;
370 table->red_flags = sopt->flags;

--- 49 unchanged lines hidden (view full) ---

420
421 red_set_parms(&q->parms,
422 ctl->qth_min, ctl->qth_max, ctl->Wlog, ctl->Plog,
423 ctl->Scell_log, stab);
424
425 return 0;
426}
427
363
364 if (sopt->DPs > MAX_DPs || sopt->DPs == 0 || sopt->def_DP >= sopt->DPs)
365 return -EINVAL;
366
367 sch_tree_lock(sch);
368 table->DPs = sopt->DPs;
369 table->def = sopt->def_DP;
370 table->red_flags = sopt->flags;

--- 49 unchanged lines hidden (view full) ---

420
421 red_set_parms(&q->parms,
422 ctl->qth_min, ctl->qth_max, ctl->Wlog, ctl->Plog,
423 ctl->Scell_log, stab);
424
425 return 0;
426}
427
428static int gred_change(struct Qdisc *sch, struct rtattr *opt)
428static int gred_change(struct Qdisc *sch, struct nlattr *opt)
429{
430 struct gred_sched *table = qdisc_priv(sch);
431 struct tc_gred_qopt *ctl;
429{
430 struct gred_sched *table = qdisc_priv(sch);
431 struct tc_gred_qopt *ctl;
432 struct rtattr *tb[TCA_GRED_MAX];
432 struct nlattr *tb[TCA_GRED_MAX + 1];
433 int err = -EINVAL, prio = GRED_DEF_PRIO;
434 u8 *stab;
435
433 int err = -EINVAL, prio = GRED_DEF_PRIO;
434 u8 *stab;
435
436 if (opt == NULL || rtattr_parse_nested(tb, TCA_GRED_MAX, opt))
436 if (opt == NULL || nla_parse_nested(tb, TCA_GRED_MAX, opt, NULL))
437 return -EINVAL;
438
437 return -EINVAL;
438
439 if (tb[TCA_GRED_PARMS-1] == NULL && tb[TCA_GRED_STAB-1] == NULL)
439 if (tb[TCA_GRED_PARMS] == NULL && tb[TCA_GRED_STAB] == NULL)
440 return gred_change_table_def(sch, opt);
441
440 return gred_change_table_def(sch, opt);
441
442 if (tb[TCA_GRED_PARMS-1] == NULL ||
443 RTA_PAYLOAD(tb[TCA_GRED_PARMS-1]) < sizeof(*ctl) ||
444 tb[TCA_GRED_STAB-1] == NULL ||
445 RTA_PAYLOAD(tb[TCA_GRED_STAB-1]) < 256)
442 if (tb[TCA_GRED_PARMS] == NULL ||
443 nla_len(tb[TCA_GRED_PARMS]) < sizeof(*ctl) ||
444 tb[TCA_GRED_STAB] == NULL ||
445 nla_len(tb[TCA_GRED_STAB]) < 256)
446 return -EINVAL;
447
446 return -EINVAL;
447
448 ctl = RTA_DATA(tb[TCA_GRED_PARMS-1]);
449 stab = RTA_DATA(tb[TCA_GRED_STAB-1]);
448 ctl = nla_data(tb[TCA_GRED_PARMS]);
449 stab = nla_data(tb[TCA_GRED_STAB]);
450
451 if (ctl->DP >= table->DPs)
452 goto errout;
453
454 if (gred_rio_mode(table)) {
455 if (ctl->prio == 0) {
456 int def_prio = GRED_DEF_PRIO;
457

--- 23 unchanged lines hidden (view full) ---

481 err = 0;
482
483errout_locked:
484 sch_tree_unlock(sch);
485errout:
486 return err;
487}
488
450
451 if (ctl->DP >= table->DPs)
452 goto errout;
453
454 if (gred_rio_mode(table)) {
455 if (ctl->prio == 0) {
456 int def_prio = GRED_DEF_PRIO;
457

--- 23 unchanged lines hidden (view full) ---

481 err = 0;
482
483errout_locked:
484 sch_tree_unlock(sch);
485errout:
486 return err;
487}
488
489static int gred_init(struct Qdisc *sch, struct rtattr *opt)
489static int gred_init(struct Qdisc *sch, struct nlattr *opt)
490{
490{
491 struct rtattr *tb[TCA_GRED_MAX];
491 struct nlattr *tb[TCA_GRED_MAX + 1];
492
492
493 if (opt == NULL || rtattr_parse_nested(tb, TCA_GRED_MAX, opt))
493 if (opt == NULL || nla_parse_nested(tb, TCA_GRED_MAX, opt, NULL))
494 return -EINVAL;
495
494 return -EINVAL;
495
496 if (tb[TCA_GRED_PARMS-1] || tb[TCA_GRED_STAB-1])
496 if (tb[TCA_GRED_PARMS] || tb[TCA_GRED_STAB])
497 return -EINVAL;
498
497 return -EINVAL;
498
499 return gred_change_table_def(sch, tb[TCA_GRED_DPS-1]);
499 return gred_change_table_def(sch, tb[TCA_GRED_DPS]);
500}
501
502static int gred_dump(struct Qdisc *sch, struct sk_buff *skb)
503{
504 struct gred_sched *table = qdisc_priv(sch);
500}
501
502static int gred_dump(struct Qdisc *sch, struct sk_buff *skb)
503{
504 struct gred_sched *table = qdisc_priv(sch);
505 struct rtattr *parms, *opts = NULL;
505 struct nlattr *parms, *opts = NULL;
506 int i;
507 struct tc_gred_sopt sopt = {
508 .DPs = table->DPs,
509 .def_DP = table->def,
510 .grio = gred_rio_mode(table),
511 .flags = table->red_flags,
512 };
513
506 int i;
507 struct tc_gred_sopt sopt = {
508 .DPs = table->DPs,
509 .def_DP = table->def,
510 .grio = gred_rio_mode(table),
511 .flags = table->red_flags,
512 };
513
514 opts = RTA_NEST(skb, TCA_OPTIONS);
515 RTA_PUT(skb, TCA_GRED_DPS, sizeof(sopt), &sopt);
516 parms = RTA_NEST(skb, TCA_GRED_PARMS);
514 opts = nla_nest_start(skb, TCA_OPTIONS);
515 if (opts == NULL)
516 goto nla_put_failure;
517 NLA_PUT(skb, TCA_GRED_DPS, sizeof(sopt), &sopt);
518 parms = nla_nest_start(skb, TCA_GRED_PARMS);
519 if (parms == NULL)
520 goto nla_put_failure;
517
518 for (i = 0; i < MAX_DPs; i++) {
519 struct gred_sched_data *q = table->tab[i];
520 struct tc_gred_qopt opt;
521
522 memset(&opt, 0, sizeof(opt));
523
524 if (!q) {

--- 25 unchanged lines hidden (view full) ---

550 q->parms.qidlestart =
551 table->tab[table->def]->parms.qidlestart;
552 q->parms.qavg = table->tab[table->def]->parms.qavg;
553 }
554
555 opt.qave = red_calc_qavg(&q->parms, q->parms.qavg);
556
557append_opt:
521
522 for (i = 0; i < MAX_DPs; i++) {
523 struct gred_sched_data *q = table->tab[i];
524 struct tc_gred_qopt opt;
525
526 memset(&opt, 0, sizeof(opt));
527
528 if (!q) {

--- 25 unchanged lines hidden (view full) ---

554 q->parms.qidlestart =
555 table->tab[table->def]->parms.qidlestart;
556 q->parms.qavg = table->tab[table->def]->parms.qavg;
557 }
558
559 opt.qave = red_calc_qavg(&q->parms, q->parms.qavg);
560
561append_opt:
558 RTA_APPEND(skb, sizeof(opt), &opt);
562 if (nla_append(skb, sizeof(opt), &opt) < 0)
563 goto nla_put_failure;
559 }
560
564 }
565
561 RTA_NEST_END(skb, parms);
566 nla_nest_end(skb, parms);
562
567
563 return RTA_NEST_END(skb, opts);
568 return nla_nest_end(skb, opts);
564
569
565rtattr_failure:
566 return RTA_NEST_CANCEL(skb, opts);
570nla_put_failure:
571 return nla_nest_cancel(skb, opts);
567}
568
569static void gred_destroy(struct Qdisc *sch)
570{
571 struct gred_sched *table = qdisc_priv(sch);
572 int i;
573
574 for (i = 0; i < table->DPs; i++) {

--- 34 unchanged lines hidden ---
572}
573
574static void gred_destroy(struct Qdisc *sch)
575{
576 struct gred_sched *table = qdisc_priv(sch);
577 int i;
578
579 for (i = 0; i < table->DPs; i++) {

--- 34 unchanged lines hidden ---