Source-Changes-HG archive

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

[src/trunk]: src/sys Move in6if_do_dad() to if_do_dad() as the routine is not...



details:   https://anonhg.NetBSD.org/src/rev/b519e7fd30cc
branches:  trunk
changeset: 807378:b519e7fd30cc
user:      roy <roy%NetBSD.org@localhost>
date:      Tue Apr 07 23:30:36 2015 +0000

description:
Move in6if_do_dad() to if_do_dad() as the routine is not INET6 specific
and could equally be used by INET.

diffstat:

 sys/net/if.c           |  37 +++++++++++++++++++++++++++++++++++--
 sys/net/if.h           |   3 ++-
 sys/netinet6/in6.c     |  43 +++++--------------------------------------
 sys/netinet6/in6_var.h |   3 +--
 4 files changed, 43 insertions(+), 43 deletions(-)

diffs (177 lines):

diff -r d37cdcfb9708 -r b519e7fd30cc sys/net/if.c
--- a/sys/net/if.c      Tue Apr 07 21:19:28 2015 +0000
+++ b/sys/net/if.c      Tue Apr 07 23:30:36 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.c,v 1.308 2015/01/16 10:36:14 ozaki-r Exp $ */
+/*     $NetBSD: if.c,v 1.309 2015/04/07 23:30:36 roy 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.308 2015/01/16 10:36:14 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.309 2015/04/07 23:30:36 roy Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -2317,6 +2317,39 @@
 }
 
 int
+if_do_dad(struct ifnet *ifp)
+{
+       if ((ifp->if_flags & IFF_LOOPBACK) != 0)
+               return 0;
+
+       switch (ifp->if_type) {
+       case IFT_FAITH:
+               /*
+                * These interfaces do not have the IFF_LOOPBACK flag,
+                * but loop packets back.  We do not have to do DAD on such
+                * interfaces.  We should even omit it, because loop-backed
+                * responses would confuse the DAD procedure.
+                */
+               return 0;
+       default:
+               /*
+                * Our DAD routine requires the interface up and running.
+                * However, some interfaces can be up before the RUNNING
+                * status.  Additionaly, users may try to assign addresses
+                * before the interface becomes up (or running).
+                * We simply skip DAD in such a case as a work around.
+                * XXX: we should rather mark "tentative" on such addresses,
+                * and do DAD after the interface becomes ready.
+                */
+               if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) !=
+                   (IFF_UP|IFF_RUNNING))
+                       return 0;
+
+               return 1;
+       }
+}
+
+int
 if_flags_set(ifnet_t *ifp, const short flags)
 {
        int rc;
diff -r d37cdcfb9708 -r b519e7fd30cc sys/net/if.h
--- a/sys/net/if.h      Tue Apr 07 21:19:28 2015 +0000
+++ b/sys/net/if.h      Tue Apr 07 23:30:36 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.h,v 1.186 2015/04/03 08:20:55 msaitoh Exp $ */
+/*     $NetBSD: if.h,v 1.187 2015/04/07 23:30:36 roy Exp $     */
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -879,6 +879,7 @@
 int    ifpromisc(struct ifnet *, int);
 struct ifnet *ifunit(const char *);
 int    if_addr_init(ifnet_t *, struct ifaddr *, bool);
+int    if_do_dad(struct ifnet *);
 int    if_mcast_op(ifnet_t *, const unsigned long, const struct sockaddr *);
 int    if_flags_set(struct ifnet *, const short);
 
diff -r d37cdcfb9708 -r b519e7fd30cc sys/netinet6/in6.c
--- a/sys/netinet6/in6.c        Tue Apr 07 21:19:28 2015 +0000
+++ b/sys/netinet6/in6.c        Tue Apr 07 23:30:36 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in6.c,v 1.185 2015/02/26 12:58:36 roy Exp $    */
+/*     $NetBSD: in6.c,v 1.186 2015/04/07 23:30:36 roy 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.185 2015/02/26 12:58:36 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.186 2015/04/07 23:30:36 roy Exp $");
 
 #include "opt_inet.h"
 #include "opt_compat_netbsd.h"
@@ -979,7 +979,7 @@
        if (ifp->if_link_state == LINK_STATE_DOWN) {
                ia->ia6_flags |= IN6_IFF_DETACHED;
                ia->ia6_flags &= ~IN6_IFF_TENTATIVE;
-       } else if ((hostIsNew || was_tentative) && in6if_do_dad(ifp))
+       } else if ((hostIsNew || was_tentative) && if_do_dad(ifp))
                ia->ia6_flags |= IN6_IFF_TENTATIVE;
 
        /*
@@ -1205,7 +1205,7 @@
         * XXX It may be of use, if we can administratively
         * disable DAD.
         */
-       if (hostIsNew && in6if_do_dad(ifp) &&
+       if (hostIsNew && if_do_dad(ifp) &&
            ((ifra->ifra_flags & IN6_IFF_NODAD) == 0) &&
            (ia->ia6_flags & IN6_IFF_TENTATIVE))
        {
@@ -2005,7 +2005,7 @@
                /* If detached then mark as tentative */
                if (ia->ia6_flags & IN6_IFF_DETACHED) {
                        ia->ia6_flags &= ~IN6_IFF_DETACHED;
-                       if (in6if_do_dad(ifp)) {
+                       if (if_do_dad(ifp)) {
                                ia->ia6_flags |= IN6_IFF_TENTATIVE;
                                nd6log((LOG_ERR, "in6_if_up: "
                                    "%s marked tentative\n",
@@ -2097,39 +2097,6 @@
        in6_if_link_down(ifp);
 }
 
-int
-in6if_do_dad(struct ifnet *ifp)
-{
-       if ((ifp->if_flags & IFF_LOOPBACK) != 0)
-               return 0;
-
-       switch (ifp->if_type) {
-       case IFT_FAITH:
-               /*
-                * These interfaces do not have the IFF_LOOPBACK flag,
-                * but loop packets back.  We do not have to do DAD on such
-                * interfaces.  We should even omit it, because loop-backed
-                * NS would confuse the DAD procedure.
-                */
-               return 0;
-       default:
-               /*
-                * Our DAD routine requires the interface up and running.
-                * However, some interfaces can be up before the RUNNING
-                * status.  Additionaly, users may try to assign addresses
-                * before the interface becomes up (or running).
-                * We simply skip DAD in such a case as a work around.
-                * XXX: we should rather mark "tentative" on such addresses,
-                * and do DAD after the interface becomes ready.
-                */
-               if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) !=
-                   (IFF_UP|IFF_RUNNING))
-                       return 0;
-
-               return 1;
-       }
-}
-
 /*
  * Calculate max IPv6 MTU through all the interfaces and store it
  * to in6_maxmtu.
diff -r d37cdcfb9708 -r b519e7fd30cc sys/netinet6/in6_var.h
--- a/sys/netinet6/in6_var.h    Tue Apr 07 21:19:28 2015 +0000
+++ b/sys/netinet6/in6_var.h    Tue Apr 07 23:30:36 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in6_var.h,v 1.72 2015/02/26 09:54:46 roy Exp $ */
+/*     $NetBSD: in6_var.h,v 1.73 2015/04/07 23:30:36 roy Exp $ */
 /*     $KAME: in6_var.h,v 1.81 2002/06/08 11:16:51 itojun Exp $        */
 
 /*
@@ -685,7 +685,6 @@
 int    in6_update_ifa(struct ifnet *, struct in6_aliasreq *,
        struct in6_ifaddr *, int);
 void   in6_purgeaddr(struct ifaddr *);
-int    in6if_do_dad(struct ifnet *);
 void   in6_purgeif(struct ifnet *);
 void   in6_savemkludge(struct in6_ifaddr *);
 void   in6_setmaxmtu  (void);



Home | Main Index | Thread Index | Old Index