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_atm.c | |
parent | 5feb5e1aaa887f6427b8290bce48bfb6b7010fc6 (diff) | |
download | blackbird-op-linux-27a3421e4821734bc19496faa77b380605dc3b23.tar.gz blackbird-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_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[] = { 0x08, 0x00 }; /* Ethertype IP (0800) */ +static const struct nla_policy atm_policy[TCA_ATM_MAX + 1] = { + [TCA_ATM_FD] = { .type = NLA_U32 }, + [TCA_ATM_EXCESS] = { .type = NLA_U32 }, +}; + static int atm_tc_change(struct Qdisc *sch, u32 classid, u32 parent, struct nlattr **tca, unsigned long *arg) { @@ -225,11 +230,12 @@ static int atm_tc_change(struct Qdisc *sch, u32 classid, u32 parent, return -EBUSY; if (opt == NULL) return -EINVAL; - error = nla_parse_nested(tb, TCA_ATM_MAX, opt, NULL); + + error = nla_parse_nested(tb, TCA_ATM_MAX, opt, atm_policy); if (error < 0) return error; - if (!tb[TCA_ATM_FD] || nla_len(tb[TCA_ATM_FD]) < sizeof(fd)) + if (!tb[TCA_ATM_FD]) return -EINVAL; fd = nla_get_u32(tb[TCA_ATM_FD]); 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, if (!tb[TCA_ATM_EXCESS]) excess = NULL; else { - if (nla_len(tb[TCA_ATM_EXCESS]) != sizeof(u32)) - return -EINVAL; excess = (struct atm_flow_data *) atm_tc_get(sch, nla_get_u32(tb[TCA_ATM_EXCESS])); if (!excess) |