[NET]: Fix sch_api to properly set sch->parent on the root.
authorPatrick McHardy <trash@kaber.net>
Tue, 31 Jul 2007 00:11:50 +0000 (17:11 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Tue, 31 Jul 2007 09:28:19 +0000 (02:28 -0700)
Fix sch_api to correctly set sch->parent for both ingress and egress
qdiscs in qdisc_create().

Signed-off-by: Patrick McHardy <trash@kaber.net>
Signed-off-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/sch_api.c

index 13c09bc32aa32a10af58ec01eab462fab55958ba..dee0d5fb39c555a5f1f60eaaf4f4dd3df9ae666d 100644 (file)
@@ -380,6 +380,10 @@ void qdisc_tree_decrease_qlen(struct Qdisc *sch, unsigned int n)
                return;
        while ((parentid = sch->parent)) {
                sch = qdisc_lookup(sch->dev, TC_H_MAJ(parentid));
+               if (sch == NULL) {
+                       WARN_ON(parentid != TC_H_ROOT);
+                       return;
+               }
                cops = sch->ops->cl_ops;
                if (cops->qlen_notify) {
                        cl = cops->get(sch, parentid);
@@ -420,8 +424,6 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent,
                        unsigned long cl = cops->get(parent, classid);
                        if (cl) {
                                err = cops->graft(parent, cl, new, old);
-                               if (new)
-                                       new->parent = classid;
                                cops->put(parent, cl);
                        }
                }
@@ -436,7 +438,8 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent,
  */
 
 static struct Qdisc *
-qdisc_create(struct net_device *dev, u32 handle, struct rtattr **tca, int *errp)
+qdisc_create(struct net_device *dev, u32 parent, u32 handle,
+          struct rtattr **tca, int *errp)
 {
        int err;
        struct rtattr *kind = tca[TCA_KIND-1];
@@ -482,6 +485,8 @@ qdisc_create(struct net_device *dev, u32 handle, struct rtattr **tca, int *errp)
                goto err_out2;
        }
 
+       sch->parent = parent;
+
        if (handle == TC_H_INGRESS) {
                sch->flags |= TCQ_F_INGRESS;
                sch->stats_lock = &dev->ingress_lock;
@@ -758,9 +763,11 @@ create_n_graft:
        if (!(n->nlmsg_flags&NLM_F_CREATE))
                return -ENOENT;
        if (clid == TC_H_INGRESS)
-               q = qdisc_create(dev, tcm->tcm_parent, tca, &err);
+               q = qdisc_create(dev, tcm->tcm_parent, tcm->tcm_parent,
+                                tca, &err);
        else
-               q = qdisc_create(dev, tcm->tcm_handle, tca, &err);
+               q = qdisc_create(dev, tcm->tcm_parent, tcm->tcm_handle,
+                                tca, &err);
        if (q == NULL) {
                if (err == -EAGAIN)
                        goto replay;