Subject: Re: if_delete * if_alloc
To: Matt Thomas <firstname.lastname@example.org>
From: Bill Studenmund <email@example.com>
Date: 07/09/1997 17:53:06
> >Yes, this would be ok from the driver LKM point of view.
> >If I understand it correctly, it would boil down to a
> >function which is called by the driver at unload time
> >(let's call it detach function) and which tells if a given
> >ifnet can be freed. The (userland) unload program has
> >to retry in necessary.
> No it doesn't. The struct device of the driver should have a
> pointer to the internal kernel structure describing the lkm.
> The iffree should call device_release(struct device *) (ie. the
> softc) which can decrement a reference count, free the softc,
> and if 0, free the lkm. It would not be a half open lkm since
> all the forward pointers to the lkm should be cut.
One thing I'd like to point out about the if_detach stuff as I
see it: having iffree release an lkm could be done. But it would
be the decision of the lkm author. The if_detach patches are just
a way of getting us to where we can know when an interface
can be free'd.
It strikes me as a bit weird for the removal of an ifnet to cause the
unloading of an lkm driver. Say you have a pcmcia ethernet card, and
have the driver loaded as an lkm. Say you want to swap one version of
the card for another (someone pulled the plug out the back, and broke
or damaged the card in the process). So you hit the eject button and
pop in another one. Though it seems very reasonable for the interface
to get zapped in that case, it doesn't seem reasonable to me for the
lkm to get dumped. The lkm should only get dumped when root does a
modunload on it (in which case I think the driver unload should do a
sleep until all its ifnets are dead).