Source-Changes-HG archive

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

[src/trunk]: src/sys Introduce and use ip_dad_enabled() and ip6_dad_enabled()...



details:   https://anonhg.NetBSD.org/src/rev/a12294151fee
branches:  trunk
changeset: 994945:a12294151fee
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Thu Nov 29 09:51:20 2018 +0000

description:
Introduce and use ip_dad_enabled() and ip6_dad_enabled() functions

diffstat:

 sys/netinet/if_arp.c   |  12 ++++++------
 sys/netinet/in.c       |  10 +++-------
 sys/netinet/in_var.h   |  13 ++++++++++++-
 sys/netinet6/in6.c     |   6 +++---
 sys/netinet6/ip6_var.h |   9 ++++++++-
 sys/netinet6/nd6_nbr.c |   8 ++++----
 6 files changed, 36 insertions(+), 22 deletions(-)

diffs (198 lines):

diff -r 06c0da4d9814 -r a12294151fee sys/netinet/if_arp.c
--- a/sys/netinet/if_arp.c      Thu Nov 29 03:10:20 2018 +0000
+++ b/sys/netinet/if_arp.c      Thu Nov 29 09:51:20 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_arp.c,v 1.276 2018/10/30 05:54:41 ozaki-r Exp $     */
+/*     $NetBSD: if_arp.c,v 1.277 2018/11/29 09:51:20 ozaki-r Exp $     */
 
 /*
  * Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.276 2018/10/30 05:54:41 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.277 2018/11/29 09:51:20 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -1491,7 +1491,7 @@
        } else {
                ia->ia_dad_start = arp_dad_start;
                ia->ia_dad_stop = arp_dad_stop;
-               if (ia->ia4_flags & IN_IFF_TRYTENTATIVE && ip_dad_count > 0)
+               if (ia->ia4_flags & IN_IFF_TRYTENTATIVE && ip_dad_enabled())
                        ia->ia4_flags |= IN_IFF_TENTATIVE;
                else
                        arpannounce1(ifa);
@@ -1597,7 +1597,7 @@
 
        /*
         * If we don't need DAD, don't do it.
-        * - DAD is disabled (ip_dad_count == 0)
+        * - DAD is disabled
         */
        if (!(ia->ia4_flags & IN_IFF_TENTATIVE)) {
                log(LOG_DEBUG,
@@ -1606,7 +1606,7 @@
                    ifa->ifa_ifp ? if_name(ifa->ifa_ifp) : "???");
                return;
        }
