remove route to link-local allnodes multicast address (ff02:/32),

when the last IPv6 address on an interface is get removed.
in6_ifattach() configures it and in6_ifdetach() removes it.

XXX last part of in6_purgeaddr looks very ugly, but there's no event for
"interface detach" (events are for "address detach").
This commit is contained in:
itojun 2000-02-02 13:44:05 +00:00
parent cee0dfa2d5
commit 6f13dac00f
2 changed files with 29 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: in6.c,v 1.10 2000/02/01 22:52:10 thorpej Exp $ */
/* $NetBSD: in6.c,v 1.11 2000/02/02 13:44:05 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -946,6 +946,20 @@ in6_purgeaddr(ifa, ifp)
}
IFAFREE(&oia->ia_ifa);
/*
* if the interface is going away, and this was the last IPv6
* address on the interface, remove route to link-local
* allnodes multicast address
*/
if (ifp->if_output == if_nulloutput) {
/* was it the last IPv6 address for the interface? */
for (ifa = ifp->if_addrlist.tqh_first; ifa; ifa = ifa->ifa_list.tqe_next)
if (ifa->ifa_addr->sa_family == AF_INET6)
return;
in6_ifdetach(ifp);
}
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: in6_ifattach.c,v 1.15 2000/02/01 22:52:11 thorpej Exp $ */
/* $NetBSD: in6_ifattach.c,v 1.16 2000/02/02 13:44:06 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -619,6 +619,7 @@ in6_ifdetach(ifp)
struct ifaddr *ifa;
struct rtentry *rt;
short rtflags;
struct sockaddr_in6 sin6;
for (ifa = ifp->if_addrlist.tqh_first; ifa; ifa = ifa->ifa_list.tqe_next)
{
@ -662,4 +663,16 @@ in6_ifdetach(ifp)
free(ia, M_IFADDR);
}
/* remove route to link-local allnodes multicast (ff02::1) */
bzero(&sin6, sizeof(sin6));
sin6.sin6_len = sizeof(struct sockaddr_in6);
sin6.sin6_family = AF_INET6;
sin6.sin6_addr = in6addr_linklocal_allnodes;
sin6.sin6_addr.s6_addr16[1] = htons(ifp->if_index);
if ((rt = rtalloc1((struct sockaddr *)&sin6, 0)) != NULL) {
rtrequest(RTM_DELETE, (struct sockaddr *)rt_key(rt),
rt->rt_gateway, rt_mask(rt), rt->rt_flags, 0);
rtfree(rt);
}
}