pkt_sched: Add 'deactivated' state.
authorDavid S. Miller <davem@davemloft.net>
Mon, 18 Aug 2008 04:51:03 +0000 (21:51 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 18 Aug 2008 04:51:03 +0000 (21:51 -0700)
This new state lets dev_deactivate() mark a qdisc as having been
deactivated.

dev_queue_xmit() and ing_filter() check for this bit and do not
try to process the qdisc if the bit is set.

dev_deactivate() polls the qdisc after setting the bit, waiting
for both __QDISC_STATE_RUNNING and __QDISC_STATE_SCHED to clear.

This isn't perfect yet, but subsequent changesets will make it so.
This part is just one piece of the puzzle.

Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/sch_generic.h
net/core/dev.c
net/sched/sch_generic.c

index a7abfda3e447896a0be5b06ed1809aa6e0b185fb..757ab087adbf758097e34113a1901ae82c77c038 100644 (file)
@@ -27,6 +27,7 @@ enum qdisc_state_t
 {
        __QDISC_STATE_RUNNING,
        __QDISC_STATE_SCHED,
+       __QDISC_STATE_DEACTIVATED,
 };
 
 struct qdisc_size_table {
index 600bb23c4c2e3743239dc571c459fe3a5e8b19d5..d9e31f63aded8a8a7ac346b663884bf8c5e8f3d4 100644 (file)
@@ -1800,6 +1800,12 @@ gso:
 
                spin_lock(root_lock);
 
+               if (unlikely(test_bit(__QDISC_STATE_DEACTIVATED, &q->state))) {
+                       spin_unlock(root_lock);
+                       rc = NET_XMIT_DROP;
+                       goto out_kfree_skb;
+               }
+
                rc = qdisc_enqueue_root(skb, q);
                qdisc_run(q);
 
@@ -2084,7 +2090,8 @@ static int ing_filter(struct sk_buff *skb)
        q = rxq->qdisc;
        if (q != &noop_qdisc) {
                spin_lock(qdisc_lock(q));
-               result = qdisc_enqueue_root(skb, q);
+               if (likely(!test_bit(__QDISC_STATE_DEACTIVATED, &q->state)))
+                       result = qdisc_enqueue_root(skb, q);
                spin_unlock(qdisc_lock(q));
        }
 
index 468574682caab154eba2d8f35b09de3f8272522e..ff1c4557e5f877871479967b9498b0073a18cea0 100644 (file)
@@ -597,6 +597,9 @@ static void transition_one_qdisc(struct net_device *dev,
        struct Qdisc *new_qdisc = dev_queue->qdisc_sleeping;
        int *need_watchdog_p = _need_watchdog;
 
+       if (!(new_qdisc->flags & TCQ_F_BUILTIN))
+               clear_bit(__QDISC_STATE_DEACTIVATED, &new_qdisc->state);
+
        rcu_assign_pointer(dev_queue->qdisc, new_qdisc);
        if (need_watchdog_p && new_qdisc != &noqueue_qdisc)
                *need_watchdog_p = 1;
@@ -640,6 +643,9 @@ static void dev_deactivate_queue(struct net_device *dev,
        if (qdisc) {
                spin_lock_bh(qdisc_lock(qdisc));
 
+               if (!(qdisc->flags & TCQ_F_BUILTIN))
+                       set_bit(__QDISC_STATE_DEACTIVATED, &qdisc->state);
+
                dev_queue->qdisc = qdisc_default;
                qdisc_reset(qdisc);