]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 153] Avoid DNS lookups of known netmasks or refclocks
authorHarlan Stenn <stenn@ntp.org>
Sun, 27 Aug 2006 23:44:15 +0000 (23:44 +0000)
committerHarlan Stenn <stenn@ntp.org>
Sun, 27 Aug 2006 23:44:15 +0000 (23:44 +0000)
bk: 44f22e4fIUnl5werMPakKJGtTx1Eeg

ntpd/ntp_config.c

index 7bec162bd3e6137b027e2555ed1a28905bbd838f..d4ba6b42af73d961e10421b3ee32f278a16463f8 100644 (file)
@@ -2206,6 +2206,19 @@ getnetnum(
        struct addrinfo *ptr;
        int retval;
 
+#if 0
+       printf("getnetnum: <%s> is a %s (%d)\n",
+               num,
+               (a_type == t_UNK)
+               ? "t_UNK"
+               : (a_type == t_REF)
+                 ? "t_REF"
+                 : (a_type == t_MSK)
+                   ? "t_MSK"
+                   : "???",
+               a_type);
+#endif
+
        /* Get host address. Looking for UDP datagram connection */
        memset(&hints, 0, sizeof (hints));
        if (addr->ss_family == AF_INET || addr->ss_family == AF_INET6)
@@ -2219,9 +2232,14 @@ getnetnum(
                hints.ai_family = AF_INET;
 
        hints.ai_socktype = SOCK_DGRAM;
+
+       if (a_type != t_UNK) {
+               hints.ai_flags = AI_NUMERICHOST;
+       }
+
 #ifdef DEBUG
-               if (debug > 3)
-                       printf("getaddrinfo %s\n", num);
+       if (debug > 3)
+               printf("getnetnum: calling getaddrinfo(%s,...)\n", num);
 #endif
        retval = getaddrinfo(num, "ntp", &hints, &ptr);
        if (retval != 0 ||
@@ -2252,8 +2270,16 @@ getnetnum(
        memcpy(addr, ptr->ai_addr, ptr->ai_addrlen);
 #ifdef DEBUG
        if (debug > 1)
-               printf("getnetnum given %s, got %s \n",
-                  num, stoa(addr));
+               printf("getnetnum given %s, got %s (%s/%d)\n",
+                  num, stoa(addr),
+                       (a_type == t_UNK)
+                       ? "t_UNK"
+                       : (a_type == t_REF)
+                         ? "t_REF"
+                         : (a_type == t_MSK)
+                           ? "t_MSK"
+                           : "???",
+                       a_type);
 #endif
         freeaddrinfo(ptr);
        return 1;