-       if (!ip_dad_count) {
+       if (!ip_dad_enabled()) {
                ia->ia4_flags &= ~IN_IFF_TENTATIVE;
                rt_newaddrmsg(RTM_NEWADDR, ifa, 0, NULL);
                arpannounce1(ifa);
@@ -1806,7 +1806,7 @@
                return;
        } else {
                /* If DAD is disabled, just report the duplicate. */
-               if (ip_dad_count == 0) {
+               if (!ip_dad_enabled()) {
                        log(LOG_ERR,
                            "%s: DAD ignoring duplicate address %s from %s\n",
                            if_name(ifp), iastr, sha);
diff -r 06c0da4d9814 -r a12294151fee sys/netinet/in.c
--- a/sys/netinet/in.c  Thu Nov 29 03:10:20 2018 +0000
+++ b/sys/netinet/in.c  Thu Nov 29 09:51:20 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in.c,v 1.231 2018/05/13 22:42:51 khorben Exp $ */
+/*     $NetBSD: in.c,v 1.232 2018/11/29 09:51:20 ozaki-r Exp $ */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.231 2018/05/13 22:42:51 khorben Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.232 2018/11/29 09:51:20 ozaki-r Exp $");
 
 #include "arp.h"
 
@@ -1155,11 +1155,7 @@
        if (ifp->if_link_state == LINK_STATE_DOWN) {
                ia->ia4_flags |= IN_IFF_DETACHED;
                ia->ia4_flags &= ~IN_IFF_TENTATIVE;
-       } else if (hostIsNew && if_do_dad(ifp)
-#if NARP > 0
-           && ip_dad_count > 0
-#endif
-       )
+       } else if (hostIsNew && if_do_dad(ifp) && ip_dad_enabled())
                ia->ia4_flags |= IN_IFF_TRYTENTATIVE;
 
        /*
diff -r 06c0da4d9814 -r a12294151fee sys/netinet/in_var.h
--- a/sys/netinet/in_var.h      Thu Nov 29 03:10:20 2018 +0000
+++ b/sys/netinet/in_var.h      Thu Nov 29 09:51:20 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in_var.h,v 1.96 2018/04/19 21:21:44 christos Exp $     */
+/*     $NetBSD: in_var.h,v 1.97 2018/11/29 09:51:20 ozaki-r Exp $      */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -378,6 +378,17 @@
 extern pktqueue_t *ip_pktq;
 
 extern int ip_dad_count;               /* Duplicate Address Detection probes */
+
+static inline bool
+ip_dad_enabled(void)
+{
+#if NARP > 0
+       return ip_dad_count > 0;
+#else
+       return false;
+#endif
+}
+
 #if defined(INET) && NARP > 0
 extern int arp_debug;
 #define ARPLOGADDR(a) IN_PRINT(_ipbuf, a)
diff -r 06c0da4d9814 -r a12294151fee sys/netinet6/in6.c
--- a/sys/netinet6/in6.c        Thu Nov 29 03:10:20 2018 +0000
+++ b/sys/netinet6/in6.c        Thu Nov 29 09:51:20 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in6.c,v 1.270 2018/10/30 05:56:02 ozaki-r Exp $        */
+/*     $NetBSD: in6.c,v 1.271 2018/11/29 09:51:21 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.270 2018/10/30 05:56:02 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.271 2018/11/29 09:51:21 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1269,7 +1269,7 @@
                ia->ia6_flags |= IN6_IFF_DETACHED;
                ia->ia6_flags &= ~IN6_IFF_TENTATIVE;
        } else if ((hostIsNew || was_tentative) && if_do_dad(ifp) &&
-                  ip6_dad_count > 0) {
+                  ip6_dad_enabled()) {
                ia->ia6_flags |= IN6_IFF_TENTATIVE;
        }
 
diff -r 06c0da4d9814 -r a12294151fee sys/netinet6/ip6_var.h
--- a/sys/netinet6/ip6_var.h    Thu Nov 29 03:10:20 2018 +0000
+++ b/sys/netinet6/ip6_var.h    Thu Nov 29 09:51:20 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip6_var.h,v 1.80 2018/02/14 05:29:39 maxv Exp $        */
+/*     $NetBSD: ip6_var.h,v 1.81 2018/11/29 09:51:21 ozaki-r Exp $     */
 /*     $KAME: ip6_var.h,v 1.33 2000/06/11 14:59:20 jinmei Exp $        */
 
 /*
@@ -364,6 +364,13 @@
 
 u_int32_t ip6_randomid(void);
 u_int32_t ip6_randomflowlabel(void);
+
+static inline bool
+ip6_dad_enabled(void)
+{
+
+       return ip6_dad_count > 0;
+}
 #endif /* _KERNEL */
 
 #endif /* !_NETINET6_IP6_VAR_H_ */
diff -r 06c0da4d9814 -r a12294151fee sys/netinet6/nd6_nbr.c
--- a/sys/netinet6/nd6_nbr.c    Thu Nov 29 03:10:20 2018 +0000
+++ b/sys/netinet6/nd6_nbr.c    Thu Nov 29 09:51:20 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nd6_nbr.c,v 1.156 2018/05/19 08:22:58 maxv Exp $       */
+/*     $NetBSD: nd6_nbr.c,v 1.157 2018/11/29 09:51:21 ozaki-r Exp $    */
 /*     $KAME: nd6_nbr.c,v 1.61 2001/02/10 16:06:14 jinmei Exp $        */
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nd6_nbr.c,v 1.156 2018/05/19 08:22:58 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6_nbr.c,v 1.157 2018/11/29 09:51:21 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1187,7 +1187,7 @@
        /*
         * If we don't need DAD, don't do it.
         * There are several cases:
-        * - DAD is disabled (ip6_dad_count == 0)
+        * - DAD is disabled
         * - the interface address is anycast
         */
        if (!(ia->ia6_flags & IN6_IFF_TENTATIVE)) {
@@ -1198,7 +1198,7 @@
                        ifa->ifa_ifp ? if_name(ifa->ifa_ifp) : "???");
                return;
        }
-       if (ia->ia6_flags & IN6_IFF_ANYCAST || !ip6_dad_count) {
+       if (ia->ia6_flags & IN6_IFF_ANYCAST || !ip6_dad_enabled()) {
                ia->ia6_flags &= ~IN6_IFF_TENTATIVE;
                rt_newaddrmsg(RTM_NEWADDR, ifa, 0, NULL);
                return;



Home | Main Index | Thread Index | Old Index