Ethernet driver teardown
M. Warner Losh
imp at bsdimp.com
Mon Oct 3 10:24:45 PDT 2005
In message: <200510031246.14835.jhb at FreeBSD.org>
John Baldwin <jhb at FreeBSD.org> writes:
: So, I was thinking about the problem with ethernet driver detach races this
: morning and had an idea. What if the sequence for detach() was altered such
: that we called ether_ifdetach() before the driver's stop() routine? Thus,
: you would end up with something like this:
:
: foo_detach()
: {
:
: ether_ifdetach(sc->foo_ifp);
: FOO_LOCK(sc);
: foo_stop(sc);
ifp->if_drv_flags &= ~IFF_DRV_RUNNING; /* or does foo_stop do this? */
: FOO_UNLOCK(sc);
: callout_drain(...);
: bus_teardown_intr(...);
: if_free(sc->foo_ifp);
: bus_release_resources(...);
: ...
: }
:
: Would that solve the various races including letting BPF turn off promiscuous
: mode cleanly without requiring detaching flags in each driver to bail out of
: foo_ioctl()?
I'm unusure. I'm prettys sure that the promisc mode would be turned
off correctly, but see below.
This does represent an improvement over the current method. I have a
couple of concerns.
(1) What happens to the packets received when the device is detached.
We'll have to make sure that the ifp is in a state that can allow
for the input routine to still be called w/o leaking memory.
(2) Does this solve the problems that I originally suggested a
if_dead() routine for?
(3) How do we know that we're out of all the ifp callbacks when
ether_ifdetach() returns? If we forced a lock/unlock pair for all
ioctl functions, then we could know for sure when we acquire the
lock. I'm unsure what to do about if_output, if_start and
if_watchdog.
Warner
More information about the freebsd-arch
mailing list