Source-Changes-HG archive

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

[src/trunk]: src/sys/netinet6 Remove redundant codes purging IPv6 addresses



details:   https://anonhg.NetBSD.org/src/rev/7387b6a5037d
branches:  trunk
changeset: 346255:7387b6a5037d
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Mon Jul 04 02:41:18 2016 +0000

description:
Remove redundant codes purging IPv6 addresses

Proposed on tech-net and tech-kern.

diffstat:

 sys/netinet6/in6.c          |   5 +--
 sys/netinet6/in6_ifattach.c |  64 +-------------------------------------------
 2 files changed, 4 insertions(+), 65 deletions(-)

diffs (121 lines):

diff -r bbf88c62f2d2 -r 7387b6a5037d sys/netinet6/in6.c
--- a/sys/netinet6/in6.c        Mon Jul 04 02:05:56 2016 +0000
+++ b/sys/netinet6/in6.c        Mon Jul 04 02:41:18 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in6.c,v 1.202 2016/06/30 01:34:53 ozaki-r Exp $        */
+/*     $NetBSD: in6.c,v 1.203 2016/07/04 02:41:18 ozaki-r Exp $        */
 /*     $KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $   */
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.202 2016/06/30 01:34:53 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.203 2016/07/04 02:41:18 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1420,7 +1420,6 @@
 void
 in6_purgeif(struct ifnet *ifp)
 {
-       if_purgeaddrs(ifp, AF_INET6, in6_purgeaddr);
 
        in6_ifdetach(ifp);
 }
diff -r bbf88c62f2d2 -r 7387b6a5037d sys/netinet6/in6_ifattach.c
--- a/sys/netinet6/in6_ifattach.c       Mon Jul 04 02:05:56 2016 +0000
+++ b/sys/netinet6/in6_ifattach.c       Mon Jul 04 02:41:18 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in6_ifattach.c,v 1.98 2016/05/12 02:24:17 ozaki-r Exp $        */
+/*     $NetBSD: in6_ifattach.c,v 1.99 2016/07/04 02:41:18 ozaki-r Exp $        */
 /*     $KAME: in6_ifattach.c,v 1.124 2001/07/18 08:32:51 jinmei Exp $  */
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6_ifattach.c,v 1.98 2016/05/12 02:24:17 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_ifattach.c,v 1.99 2016/07/04 02:41:18 ozaki-r Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -838,11 +838,6 @@
 void
 in6_ifdetach(struct ifnet *ifp)
 {
-       struct in6_ifaddr *ia, *oia;
-       struct ifaddr *ifa, *next;
-       struct rtentry *rt;
-       short rtflags;
-       struct in6_multi_mship *imm;
 
        /* remove ip6_mrouter stuff */
        ip6_mrouter_detach(ifp);
@@ -850,64 +845,9 @@
        /* remove neighbor management table */
        nd6_purge(ifp, NULL);
 
-       /* XXX this code is duplicated in in6_purgeif() --dyoung */
        /* nuke any of IPv6 addresses we have */
        if_purgeaddrs(ifp, AF_INET6, in6_purgeaddr);
 
-       /* XXX isn't this code is redundant, given the above? --dyoung */
-       /* XXX doesn't this code replicate code in in6_purgeaddr() ? --dyoung */
-       /* undo everything done by in6_ifattach(), just in case */
-       for (ifa = IFADDR_FIRST(ifp); ifa != NULL; ifa = next) {
-               next = IFADDR_NEXT(ifa);
-
-               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 from the routing table */
-               if ((ia->ia_flags & IFA_ROUTE) &&
-                   (rt = rtalloc1((struct sockaddr *)&ia->ia_addr, 0))) {
-                       rtflags = rt->rt_flags;
-                       rtfree(rt);
-                       rtrequest(RTM_DELETE, (struct sockaddr *)&ia->ia_addr,
-                           (struct sockaddr *)&ia->ia_addr,
-                           (struct sockaddr *)&ia->ia_prefixmask,
-                           rtflags, NULL);
-               }
-
-               /* remove from the linked list */
-               ifa_remove(ifp, &ia->ia_ifa);
-
-               /* also remove from the IPv6 address chain(itojun&jinmei) */
-               oia = ia;
-               if (oia == (ia = in6_ifaddr))
-                       in6_ifaddr = ia->ia_next;
-               else {
-                       while (ia->ia_next && (ia->ia_next != oia))
-                               ia = ia->ia_next;
-                       if (ia->ia_next)
-                               ia->ia_next = oia->ia_next;
-                       else {
-                               nd6log(LOG_ERR,
-                                   "%s: didn't unlink in6ifaddr from list\n",
-                                   if_name(ifp));
-                       }
-               }
-
-               ifafree(&oia->ia_ifa);
-       }
-
        /* cleanup multicast address kludge table, if there is any */
        in6_purgemkludge(ifp);
 



Home | Main Index | Thread Index | Old Index