aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/cls_basic.c
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2008-01-23 23:36:12 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:11:23 -0500
commit6fa8c0144b770dac941cf2c15053b6e24f046c8a (patch)
tree7c91cd0e9a98f0532df30a9d8549e2c76a3ce716 /net/sched/cls_basic.c
parent27a3421e4821734bc19496faa77b380605dc3b23 (diff)
[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_basic.c')
-rw-r--r--net/sched/cls_basic.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/net/sched/cls_basic.c b/net/sched/cls_basic.c
index 0c872a76c4b0..bfb4342ea88c 100644
--- a/net/sched/cls_basic.c
+++ b/net/sched/cls_basic.c
@@ -129,6 +129,11 @@ static int basic_delete(struct tcf_proto *tp, unsigned long arg)
129 return -ENOENT; 129 return -ENOENT;
130} 130}
131 131
132static const struct nla_policy basic_policy[TCA_BASIC_MAX + 1] = {
133 [TCA_BASIC_CLASSID] = { .type = NLA_U32 },
134 [TCA_BASIC_EMATCHES] = { .type = NLA_NESTED },
135};
136
132static inline int basic_set_parms(struct tcf_proto *tp, struct basic_filter *f, 137static inline int basic_set_parms(struct tcf_proto *tp, struct basic_filter *f,
133 unsigned long base, struct nlattr **tb, 138 unsigned long base, struct nlattr **tb,
134 struct nlattr *est) 139 struct nlattr *est)
@@ -137,10 +142,6 @@ static inline int basic_set_parms(struct tcf_proto *tp, struct basic_filter *f,
137 struct tcf_exts e; 142 struct tcf_exts e;
138 struct tcf_ematch_tree t; 143 struct tcf_ematch_tree t;
139 144
140 if (tb[TCA_BASIC_CLASSID])
141 if (nla_len(tb[TCA_BASIC_CLASSID]) < sizeof(u32))
142 return err;
143
144 err = tcf_exts_validate(tp, tb, est, &e, &basic_ext_map); 145 err = tcf_exts_validate(tp, tb, est, &e, &basic_ext_map);
145 if (err < 0) 146 if (err < 0)
146 return err; 147 return err;
@@ -174,7 +175,8 @@ static int basic_change(struct tcf_proto *tp, unsigned long base, u32 handle,
174 if (tca[TCA_OPTIONS] == NULL) 175 if (tca[TCA_OPTIONS] == NULL)
175 return -EINVAL; 176 return -EINVAL;
176 177
177 err = nla_parse_nested(tb, TCA_BASIC_MAX, tca[TCA_OPTIONS], NULL); 178 err = nla_parse_nested(tb, TCA_BASIC_MAX, tca[TCA_OPTIONS],
179 basic_policy);
178 if (err < 0) 180 if (err < 0)
179 return err; 181 return err;
180 182