aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/sch_hfsc.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_hfsc.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_hfsc.c')
-rw-r--r--net/sched/sch_hfsc.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c
index 10a2f35a27a8..87293d0db1d7 100644
--- a/net/sched/sch_hfsc.c
+++ b/net/sched/sch_hfsc.c
@@ -986,6 +986,12 @@ hfsc_change_usc(struct hfsc_class *cl, struct tc_service_curve *usc,
986 cl->cl_flags |= HFSC_USC; 986 cl->cl_flags |= HFSC_USC;
987} 987}
988 988
989static const struct nla_policy hfsc_policy[TCA_HFSC_MAX + 1] = {
990 [TCA_HFSC_RSC] = { .len = sizeof(struct tc_service_curve) },
991 [TCA_HFSC_FSC] = { .len = sizeof(struct tc_service_curve) },
992 [TCA_HFSC_USC] = { .len = sizeof(struct tc_service_curve) },
993};
994
989static int 995static int
990hfsc_change_class(struct Qdisc *sch, u32 classid, u32 parentid, 996hfsc_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
991 struct nlattr **tca, unsigned long *arg) 997 struct nlattr **tca, unsigned long *arg)
@@ -1002,29 +1008,23 @@ hfsc_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
1002 if (opt == NULL) 1008 if (opt == NULL)
1003 return -EINVAL; 1009 return -EINVAL;
1004 1010
1005 err = nla_parse_nested(tb, TCA_HFSC_MAX, opt, NULL); 1011 err = nla_parse_nested(tb, TCA_HFSC_MAX, opt, hfsc_policy);
1006 if (err < 0) 1012 if (err < 0)
1007 return err; 1013 return err;
1008 1014
1009 if (tb[TCA_HFSC_RSC]) { 1015 if (tb[TCA_HFSC_RSC]) {
1010 if (nla_len(tb[TCA_HFSC_RSC]) < sizeof(*rsc))
1011 return -EINVAL;
1012 rsc = nla_data(tb[TCA_HFSC_RSC]); 1016 rsc = nla_data(tb[TCA_HFSC_RSC]);
1013 if (rsc->m1 == 0 && rsc->m2 == 0) 1017 if (rsc->m1 == 0 && rsc->m2 == 0)
1014 rsc = NULL; 1018 rsc = NULL;
1015 } 1019 }
1016 1020
1017 if (tb[TCA_HFSC_FSC]) { 1021 if (tb[TCA_HFSC_FSC]) {
1018 if (nla_len(tb[TCA_HFSC_FSC]) < sizeof(*fsc))
1019 return -EINVAL;
1020 fsc = nla_data(tb[TCA_HFSC_FSC]); 1022 fsc = nla_data(tb[TCA_HFSC_FSC]);
1021 if (fsc->m1 == 0 && fsc->m2 == 0) 1023 if (fsc->m1 == 0 && fsc->m2 == 0)
1022 fsc = NULL; 1024 fsc = NULL;
1023 } 1025 }
1024 1026
1025 if (tb[TCA_HFSC_USC]) { 1027 if (tb[TCA_HFSC_USC]) {
1026 if (nla_len(tb[TCA_HFSC_USC]) < sizeof(*usc))
1027 return -EINVAL;
1028 usc = nla_data(tb[TCA_HFSC_USC]); 1028 usc = nla_data(tb[TCA_HFSC_USC]);
1029 if (usc->m1 == 0 && usc->m2 == 0) 1029 if (usc->m1 == 0 && usc->m2 == 0)
1030 usc = NULL; 1030 usc = NULL;