aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/cls_u32.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_u32.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_u32.c')
-rw-r--r--net/sched/cls_u32.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
index a4e72e8a882f..e8a775689123 100644
--- a/net/sched/cls_u32.c
+++ b/net/sched/cls_u32.c
@@ -460,6 +460,16 @@ static u32 gen_new_kid(struct tc_u_hnode *ht, u32 handle)
460 return handle|(i>0xFFF ? 0xFFF : i); 460 return handle|(i>0xFFF ? 0xFFF : i);
461} 461}
462 462
463static const struct nla_policy u32_policy[TCA_U32_MAX + 1] = {
464 [TCA_U32_CLASSID] = { .type = NLA_U32 },
465 [TCA_U32_HASH] = { .type = NLA_U32 },
466 [TCA_U32_LINK] = { .type = NLA_U32 },
467 [TCA_U32_DIVISOR] = { .type = NLA_U32 },
468 [TCA_U32_SEL] = { .len = sizeof(struct tc_u32_sel) },
469 [TCA_U32_INDEV] = { .type = NLA_STRING, .len = IFNAMSIZ },
470 [TCA_U32_MARK] = { .len = sizeof(struct tc_u32_mark) },
471};
472
463static int u32_set_parms(struct tcf_proto *tp, unsigned long base, 473static int u32_set_parms(struct tcf_proto *tp, unsigned long base,
464 struct tc_u_hnode *ht, 474 struct tc_u_hnode *ht,
465 struct tc_u_knode *n, struct nlattr **tb, 475 struct tc_u_knode *n, struct nlattr **tb,
@@ -531,7 +541,7 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle,
531 if (opt == NULL) 541 if (opt == NULL)
532 return handle ? -EINVAL : 0; 542 return handle ? -EINVAL : 0;
533 543
534 err = nla_parse_nested(tb, TCA_U32_MAX, opt, NULL); 544 err = nla_parse_nested(tb, TCA_U32_MAX, opt, u32_policy);
535 if (err < 0) 545 if (err < 0)
536 return err; 546 return err;
537 547
@@ -593,8 +603,7 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle,
593 } else 603 } else
594 handle = gen_new_kid(ht, htid); 604 handle = gen_new_kid(ht, htid);
595 605
596 if (tb[TCA_U32_SEL] == NULL || 606 if (tb[TCA_U32_SEL] == NULL)
597 nla_len(tb[TCA_U32_SEL]) < sizeof(struct tc_u32_sel))
598 return -EINVAL; 607 return -EINVAL;
599 608
600 s = nla_data(tb[TCA_U32_SEL]); 609 s = nla_data(tb[TCA_U32_SEL]);
@@ -620,13 +629,6 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle,
620 if (tb[TCA_U32_MARK]) { 629 if (tb[TCA_U32_MARK]) {
621 struct tc_u32_mark *mark; 630 struct tc_u32_mark *mark;
622 631
623 if (nla_len(tb[TCA_U32_MARK]) < sizeof(struct tc_u32_mark)) {
624#ifdef CONFIG_CLS_U32_PERF
625 kfree(n->pf);
626#endif
627 kfree(n);
628 return -EINVAL;
629 }
630 mark = nla_data(tb[TCA_U32_MARK]); 632 mark = nla_data(tb[TCA_U32_MARK]);
631 memcpy(&n->mark, mark, sizeof(struct tc_u32_mark)); 633 memcpy(&n->mark, mark, sizeof(struct tc_u32_mark));
632 n->mark.success = 0; 634 n->mark.success = 0;