diff options
author | 2013-08-19 08:45:34 +0000 | |
---|---|---|
committer | 2013-08-19 08:45:34 +0000 | |
commit | 5edc58b70b65d8ea5f54449a5abf579cfb711bb8 (patch) | |
tree | df001f134c4375b4e252bb02ba596d7b80033bf2 | |
parent | Mark all the C functions called in real mode as non instrumented and (diff) | |
download | wireguard-openbsd-5edc58b70b65d8ea5f54449a5abf579cfb711bb8.tar.xz wireguard-openbsd-5edc58b70b65d8ea5f54449a5abf579cfb711bb8.zip |
In case something bad happened when configuring an IPv4 address, make
sure we add its descriptor back to the tree and interface list to keep
the various global structures consistent.
ok mikeb@, bluhm@
-rw-r--r-- | sys/netinet/in.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/sys/netinet/in.c b/sys/netinet/in.c index 5e4e2185103..61a913fe97b 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in.c,v 1.82 2013/08/08 07:39:13 mpi Exp $ */ +/* $OpenBSD: in.c,v 1.83 2013/08/19 08:45:34 mpi Exp $ */ /* $NetBSD: in.c,v 1.26 1996/02/13 23:41:39 christos Exp $ */ /* @@ -411,8 +411,7 @@ cleanup: */ s = splsoftnet(); in_ifscrub(ifp, ia); - if (!error) - ifa_del(ifp, &ia->ia_ifa); + ifa_del(ifp, &ia->ia_ifa); TAILQ_REMOVE(&in_ifaddr, ia, ia_list); if (ia->ia_allhosts != NULL) { in_delmulti(ia->ia_allhosts); @@ -641,7 +640,7 @@ in_ifinit(struct ifnet *ifp, struct in_ifaddr *ia, struct sockaddr_in *sin, { u_int32_t i = sin->sin_addr.s_addr; struct sockaddr_in oldaddr; - int s = splnet(), flags = RTF_UP, error; + int s = splnet(), flags = RTF_UP, error = 0; if (newaddr) TAILQ_INSERT_TAIL(&in_ifaddr, ia, ia_list); @@ -664,7 +663,7 @@ in_ifinit(struct ifnet *ifp, struct in_ifaddr *ia, struct sockaddr_in *sin, (error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, (caddr_t)ia))) { ia->ia_addr = oldaddr; splx(s); - return (error); + goto out; } splx(s); @@ -703,10 +702,8 @@ in_ifinit(struct ifnet *ifp, struct in_ifaddr *ia, struct sockaddr_in *sin, ia->ia_dstaddr = ia->ia_addr; flags |= RTF_HOST; } else if (ifp->if_flags & IFF_POINTOPOINT) { - if (ia->ia_dstaddr.sin_family != AF_INET) { - ifa_add(ifp, &ia->ia_ifa); - return (0); - } + if (ia->ia_dstaddr.sin_family != AF_INET) + goto out; flags |= RTF_HOST; } error = in_addprefix(ia, flags); @@ -722,8 +719,17 @@ in_ifinit(struct ifnet *ifp, struct in_ifaddr *ia, struct sockaddr_in *sin, ia->ia_allhosts = in_addmulti(&addr, ifp); } - if (!error) - ifa_add(ifp, &ia->ia_ifa); +out: + /* + * Add the address to the local list and the global tree + * even if an error occured to make sure the various + * global structures are consistent. + * + * XXX This is necessary because we added the address + * to the global list in the first place because of + * carp(4). + */ + ifa_add(ifp, &ia->ia_ifa); return (error); } |