diff options
author | Patrick McHardy <kaber@trash.net> | 2008-01-23 23:35:39 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:11:22 -0500 |
commit | 27a3421e4821734bc19496faa77b380605dc3b23 (patch) | |
tree | f9ded49845a39f41352ed09130bf3d2bd05e4ffe /net/sched/sch_red.c | |
parent | 5feb5e1aaa887f6427b8290bce48bfb6b7010fc6 (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_red.c')
-rw-r--r-- | net/sched/sch_red.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/net/sched/sch_red.c b/net/sched/sch_red.c index dcf6afc196f8..3dcd493f4f4a 100644 --- a/net/sched/sch_red.c +++ b/net/sched/sch_red.c | |||
@@ -201,6 +201,11 @@ static struct Qdisc *red_create_dflt(struct Qdisc *sch, u32 limit) | |||
201 | return NULL; | 201 | return NULL; |
202 | } | 202 | } |
203 | 203 | ||
204 | static const struct nla_policy red_policy[TCA_RED_MAX + 1] = { | ||
205 | [TCA_RED_PARMS] = { .len = sizeof(struct tc_red_qopt) }, | ||
206 | [TCA_RED_STAB] = { .len = RED_STAB_SIZE }, | ||
207 | }; | ||
208 | |||
204 | static int red_change(struct Qdisc *sch, struct nlattr *opt) | 209 | static int red_change(struct Qdisc *sch, struct nlattr *opt) |
205 | { | 210 | { |
206 | struct red_sched_data *q = qdisc_priv(sch); | 211 | struct red_sched_data *q = qdisc_priv(sch); |
@@ -212,14 +217,12 @@ static int red_change(struct Qdisc *sch, struct nlattr *opt) | |||
212 | if (opt == NULL) | 217 | if (opt == NULL) |
213 | return -EINVAL; | 218 | return -EINVAL; |
214 | 219 | ||
215 | err = nla_parse_nested(tb, TCA_RED_MAX, opt, NULL); | 220 | err = nla_parse_nested(tb, TCA_RED_MAX, opt, red_policy); |
216 | if (err < 0) | 221 | if (err < 0) |
217 | return err; | 222 | return err; |
218 | 223 | ||
219 | if (tb[TCA_RED_PARMS] == NULL || | 224 | if (tb[TCA_RED_PARMS] == NULL || |
220 | nla_len(tb[TCA_RED_PARMS]) < sizeof(*ctl) || | 225 | tb[TCA_RED_STAB] == NULL) |
221 | tb[TCA_RED_STAB] == NULL || | ||
222 | nla_len(tb[TCA_RED_STAB]) < RED_STAB_SIZE) | ||
223 | return -EINVAL; | 226 | return -EINVAL; |
224 | 227 | ||
225 | ctl = nla_data(tb[TCA_RED_PARMS]); | 228 | ctl = nla_data(tb[TCA_RED_PARMS]); |