Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 1 Dec 2009 16:07:50 +0000 (UTC)
From:      Hajimu UMEMOTO <ume@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r199995 - head/contrib/ntp/ntpd
Message-ID:  <200912011607.nB1G7oQG069419@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ume
Date: Tue Dec  1 16:07:50 2009
New Revision: 199995
URL: http://svn.freebsd.org/changeset/base/199995

Log:
  Don't try to bind to an anycast addeess.  The KAME IPv6 stack doesn't
  allow bind to an anycast addeess.  It does away with an annoying
  message.
  
  Reviewed by:	bz, roberto
  MFC after:	2 weeks

Modified:
  head/contrib/ntp/ntpd/ntp_io.c

Modified: head/contrib/ntp/ntpd/ntp_io.c
==============================================================================
--- head/contrib/ntp/ntpd/ntp_io.c	Tue Dec  1 15:27:39 2009	(r199994)
+++ head/contrib/ntp/ntpd/ntp_io.c	Tue Dec  1 16:07:50 2009	(r199995)
@@ -65,6 +65,12 @@
 #endif	/* IPV6 Multicast Support */
 #endif  /* IPv6 Support */
 
+#ifdef INCLUDE_IPV6_SUPPORT
+#include <netinet/in.h>
+#include <net/if_var.h>
+#include <netinet/in_var.h>
+#endif /* !INCLUDE_IPV6_SUPPORT */
+
 extern int listen_to_virtual_ips;
 extern const char *specific_interface;
 
@@ -1137,6 +1143,36 @@ set_wildcard_reuse(int family, int on)
 }
 #endif /* OS_NEEDS_REUSEADDR_FOR_IFADDRBIND */
 
+#ifdef INCLUDE_IPV6_SUPPORT
+static isc_boolean_t
+is_anycast(struct sockaddr *sa, char *name)
+{
+#if defined(SIOCGIFAFLAG_IN6) && defined(IN6_IFF_ANYCAST)
+	struct in6_ifreq ifr6;
+	int fd;
+	u_int32_t flags6;
+
+	if (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, (struct sockaddr_in6 *)sa,
+	    sizeof(struct sockaddr_in6));
+	strlcpy(ifr6.ifr_name, name, IF_NAMESIZE);
+	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 /* !SIOCGIFAFLAG_IN6 || !IN6_IFF_ANYCAST */
+	return ISC_FALSE;
+}
+#endif /* !INCLUDE_IPV6_SUPPORT */
+
 /*
  * update_interface strategy
  *
@@ -1276,6 +1312,11 @@ update_interfaces(
 		if (is_wildcard_addr(&interface.sin))
 			continue;
 
+#ifdef INCLUDE_IPV6_SUPPORT
+		if (is_anycast((struct sockaddr *)&interface.sin, isc_if.name))
+			continue;
+#endif /* !INCLUDE_IPV6_SUPPORT */
+
 		/*
 		 * map to local *address* in order
 		 * to map all duplicate interfaces to an interface structure



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200912011607.nB1G7oQG069419>