diff options
author | Patrick McHardy <kaber@trash.net> | 2008-01-24 05:35:39 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-29 00:11:22 +0100 |
commit | 27a3421e4821734bc19496faa77b380605dc3b23 (patch) | |
tree | f9ded49845a39f41352ed09130bf3d2bd05e4ffe /net/sched/sch_tbf.c | |
parent | [NET_SCHED]: sch_api: introduce constant for rate table size (diff) | |
download | linux-27a3421e4821734bc19496faa77b380605dc3b23.tar.xz 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_tbf.c')
-rw-r--r-- | net/sched/sch_tbf.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c index b7a185dc3def..0b7d78f59d8c 100644 --- a/net/sched/sch_tbf.c +++ b/net/sched/sch_tbf.c @@ -270,6 +270,12 @@ static struct Qdisc *tbf_create_dflt_qdisc(struct Qdisc *sch, u32 limit) return NULL; } +static const struct nla_policy tbf_policy[TCA_TBF_MAX + 1] = { + [TCA_TBF_PARMS] = { .len = sizeof(struct tc_tbf_qopt) }, + [TCA_TBF_RTAB] = { .type = NLA_BINARY, .len = TC_RTAB_SIZE }, + [TCA_TBF_PTAB] = { .type = NLA_BINARY, .len = TC_RTAB_SIZE }, +}; + static int tbf_change(struct Qdisc* sch, struct nlattr *opt) { int err; @@ -281,13 +287,12 @@ static int tbf_change(struct Qdisc* sch, struct nlattr *opt) struct Qdisc *child = NULL; int max_size,n; - err = nla_parse_nested(tb, TCA_TBF_PTAB, opt, NULL); + err = nla_parse_nested(tb, TCA_TBF_PTAB, opt, tbf_policy); if (err < 0) return err; err = -EINVAL; - if (tb[TCA_TBF_PARMS] == NULL || - nla_len(tb[TCA_TBF_PARMS]) < sizeof(*qopt)) + if (tb[TCA_TBF_PARMS] == NULL) goto done; qopt = nla_data(tb[TCA_TBF_PARMS]); |