]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
configure.ac, ntp_intres.c:
authorHal Murray <murray@ntp.org>
Mon, 9 Nov 2009 23:15:07 +0000 (18:15 -0500)
committerHal Murray <murray@ntp.org>
Mon, 9 Nov 2009 23:15:07 +0000 (18:15 -0500)
  Fix for bug-1266: reload /etc/resolv.conf on deferred DNS
ntp_config.c:
  Hacks to help debug deferred DNS
  (default off)

bk: 4af8a27bMP7Pq3wvMtZVWapyWn-qkQ

configure.ac
ntpd/ntp_config.c
ntpd/ntp_intres.c

index 1d5f197ce7824496dc323dcd4be411f7e573c232..c9eb8972af814b2b8b77bca282b219beb1f5efc1 100644 (file)
@@ -456,6 +456,10 @@ esac
 AC_CHECK_FUNC(setsockopt, ,
        [AC_SEARCH_LIBS([setsockopt], [socket xnet])])
 
+AC_SEARCH_LIBS([setsockopt], [socket xnet])
+AC_SEARCH_LIBS([res_init], [resolv], , , [-lsocket -lnsl])
+AC_CHECK_FUNCS(res_init __res_init)
+
 AC_HEADER_STDC
 AC_CHECK_HEADERS(bstring.h)
 AC_CHECK_HEADER(dns_sd.h,
index 33825c115ff9d0843bad6b3ea5dfccffed945939..88655b799dd99dd1f202a69cb96692749e0c25f5 100644 (file)
@@ -3362,6 +3362,21 @@ config_peers(
                status = get_multiple_netnums(curr_peer->addr->address,
                    &peeraddr, &res, 0, t_UNK);
 
+#if 0 /* Hack for debugging Deferred DNS */
+               if (status == 1) {
+                       /* Deferring everything breaks refclocks. */
+                       memcpy(&peeraddr, res->ai_addr, res->ai_addrlen);
+                       if (!ISREFCLOCKADR(&peeraddr)) {
+                               status = 0;  /* force deferred DNS path */
+                               msyslog(LOG_INFO, "Forcing Deferred DNS for %s, %s",
+                                       curr_peer->addr->address, stoa(&peeraddr));
+                       } else {
+                               msyslog(LOG_INFO, "NOT Deferred DNS for %s, %s",
+                                       curr_peer->addr->address, stoa(&peeraddr));
+                       }
+               }
+#endif
+
                /* I don't know why getnetnum would return -1.
                 * The old code had this test, so I guess it must be
                 * useful
@@ -3375,6 +3390,7 @@ config_peers(
                 * resolution later
                 */
                else if (status != 1) {
+                       msyslog(LOG_INFO, "Deferring DNS for %s", curr_peer->addr->address);
                        save_resolve(curr_peer->addr->address,
                                     hmode,
                                     curr_peer->peerversion,
index be8d24e21c44b33db4368331e841ef1d06a0c13a..c11b520d84cf635e06dc0b1de415a2293a371923 100644 (file)
 # include <sys/param.h>                /* MAXHOSTNAMELEN (often) */
 #endif
 
+#if defined(HAVE_RES_INIT) || defined(HAVE___RES_INIT)
+#include <resolv.h>
+#endif
+
 #include <isc/net.h>
 #include <isc/result.h>
 
@@ -492,6 +496,7 @@ findhostaddr(
        }
 
        if (entry->ce_name) {
+               if (0) msyslog(LOG_INFO, "findhostaddr: Trying %s", entry->ce_name);
                DPRINTF(2, ("findhostaddr: Resolving <%s>\n",
                        entry->ce_name));
 
@@ -502,7 +507,6 @@ findhostaddr(
                 */
                if (!ipv6_works)
                        hints.ai_family = AF_INET;
-
                error = getaddrinfo(entry->ce_name, NULL, &hints, &addr);
                if (error == 0) {
                        entry->peer_store = *((sockaddr_u *)(addr->ai_addr));
@@ -945,32 +949,32 @@ request(
                
                    case INFO_ERR_IMPL:
                        msyslog(LOG_ERR,
-                               "ntpd reports implementation mismatch!");
+                               "ntp_intres.request: implementation mismatch");
                        return 0;
                
                    case INFO_ERR_REQ:
                        msyslog(LOG_ERR,
-                               "ntpd says configuration request is unknown!");
+                               "ntp_intres.request: request unknown");
                        return 0;
                
                    case INFO_ERR_FMT:
                        msyslog(LOG_ERR,
-                               "ntpd indicates a format error occurred!");
+                               "ntp_intres.request: format error");
                        return 0;
 
                    case INFO_ERR_NODATA:
                        msyslog(LOG_ERR,
-                               "ntpd indicates no data available!");
+                               "ntp_intres.request: no data available");
                        return 0;
                
                    case INFO_ERR_AUTH:
                        msyslog(LOG_ERR,
-                               "ntpd returns a permission denied error!");
+                               "ntp_intres.request: permission denied");
                        return 0;
 
                    default:
                        msyslog(LOG_ERR,
-                               "ntpd returns unknown error code %d!", n);
+                               "ntp_intres.request: unknown error code %d", n);
                        return 0;
                }
        }
@@ -1146,6 +1150,9 @@ doconfigure(
                            dores ? "with" : "without" );
 #endif
 
+#if defined(HAVE_RES_INIT) || defined(HAVE___RES_INIT)
+       if (dores) res_init();  /* Reload /etc/resolv.conf - bug 1226 */
+#endif
        ce = confentries;
        while (ce != NULL) {
 #ifdef DEBUG
@@ -1175,6 +1182,7 @@ doconfigure(
                                removeentry(ceremove);
                                continue;
                        }
+                       // Failed case.  Should bump counter and give up.
 #ifdef DEBUG
                        if (debug > 1) {
                                msyslog(LOG_INFO,