]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 1080] ntpd on ipv6 routers very chatty.
authorDave Hart <hart@ntp.org>
Tue, 12 Oct 2010 14:27:43 +0000 (14:27 +0000)
committerDave Hart <hart@ntp.org>
Tue, 12 Oct 2010 14:27:43 +0000 (14:27 +0000)
bk: 4cb4705f0-7oLzY15vMPxO_B-xXLbw

ChangeLog
configure.ac
include/ntp_net.h
ntpd/ntp_io.c

index bf01e325ead44780a68d4a036bbc8731a71b9f00..8d3310817484a9d424295c11773f4e5817367e8b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 ---
 
 * [Bug 750] Non-existing device causes coredump with RIPE-NCC driver.
+* [Bug 1080] ntpd on ipv6 routers very chatty.
 * [Bug 1567] Support Arbiter 1093C Satellite Clock on Windows.
 * [Bug 1643] Range-check the decoding of the RIPE-NCC status codes.
 * [Bug 1644] cvo.sh should use lsb_release to identify linux distros.
index 5f57818f9a08da5146ff246cd7601cf7d05a8aae..e1d14c2c6c1aebaa1fb29670c66b018e29b9de3d 100644 (file)
@@ -462,29 +462,51 @@ case "$host" in
     AC_CHECK_FUNCS(getpassphrase)
 esac
 
-AC_CHECK_HEADERS(arpa/nameser.h)
-AC_CHECK_HEADERS(sys/socket.h)
-AC_CHECK_HEADERS(net/if.h, [], [],
-[#if HAVE_SYS_SOCKET_H
+AC_CHECK_HEADERS([arpa/nameser.h])
+AC_CHECK_HEADERS([sys/socket.h])
+AC_CHECK_HEADERS([net/if.h], [], [],
+[#ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
 #endif
 ])
-AC_CHECK_HEADERS(net/if6.h)
-AC_CHECK_HEADERS(net/route.h, [], [], [
+AC_CHECK_HEADERS([net/if6.h])
+AC_CHECK_HEADERS([net/route.h], [], [], [
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <net/if.h>
 ])
-AC_CHECK_HEADERS(netinet/in_system.h netinet/in_systm.h)
-AC_CHECK_HEADERS(netinet/in.h)
-AC_CHECK_HEADERS(netinet/ip.h, [], [],
+AC_CHECK_HEADERS([netinet/in_system.h netinet/in_systm.h netinet/in.h])
+AC_CHECK_HEADERS([net/if_var.h], [], [],
 [#if HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
-#if HAVE_NETINET_IN_H
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#ifdef HAVE_NET_IF_H
+#include <net/if.h>
+#endif
+])
+AC_CHECK_HEADERS([netinet/ip.h netinet/in_var.h], [], [],
+[#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#ifdef HAVE_NET_IF_H
+#include <net/if.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
 #include <netinet/in.h>
 #endif
-#if HAVE_NETINET_IN_SYSTM_H
+#ifdef HAVE_NET_IF_VAR_H
+#include <net/if_var.h>
+#endif
+#ifdef HAVE_NETINET_IN_SYSTM_H
 #include <netinet/in_systm.h>
 #endif
 ])
index da2a22ab5bc7dd3e1c9121b1cef1118c12973f56..97e7805ea94d854377a6d90219fab3e6fb895405 100644 (file)
@@ -9,9 +9,18 @@
 #ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
 #endif
+#ifdef HAVE_NET_IF_H
+#include <net/if.h>
+#endif
 #ifdef HAVE_NETINET_IN_H
 #include <netinet/in.h>
 #endif
+#ifdef HAVE_NET_IF_VAR_H
+#include <net/if_var.h>
+#endif
+#ifdef HAVE_NETINET_IN_VAR_H
+#include <netinet/in_var.h>
+#endif
 
 #include "ntp_rfc2553.h"
 
index 7eaa9c0b6a14e6402451ffcea102ac85378737e4..366927a0f1df48026895ad191816e74146c2d8e6 100644 (file)
@@ -193,6 +193,9 @@ static int  is_wildcard_netaddr     (const isc_netaddr_t *);
  * Multicast functions
  */
 static isc_boolean_t   addr_ismulticast        (sockaddr_u *);
+static isc_boolean_t   is_anycast              (sockaddr_u *,
+                                                const char *);
+
 /*
  * Not all platforms support multicast
  */
@@ -1470,6 +1473,39 @@ set_wildcard_reuse(
 }
 #endif /* OS_NEEDS_REUSEADDR_FOR_IFADDRBIND */
 
+
+static isc_boolean_t
+is_anycast(
+       sockaddr_u *psau,
+       const char *name
+       )
+{
+#if defined(INCLUDE_IPV6_SUPPORT) && defined(SIOCGIFAFLAG_IN6) && \
+    defined(IN6_IFF_ANYCAST)
+       struct in6_ifreq ifr6;
+       int fd;
+       u_int32_t flags6;
+
+       if (psau->sa.sa_family != AF_INET6)
+               return ISC_FALSE;
+       if ((fd = socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
+               return ISC_FALSE;
+       memset(&ifr6, 0, sizeof(ifr6));
+       memcpy(&ifr6.ifr_addr, &psau->sa6, sizeof(ifr6.ifr_addr));
+       strncpy(ifr6.ifr_name, name, sizeof(ifr6.ifr_name));
+       if (ioctl(fd, SIOCGIFAFLAG_IN6, &ifr6) < 0) {
+               close(fd);
+               return ISC_FALSE;
+       }
+       close(fd);
+       flags6 = ifr6.ifr_ifru.ifru_flags6;
+       if ((flags6 & IN6_IFF_ANYCAST) != 0)
+               return ISC_TRUE;
+#endif /* INCLUDE_IPV6_SUPPORT && SIOCGIFAFLAG_IN6 && IN6_IFF_ANYCAST */
+       return ISC_FALSE;
+}
+
+
 /*
  * update_interface strategy
  *
@@ -1592,6 +1628,9 @@ update_interfaces(
                if (is_wildcard_addr(&interface.sin))
                        continue;
 
+               if (is_anycast(&interface.sin, isc_if.name))
+                       continue;
+
                /*
                 * map to local *address* in order to map all duplicate
                 * interfaces to an interface structure with the