From d39c3b5276f1080752417aae1e82557e11a6a9c5 Mon Sep 17 00:00:00 2001 From: Martin Pieuchot Date: Thu, 8 Aug 2013 07:39:14 +0000 Subject: Insert new IPv4 addresses in only one place, no functional change. ok mikeb@, henning@ --- sys/net/if_pppx.c | 3 +-- sys/netinet/in.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'sys') diff --git a/sys/net/if_pppx.c b/sys/net/if_pppx.c index fd6dcd82b78..1656a49eeb9 100644 --- a/sys/net/if_pppx.c +++ b/sys/net/if_pppx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pppx.c,v 1.23 2013/06/24 09:34:59 mpi Exp $ */ +/* $OpenBSD: if_pppx.c,v 1.24 2013/08/08 07:39:13 mpi Exp $ */ /* * Copyright (c) 2010 Claudio Jeker @@ -894,7 +894,6 @@ pppx_add_session(struct pppx_dev *pxd, struct pipex_session_req *req) ifaddr.sin_addr = req->pr_ip_srcaddr; ia = malloc(sizeof (*ia), M_IFADDR, M_WAITOK | M_ZERO); - TAILQ_INSERT_TAIL(&in_ifaddr, ia, ia_list); ia->ia_addr.sin_family = AF_INET; ia->ia_addr.sin_len = sizeof(struct sockaddr_in); 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; -- cgit v1.2.3