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_atm.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_atm.c')
-rw-r--r-- | net/sched/sch_atm.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/net/sched/sch_atm.c b/net/sched/sch_atm.c index 0c71f2eb96bc..335273416384 100644 --- a/net/sched/sch_atm.c +++ b/net/sched/sch_atm.c | |||
@@ -195,6 +195,11 @@ static const u8 llc_oui_ip[] = { | |||
195 | 0x08, 0x00 | 195 | 0x08, 0x00 |
196 | }; /* Ethertype IP (0800) */ | 196 | }; /* Ethertype IP (0800) */ |
197 | 197 | ||
198 | static const struct nla_policy atm_policy[TCA_ATM_MAX + 1] = { | ||
199 | [TCA_ATM_FD] = { .type = NLA_U32 }, | ||
200 | [TCA_ATM_EXCESS] = { .type = NLA_U32 }, | ||
201 | }; | ||
202 | |||
198 | static int atm_tc_change(struct Qdisc *sch, u32 classid, u32 parent, | 203 | static int atm_tc_change(struct Qdisc *sch, u32 classid, u32 parent, |
199 | struct nlattr **tca, unsigned long *arg) | 204 | struct nlattr **tca, unsigned long *arg) |
200 | { | 205 | { |
@@ -225,11 +230,12 @@ static int atm_tc_change(struct Qdisc *sch, u32 classid, u32 parent, | |||
225 | return -EBUSY; | 230 | return -EBUSY; |
226 | if (opt == NULL) | 231 | if (opt == NULL) |
227 | return -EINVAL; | 232 | return -EINVAL; |
228 | error = nla_parse_nested(tb, TCA_ATM_MAX, opt, NULL); | 233 | |
234 | error = nla_parse_nested(tb, TCA_ATM_MAX, opt, atm_policy); | ||
229 | if (error < 0) | 235 | if (error < 0) |
230 | return error; | 236 | return error; |
231 | 237 | ||
232 | if (!tb[TCA_ATM_FD] || nla_len(tb[TCA_ATM_FD]) < sizeof(fd)) | 238 | if (!tb[TCA_ATM_FD]) |
233 | return -EINVAL; | 239 | return -EINVAL; |
234 | fd = nla_get_u32(tb[TCA_ATM_FD]); | 240 | fd = nla_get_u32(tb[TCA_ATM_FD]); |
235 | pr_debug("atm_tc_change: fd %d\n", fd); | 241 | pr_debug("atm_tc_change: fd %d\n", fd); |
@@ -243,8 +249,6 @@ static int atm_tc_change(struct Qdisc *sch, u32 classid, u32 parent, | |||
243 | if (!tb[TCA_ATM_EXCESS]) | 249 | if (!tb[TCA_ATM_EXCESS]) |
244 | excess = NULL; | 250 | excess = NULL; |
245 | else { | 251 | else { |
246 | if (nla_len(tb[TCA_ATM_EXCESS]) != sizeof(u32)) | ||
247 | return -EINVAL; | ||
248 | excess = (struct atm_flow_data *) | 252 | excess = (struct atm_flow_data *) |
249 | atm_tc_get(sch, nla_get_u32(tb[TCA_ATM_EXCESS])); | 253 | atm_tc_get(sch, nla_get_u32(tb[TCA_ATM_EXCESS])); |
250 | if (!excess) | 254 | if (!excess) |