Subject: I want to detach network interfaces now
To: None <firstname.lastname@example.org>
From: Lloyd Parkes <email@example.com>
Date: 10/13/1999 13:58:40
I between everything else in life, I still working on my driver for my
(MACE based) LiveWire PCMCIA card. All the boring stuff like reading and
writing data works, so I have been doing the other stuff at a slightly
less urgent pace.
One thing that has come up is detaching network interfaces. I know this
can't be done at the moment, and I saw a post recently where someone
mentioned it was being worked on. The problem I have is the sense of
moral outrage I feel knowing that I can make my laptop panic by removing
the PCMCIA card.
I decided to have a look at this night, and even though I was rather
tired, I did manage to fend the cat off long enough to get my laptop
out. I had a look at some things with some ideas in mind. Some of those
ideas have been discarded and replaced with new ideas. I would
appreciate any comments or corrections anybody has on this latest set of
When a PCMCIA device is removed, the autoconf code is told to perform a
forced detach of the device. If the detach fails, then the kernel panics
(guess who found this out the hard way). Once the device has been
detached, its softc is freed. This softc is usually contains the
interface struct (struct ifnet? can't remember offhand). Without
detaching the interface, we end up with pointers into this now freed
One obvious fix (spelled 'H', 'A', 'C', 'K') is to not free the softc.
Since we know by the device class whether or not it is a network device,
and we know that network interfaces can't be detached, we can even pick
and choose which softcs we free. There is still some tidying up that the
device specific detach function can do instead of calling if_detach().
For a start, it should probably remove the interface from the list of
interfaces. That way it will not appear when someone types ifconfig -l.
Should the address list for the interface be cut loose as well? I have
no idea what to do with any routes that might be in place. As a user I
would expect routes through (addresses on) interfaces to go away with
the interface, but I don't even know how to do this, let whether or not
I should do it.
As long as my laptop looks as if it is behaving itself without too much
cruft in the kernel, I'll be happy.
Lloyd Parkes, Network Manager, School of Earth Sciences
Victoria University of Wellington