Source-Changes-HG archive

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

[src/trunk]: src Remove mkludge stuffs



details:   https://anonhg.NetBSD.org/src/rev/78d75441257b
branches:  trunk
changeset: 821958:78d75441257b
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Thu Feb 23 07:57:09 2017 +0000

description:
Remove mkludge stuffs

For unknown reasons, IPv6 multicast addresses are linked to a first
IPv6 address assigned to an interface. Due to the design, when removing
a first address having multicast addresses, we need to save them to
somewhere and later restore them once a new IPv6 address is activated.
mkludge stuffs support the operations.

This change links multicast addresses to an interface directly and
throws the kludge away.

Note that as usual some obsolete member variables remain for kvm(3)
users. And also sysctl net.inet6.multicast_kludge remains to avoid
breaking old ifmcstat.

TODO: currently ifnet has a list of in6_multi but obviously the list
should be protocol independent. Provide a common structure (if_multi
or something) to handle in6_multi and in_multi together as well as
ifaddr does for in_ifaddr and in6_ifaddr.

diffstat:

 sys/net/if.c                 |    5 +-
 sys/net/if.h                 |    5 +-
 sys/netinet6/in6.c           |   24 +---
 sys/netinet6/in6_ifattach.c  |   12 +-
 sys/netinet6/in6_var.h       |   88 +------------
 sys/netinet6/mld6.c          |  281 ++++++++----------------------------------
 sys/netipsec/key.c           |   13 +-
 usr.bin/netstat/if.c         |    6 +-
 usr.sbin/ifmcstat/ifmcstat.c |   38 +-----
 9 files changed, 85 insertions(+), 387 deletions(-)

diffs (truncated from 847 to 300 lines):

diff -r 64002ca5c275 -r 78d75441257b sys/net/if.c
--- a/sys/net/if.c      Thu Feb 23 05:48:14 2017 +0000
+++ b/sys/net/if.c      Thu Feb 23 07:57:09 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.c,v 1.380 2017/02/17 03:57:17 ozaki-r Exp $ */
+/*     $NetBSD: if.c,v 1.381 2017/02/23 07:57:10 ozaki-r Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.380 2017/02/17 03:57:17 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.381 2017/02/23 07:57:10 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -720,6 +720,7 @@
        PSLIST_INIT(&ifp->if_addr_pslist);
        psref_target_init(&ifp->if_psref, ifnet_psref_class);
        ifp->if_ioctl_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NONE);
+       LIST_INIT(&ifp->if_multiaddrs);
 
        IFNET_LOCK();
        if_getindex(ifp);
diff -r 64002ca5c275 -r 78d75441257b sys/net/if.h
--- a/sys/net/if.h      Thu Feb 23 05:48:14 2017 +0000
+++ b/sys/net/if.h      Thu Feb 23 07:57:09 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.h,v 1.234 2017/02/17 03:57:17 ozaki-r Exp $ */
+/*     $NetBSD: if.h,v 1.235 2017/02/23 07:57:10 ozaki-r Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -231,6 +231,7 @@
 struct krwlock;
 struct if_percpuq;
 struct if_deferred_start;
+struct in6_multi;
 
 typedef unsigned short if_index_t;
 
@@ -344,6 +345,8 @@
        struct psref_target     if_psref;
        struct pslist_head      if_addr_pslist;
        struct if_deferred_start        *if_deferred_start;
+       /* XXX should be protocol independent */
+       LIST_HEAD(, in6_multi) if_multiaddrs;
 #endif
 } ifnet_t;
  
diff -r 64002ca5c275 -r 78d75441257b sys/netinet6/in6.c
--- a/sys/netinet6/in6.c        Thu Feb 23 05:48:14 2017 +0000
+++ b/sys/netinet6/in6.c        Thu Feb 23 07:57:09 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in6.c,v 1.237 2017/01/23 10:19:03 ozaki-r Exp $        */
+/*     $NetBSD: in6.c,v 1.238 2017/02/23 07:57:10 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.237 2017/01/23 10:19:03 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.238 2017/02/23 07:57:10 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1370,23 +1370,6 @@
        mutex_exit(&in6_ifaddr_lock);
 
        /*
-        * XXX thorpej%NetBSD.org@localhost -- if the interface is going
-        * XXX away, don't save the multicast entries, delete them!
-        */
-       if (LIST_EMPTY(&ia->ia6_multiaddrs))
-               ;
-       else if (if_is_deactivated(ia->ia_ifa.ifa_ifp)) {
-               struct in6_multi *in6m, *next;
-
-               for (in6m = LIST_FIRST(&ia->ia6_multiaddrs); in6m != NULL;
-                    in6m = next) {
-                       next = LIST_NEXT(in6m, in6m_entry);
-                       in6_delmulti(in6m);
-               }
-       } else
-               in6_savemkludge(ia);
-
-       /*
         * Release the reference to the ND prefix.
         */
        if (ia->ia6_ndpr != NULL) {
@@ -1754,9 +1737,6 @@
                return error;
        }
 
