]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 1342] ignore|drop one IPv6 address on an interface blocks all
authorDave Hart <hart@ntp.org>
Thu, 15 Oct 2009 03:30:56 +0000 (03:30 +0000)
committerDave Hart <hart@ntp.org>
Thu, 15 Oct 2009 03:30:56 +0000 (03:30 +0000)
  addresses on that interface.

bk: 4ad69770UjMPMqJfcP_kAFfvL7y5ow

ChangeLog
lib/isc/win32/interfaceiter.c
ntpd/ntp_config.c
ntpd/ntp_io.c
ntpd/ntp_peer.c
ports/winnt/ntpd/ntservice.c

index e16d507165398e5db95f96ff5b961e5738b6c896..0777a83855e541f32f6ee2e5c0ba53c62858bf60 100644 (file)
--- 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 <stenn@ntp.org>
 * [Bug 1302] OpenSSL under Windows needs applink support.
 * [Bug 1337] fix incorrect args to setsockopt(fd, IP_MULTICAST_IF,...).
index 09133dff35bd86fd9bb5944a658d339b5742ae5b..b71cb245abcc011123b61a38b80e80b6fc2e79cb 100644 (file)
@@ -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,
index ddad85c079f9181bec905c3a479951a76c3493f1..114db85121a647c46359ae9c42578ee1aec3b54b 100644 (file)
@@ -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,
index 2d47d13523d949dfdbe7c52bc8409a93c488cd71..bb4533805d5c08361e6a76e8b04c4d8d6ae382f7 100644 (file)
@@ -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;
                }
index 91273aa86ccef01f0c89301591ec9bc4e9cbe6bc..18ba4844d8e92888bc6c38542ac319b17b50224c 100644 (file)
@@ -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");
 
                /*
index 11cf708c4526703c16635978a6b89c3dfc68574e..c81decd43ebc384d049d96e8043a6377973efce3 100644 (file)
@@ -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[] = {