Add some gross ad-hock hacks to increase stability of if_detach:

o be more careful about clearing addresses (this isn't a kludge)
o For AF_INET interfaces, call SIOCDIFFADDR to remove last(?) bit
  of cruft.

Special cases for AF_INET shouldn't be here, but I didn't see a good
generic way of doing this.  If I missed something, please let me know.

This gross hack makes pccard ejection stable for ethernet cards.

Submitted by: Atushi Onoe-san
This commit is contained in:
imp 1999-12-10 16:31:25 +00:00
parent a0aeba94d4
commit 108333f0a4

View File

@ -227,12 +227,27 @@ if_detach(ifp)
* Remove address from ifnet_addrs[] and maybe decrement if_index.
* Clean up all addresses.
*/
ifnet_addrs[ifp->if_index] = 0;
while (ifnet_addrs[if_index] == 0)
ifnet_addrs[ifp->if_index - 1] = 0;
while (if_index > 0 && ifnet_addrs[if_index - 1] == 0)
if_index--;
for (ifa = TAILQ_FIRST(&ifp->if_addrhead); ifa;
ifa = TAILQ_FIRST(&ifp->if_addrhead)) {
#if 1 /* ONOE */
/* XXX: Ugly!! ad hoc just for INET */
if (ifa->ifa_addr && ifa->ifa_addr->sa_family == AF_INET) {
struct ifaliasreq ifr;
bzero(&ifr, sizeof(ifr));
if (ifa->ifa_addr)
ifr.ifra_addr = *ifa->ifa_addr;
if (ifa->ifa_dstaddr)
ifr.ifra_broadaddr = *ifa->ifa_dstaddr;
if (in_control(NULL, SIOCDIFADDR, (caddr_t)&ifr, ifp,
NULL) == 0)
continue;
}
#endif /* ONOE */
TAILQ_REMOVE(&ifp->if_addrhead, ifa, ifa_link);
IFAFREE(ifa);
}