-       if (ifp->if_flags & IFF_MULTICAST)
-               in6_restoremkludge(ia, ifp);
-
        return error;
 }
 
diff -r 64002ca5c275 -r 78d75441257b sys/netinet6/in6_ifattach.c
--- a/sys/netinet6/in6_ifattach.c       Thu Feb 23 05:48:14 2017 +0000
+++ b/sys/netinet6/in6_ifattach.c       Thu Feb 23 07:57:09 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in6_ifattach.c,v 1.111 2017/02/16 08:12:44 knakahara Exp $     */
+/*     $NetBSD: in6_ifattach.c,v 1.112 2017/02/23 07:57:10 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.111 2017/02/16 08:12:44 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_ifattach.c,v 1.112 2017/02/23 07:57:10 ozaki-r Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -735,9 +735,6 @@
                return;
        }
 
-       /* create a multicast kludge storage (if we have not had one) */
-       in6_createmkludge(ifp);
-
        /*
         * quirks based on interface type
         */
@@ -812,12 +809,11 @@
        /* nuke any of IPv6 addresses we have */
        if_purgeaddrs(ifp, AF_INET6, in6_purgeaddr);
 
+       in6_purge_multi(ifp);
+
        /* remove ip6_mrouter stuff */
        ip6_mrouter_detach(ifp);
 
-       /* cleanup multicast address kludge table, if there is any */
-       in6_purgemkludge(ifp);
-
        /* remove neighbor management table */
        nd6_purge(ifp, NULL);
 
diff -r 64002ca5c275 -r 78d75441257b sys/netinet6/in6_var.h
--- a/sys/netinet6/in6_var.h    Thu Feb 23 05:48:14 2017 +0000
+++ b/sys/netinet6/in6_var.h    Thu Feb 23 07:57:09 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in6_var.h,v 1.92 2017/02/22 07:46:00 ozaki-r Exp $     */
+/*     $NetBSD: in6_var.h,v 1.93 2017/02/23 07:57:10 ozaki-r Exp $     */
 /*     $KAME: in6_var.h,v 1.81 2002/06/08 11:16:51 itojun Exp $        */
 
 /*
@@ -113,7 +113,8 @@
        u_int32_t ia_plen;              /* prefix length */
        /* DEPRECATED. Keep it to avoid breaking kvm(3) users */
        struct  in6_ifaddr *ia_next;    /* next in6 list of IP6 addresses */
-       struct  in6_multihead ia6_multiaddrs;
+       /* DEPRECATED. Keep it to avoid breaking kvm(3) users */
+       struct  in6_multihead _ia6_multiaddrs;
                                        /* list of multicast addresses */
        int     ia6_flags;
 
@@ -630,7 +631,8 @@
        LIST_ENTRY(in6_multi) in6m_entry; /* list glue */
        struct  in6_addr in6m_addr;     /* IP6 multicast address */
        struct  ifnet *in6m_ifp;        /* back pointer to ifnet */
-       struct  in6_ifaddr *in6m_ia;    /* back pointer to in6_ifaddr */
+       /* DEPRECATED. Keep it to avoid breaking kvm(3) users */
+       struct  in6_ifaddr *_in6m_ia;   /* back pointer to in6_ifaddr */
        u_int   in6m_refcount;          /* # membership claims by sockets */
        u_int   in6m_state;             /* state of the membership */
        int     in6m_timer;             /* delay to send the 1st report */
@@ -645,79 +647,6 @@
 /* flags to in6_update_ifa */
 #define IN6_IFAUPDATE_DADDELAY 0x1 /* first time to configure an address */
 
