summaryrefslogtreecommitdiff
path: root/sys/netinet/in.c
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2013-08-08 07:39:14 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2013-08-08 07:39:14 +0000
commitd39c3b5276f1080752417aae1e82557e11a6a9c5 (patch)
treec06ff9fe9ccba7eb55921e74d1f2e5873d7b1323 /sys/netinet/in.c
parent22562d85c38d4b12fba904eb2fb4620cb66702a8 (diff)
Insert new IPv4 addresses in only one place, no functional change.
ok mikeb@, henning@
Diffstat (limited to 'sys/netinet/in.c')
-rw-r--r--sys/netinet/in.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/sys/netinet/in.c b/sys/netinet/in.c
index 02babe701ce..5e4e2185103 100644
--- a/sys/netinet/in.c
+++ b/sys/netinet/in.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in.c,v 1.81 2013/06/23 16:30:46 sthen Exp $ */
+/* $OpenBSD: in.c,v 1.82 2013/08/08 07:39:13 mpi Exp $ */
/* $NetBSD: in.c,v 1.26 1996/02/13 23:41:39 christos Exp $ */
/*
@@ -241,8 +241,6 @@ in_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp)
panic("in_control");
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);
@@ -255,7 +253,6 @@ in_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp)
}
ia->ia_ifp = ifp;
LIST_INIT(&ia->ia_multiaddrs);
- splx(s);
newifaddr = 1;
} else
@@ -646,6 +643,13 @@ 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)
+ TAILQ_INSERT_TAIL(&in_ifaddr, ia, ia_list);
+
+ /*
+ * Always remove the address from the tree to make sure its
+ * position gets updated in case the key changes.
+ */
if (!newaddr)
ifa_del(ifp, &ia->ia_ifa);
oldaddr = ia->ia_addr;