Skip to content
Browse files

fixed a kernel crash when ifp->if_ioctl(SIOCSIFADDR) returns an error…

… at IPv4 address addition or change. (e.g. "ifconfig stf0 inet 1.2.3.4")
  • Loading branch information...
1 parent bfac6b6 commit 92d76f8c66d5393e5430ee1099c4a0e50c79c23f suz committed Oct 22, 2002
Showing with 9 additions and 5 deletions.
  1. +9 −5 freebsd4/sys/netinet/in.c
View
14 freebsd4/sys/netinet/in.c
@@ -729,7 +729,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,
@@ -738,14 +743,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;

0 comments on commit 92d76f8

Please sign in to comment.
Something went wrong with that request. Please try again.