aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/sch_htb.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_htb.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_htb.c')
-rw-r--r--net/sched/sch_htb.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index 69fac320f8bc..e1a579efc215 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -992,6 +992,13 @@ static void htb_reset(struct Qdisc *sch)
992 INIT_LIST_HEAD(q->drops + i); 992 INIT_LIST_HEAD(q->drops + i);
993} 993}
994 994
995static const struct nla_policy htb_policy[TCA_HTB_MAX + 1] = {
996 [TCA_HTB_PARMS] = { .len = sizeof(struct tc_htb_opt) },
997 [TCA_HTB_INIT] = { .len = sizeof(struct tc_htb_glob) },
998 [TCA_HTB_CTAB] = { .type = NLA_BINARY, .len = TC_RTAB_SIZE },
999 [TCA_HTB_RTAB] = { .type = NLA_BINARY, .len = TC_RTAB_SIZE },
1000};
1001
995static int htb_init(struct Qdisc *sch, struct nlattr *opt) 1002static int htb_init(struct Qdisc *sch, struct nlattr *opt)
996{ 1003{
997 struct htb_sched *q = qdisc_priv(sch); 1004 struct htb_sched *q = qdisc_priv(sch);
@@ -1003,12 +1010,11 @@ static int htb_init(struct Qdisc *sch, struct nlattr *opt)
1003 if (!opt) 1010 if (!opt)
1004 return -EINVAL; 1011 return -EINVAL;
1005 1012
1006 err = nla_parse_nested(tb, TCA_HTB_INIT, opt, NULL); 1013 err = nla_parse_nested(tb, TCA_HTB_INIT, opt, htb_policy);
1007 if (err < 0) 1014 if (err < 0)
1008 return err; 1015 return err;
1009 1016
1010 if (tb[TCA_HTB_INIT] == NULL || 1017 if (tb[TCA_HTB_INIT] == NULL) {
1011 nla_len(tb[TCA_HTB_INIT]) < sizeof(*gopt)) {
1012 printk(KERN_ERR "HTB: hey probably you have bad tc tool ?\n"); 1018 printk(KERN_ERR "HTB: hey probably you have bad tc tool ?\n");
1013 return -EINVAL; 1019 return -EINVAL;
1014 } 1020 }
@@ -1319,13 +1325,12 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
1319 if (!opt) 1325 if (!opt)
1320 goto failure; 1326 goto failure;
1321 1327
1322 err = nla_parse_nested(tb, TCA_HTB_RTAB, opt, NULL); 1328 err = nla_parse_nested(tb, TCA_HTB_RTAB, opt, htb_policy);
1323 if (err < 0) 1329 if (err < 0)
1324 goto failure; 1330 goto failure;
1325 1331
1326 err = -EINVAL; 1332 err = -EINVAL;
1327 if (tb[TCA_HTB_PARMS] == NULL || 1333 if (tb[TCA_HTB_PARMS] == NULL)
1328 nla_len(tb[TCA_HTB_PARMS]) < sizeof(*hopt))
1329 goto failure; 1334 goto failure;
1330 1335
1331 parent = parentid == TC_H_ROOT ? NULL : htb_find(parentid, sch); 1336 parent = parentid == TC_H_ROOT ? NULL : htb_find(parentid, sch);