|
Adam Tkac |
2bd245 |
diff -up bind-9.7.3-P3/bin/nsupdate/nsupdate.c.rh714049 bind-9.7.3-P3/bin/nsupdate/nsupdate.c
|
|
Adam Tkac |
2bd245 |
--- bind-9.7.3-P3/bin/nsupdate/nsupdate.c.rh714049 2011-08-12 14:17:39.520175003 +0200
|
|
Adam Tkac |
2bd245 |
+++ bind-9.7.3-P3/bin/nsupdate/nsupdate.c 2011-08-12 15:11:01.812173573 +0200
|
|
Adam Tkac |
2bd245 |
@@ -109,6 +109,13 @@ extern int h_errno;
|
|
Adam Tkac |
2bd245 |
|
|
Adam Tkac |
2bd245 |
#define DNSDEFAULTPORT 53
|
|
Adam Tkac |
2bd245 |
|
|
Adam Tkac |
2bd245 |
+/*
|
|
Adam Tkac |
2bd245 |
+ * Assume that bind9_getaddresses returns IPv6 and IPv4 addrs
|
|
Adam Tkac |
2bd245 |
+ * so when master server is not reachable via IPv6
|
|
Adam Tkac |
2bd245 |
+ * we can switch to IPv4.
|
|
Adam Tkac |
2bd245 |
+ */
|
|
Adam Tkac |
2bd245 |
+#define MAX_SERVERADDRS 4
|
|
Adam Tkac |
2bd245 |
+
|
|
Adam Tkac |
2bd245 |
static isc_uint16_t dnsport = DNSDEFAULTPORT;
|
|
Adam Tkac |
2bd245 |
|
|
Adam Tkac |
2bd245 |
#ifndef RESOLV_CONF
|
|
Adam Tkac |
2bd245 |
@@ -151,6 +158,8 @@ static isc_sockaddr_t *servers;
|
|
Adam Tkac |
2bd245 |
static int ns_inuse = 0;
|
|
Adam Tkac |
2bd245 |
static int ns_total = 0;
|
|
Adam Tkac |
2bd245 |
static isc_sockaddr_t *userserver = NULL;
|
|
Adam Tkac |
2bd245 |
+static int curserver = 0;
|
|
Adam Tkac |
2bd245 |
+static int userservers = 0;
|
|
Adam Tkac |
2bd245 |
static isc_sockaddr_t *localaddr = NULL;
|
|
Adam Tkac |
2bd245 |
static isc_sockaddr_t *serveraddr = NULL;
|
|
Adam Tkac |
2bd245 |
static isc_sockaddr_t tempaddr;
|
|
Adam Tkac |
2bd245 |
@@ -703,7 +712,8 @@ doshutdown(void) {
|
|
Adam Tkac |
2bd245 |
isc_task_detach(&global_task);
|
|
Adam Tkac |
2bd245 |
|
|
Adam Tkac |
2bd245 |
if (userserver != NULL)
|
|
Adam Tkac |
2bd245 |
- isc_mem_put(mctx, userserver, sizeof(isc_sockaddr_t));
|
|
Adam Tkac |
2bd245 |
+ isc_mem_put(mctx, userserver,
|
|
Adam Tkac |
2bd245 |
+ MAX_SERVERADDRS * sizeof(isc_sockaddr_t));
|
|
Adam Tkac |
2bd245 |
|
|
Adam Tkac |
2bd245 |
if (localaddr != NULL)
|
|
Adam Tkac |
2bd245 |
isc_mem_put(mctx, localaddr, sizeof(isc_sockaddr_t));
|
|
Adam Tkac |
2bd245 |
@@ -914,17 +924,21 @@ setup_system(void) {
|
|
Adam Tkac |
2bd245 |
}
|
|
Adam Tkac |
2bd245 |
|
|
Adam Tkac |
2bd245 |
static void
|
|
Adam Tkac |
2bd245 |
-get_address(char *host, in_port_t port, isc_sockaddr_t *sockaddr) {
|
|
Adam Tkac |
2bd245 |
+get_addresses(char *host, in_port_t port, isc_sockaddr_t *sockaddr, int *naddrs) {
|
|
Adam Tkac |
2bd245 |
int count;
|
|
Adam Tkac |
2bd245 |
isc_result_t result;
|
|
Adam Tkac |
2bd245 |
|
|
Adam Tkac |
2bd245 |
isc_app_block();
|
|
Adam Tkac |
2bd245 |
- result = bind9_getaddresses(host, port, sockaddr, 1, &count);
|
|
Adam Tkac |
2bd245 |
+ result = bind9_getaddresses(host, port, sockaddr,
|
|
Adam Tkac |
2bd245 |
+ (naddrs == NULL) ? 1 : MAX_SERVERADDRS, &count);
|
|
Adam Tkac |
2bd245 |
isc_app_unblock();
|
|
Adam Tkac |
2bd245 |
if (result != ISC_R_SUCCESS)
|
|
Adam Tkac |
2bd245 |
fatal("couldn't get address for '%s': %s",
|
|
Adam Tkac |
2bd245 |
host, isc_result_totext(result));
|
|
Adam Tkac |
2bd245 |
- INSIST(count == 1);
|
|
Adam Tkac |
2bd245 |
+ if (naddrs == NULL)
|
|
Adam Tkac |
2bd245 |
+ INSIST(count == 1);
|
|
Adam Tkac |
2bd245 |
+ else
|
|
Adam Tkac |
2bd245 |
+ *naddrs = count;
|
|
Adam Tkac |
2bd245 |
}
|
|
Adam Tkac |
2bd245 |
|
|
Adam Tkac |
2bd245 |
#define PARSE_ARGS_FMT "dDML:y:ghlovk:p:rR::t:u:"
|
|
Adam Tkac |
2bd245 |
@@ -1364,12 +1378,14 @@ evaluate_server(char *cmdline) {
|
|
Adam Tkac |
2bd245 |
}
|
|
Adam Tkac |
2bd245 |
|
|
Adam Tkac |
2bd245 |
if (userserver == NULL) {
|
|
Adam Tkac |
2bd245 |
- userserver = isc_mem_get(mctx, sizeof(isc_sockaddr_t));
|
|
Adam Tkac |
2bd245 |
+ userserver = isc_mem_get(mctx,
|
|
Adam Tkac |
2bd245 |
+ MAX_SERVERADDRS * sizeof(isc_sockaddr_t));
|
|
Adam Tkac |
2bd245 |
if (userserver == NULL)
|
|
Adam Tkac |
2bd245 |
fatal("out of memory");
|
|
Adam Tkac |
2bd245 |
}
|
|
Adam Tkac |
2bd245 |
|
|
Adam Tkac |
2bd245 |
- get_address(server, (in_port_t)port, userserver);
|
|
Adam Tkac |
2bd245 |
+ memset(userserver, 0, MAX_SERVERADDRS * sizeof(isc_sockaddr_t));
|
|
Adam Tkac |
2bd245 |
+ get_addresses(server, (in_port_t)port, userserver, &userservers);
|
|
Adam Tkac |
2bd245 |
|
|
Adam Tkac |
2bd245 |
return (STATUS_MORE);
|
|
Adam Tkac |
2bd245 |
}
|
|
Adam Tkac |
2bd245 |
@@ -2207,19 +2223,25 @@ recvsoa(isc_task_t *task, isc_event_t *e
|
|
Adam Tkac |
2bd245 |
|
|
Adam Tkac |
2bd245 |
if (eresult != ISC_R_SUCCESS) {
|
|
Adam Tkac |
2bd245 |
char addrbuf[ISC_SOCKADDR_FORMATSIZE];
|
|
Adam Tkac |
2bd245 |
+ isc_sockaddr_t *server;
|
|
Adam Tkac |
2bd245 |
|
|
Adam Tkac |
2bd245 |
isc_sockaddr_format(addr, addrbuf, sizeof(addrbuf));
|
|
Adam Tkac |
2bd245 |
fprintf(stderr, "; Communication with %s failed: %s\n",
|
|
Adam Tkac |
2bd245 |
addrbuf, isc_result_totext(eresult));
|
|
Adam Tkac |
2bd245 |
- if (userserver != NULL)
|
|
Adam Tkac |
2bd245 |
- fatal("could not talk to specified name server");
|
|
Adam Tkac |
2bd245 |
- else if (++ns_inuse >= lwconf->nsnext)
|
|
Adam Tkac |
2bd245 |
+ if (userserver != NULL) {
|
|
Adam Tkac |
2bd245 |
+ if (++curserver == MAX_SERVERADDRS)
|
|
Adam Tkac |
2bd245 |
+ fatal("could not talk to specified name server");
|
|
Adam Tkac |
2bd245 |
+ else
|
|
Adam Tkac |
2bd245 |
+ ddebug("recvsoa: trying next server");
|
|
Adam Tkac |
2bd245 |
+ } else if (++ns_inuse >= lwconf->nsnext)
|
|
Adam Tkac |
2bd245 |
fatal("could not talk to any default name server");
|
|
Adam Tkac |
2bd245 |
ddebug("Destroying request [%p]", request);
|
|
Adam Tkac |
2bd245 |
dns_request_destroy(&request);
|
|
Adam Tkac |
2bd245 |
dns_message_renderreset(soaquery);
|
|
Adam Tkac |
2bd245 |
dns_message_settsigkey(soaquery, NULL);
|
|
Adam Tkac |
2bd245 |
- sendrequest(localaddr, &servers[ns_inuse], soaquery, &request);
|
|
Adam Tkac |
2bd245 |
+ server = (userserver != NULL) ? &userserver[curserver] :
|
|
Adam Tkac |
2bd245 |
+ &servers[ns_inuse];
|
|
Adam Tkac |
2bd245 |
+ sendrequest(localaddr, server, soaquery, &request);
|
|
Adam Tkac |
2bd245 |
isc_mem_put(mctx, reqinfo, sizeof(nsu_requestinfo_t));
|
|
Adam Tkac |
2bd245 |
isc_event_free(&event);
|
|
Adam Tkac |
2bd245 |
setzoneclass(dns_rdataclass_none);
|
|
Adam Tkac |
2bd245 |
@@ -2351,7 +2373,7 @@ recvsoa(isc_task_t *task, isc_event_t *e
|
|
Adam Tkac |
2bd245 |
}
|
|
Adam Tkac |
2bd245 |
|
|
Adam Tkac |
2bd245 |
if (userserver != NULL)
|
|
Adam Tkac |
2bd245 |
- serveraddr = userserver;
|
|
Adam Tkac |
2bd245 |
+ serveraddr = &userserver[curserver];
|
|
Adam Tkac |
2bd245 |
else {
|
|
Adam Tkac |
2bd245 |
char serverstr[DNS_NAME_MAXTEXT+1];
|
|
Adam Tkac |
2bd245 |
isc_buffer_t buf;
|
|
Adam Tkac |
2bd245 |
@@ -2360,7 +2382,7 @@ recvsoa(isc_task_t *task, isc_event_t *e
|
|
Adam Tkac |
2bd245 |
result = dns_name_totext(&master, ISC_TRUE, &buf;;
|
|
Adam Tkac |
2bd245 |
check_result(result, "dns_name_totext");
|
|
Adam Tkac |
2bd245 |
serverstr[isc_buffer_usedlength(&buf)] = 0;
|
|
Adam Tkac |
2bd245 |
- get_address(serverstr, dnsport, &tempaddr);
|
|
Adam Tkac |
2bd245 |
+ get_addresses(serverstr, dnsport, &tempaddr, NULL);
|
|
Adam Tkac |
2bd245 |
serveraddr = &tempaddr;
|
|
Adam Tkac |
2bd245 |
}
|
|
Adam Tkac |
2bd245 |
dns_rdata_freestruct(&soa;;
|
|
Adam Tkac |
2bd245 |
@@ -2464,9 +2486,9 @@ start_gssrequest(dns_name_t *master)
|
|
Adam Tkac |
2bd245 |
fatal("out of memory");
|
|
Adam Tkac |
2bd245 |
}
|
|
Adam Tkac |
2bd245 |
if (userserver == NULL)
|
|
Adam Tkac |
2bd245 |
- get_address(namestr, dnsport, kserver);
|
|
Adam Tkac |
2bd245 |
+ get_addresses(namestr, dnsport, kserver, NULL);
|
|
Adam Tkac |
2bd245 |
else
|
|
Adam Tkac |
2bd245 |
- (void)memcpy(kserver, userserver, sizeof(isc_sockaddr_t));
|
|
Adam Tkac |
2bd245 |
+ (void)memcpy(kserver, &userserver[curserver], sizeof(isc_sockaddr_t));
|
|
Adam Tkac |
2bd245 |
|
|
Adam Tkac |
2bd245 |
dns_fixedname_init(&fname);
|
|
Adam Tkac |
2bd245 |
servname = dns_fixedname_name(&fname);
|
|
Adam Tkac |
2bd245 |
@@ -2594,15 +2616,17 @@ recvgss(isc_task_t *task, isc_event_t *e
|
|
Adam Tkac |
2bd245 |
isc_sockaddr_format(addr, addrbuf, sizeof(addrbuf));
|
|
Adam Tkac |
2bd245 |
fprintf(stderr, "; Communication with %s failed: %s\n",
|
|
Adam Tkac |
2bd245 |
addrbuf, isc_result_totext(eresult));
|
|
Adam Tkac |
2bd245 |
- if (userserver != NULL)
|
|
Adam Tkac |
2bd245 |
+ if (userserver != NULL) {
|
|
Adam Tkac |
2bd245 |
fatal("could not talk to specified name server");
|
|
Adam Tkac |
2bd245 |
- else if (++ns_inuse >= lwconf->nsnext)
|
|
Adam Tkac |
2bd245 |
+ } else if (++ns_inuse >= lwconf->nsnext)
|
|
Adam Tkac |
2bd245 |
fatal("could not talk to any default name server");
|
|
Adam Tkac |
2bd245 |
ddebug("Destroying request [%p]", request);
|
|
Adam Tkac |
2bd245 |
dns_request_destroy(&request);
|
|
Adam Tkac |
2bd245 |
dns_message_renderreset(tsigquery);
|
|
Adam Tkac |
2bd245 |
- sendrequest(localaddr, &servers[ns_inuse], tsigquery,
|
|
Adam Tkac |
2bd245 |
- &request);
|
|
Adam Tkac |
2bd245 |
+ sendrequest(localaddr,
|
|
Adam Tkac |
2bd245 |
+ (userserver != NULL) ? &userserver[curserver] :
|
|
Adam Tkac |
2bd245 |
+ &servers[ns_inuse],
|
|
Adam Tkac |
2bd245 |
+ tsigquery, &request);
|
|
Adam Tkac |
2bd245 |
isc_mem_put(mctx, reqinfo, sizeof(nsu_gssinfo_t));
|
|
Adam Tkac |
2bd245 |
isc_event_free(&event);
|
|
Adam Tkac |
2bd245 |
return;
|