From: Dave Hart Date: Thu, 15 Oct 2009 03:30:56 +0000 (+0000) Subject: [Bug 1342] ignore|drop one IPv6 address on an interface blocks all X-Git-Tag: NTP_4_2_5P233_RC~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=08c310cfab35e3d8cb47754161e2942cf4278879;p=thirdparty%2Fntp.git [Bug 1342] ignore|drop one IPv6 address on an interface blocks all addresses on that interface. bk: 4ad69770UjMPMqJfcP_kAFfvL7y5ow --- diff --git a/ChangeLog b/ChangeLog index e16d50716..0777a8385 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,5 @@ +* [Bug 1342] ignore|drop one IPv6 address on an interface blocks all + addresses on that interface. (4.2.5p232-RC) 2009/10/14 Released by Harlan Stenn * [Bug 1302] OpenSSL under Windows needs applink support. * [Bug 1337] fix incorrect args to setsockopt(fd, IP_MULTICAST_IF,...). diff --git a/lib/isc/win32/interfaceiter.c b/lib/isc/win32/interfaceiter.c index 09133dff3..b71cb245a 100644 --- a/lib/isc/win32/interfaceiter.c +++ b/lib/isc/win32/interfaceiter.c @@ -107,11 +107,11 @@ get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src) { } /* - * Unlike on POSIX systems, Windows does not provide the broadcast - * address associated with each interface address, so we need to - * reconstruct it from the address and mask. + * Windows always provides 255.255.255.255 as the the broadcast + * address. ntpd needs to know the broadcast address which will target + * only that network interface, not all. Reconstruct it from the + * address and mask. */ - static void get_broadcastaddr(isc_netaddr_t *bcastaddr, isc_netaddr_t *addr, isc_netaddr_t *netmask) { @@ -390,20 +390,6 @@ internal_current(isc_interfaceiter_t *iter) { (struct sockaddr *)&(iter->IFData.iiBroadcastAddress)); } - /* - * If the interface is broadcast, get the broadcast address. - */ - if ((iter->current.flags & INTERFACE_F_BROADCAST) != 0) { - get_addr(AF_INET, &iter->current.broadcast, - (struct sockaddr *)&(iter->IFData.iiBroadcastAddress)); - /* !!! get_broadcastaddr(&iter->current.broadcast, &iter->current.address, - &iter->current.netmask); */ - } - - if (ifNamed == FALSE) - sprintf(iter->current.name, - "TCP/IP Interface %d", iter->numIF); - /* * Get the network mask. */ @@ -411,14 +397,13 @@ internal_current(isc_interfaceiter_t *iter) { (struct sockaddr *)&(iter->IFData.iiNetmask)); /* - * If the interface is broadcast, get the broadcast address. + * If the interface is broadcast, get the broadcast address, + * based on the unicast address and network mask. */ - if ((iter->current.flags & INTERFACE_F_BROADCAST) != 0) { - get_addr(AF_INET, &iter->current.broadcast, - (struct sockaddr *)&(iter->IFData.iiBroadcastAddress)); - get_broadcastaddr(&iter->current.broadcast, &iter->current.address, - &iter->current.netmask); - } + if ((iter->current.flags & INTERFACE_F_BROADCAST) != 0) + get_broadcastaddr(&iter->current.broadcast, + &iter->current.address, + &iter->current.netmask); if (ifNamed == FALSE) sprintf(iter->current.name, diff --git a/ntpd/ntp_config.c b/ntpd/ntp_config.c index ddad85c07..114db8512 100644 --- a/ntpd/ntp_config.c +++ b/ntpd/ntp_config.c @@ -3422,7 +3422,7 @@ config_peers( curr_peer->host_mode)) peer_config(&peeraddr, - ANY_INTERFACE_CHOOSE(&peeraddr), + NULL, hmode, curr_peer->peerversion, curr_peer->minpoll, diff --git a/ntpd/ntp_io.c b/ntpd/ntp_io.c index 2d47d1352..bb4533805 100644 --- a/ntpd/ntp_io.c +++ b/ntpd/ntp_io.c @@ -944,17 +944,17 @@ remove_interface( static void list_if_listening( - struct interface * interface + struct interface * iface ) { - msyslog(LOG_INFO, "Listening on interface #%d %s, %s#%d %s", - interface->ifnum, - interface->name, - stoa(&interface->sin), - SRCPORT(&interface->sin), - (interface->ignore_packets) - ? "Disabled" - : "Enabled"); + msyslog(LOG_INFO, "%s on %d %s %s UDP %d", + (iface->ignore_packets) + ? "Listen and drop" + : "Listen normally", + iface->ifnum, + iface->name, + stoa(&iface->sin), + SRCPORT(&iface->sin)); } @@ -3540,7 +3540,7 @@ findlocalinterface( * another address is enabled on the same subnet. * See http://bugs.ntp.org/1184 for more detail. */ - if (NULL == iface) + if (NULL == iface || iface->ignore_packets) iface = getsamenetinterface(&saddr, flags); /* Don't use an interface which will ignore replies */ @@ -3614,7 +3614,7 @@ findlocalcastinterface( */ nif = findlocalinterface(addr, 0, 0); - if (nif) { + if (nif != NULL && !nif->ignore_packets) { DPRINTF(2, ("findlocalcastinterface: kernel recommends interface #%d %s for %s\n", nif->ifnum, nif->name, stoa(addr))); return nif; @@ -4143,7 +4143,8 @@ same_network( } /* - * Find an address in the list on the same network as addr + * Find an address in the list on the same network as addr which is not + * addr. */ static struct interface * find_samenet_addr_in_list( @@ -4159,8 +4160,10 @@ find_samenet_addr_in_list( entry != NULL; entry = entry->link) - if (same_network(&entry->addr, &entry->interface->mask, - addr)) { + if (!SOCK_EQ(addr, &entry->addr) + && same_network(&entry->addr, + &entry->interface->mask, + addr)) { DPRINTF(4, ("FOUND\n")); return entry->interface; } diff --git a/ntpd/ntp_peer.c b/ntpd/ntp_peer.c index 91273aa86..18ba4844d 100644 --- a/ntpd/ntp_peer.c +++ b/ntpd/ntp_peer.c @@ -590,7 +590,7 @@ peer_refresh_interface( * clear crypto if we change the local address */ if (peer->dstadr != piface && !(peer->cast_flags & - MDF_BCLNT)) + (MDF_ACAST | MDF_BCLNT))) peer_clear(peer, "XFAC"); /* diff --git a/ports/winnt/ntpd/ntservice.c b/ports/winnt/ntpd/ntservice.c index 11cf708c4..c81decd43 100644 --- a/ports/winnt/ntpd/ntservice.c +++ b/ports/winnt/ntpd/ntservice.c @@ -111,22 +111,34 @@ int main( int argc, char *argv[] ) if ( isc_win32os_majorversion() <= 4 ) accept_wildcard_if_for_winnt = 1; - /* Command line users should put -n in the options */ + /* + * This is a hack in the Windows port of ntpd. Before the + * portable ntpd libopts processing of the command line, we + * need to know if we're "daemonizing" (attempting to start as + * a service). There is undoubtedly a better way. Legitimate + * option combinations are broken by this code , such as: + * ntpd -nc debug.conf + */ while (argv[i]) { - if (!_strnicmp(argv[i], "-d", 2) || - !strcmp(argv[i], "-q") || - !strcmp(argv[i], "--help") || - !strcmp(argv[i], "-n")) { + if (!_strnicmp(argv[i], "-d", 2) + || !strcmp(argv[i], "--debug_level") + || !strcmp(argv[i], "--set-debug_level") + || !strcmp(argv[i], "-q") + || !strcmp(argv[i], "--quit") + || !strcmp(argv[i], "-?") + || !strcmp(argv[i], "--help") + || !_strnicmp(argv[i], "-n", 2) + || !strcmp(argv[i], "--nofork") + || !strcmp(argv[i], "--saveconfigquit")) { foreground = TRUE; break; } i++; } - if (foreground) { - /* run in console window */ + if (foreground) /* run in console window */ rc = ntpdmain(argc, argv); - } else { + else { /* Start up as service */ SERVICE_TABLE_ENTRY dispatchTable[] = {