From: Hal Murray Date: Mon, 9 Nov 2009 23:15:07 +0000 (-0500) Subject: configure.ac, ntp_intres.c: X-Git-Tag: NTP_4_2_5P243_RC~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e4b1c1e90f010ab9c781f5a1e288e2870629b80f;p=thirdparty%2Fntp.git configure.ac, ntp_intres.c: 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 --- diff --git a/configure.ac b/configure.ac index 1d5f197ce..c9eb8972a 100644 --- a/configure.ac +++ b/configure.ac @@ -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, diff --git a/ntpd/ntp_config.c b/ntpd/ntp_config.c index 33825c115..88655b799 100644 --- a/ntpd/ntp_config.c +++ b/ntpd/ntp_config.c @@ -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, diff --git a/ntpd/ntp_intres.c b/ntpd/ntp_intres.c index be8d24e21..c11b520d8 100644 --- a/ntpd/ntp_intres.c +++ b/ntpd/ntp_intres.c @@ -41,6 +41,10 @@ # include /* MAXHOSTNAMELEN (often) */ #endif +#if defined(HAVE_RES_INIT) || defined(HAVE___RES_INIT) +#include +#endif + #include #include @@ -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,