aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/sch_gred.c
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2008-01-23 23:35:39 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:11:22 -0500
commit27a3421e4821734bc19496faa77b380605dc3b23 (patch)
treef9ded49845a39f41352ed09130bf3d2bd05e4ffe /net/sched/sch_gred.c
parent5feb5e1aaa887f6427b8290bce48bfb6b7010fc6 (diff)
[NET_SCHED]: Use nla_policy for attribute validation in packet schedulers
Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/sch_gred.c')
-rw-r--r--net/sched/sch_gred.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/net/sched/sch_gred.c b/net/sched/sch_gred.c
index 365c7d8b17ab..3a9d226ff1e4 100644
--- a/net/sched/sch_gred.c
+++ b/net/sched/sch_gred.c
@@ -356,7 +356,7 @@ static inline int gred_change_table_def(struct Qdisc *sch, struct nlattr *dps)
356 struct tc_gred_sopt *sopt; 356 struct tc_gred_sopt *sopt;
357 int i; 357 int i;
358 358
359 if (dps == NULL || nla_len(dps) < sizeof(*sopt)) 359 if (dps == NULL)
360 return -EINVAL; 360 return -EINVAL;
361 361
362 sopt = nla_data(dps); 362 sopt = nla_data(dps);
@@ -425,6 +425,12 @@ static inline int gred_change_vq(struct Qdisc *sch, int dp,
425 return 0; 425 return 0;
426} 426}
427 427
428static const struct nla_policy gred_policy[TCA_GRED_MAX + 1] = {
429 [TCA_GRED_PARMS] = { .len = sizeof(struct tc_gred_qopt) },
430 [TCA_GRED_STAB] = { .len = 256 },
431 [TCA_GRED_DPS] = { .len = sizeof(struct tc_gred_sopt) },
432};
433
428static int gred_change(struct Qdisc *sch, struct nlattr *opt) 434static int gred_change(struct Qdisc *sch, struct nlattr *opt)
429{ 435{
430 struct gred_sched *table = qdisc_priv(sch); 436 struct gred_sched *table = qdisc_priv(sch);
@@ -436,7 +442,7 @@ static int gred_change(struct Qdisc *sch, struct nlattr *opt)
436 if (opt == NULL) 442 if (opt == NULL)
437 return -EINVAL; 443 return -EINVAL;
438 444
439 err = nla_parse_nested(tb, TCA_GRED_MAX, opt, NULL); 445 err = nla_parse_nested(tb, TCA_GRED_MAX, opt, gred_policy);
440 if (err < 0) 446 if (err < 0)
441 return err; 447 return err;
442 448
@@ -444,9 +450,7 @@ static int gred_change(struct Qdisc *sch, struct nlattr *opt)
444 return gred_change_table_def(sch, opt); 450 return gred_change_table_def(sch, opt);
445 451
446 if (tb[TCA_GRED_PARMS] == NULL || 452 if (tb[TCA_GRED_PARMS] == NULL ||
447 nla_len(tb[TCA_GRED_PARMS]) < sizeof(*ctl) || 453 tb[TCA_GRED_STAB] == NULL)
448 tb[TCA_GRED_STAB] == NULL ||
449 nla_len(tb[TCA_GRED_STAB]) < 256)
450 return -EINVAL; 454 return -EINVAL;
451 455
452 err = -EINVAL; 456 err = -EINVAL;
@@ -499,7 +503,7 @@ static int gred_init(struct Qdisc *sch, struct nlattr *opt)
499 if (opt == NULL) 503 if (opt == NULL)
500 return -EINVAL; 504 return -EINVAL;
501 505
502 err = nla_parse_nested(tb, TCA_GRED_MAX, opt, NULL); 506 err = nla_parse_nested(tb, TCA_GRED_MAX, opt, gred_policy);
503 if (err < 0) 507 if (err < 0)
504 return err; 508 return err;
505 509