pkt_sched: Grab correct lock in notify_and_destroy().
[pandora-kernel.git] / net / sched / sch_api.c
index 4840aff..c8dc72e 100644 (file)
@@ -183,24 +183,34 @@ EXPORT_SYMBOL(unregister_qdisc);
    (root qdisc, all its children, children of children etc.)
  */
 
+struct Qdisc *qdisc_match_from_root(struct Qdisc *root, u32 handle)
+{
+       struct Qdisc *q;
+
+       if (!(root->flags & TCQ_F_BUILTIN) &&
+           root->handle == handle)
+               return root;
+
+       list_for_each_entry(q, &root->list, list) {
+               if (q->handle == handle)
+                       return q;
+       }
+       return NULL;
+}
+
 struct Qdisc *qdisc_lookup(struct net_device *dev, u32 handle)
 {
        unsigned int i;
 
        for (i = 0; i < dev->num_tx_queues; i++) {
                struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
-               struct Qdisc *q, *txq_root = txq->qdisc;
+               struct Qdisc *q, *txq_root = txq->qdisc_sleeping;
 
-               if (!(txq_root->flags & TCQ_F_BUILTIN) &&
-                   txq_root->handle == handle)
-                       return txq_root;
-
-               list_for_each_entry(q, &txq_root->list, list) {
-                       if (q->handle == handle)
-                               return q;
-               }
+               q = qdisc_match_from_root(txq_root, handle);
+               if (q)
+                       return q;
        }
-       return NULL;
+       return qdisc_match_from_root(dev->rx_queue.qdisc_sleeping, handle);
 }
 
 static struct Qdisc *qdisc_leaf(struct Qdisc *p, u32 classid)
@@ -321,7 +331,7 @@ static struct qdisc_size_table *qdisc_get_stab(struct nlattr *opt)
        if (!s || tsize != s->tsize || (!tab && tsize > 0))
                return ERR_PTR(-EINVAL);
 
-       spin_lock(&qdisc_stab_lock);
+       spin_lock_bh(&qdisc_stab_lock);
 
        list_for_each_entry(stab, &qdisc_stab_list, list) {
                if (memcmp(&stab->szopts, s, sizeof(*s)))
@@ -329,11 +339,11 @@ static struct qdisc_size_table *qdisc_get_stab(struct nlattr *opt)
                if (tsize > 0 && memcmp(stab->data, tab, tsize * sizeof(u16)))
                        continue;
                stab->refcnt++;
-               spin_unlock(&qdisc_stab_lock);
+               spin_unlock_bh(&qdisc_stab_lock);
                return stab;
        }
 
-       spin_unlock(&qdisc_stab_lock);
+       spin_unlock_bh(&qdisc_stab_lock);
 
        stab = kmalloc(sizeof(*stab) + tsize * sizeof(u16), GFP_KERNEL);
        if (!stab)
@@ -344,9 +354,9 @@ static struct qdisc_size_table *qdisc_get_stab(struct nlattr *opt)
        if (tsize > 0)
                memcpy(stab->data, tab, tsize * sizeof(u16));
 
-       spin_lock(&qdisc_stab_lock);
+       spin_lock_bh(&qdisc_stab_lock);
        list_add_tail(&stab->list, &qdisc_stab_list);
-       spin_unlock(&qdisc_stab_lock);
+       spin_unlock_bh(&qdisc_stab_lock);
 
        return stab;
 }
@@ -356,14 +366,14 @@ void qdisc_put_stab(struct qdisc_size_table *tab)
        if (!tab)
                return;
 
-       spin_lock(&qdisc_stab_lock);
+       spin_lock_bh(&qdisc_stab_lock);
 
        if (--tab->refcnt == 0) {
                list_del(&tab->list);
                kfree(tab);
        }
 
-       spin_unlock(&qdisc_stab_lock);
+       spin_unlock_bh(&qdisc_stab_lock);
 }
 EXPORT_SYMBOL(qdisc_put_stab);
 
@@ -628,9 +638,9 @@ static void notify_and_destroy(struct sk_buff *skb, struct nlmsghdr *n, u32 clid
                qdisc_notify(skb, n, clid, old, new);
 
        if (old) {
-               spin_lock_bh(&old->q.lock);
+               sch_tree_lock(old);
                qdisc_destroy(old);
-               spin_unlock_bh(&old->q.lock);
+               sch_tree_unlock(old);
        }
 }
 
@@ -792,8 +802,8 @@ qdisc_create(struct net_device *dev, struct netdev_queue *dev_queue,
                                goto err_out3;
                        }
                }
-               if (parent && !(sch->flags & TCQ_F_INGRESS))
-                       list_add_tail(&sch->list, &dev_queue->qdisc->list);
+               if ((parent != TC_H_ROOT) && !(sch->flags & TCQ_F_INGRESS))
+                       list_add_tail(&sch->list, &dev_queue->qdisc_sleeping->list);
 
                return sch;
        }
@@ -908,7 +918,7 @@ static int tc_get_qdisc(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
                                        return -ENOENT;
                                q = qdisc_leaf(p, clid);
                        } else { /* ingress */
-                               q = dev->rx_queue.qdisc;
+                               q = dev->rx_queue.qdisc_sleeping;
                        }
                } else {
                        struct netdev_queue *dev_queue;
@@ -978,7 +988,7 @@ replay:
                                        return -ENOENT;
                                q = qdisc_leaf(p, clid);
                        } else { /*ingress */
-                               q = dev->rx_queue.qdisc;
+                               q = dev->rx_queue.qdisc_sleeping;
                        }
                } else {
                        struct netdev_queue *dev_queue;
@@ -1236,11 +1246,11 @@ static int tc_dump_qdisc(struct sk_buff *skb, struct netlink_callback *cb)
                q_idx = 0;
 
                dev_queue = netdev_get_tx_queue(dev, 0);
-               if (tc_dump_qdisc_root(dev_queue->qdisc, skb, cb, &q_idx, s_q_idx) < 0)
+               if (tc_dump_qdisc_root(dev_queue->qdisc_sleeping, skb, cb, &q_idx, s_q_idx) < 0)
                        goto done;
 
                dev_queue = &dev->rx_queue;
-               if (tc_dump_qdisc_root(dev_queue->qdisc, skb, cb, &q_idx, s_q_idx) < 0)
+               if (tc_dump_qdisc_root(dev_queue->qdisc_sleeping, skb, cb, &q_idx, s_q_idx) < 0)
                        goto done;
 
 cont:
@@ -1529,11 +1539,11 @@ static int tc_dump_tclass(struct sk_buff *skb, struct netlink_callback *cb)
        t = 0;
 
        dev_queue = netdev_get_tx_queue(dev, 0);
-       if (tc_dump_tclass_root(dev_queue->qdisc, skb, tcm, cb, &t, s_t) < 0)
+       if (tc_dump_tclass_root(dev_queue->qdisc_sleeping, skb, tcm, cb, &t, s_t) < 0)
                goto done;
 
        dev_queue = &dev->rx_queue;
-       if (tc_dump_tclass_root(dev_queue->qdisc, skb, tcm, cb, &t, s_t) < 0)
+       if (tc_dump_tclass_root(dev_queue->qdisc_sleeping, skb, tcm, cb, &t, s_t) < 0)
                goto done;
 
 done: