]> bbs.cooldavid.org Git - net-next-2.6.git/commit - net/core/dev.c
[NET]: Prevent transmission after dev_deactivate
authorHerbert Xu <herbert@gondor.apana.org.au>
Thu, 22 Jun 2006 09:28:18 +0000 (02:28 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Fri, 23 Jun 2006 09:07:26 +0000 (02:07 -0700)
commitd4828d85d188dc70ed172802e798d3978bb6e29e
tree11e70b1c93b25c5e2c9a1547e23086fc9a76d287
parent5e2707fa3aed8c24075087cbaea2628725adbe55
[NET]: Prevent transmission after dev_deactivate

The dev_deactivate function has bit-rotted since the introduction of
lockless drivers.  In particular, the spin_unlock_wait call at the end
has no effect on the xmit routine of lockless drivers.

With a little bit of work, we can make it much more useful by providing
the guarantee that when it returns, no more calls to the xmit routine
of the underlying driver will be made.

The idea is simple.  There are two entry points in to the xmit routine.
The first comes from dev_queue_xmit.  That one is easily stopped by
using synchronize_rcu.  This works because we set the qdisc to noop_qdisc
before the synchronize_rcu call.  That in turn causes all subsequent
packets sent to dev_queue_xmit to be dropped.  The synchronize_rcu call
also ensures all outstanding calls leave their critical section.

The other entry point is from qdisc_run.  Since we now have a bit that
indicates whether it's running, all we have to do is to wait until the
bit is off.

I've removed the loop to wait for __LINK_STATE_SCHED to clear.  This is
useless because netif_wake_queue can cause it to be set again.  It is
also harmless because we've disarmed qdisc_run.

I've also removed the spin_unlock_wait on xmit_lock because its only
purpose of making sure that all outstanding xmit_lock holders have
exited is also given by dev_watchdog_down.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/dev.c
net/sched/sch_generic.c