diff options
author | Patrick McHardy <kaber@trash.net> | 2008-01-23 20:35:39 -0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 15:11:22 -0800 |
commit | 27a3421e4821734bc19496faa77b380605dc3b23 (patch) | |
tree | f9ded49845a39f41352ed09130bf3d2bd05e4ffe /net/sched/sch_htb.c | |
parent | 5feb5e1aaa887f6427b8290bce48bfb6b7010fc6 (diff) | |
download | talos-op-linux-27a3421e4821734bc19496faa77b380605dc3b23.tar.gz talos-op-linux-27a3421e4821734bc19496faa77b380605dc3b23.zip |
[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.c | 17 |
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) INIT_LIST_HEAD(q->drops + i); } +static const struct nla_policy htb_policy[TCA_HTB_MAX + 1] = { + [TCA_HTB_PARMS] = { .len = sizeof(struct tc_htb_opt) }, + [TCA_HTB_INIT] = { .len = sizeof(struct tc_htb_glob) }, + [TCA_HTB_CTAB] = { .type = NLA_BINARY, .len = TC_RTAB_SIZE }, + [TCA_HTB_RTAB] = { .type = NLA_BINARY, .len = TC_RTAB_SIZE }, +}; + static int htb_init(struct Qdisc *sch, struct nlattr *opt) { struct htb_sched *q = qdisc_priv(sch); @@ -1003,12 +1010,11 @@ static int htb_init(struct Qdisc *sch, struct nlattr *opt) if (!opt) return -EINVAL; - err = nla_parse_nested(tb, TCA_HTB_INIT, opt, NULL); + err = nla_parse_nested(tb, TCA_HTB_INIT, opt, htb_policy); if (err < 0) return err; - if (tb[TCA_HTB_INIT] == NULL || - nla_len(tb[TCA_HTB_INIT]) < sizeof(*gopt)) { + if (tb[TCA_HTB_INIT] == NULL) { printk(KERN_ERR "HTB: hey probably you have bad tc tool ?\n"); return -EINVAL; } @@ -1319,13 +1325,12 @@ static int htb_change_class(struct Qdisc *sch, u32 classid, if (!opt) goto failure; - err = nla_parse_nested(tb, TCA_HTB_RTAB, opt, NULL); + err = nla_parse_nested(tb, TCA_HTB_RTAB, opt, htb_policy); if (err < 0) goto failure; err = -EINVAL; - if (tb[TCA_HTB_PARMS] == NULL || - nla_len(tb[TCA_HTB_PARMS]) < sizeof(*hopt)) + if (tb[TCA_HTB_PARMS] == NULL) goto failure; parent = parentid == TC_H_ROOT ? NULL : htb_find(parentid, sch); |