summaryrefslogtreecommitdiff
path: root/sys/netinet
diff options
context:
space:
mode:
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/in.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/sys/netinet/in.c b/sys/netinet/in.c
index 3901a84ed9a..136dd5dcb1b 100644
--- a/sys/netinet/in.c
+++ b/sys/netinet/in.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in.c,v 1.77 2013/05/31 19:16:52 mpi Exp $ */
+/* $OpenBSD: in.c,v 1.78 2013/06/17 11:58:16 mpi Exp $ */
/* $NetBSD: in.c,v 1.26 1996/02/13 23:41:39 christos Exp $ */
/*
@@ -242,7 +242,6 @@ in_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp)
if (ia == NULL) {
ia = malloc(sizeof *ia, M_IFADDR, M_WAITOK | M_ZERO);
s = splsoftnet();
- TAILQ_INSERT_TAIL(&in_ifaddr, ia, ia_list);
ia->ia_addr.sin_family = AF_INET;
ia->ia_addr.sin_len = sizeof(ia->ia_addr);
ia->ia_ifa.ifa_addr = sintosa(&ia->ia_addr);
@@ -414,9 +413,10 @@ cleanup:
*/
s = splsoftnet();
in_ifscrub(ifp, ia);
- if (!error)
+ if (!error) {
ifa_del(ifp, &ia->ia_ifa);
- TAILQ_REMOVE(&in_ifaddr, ia, ia_list);
+ TAILQ_REMOVE(&in_ifaddr, ia, ia_list);
+ }
if (ia->ia_allhosts != NULL) {
in_delmulti(ia->ia_allhosts);
ia->ia_allhosts = NULL;
@@ -646,8 +646,10 @@ in_ifinit(struct ifnet *ifp, struct in_ifaddr *ia, struct sockaddr_in *sin,
struct sockaddr_in oldaddr;
int s = splnet(), flags = RTF_UP, error;
- if (!newaddr)
+ if (!newaddr) {
ifa_del(ifp, &ia->ia_ifa);
+ TAILQ_REMOVE(&in_ifaddr, ia, ia_list);
+ }
oldaddr = ia->ia_addr;
ia->ia_addr = *sin;
@@ -700,8 +702,8 @@ in_ifinit(struct ifnet *ifp, struct in_ifaddr *ia, struct sockaddr_in *sin,
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);
+ error = 0;
+ goto done;
}
flags |= RTF_HOST;
}
@@ -718,8 +720,11 @@ in_ifinit(struct ifnet *ifp, struct in_ifaddr *ia, struct sockaddr_in *sin,
ia->ia_allhosts = in_addmulti(&addr, ifp);
}
- if (!error)
+done:
+ if (!error) {
+ TAILQ_INSERT_TAIL(&in_ifaddr, ia, ia_list);
ifa_add(ifp, &ia->ia_ifa);
+ }
return (error);
}