Module Name: src
Committed By: roy
Date: Fri Jan 17 17:25:47 UTC 2014
Modified Files:
src/external/bsd/ntp/dist/ntpd: ntp_io.c
Log Message:
Do not try to bind to un-useable IPv6 addresses.
To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/external/bsd/ntp/dist/ntpd/ntp_io.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/external/bsd/ntp/dist/ntpd/ntp_io.c
diff -u src/external/bsd/ntp/dist/ntpd/ntp_io.c:1.12 src/external/bsd/ntp/dist/ntpd/ntp_io.c:1.13
--- src/external/bsd/ntp/dist/ntpd/ntp_io.c:1.12 Sat Dec 28 17:00:50 2013
+++ src/external/bsd/ntp/dist/ntpd/ntp_io.c Fri Jan 17 17:25:47 2014
@@ -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 @@ set_wildcard_reuse(
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 @@ is_anycast(
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 @@ update_interfaces(
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