aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/sch_cbq.c
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2008-01-23 23:35:39 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:11:22 -0500
commit27a3421e4821734bc19496faa77b380605dc3b23 (patch)
treef9ded49845a39f41352ed09130bf3d2bd05e4ffe /net/sched/sch_cbq.c
parent5feb5e1aaa887f6427b8290bce48bfb6b7010fc6 (diff)
[NET_SCHED]: Use nla_policy for attribute validation in packet schedulers
Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/sch_cbq.c')
-rw-r--r--net/sched/sch_cbq.c47
1 files changed, 13 insertions, 34 deletions
diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c
index da0f6c0152de..09969c1fbc08 100644
--- a/net/sched/sch_cbq.c
+++ b/net/sched/sch_cbq.c
@@ -1377,6 +1377,16 @@ static int cbq_set_fopt(struct cbq_class *cl, struct tc_cbq_fopt *fopt)
1377 return 0; 1377 return 0;
1378} 1378}
1379 1379
1380static const struct nla_policy cbq_policy[TCA_CBQ_MAX + 1] = {
1381 [TCA_CBQ_LSSOPT] = { .len = sizeof(struct tc_cbq_lssopt) },
1382 [TCA_CBQ_WRROPT] = { .len = sizeof(struct tc_cbq_wrropt) },
1383 [TCA_CBQ_FOPT] = { .len = sizeof(struct tc_cbq_fopt) },
1384 [TCA_CBQ_OVL_STRATEGY] = { .len = sizeof(struct tc_cbq_ovl) },
1385 [TCA_CBQ_RATE] = { .len = sizeof(struct tc_ratespec) },
1386 [TCA_CBQ_RTAB] = { .type = NLA_BINARY, .len = TC_RTAB_SIZE },
1387 [TCA_CBQ_POLICE] = { .len = sizeof(struct tc_cbq_police) },
1388};
1389
1380static int cbq_init(struct Qdisc *sch, struct nlattr *opt) 1390static int cbq_init(struct Qdisc *sch, struct nlattr *opt)
1381{ 1391{
1382 struct cbq_sched_data *q = qdisc_priv(sch); 1392 struct cbq_sched_data *q = qdisc_priv(sch);
@@ -1384,16 +1394,11 @@ static int cbq_init(struct Qdisc *sch, struct nlattr *opt)
1384 struct tc_ratespec *r; 1394 struct tc_ratespec *r;
1385 int err; 1395 int err;
1386 1396
1387 err = nla_parse_nested(tb, TCA_CBQ_MAX, opt, NULL); 1397 err = nla_parse_nested(tb, TCA_CBQ_MAX, opt, cbq_policy);
1388 if (err < 0) 1398 if (err < 0)
1389 return err; 1399 return err;
1390 1400
1391 if (tb[TCA_CBQ_RTAB] == NULL || tb[TCA_CBQ_RATE] == NULL || 1401 if (tb[TCA_CBQ_RTAB] == NULL || tb[TCA_CBQ_RATE] == NULL)
1392 nla_len(tb[TCA_CBQ_RATE]) < sizeof(struct tc_ratespec))
1393 return -EINVAL;
1394
1395 if (tb[TCA_CBQ_LSSOPT] &&
1396 nla_len(tb[TCA_CBQ_LSSOPT]) < sizeof(struct tc_cbq_lssopt))
1397 return -EINVAL; 1402 return -EINVAL;
1398 1403
1399 r = nla_data(tb[TCA_CBQ_RATE]); 1404 r = nla_data(tb[TCA_CBQ_RATE]);
@@ -1771,36 +1776,10 @@ cbq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct nlattr **t
1771 if (opt == NULL) 1776 if (opt == NULL)
1772 return -EINVAL; 1777 return -EINVAL;
1773 1778
1774 err = nla_parse_nested(tb, TCA_CBQ_MAX, opt, NULL); 1779 err = nla_parse_nested(tb, TCA_CBQ_MAX, opt, cbq_policy);
1775 if (err < 0) 1780 if (err < 0)
1776 return err; 1781 return err;
1777 1782
1778 if (tb[TCA_CBQ_OVL_STRATEGY] &&
1779 nla_len(tb[TCA_CBQ_OVL_STRATEGY]) < sizeof(struct tc_cbq_ovl))
1780 return -EINVAL;
1781
1782 if (tb[TCA_CBQ_FOPT] &&
1783 nla_len(tb[TCA_CBQ_FOPT]) < sizeof(struct tc_cbq_fopt))
1784 return -EINVAL;
1785
1786 if (tb[TCA_CBQ_RATE] &&
1787 nla_len(tb[TCA_CBQ_RATE]) < sizeof(struct tc_ratespec))
1788 return -EINVAL;
1789
1790 if (tb[TCA_CBQ_LSSOPT] &&
1791 nla_len(tb[TCA_CBQ_LSSOPT]) < sizeof(struct tc_cbq_lssopt))
1792 return -EINVAL;
1793
1794 if (tb[TCA_CBQ_WRROPT] &&
1795 nla_len(tb[TCA_CBQ_WRROPT]) < sizeof(struct tc_cbq_wrropt))
1796 return -EINVAL;
1797
1798#ifdef CONFIG_NET_CLS_ACT
1799 if (tb[TCA_CBQ_POLICE] &&
1800 nla_len(tb[TCA_CBQ_POLICE]) < sizeof(struct tc_cbq_police))
1801 return -EINVAL;
1802#endif
1803
1804 if (cl) { 1783 if (cl) {
1805 /* Check parent */ 1784 /* Check parent */
1806 if (parentid) { 1785 if (parentid) {