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
This commit is contained in:
Andrey V. Elsukov 2014-10-30 12:44:46 +00:00
parent 3c268b3afc
commit 94a43496c2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=273858

View File

@ -775,12 +775,7 @@ in6_ifattach(struct ifnet *ifp, struct ifnet *altifp)
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