From f88a4ba1c1ad595fb9d578a46f445c17b742daf5 Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Mon, 27 Jul 2015 22:47:58 +0800 Subject: [PATCH] inet6: No need to explicitly avoid calling ioctl(SIOCSADDR) Rearrange the code a little bit. --- sys/netinet6/in6.c | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c index f169e3938b..532bc169cf 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -1632,34 +1632,18 @@ static int in6_ifinit(struct ifnet *ifp, struct in6_ifaddr *ia, struct sockaddr_in6 *sin6, int newhost) { - int error = 0, plen, ifacount = 0; - struct ifaddr_container *ifac; - - /* - * Give the interface a chance to initialize - * if this is its first address, - * and to validate the address if necessary. - */ - TAILQ_FOREACH(ifac, &ifp->if_addrheads[mycpuid], ifa_link) { - if (ifac->ifa->ifa_addr == NULL) - continue; /* just for safety */ - if (ifac->ifa->ifa_addr->sa_family != AF_INET6) - continue; - ifacount++; - } - - ifnet_serialize_all(ifp); + int error = 0, plen; ia->ia_addr = *sin6; - if (ifacount <= 1 && ifp->if_ioctl && - (error = ifp->if_ioctl(ifp, SIOCSIFADDR, (caddr_t)ia, NULL))) { + if (ifp->if_ioctl != NULL) { + ifnet_serialize_all(ifp); + error = ifp->if_ioctl(ifp, SIOCSIFADDR, (caddr_t)ia, NULL); ifnet_deserialize_all(ifp); - return (error); + if (error) + return (error); } - ifnet_deserialize_all(ifp); - ia->ia_ifa.ifa_metric = ifp->if_metric; /* we could do in(6)_socktrim here, but just omit it at this moment. */ -- 2.41.0