]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/sched/sch_red.c
Merge branches 'pxa-ian' and 'pxa-xm270' into pxa
[linux-2.6-omap-h63xx.git] / net / sched / sch_red.c
index 6ce8da5aca0ba64c902a989ef5725b96742093fd..5c569853b9c052967fbe9b2ca66f8e651985f206 100644 (file)
@@ -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]);
@@ -273,7 +281,8 @@ static int red_dump(struct Qdisc *sch, struct sk_buff *skb)
        return nla_nest_end(skb, opts);
 
 nla_put_failure:
-       return nla_nest_cancel(skb, opts);
+       nla_nest_cancel(skb, opts);
+       return -EMSGSIZE;
 }
 
 static int red_dump_stats(struct Qdisc *sch, struct gnet_dump *d)