diff options
author | Patrick McHardy <kaber@trash.net> | 2008-01-24 07:36:12 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-29 02:11:23 +0300 |
commit | 6fa8c0144b770dac941cf2c15053b6e24f046c8a (patch) | |
tree | 7c91cd0e9a98f0532df30a9d8549e2c76a3ce716 /net/sched/cls_fw.c | |
parent | 27a3421e4821734bc19496faa77b380605dc3b23 (diff) | |
download | linux-6fa8c0144b770dac941cf2c15053b6e24f046c8a.tar.xz |
[NET_SCHED]: Use nla_policy for attribute validation in classifiers
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/cls_fw.c')
-rw-r--r-- | net/sched/cls_fw.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/net/sched/cls_fw.c b/net/sched/cls_fw.c index b75696d67ec2..436a6e7c438e 100644 --- a/net/sched/cls_fw.c +++ b/net/sched/cls_fw.c @@ -186,6 +186,12 @@ out: return -EINVAL; } +static const struct nla_policy fw_policy[TCA_FW_MAX + 1] = { + [TCA_FW_CLASSID] = { .type = NLA_U32 }, + [TCA_FW_INDEV] = { .type = NLA_STRING, .len = IFNAMSIZ }, + [TCA_FW_MASK] = { .type = NLA_U32 }, +}; + static int fw_change_attrs(struct tcf_proto *tp, struct fw_filter *f, struct nlattr **tb, struct nlattr **tca, unsigned long base) @@ -201,8 +207,6 @@ fw_change_attrs(struct tcf_proto *tp, struct fw_filter *f, err = -EINVAL; if (tb[TCA_FW_CLASSID]) { - if (nla_len(tb[TCA_FW_CLASSID]) != sizeof(u32)) - goto errout; f->res.classid = nla_get_u32(tb[TCA_FW_CLASSID]); tcf_bind_filter(tp, &f->res, base); } @@ -216,8 +220,6 @@ fw_change_attrs(struct tcf_proto *tp, struct fw_filter *f, #endif /* CONFIG_NET_CLS_IND */ if (tb[TCA_FW_MASK]) { - if (nla_len(tb[TCA_FW_MASK]) != sizeof(u32)) - goto errout; mask = nla_get_u32(tb[TCA_FW_MASK]); if (mask != head->mask) goto errout; @@ -246,7 +248,7 @@ static int fw_change(struct tcf_proto *tp, unsigned long base, if (!opt) return handle ? -EINVAL : 0; - err = nla_parse_nested(tb, TCA_FW_MAX, opt, NULL); + err = nla_parse_nested(tb, TCA_FW_MAX, opt, fw_policy); if (err < 0) return err; @@ -261,11 +263,8 @@ static int fw_change(struct tcf_proto *tp, unsigned long base, if (head == NULL) { u32 mask = 0xFFFFFFFF; - if (tb[TCA_FW_MASK]) { - if (nla_len(tb[TCA_FW_MASK]) != sizeof(u32)) - return -EINVAL; + if (tb[TCA_FW_MASK]) mask = nla_get_u32(tb[TCA_FW_MASK]); - } head = kzalloc(sizeof(struct fw_head), GFP_KERNEL); if (head == NULL) |