Source-Changes-HG archive

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

[src/trunk]: src/external/bsd/ntp/dist/ntpd Do not try to bind to un-useable ...



details:   https://anonhg.NetBSD.org/src/rev/9fbe063b3c5a
branches:  trunk
changeset: 792821:9fbe063b3c5a
user:      roy <roy%NetBSD.org@localhost>
date:      Fri Jan 17 17:25:47 2014 +0000

description:
Do not try to bind to un-useable IPv6 addresses.

diffstat:

 external/bsd/ntp/dist/ntpd/ntp_io.c |  55 ++++++++++++++++++++++++++++++------
 1 files changed, 46 insertions(+), 9 deletions(-)

diffs (92 lines):

diff -r 68ef9fda7cd1 -r 9fbe063b3c5a external/bsd/ntp/dist/ntpd/ntp_io.c
--- a/external/bsd/ntp/dist/ntpd/ntp_io.c       Fri Jan 17 16:31:45 2014 +0000
+++ b/external/bsd/ntp/dist/ntpd/ntp_io.c       Fri Jan 17 17:25:47 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ntp_io.c,v 1.12 2013/12/28 17:00:50 christos Exp $     */
+/*     $NetBSD: ntp_io.c,v 1.13 2014/01/17 17:25:47 roy Exp $  */
 
 /*
  * ntp_io.c - input/output routines for ntpd.  The socket-opening code
@@ -1632,16 +1632,15 @@
 
 
 static isc_boolean_t
-is_anycast(
+check_flags6(
        sockaddr_u *psau,
-       const char *name
+       const char *name,
+       u_int32 flags6
        )
 {
-#if defined(INCLUDE_IPV6_SUPPORT) && defined(SIOCGIFAFLAG_IN6) && \
-    defined(IN6_IFF_ANYCAST)
+#if defined(INCLUDE_IPV6_SUPPORT) && defined(SIOCGIFAFLAG_IN6)
        struct in6_ifreq ifr6;
        int fd;
-       u_int32 flags6;
 
        if (psau->sa.sa_family != AF_INET6)
                return ISC_FALSE;
@@ -1655,13 +1654,45 @@
                return ISC_FALSE;
        }
        close(fd);
-       flags6 = ifr6.ifr_ifru.ifru_flags6;
-       if ((flags6 & IN6_IFF_ANYCAST) != 0)
+       if ((ifr6.ifr_ifru.ifru_flags6 & flags6) != 0)
                return ISC_TRUE;
-#endif /* INCLUDE_IPV6_SUPPORT && SIOCGIFAFLAG_IN6 && IN6_IFF_ANYCAST */
+#endif /* INCLUDE_IPV6_SUPPORT && SIOCGIFAFLAG_IN6 */
        return ISC_FALSE;
 }
 
+static isc_boolean_t
+is_anycast(
+       sockaddr_u *psau,
+       const char *name
+       )
+{
+#ifdef IN6_IFF_ANYCAST
+       return check_flags6(psau, name, IN6_IFF_ANYCAST);
+#else
+       return ISC_FALSE;
+#endif
+}
+
+static isc_boolean_t
+is_valid(
+       sockaddr_u *psau,
+       const char *name
+       )
+{
+       u_int32 flags6;
+
+       flags6 = 0;
+#ifdef IN6_IFF_DEPARTED
+       flags6 |= IN6_IFF_DEPARTED;
+#endif
+#ifdef IN6_IFF_DETACHED
+       flags6 |= IN6_IFF_DETACHED;
+#endif
+#ifdef IN6_IFF_TENTATIVE
+       flags6 |= IN6_IFF_TENTATIVE;
+#endif
+       return check_flags6(psau, name, flags6) ? ISC_FALSE : ISC_TRUE;
+}
 
 /*
  * update_interface strategy
@@ -1795,6 +1826,12 @@
                        continue;
 
                /*
+                * skip any address that is an invalid state to be used
+                */
+               if (!is_valid(&enumep.sin, isc_if.name))
+                       continue;
+
+               /*
                 * map to local *address* in order to map all duplicate
                 * interfaces to an endpt structure with the appropriate
                 * socket.  Our name space is (ip-address), NOT



Home | Main Index | Thread Index | Old Index