-/*
- * Structure used by macros below to remember position when stepping through
- * all of the in6_multi records.
- */
-struct in6_multistep {
-       struct  in6_ifaddr *i_ia;
-       struct  in6_multi *i_in6m;
-};
-
-/*
- * Macros for looking up the in6_multi record for a given IP6 multicast
- * address on a given interface. If no matching record is found, "in6m"
- * returns NULL.
- */
-
-static inline struct in6_multi *
-in6_lookup_multi(struct in6_addr *addr, struct ifnet *ifp)
-{
-       struct in6_multi *in6m;
-       struct in6_ifaddr *ia;
-       int s;
-
-       s = pserialize_read_enter();
-       if ((ia = in6_get_ia_from_ifp(ifp)) == NULL) {
-               pserialize_read_exit(s);
-               return NULL;
-       }
-       LIST_FOREACH(in6m, &ia->ia6_multiaddrs, in6m_entry) {
-               if (IN6_ARE_ADDR_EQUAL(&in6m->in6m_addr, addr))
-                       break;
-       }
-       pserialize_read_exit(s);
-       return in6m;
-}
-
-/*
- * Macro to step through all of the in6_multi records, one at a time.
- * The current position is remembered in "step", which the caller must
- * provide.  IN6_FIRST_MULTI(), below, must be called to initialize "step"
- * and get the first record.  Both macros return a NULL "in6m" when there
- * are no remaining records.
- */
-static inline struct in6_multi *
-in6_next_multi(struct in6_multistep *step)
-{
-       struct in6_multi *in6m;
-
-       if ((in6m = step->i_in6m) != NULL) {
-               step->i_in6m = LIST_NEXT(in6m, in6m_entry);
-               return in6m;
-       }
-       while (step->i_ia != NULL) {
-               in6m = LIST_FIRST(&step->i_ia->ia6_multiaddrs);
-               /* FIXME NOMPSAFE */
-               step->i_ia = IN6_ADDRLIST_READER_NEXT(step->i_ia);
-               if (in6m != NULL) {
-                       step->i_in6m = LIST_NEXT(in6m, in6m_entry);
-                       break;
-               }
-       }
-       return in6m;
-}
-
-static inline struct in6_multi *
-in6_first_multi(struct in6_multistep *step)
-{                                              
-
-       /* FIXME NOMPSAFE */
-       step->i_ia = IN6_ADDRLIST_READER_FIRST();
-       step->i_in6m = NULL;                    
-       return in6_next_multi(step);            
-}
-
 #if 0
 /*
  * Macros for looking up the in6_multi_mship record for a given IP6 multicast
@@ -752,6 +681,9 @@
 
 void   in6_init(void);
 
+struct in6_multi *
+       in6_lookup_multi(const struct in6_addr *, const struct ifnet *);
+void   in6_purge_multi(struct ifnet *);
 struct in6_multi *in6_addmulti(struct in6_addr *, struct ifnet *,
        int *, int);
 void   in6_delmulti(struct in6_multi *);
@@ -763,16 +695,12 @@
 int    in6_update_ifa(struct ifnet *, struct in6_aliasreq *, int);
 void   in6_purgeaddr(struct ifaddr *);
 void   in6_purgeif(struct ifnet *);
-void   in6_savemkludge(struct in6_ifaddr *);
 void   in6_setmaxmtu  (void);
 int    in6_if2idlen  (struct ifnet *);
 void   *in6_domifattach(struct ifnet *);
 void   in6_domifdetach(struct ifnet *, void *);
-void   in6_restoremkludge(struct in6_ifaddr *, struct ifnet *);
 void   in6_ifremlocal(struct ifaddr *);
 void   in6_ifaddlocal(struct ifaddr *);
-void   in6_createmkludge(struct ifnet *);
-void   in6_purgemkludge(struct ifnet *);
 struct in6_ifaddr *
        in6ifa_ifpforlinklocal(const struct ifnet *, int);
 struct in6_ifaddr *
diff -r 64002ca5c275 -r 78d75441257b sys/netinet6/mld6.c
--- a/sys/netinet6/mld6.c       Thu Feb 23 05:48:14 2017 +0000
+++ b/sys/netinet6/mld6.c       Thu Feb 23 07:57:09 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mld6.c,v 1.82 2017/02/22 07:46:00 ozaki-r Exp $        */
+/*     $NetBSD: mld6.c,v 1.83 2017/02/23 07:57:10 ozaki-r Exp $        */
 /*     $KAME: mld6.c,v 1.25 2001/01/16 14:14:18 itojun Exp $   */
 
 /*
@@ -102,7 +102,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mld6.c,v 1.82 2017/02/22 07:46:00 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mld6.c,v 1.83 2017/02/23 07:57:10 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT



Home | Main Index | Thread Index | Old Index