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 Don't bind to IN_IFF_TENTATIVE or...
details: https://anonhg.NetBSD.org/src/rev/85c09eb75516
branches: trunk
changeset: 337880:85c09eb75516
user: roy <roy%NetBSD.org@localhost>
date: Sat May 02 14:46:51 2015 +0000
description:
Don't bind to IN_IFF_TENTATIVE or IN_IFF_DETACHED addresses.
diffstat:
external/bsd/ntp/dist/ntpd/ntp_io.c | 57 +++++++++++++++++++++++++++++++-----
1 files changed, 49 insertions(+), 8 deletions(-)
diffs (84 lines):
diff -r 92d764e2dab6 -r 85c09eb75516 external/bsd/ntp/dist/ntpd/ntp_io.c
--- a/external/bsd/ntp/dist/ntpd/ntp_io.c Sat May 02 14:43:51 2015 +0000
+++ b/external/bsd/ntp/dist/ntpd/ntp_io.c Sat May 02 14:46:51 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ntp_io.c,v 1.17 2015/04/07 17:34:19 christos Exp $ */
+/* $NetBSD: ntp_io.c,v 1.18 2015/05/02 14:46:51 roy Exp $ */
/*
* ntp_io.c - input/output routines for ntpd. The socket-opening code
@@ -1647,6 +1647,34 @@
}
#endif /* OS_NEEDS_REUSEADDR_FOR_IFADDRBIND */
+static isc_boolean_t
+check_flags(
+ sockaddr_u *psau,
+ const char *name,
+ u_int32 flags
+ )
+{
+#if defined(SIOCGIFAFLAG_IN)
+ struct ifreq ifr;
+ int fd;
+
+ if (psau->sa.sa_family != AF_INET)
+ return ISC_FALSE;
+ if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
+ return ISC_FALSE;
+ ZERO(ifr);
+ memcpy(&ifr.ifr_addr, &psau->sa, sizeof(ifr.ifr_addr));
+ strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
+ if (ioctl(fd, SIOCGIFAFLAG_IN, &ifr) < 0) {
+ close(fd);
+ return ISC_FALSE;
+ }
+ close(fd);
+ if ((ifr.ifr_addrflags & flags) != 0)
+ return ISC_TRUE;
+#endif /* SIOCGIFAFLAG_IN */
+ return ISC_FALSE;
+}
static isc_boolean_t
check_flags6(
@@ -1696,19 +1724,32 @@
const char *name
)
{
- u_int32 flags6;
-
- flags6 = 0;
+ u_int32 flags;
+
+ flags = 0;
+ switch (psau->sa.sa_family) {
+ case AF_INET:
+#ifdef IN_IFF_DETACHED
+ flags |= IN_IFF_DETACHED;
+#endif
+#ifdef IN_IFF_TENTATIVE
+ flags |= IN_IFF_TENTATIVE;
+#endif
+ return check_flags(psau, name, flags) ? ISC_FALSE : ISC_TRUE;
+ case AF_INET6:
#ifdef IN6_IFF_DEPARTED
- flags6 |= IN6_IFF_DEPARTED;
+ flags |= IN6_IFF_DEPARTED;
#endif
#ifdef IN6_IFF_DETACHED
- flags6 |= IN6_IFF_DETACHED;
+ flags |= IN6_IFF_DETACHED;
#endif
#ifdef IN6_IFF_TENTATIVE
- flags6 |= IN6_IFF_TENTATIVE;
+ flags |= IN6_IFF_TENTATIVE;
#endif
- return check_flags6(psau, name, flags6) ? ISC_FALSE : ISC_TRUE;
+ return check_flags6(psau, name, flags) ? ISC_FALSE : ISC_TRUE;
+ default:
+ return ISC_FALSE;
+ }
}
/*
Home |
Main Index |
Thread Index |
Old Index