Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netinet6 remove route to link-local allnodes multicast a...



details:   https://anonhg.NetBSD.org/src/rev/8a7582885c81
branches:  trunk
changeset: 481600:8a7582885c81
user:      itojun <itojun%NetBSD.org@localhost>
date:      Wed Feb 02 13:44:05 2000 +0000

description:
remove route to link-local allnodes multicast address (ff02:x::/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").

diffstat:

 sys/netinet6/in6.c          |  16 +++++++++++++++-
 sys/netinet6/in6_ifattach.c |  15 ++++++++++++++-
 2 files changed, 29 insertions(+), 2 deletions(-)

diffs (64 lines):

diff -r c73d4e5c7612 -r 8a7582885c81 sys/netinet6/in6.c
--- a/sys/netinet6/in6.c        Wed Feb 02 13:22:07 2000 +0000
+++ b/sys/netinet6/in6.c        Wed Feb 02 13:44:05 2000 +0000
@@ -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 @@
        }
 
        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);
+       }
 }
 
 /*
diff -r c73d4e5c7612 -r 8a7582885c81 sys/netinet6/in6_ifattach.c
--- a/sys/netinet6/in6_ifattach.c       Wed Feb 02 13:22:07 2000 +0000
+++ b/sys/netinet6/in6_ifattach.c       Wed Feb 02 13:44:05 2000 +0000
@@ -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 @@
        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 @@
 
                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);
+       }
 }



Home | Main Index | Thread Index | Old Index