aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/cls_route.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_route.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_route.c')
-rw-r--r--net/sched/cls_route.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/net/sched/cls_route.c b/net/sched/cls_route.c
index ae97238c57ad..f7e7d3955d28 100644
--- a/net/sched/cls_route.c
+++ b/net/sched/cls_route.c
@@ -323,6 +323,13 @@ static int route4_delete(struct tcf_proto *tp, unsigned long arg)
323 return 0; 323 return 0;
324} 324}
325 325
326static const struct nla_policy route4_policy[TCA_ROUTE4_MAX + 1] = {
327 [TCA_ROUTE4_CLASSID] = { .type = NLA_U32 },
328 [TCA_ROUTE4_TO] = { .type = NLA_U32 },
329 [TCA_ROUTE4_FROM] = { .type = NLA_U32 },
330 [TCA_ROUTE4_IIF] = { .type = NLA_U32 },
331};
332
326static int route4_set_parms(struct tcf_proto *tp, unsigned long base, 333static int route4_set_parms(struct tcf_proto *tp, unsigned long base,
327 struct route4_filter *f, u32 handle, struct route4_head *head, 334 struct route4_filter *f, u32 handle, struct route4_head *head,
328 struct nlattr **tb, struct nlattr *est, int new) 335 struct nlattr **tb, struct nlattr *est, int new)
@@ -339,15 +346,9 @@ static int route4_set_parms(struct tcf_proto *tp, unsigned long base,
339 return err; 346 return err;
340 347
341 err = -EINVAL; 348 err = -EINVAL;
342 if (tb[TCA_ROUTE4_CLASSID])
343 if (nla_len(tb[TCA_ROUTE4_CLASSID]) < sizeof(u32))
344 goto errout;
345
346 if (tb[TCA_ROUTE4_TO]) { 349 if (tb[TCA_ROUTE4_TO]) {
347 if (new && handle & 0x8000) 350 if (new && handle & 0x8000)
348 goto errout; 351 goto errout;
349 if (nla_len(tb[TCA_ROUTE4_TO]) < sizeof(u32))
350 goto errout;
351 to = nla_get_u32(tb[TCA_ROUTE4_TO]); 352 to = nla_get_u32(tb[TCA_ROUTE4_TO]);
352 if (to > 0xFF) 353 if (to > 0xFF)
353 goto errout; 354 goto errout;
@@ -357,15 +358,11 @@ static int route4_set_parms(struct tcf_proto *tp, unsigned long base,
357 if (tb[TCA_ROUTE4_FROM]) { 358 if (tb[TCA_ROUTE4_FROM]) {
358 if (tb[TCA_ROUTE4_IIF]) 359 if (tb[TCA_ROUTE4_IIF])
359 goto errout; 360 goto errout;
360 if (nla_len(tb[TCA_ROUTE4_FROM]) < sizeof(u32))
361 goto errout;
362 id = nla_get_u32(tb[TCA_ROUTE4_FROM]); 361 id = nla_get_u32(tb[TCA_ROUTE4_FROM]);
363 if (id > 0xFF) 362 if (id > 0xFF)
364 goto errout; 363 goto errout;
365 nhandle |= id << 16; 364 nhandle |= id << 16;
366 } else if (tb[TCA_ROUTE4_IIF]) { 365 } else if (tb[TCA_ROUTE4_IIF]) {
367 if (nla_len(tb[TCA_ROUTE4_IIF]) < sizeof(u32))
368 goto errout;
369 id = nla_get_u32(tb[TCA_ROUTE4_IIF]); 366 id = nla_get_u32(tb[TCA_ROUTE4_IIF]);
370 if (id > 0x7FFF) 367 if (id > 0x7FFF)
371 goto errout; 368 goto errout;
@@ -440,7 +437,7 @@ static int route4_change(struct tcf_proto *tp, unsigned long base,
440 if (opt == NULL) 437 if (opt == NULL)
441 return handle ? -EINVAL : 0; 438 return handle ? -EINVAL : 0;
442 439
443 err = nla_parse_nested(tb, TCA_ROUTE4_MAX, opt, NULL); 440 err = nla_parse_nested(tb, TCA_ROUTE4_MAX, opt, route4_policy);
444 if (err < 0) 441 if (err < 0)
445 return err; 442 return err;
446 443