]> rtime.felk.cvut.cz Git - lisovros/linux_canprio.git/commitdiff
sch_prio: Fix nla_parse_nested_compat() regression
authorThomas Graf <tgraf@suug.ch>
Wed, 3 Sep 2008 08:00:02 +0000 (01:00 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 8 Sep 2008 11:44:25 +0000 (04:44 -0700)
[ No upstream commit, this is fixing code no longer in 2.6.27 ]

nla_parse_nested_compat() was used to parse two different message
formats in the netem and prio qdisc, when it was "fixed" to work
with netem, it broke the multi queue support in the prio qdisc.
Since the prio qdisc code in question is already removed in the
development tree, this patch only fixes the regression in the
stable tree.

Based on original patch from Alexander H Duyck <alexander.h.duyck@intel.com>

Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
net/sched/sch_prio.c

index 5532f1031ab52fd3276f37b383967986de070ea9..ec0c92115ef8abd2082a1038a846702fe4b87713 100644 (file)
@@ -228,14 +228,20 @@ static int prio_tune(struct Qdisc *sch, struct nlattr *opt)
 {
        struct prio_sched_data *q = qdisc_priv(sch);
        struct tc_prio_qopt *qopt;
-       struct nlattr *tb[TCA_PRIO_MAX + 1];
+       struct nlattr *tb[TCA_PRIO_MAX + 1] = {0};
        int err;
        int i;
 
-       err = nla_parse_nested_compat(tb, TCA_PRIO_MAX, opt, NULL, qopt,
-                                     sizeof(*qopt));
-       if (err < 0)
-               return err;
+       qopt = nla_data(opt);
+       if (nla_len(opt) < sizeof(*qopt))
+               return -1;
+
+       if (nla_len(opt) >= sizeof(*qopt) + sizeof(struct nlattr)) {
+               err = nla_parse_nested(tb, TCA_PRIO_MAX,
+                                      (struct nlattr *) (qopt + 1), NULL);
+               if (err < 0)
+                       return err;
+       }
 
        q->bands = qopt->bands;
        /* If we're multiqueue, make sure the number of incoming bands