From owner-svn-src-all@FreeBSD.ORG Thu Oct 30 12:44:47 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 5BF6D321; Thu, 30 Oct 2014 12:44:47 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3D19F6DD; Thu, 30 Oct 2014 12:44:47 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s9UCilKG008811; Thu, 30 Oct 2014 12:44:47 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s9UCiljl008810; Thu, 30 Oct 2014 12:44:47 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201410301244.s9UCiljl008810@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Thu, 30 Oct 2014 12:44:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r273858 - head/sys/netinet6 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Oct 2014 12:44:47 -0000 Author: ae Date: Thu Oct 30 12:44:46 2014 New Revision: 273858 URL: https://svnweb.freebsd.org/changeset/base/273858 Log: Remove redundant code. if_detach already did these steps. Also, now we didn't keep routes to link-local addresses. Obtained from: Yandex LLC Sponsored by: Yandex LLC Modified: head/sys/netinet6/in6_ifattach.c Modified: head/sys/netinet6/in6_ifattach.c ============================================================================== --- head/sys/netinet6/in6_ifattach.c Thu Oct 30 11:34:07 2014 (r273857) +++ head/sys/netinet6/in6_ifattach.c Thu Oct 30 12:44:46 2014 (r273858) @@ -775,12 +775,7 @@ in6_ifattach(struct ifnet *ifp, struct i void in6_ifdetach(struct ifnet *ifp) { - struct in6_ifaddr *ia; struct ifaddr *ifa, *next; - struct radix_node_head *rnh; - struct rtentry *rt; - struct sockaddr_in6 sin6; - struct in6_multi_mship *imm; if (ifp->if_afdata[AF_INET6] == NULL) return; @@ -788,46 +783,15 @@ in6_ifdetach(struct ifnet *ifp) /* remove neighbor management table */ nd6_purge(ifp); - /* nuke any of IPv6 addresses we have */ + /* + * nuke any of IPv6 addresses we have + * XXX: all addresses should be already removed + */ TAILQ_FOREACH_SAFE(ifa, &ifp->if_addrhead, ifa_link, next) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; in6_purgeaddr(ifa); } - - /* undo everything done by in6_ifattach(), just in case */ - TAILQ_FOREACH_SAFE(ifa, &ifp->if_addrhead, ifa_link, next) { - if (ifa->ifa_addr->sa_family != AF_INET6 - || !IN6_IS_ADDR_LINKLOCAL(&satosin6(&ifa->ifa_addr)->sin6_addr)) { - continue; - } - - ia = (struct in6_ifaddr *)ifa; - - /* - * leave from multicast groups we have joined for the interface - */ - while ((imm = LIST_FIRST(&ia->ia6_memberships)) != NULL) { - LIST_REMOVE(imm, i6mm_chain); - in6_leavegroup(imm); - } - - /* Remove link-local from the routing table. */ - if (ia->ia_flags & IFA_ROUTE) - (void)rtinit(&ia->ia_ifa, RTM_DELETE, ia->ia_flags); - - /* remove from the linked list */ - IF_ADDR_WLOCK(ifp); - TAILQ_REMOVE(&ifp->if_addrhead, ifa, ifa_link); - IF_ADDR_WUNLOCK(ifp); - ifa_free(ifa); /* if_addrhead */ - - IN6_IFADDR_WLOCK(); - TAILQ_REMOVE(&V_in6_ifaddrhead, ia, ia_link); - IN6_IFADDR_WUNLOCK(); - ifa_free(ifa); - } - in6_pcbpurgeif0(&V_udbinfo, ifp); in6_pcbpurgeif0(&V_ulitecbinfo, ifp); in6_pcbpurgeif0(&V_ripcbinfo, ifp); @@ -843,31 +807,6 @@ in6_ifdetach(struct ifnet *ifp) * (Or can we just delay calling nd6_purge until at this point?) */ nd6_purge(ifp); - - /* - * Remove route to link-local allnodes multicast (ff02::1). - * These only get automatically installed for the default FIB. - */ - bzero(&sin6, sizeof(sin6)); - sin6.sin6_len = sizeof(struct sockaddr_in6); - sin6.sin6_family = AF_INET6; - sin6.sin6_addr = in6addr_linklocal_allnodes; - if (in6_setscope(&sin6.sin6_addr, ifp, NULL)) - /* XXX: should not fail */ - return; - /* XXX grab lock first to avoid LOR */ - rnh = rt_tables_get_rnh(RT_DEFAULT_FIB, AF_INET6); - if (rnh != NULL) { - RADIX_NODE_HEAD_LOCK(rnh); - rt = in6_rtalloc1((struct sockaddr *)&sin6, 0, RTF_RNH_LOCKED, - RT_DEFAULT_FIB); - if (rt) { - if (rt->rt_ifp == ifp) - rt_expunge(rnh, rt); - RTFREE_LOCKED(rt); - } - RADIX_NODE_HEAD_UNLOCK(rnh); - } } int