aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/cls_fw.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sched/cls_fw.c')
-rw-r--r--net/sched/cls_fw.c17
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:
186 return -EINVAL; 186 return -EINVAL;
187} 187}
188 188
189static const struct nla_policy fw_policy[TCA_FW_MAX + 1] = {
190 [TCA_FW_CLASSID] = { .type = NLA_U32 },
191 [TCA_FW_INDEV] = { .type = NLA_STRING, .len = IFNAMSIZ },
192 [TCA_FW_MASK] = { .type = NLA_U32 },
193};
194
189static int 195static int
190fw_change_attrs(struct tcf_proto *tp, struct fw_filter *f, 196fw_change_attrs(struct tcf_proto *tp, struct fw_filter *f,
191 struct nlattr **tb, struct nlattr **tca, unsigned long base) 197 struct nlattr **tb, struct nlattr **tca, unsigned long base)
@@ -201,8 +207,6 @@ fw_change_attrs(struct tcf_proto *tp, struct fw_filter *f,
201 207
202 err = -EINVAL; 208 err = -EINVAL;
203 if (tb[TCA_FW_CLASSID]) { 209 if (tb[TCA_FW_CLASSID]) {
204 if (nla_len(tb[TCA_FW_CLASSID]) != sizeof(u32))
205 goto errout;
206 f->res.classid = nla_get_u32(tb[TCA_FW_CLASSID]); 210 f->res.classid = nla_get_u32(tb[TCA_FW_CLASSID]);
207 tcf_bind_filter(tp, &f->res, base); 211 tcf_bind_filter(tp, &f->res, base);
208 } 212 }
@@ -216,8 +220,6 @@ fw_change_attrs(struct tcf_proto *tp, struct fw_filter *f,
216#endif /* CONFIG_NET_CLS_IND */ 220#endif /* CONFIG_NET_CLS_IND */
217 221
218 if (tb[TCA_FW_MASK]) { 222 if (tb[TCA_FW_MASK]) {
219 if (nla_len(tb[TCA_FW_MASK]) != sizeof(u32))
220 goto errout;
221 mask = nla_get_u32(tb[TCA_FW_MASK]); 223 mask = nla_get_u32(tb[TCA_FW_MASK]);
222 if (mask != head->mask) 224 if (mask != head->mask)
223 goto errout; 225 goto errout;
@@ -246,7 +248,7 @@ static int fw_change(struct tcf_proto *tp, unsigned long base,
246 if (!opt) 248 if (!opt)
247 return handle ? -EINVAL : 0; 249 return handle ? -EINVAL : 0;
248 250
249 err = nla_parse_nested(tb, TCA_FW_MAX, opt, NULL); 251 err = nla_parse_nested(tb, TCA_FW_MAX, opt, fw_policy);
250 if (err < 0) 252 if (err < 0)
251 return err; 253 return err;
252 254
@@ -261,11 +263,8 @@ static int fw_change(struct tcf_proto *tp, unsigned long base,
261 263
262 if (head == NULL) { 264 if (head == NULL) {
263 u32 mask = 0xFFFFFFFF; 265 u32 mask = 0xFFFFFFFF;
264 if (tb[TCA_FW_MASK]) { 266 if (tb[TCA_FW_MASK])
265 if (nla_len(tb[TCA_FW_MASK]) != sizeof(u32))
266 return -EINVAL;
267 mask = nla_get_u32(tb[TCA_FW_MASK]); 267 mask = nla_get_u32(tb[TCA_FW_MASK]);
268 }
269 268
270 head = kzalloc(sizeof(struct fw_head), GFP_KERNEL); 269 head = kzalloc(sizeof(struct fw_head), GFP_KERNEL);
271 if (head == NULL) 270 if (head == NULL)