diff options
author | Ryan Thomas McBride <mcbride@cvs.openbsd.org> | 2004-06-21 23:48:10 +0000 |
---|---|---|
committer | Ryan Thomas McBride <mcbride@cvs.openbsd.org> | 2004-06-21 23:48:10 +0000 |
commit | e84c5b85eb5d0fc9af7eb3cdcc77a22eb07dec74 (patch) | |
tree | 51534ef9f9d4c1de41d0167b839746dd78a8b24d | |
parent | c800006c610b6f3e26e521a294c102f738959eb0 (diff) |
When in_ifinit fails and we've created a new address, clean it up before
returning.
ok markus@
-rw-r--r-- | sys/netinet/in.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/sys/netinet/in.c b/sys/netinet/in.c index 32ed0e3c660..d16fe204290 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in.c,v 1.35 2004/05/31 10:48:48 mpf Exp $ */ +/* $OpenBSD: in.c,v 1.36 2004/06/21 23:48:09 mcbride Exp $ */ /* $NetBSD: in.c,v 1.26 1996/02/13 23:41:39 christos Exp $ */ /* @@ -274,6 +274,7 @@ in_control(so, cmd, data, ifp) TAILQ_INSERT_TAIL(&in_ifaddr, ia, ia_list); TAILQ_INSERT_TAIL(&ifp->if_addrlist, (struct ifaddr *)ia, ifa_list); + ia->ia_addr.sin_family = AF_INET; ia->ia_ifa.ifa_addr = sintosa(&ia->ia_addr); ia->ia_ifa.ifa_dstaddr = sintosa(&ia->ia_dstaddr); ia->ia_ifa.ifa_netmask = sintosa(&ia->ia_sockmask); @@ -372,6 +373,10 @@ in_control(so, cmd, data, ifp) error = in_ifinit(ifp, ia, satosin(&ifr->ifr_addr), 1); if (!error) dohooks(ifp->if_addrhooks, 0); + else if (newifaddr) { + splx(s); + goto cleanup; + } splx(s); return error; @@ -414,12 +419,18 @@ in_control(so, cmd, data, ifp) ia->ia_broadaddr = ifra->ifra_broadaddr; if (!error) dohooks(ifp->if_addrhooks, 0); + else if (newifaddr) { + splx(s); + goto cleanup; + } splx(s); return (error); case SIOCDIFADDR: { struct in_multi *inm; + error = 0; +cleanup: /* * Even if the individual steps were safe, shouldn't * these kinds of changes happen atomically? What @@ -435,7 +446,7 @@ in_control(so, cmd, data, ifp) IFAFREE((&ia->ia_ifa)); dohooks(ifp->if_addrhooks, 0); splx(s); - break; + return (error); } #ifdef MROUTING |