X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=net%2Fsched%2Fsch_red.c;h=3dcd493f4f4a93b6d1e064f8214d83082cfee31b;hb=7524d7d6de5d5d3f081de8cf5479819fad339661;hp=6ce8da5aca0ba64c902a989ef5725b96742093fd;hpb=1e90474c377e92db7262a8968a45c1dd980ca9e5;p=linux-2.6 diff --git a/net/sched/sch_red.c b/net/sched/sch_red.c index 6ce8da5aca..3dcd493f4f 100644 --- a/net/sched/sch_red.c +++ b/net/sched/sch_red.c @@ -201,20 +201,28 @@ static struct Qdisc *red_create_dflt(struct Qdisc *sch, u32 limit) return NULL; } +static const struct nla_policy red_policy[TCA_RED_MAX + 1] = { + [TCA_RED_PARMS] = { .len = sizeof(struct tc_red_qopt) }, + [TCA_RED_STAB] = { .len = RED_STAB_SIZE }, +}; + static int red_change(struct Qdisc *sch, struct nlattr *opt) { struct red_sched_data *q = qdisc_priv(sch); struct nlattr *tb[TCA_RED_MAX + 1]; struct tc_red_qopt *ctl; struct Qdisc *child = NULL; + int err; - if (opt == NULL || nla_parse_nested(tb, TCA_RED_MAX, opt, NULL)) + if (opt == NULL) return -EINVAL; + err = nla_parse_nested(tb, TCA_RED_MAX, opt, red_policy); + if (err < 0) + return err; + if (tb[TCA_RED_PARMS] == NULL || - nla_len(tb[TCA_RED_PARMS]) < sizeof(*ctl) || - tb[TCA_RED_STAB] == NULL || - nla_len(tb[TCA_RED_STAB]) < RED_STAB_SIZE) + tb[TCA_RED_STAB] == NULL) return -EINVAL; ctl = nla_data(tb[TCA_RED_PARMS]);