fixed a kernel crash by "ifconfig stf0 inet 1.2.3.4"

MFC after:	1 week
This commit is contained in:
SUZUKI Shinsuke 2002-10-22 22:50:38 +00:00
parent 3c2486a77c
commit 2754d95d85

View File

@ -664,7 +664,12 @@ in_ifinit(ifp, ia, sin, scrub)
int s = splimp(), flags = RTF_UP, error = 0;
oldaddr = ia->ia_addr;
if (oldaddr.sin_family == AF_INET)
LIST_REMOVE(ia, ia_hash);
ia->ia_addr = *sin;
if (ia->ia_addr.sin_family == AF_INET)
LIST_INSERT_HEAD(INADDR_HASH(ia->ia_addr.sin_addr.s_addr),
ia, ia_hash);
/*
* Give the interface a chance to initialize
* if this is its first address,
@ -673,14 +678,13 @@ in_ifinit(ifp, ia, sin, scrub)
if (ifp->if_ioctl &&
(error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, (caddr_t)ia))) {
splx(s);
/* LIST_REMOVE(ia, ia_hash) is done in in_control */
ia->ia_addr = oldaddr;
if (ia->ia_addr.sin_family == AF_INET)
LIST_INSERT_HEAD(INADDR_HASH(ia->ia_addr.sin_addr.s_addr),
ia, ia_hash);
return (error);
}
if (oldaddr.sin_family == AF_INET)
LIST_REMOVE(ia, ia_hash);
if (ia->ia_addr.sin_family == AF_INET)
LIST_INSERT_HEAD(INADDR_HASH(ia->ia_addr.sin_addr.s_addr),
ia, ia_hash);
splx(s);
if (scrub) {
ia->ia_ifa.ifa_addr = (struct sockaddr *)&oldaddr;