Commit 04c22cea authored by Mark Andrews's avatar Mark Andrews
Browse files

536. [func] Use transfer-source{-v6} when sending refresh queries.

                        Transfer-source{-v6} now take a optional port
                        parameter for setting the UDP source port.  The port
                        parameter is ignored for TCP.
parent 38a5d999
535. [func] Use xfrsource[46] when forwarding update requests.
536. [func] Use transfer-source{-v6} when sending refresh queries.
Transfer-source{-v6} now take a optional port
parameter for setting the UDP source port. The port
parameter is ignored for TCP.
535. [func] Use transfer-source{-v6} when forwarding update
requests.
534. [func] Ancestors have been removed from RBT chains. Ancestor
information can be discerned via node parent pointers.
......
......@@ -2,7 +2,7 @@
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.0//EN"
"http://www.oasis-open.org/docbook/xml/4.0/docbookx.dtd">
<!-- File: $Id: Bv9ARM-book.xml,v 1.19 2000/10/19 17:22:53 gson Exp $ -->
<!-- File: $Id: Bv9ARM-book.xml,v 1.20 2000/10/31 01:17:14 marka Exp $ -->
<book>
......@@ -2390,8 +2390,8 @@ lookups performed on behalf of clients by a caching name server.</para></entry>
<optional> transfers-in <replaceable>number</replaceable>; </optional>
<optional> transfers-out <replaceable>number</replaceable>; </optional>
<optional> transfers-per-ns <replaceable>number</replaceable>; </optional>
<optional> transfer-source <replaceable>ip4_addr</replaceable>; </optional>
<optional> transfer-source-v6 <replaceable>ip6_addr</replaceable>; </optional>
<optional> transfer-source <replaceable>ip4_addr</replaceable> <optional>port <replaceable>ip_port</replaceable></optional> ; </optional>
<optional> transfer-source-v6 <replaceable>ip6_addr</replaceable> <optional>port <replaceable>ip_port</replaceable></optional> ; </optional>
<optional> also-notify { <replaceable>ip_addr</replaceable> <optional>port <replaceable>ip_port</replaceable></optional> ; <optional> <replaceable>ip_addr</replaceable> <optional>port <replaceable>ip_port</replaceable></optional> ; ... </optional> }; </optional>
<optional> max-ixfr-log-size <replaceable>number</replaceable>; </optional>
<optional> coresize <replaceable>size_spec</replaceable> ; </optional>
......@@ -2967,7 +2967,10 @@ of the <command>server</command> statement.</para></entry>
<entry colname = "1"><para><command>transfer-source</command></para></entry>
<entry colname = "2"><para><command>transfer-source</command> determines
which local address will be bound to IPv4 TCP connections used to
fetch zones transferred inbound by the server. If not set, it defaults
fetch zones transferred inbound by the server. It also determines
the IPv4 address, and optionaly the UDP port, used for the refresh queries.
It also determines the IPv4 address used when updates are forwarded.
If not set, it defaults
to a system controlled value which will usually be the address of
the interface "closest to" the remote end. This address must appear
in the remote end's <command>allow-transfer</command> option for
......@@ -3518,8 +3521,8 @@ Statement Grammar</title>
<optional> max-transfer-time-out <replaceable>number</replaceable> ; </optional>
<optional> notify <replaceable>true_or_false</replaceable> ; </optional>
<optional> pubkey <replaceable>number</replaceable> <replaceable>number</replaceable> <replaceable>number</replaceable> <replaceable>string</replaceable> ; </optional>
<optional> transfer-source (<replaceable>ip4_addr</replaceable> | <constant>*</constant>) ; </optional>
<optional> transfer-source-v6 (<replaceable>ip6_addr</replaceable> | <constant>*</constant>) ; </optional>
<optional> transfer-source (<replaceable>ip4_addr</replaceable> | <constant>*</constant>) <optional>port <replaceable>ip_port</replaceable></optional> ; </optional>
<optional> transfer-source-v6 (<replaceable>ip6_addr</replaceable> | <constant>*</constant>) <optional>port <replaceable>ip_port</replaceable></optional> ; </optional>
<optional> sig-validity-interval <replaceable>number</replaceable> ; </optional>
}</optional>;
</programlisting>
......@@ -3745,7 +3748,9 @@ on loading and ignores the option.</para></entry>
<row rowsep = "0">
<entry colname = "1"><para><command>transfer-source</command></para></entry>
<entry colname = "2"><para>Determines which local address will be bound
to the IPv4 TCP connection used to fetch this zone. If not set,
to the IPv4 TCP connection used to fetch this zone. It also determines
the IPv4 address, and optionaly the UDP port, used for the refresh queries.
It also determines the IPv4 address used when updates are forwarded. If not set,
it defaults to a system controlled value which will usually be the
address of the interface "closest to" the remote end. If the remote
end user is an <command>allow-transfer</command> option for this
......
......@@ -17,7 +17,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: confparser.y.dirty,v 1.23 2000/10/20 19:32:47 bwelling Exp $ */
/* $Id: confparser.y.dirty,v 1.24 2000/10/31 01:17:18 marka Exp $ */
#include <config.h>
......@@ -1063,6 +1063,20 @@ option: /* Empty */
YYABORT;
}
}
| L_TRANSFER_SOURCE maybe_wild_ip4_only_addr L_PORT maybe_wild_port
{
isc_sockaddr_setport(&$2, $4);
tmpres = dns_c_ctx_settransfersource(currcfg, $2);
if (tmpres == ISC_R_EXISTS) {
parser_error(ISC_FALSE,
"cannot redefine transfer-source");
YYABORT;
} else if (tmpres != ISC_R_SUCCESS) {
parser_error(ISC_FALSE,
"failed to set transfer-source");
YYABORT;
}
}
| L_TRANSFER_SOURCE_V6 maybe_wild_ip6_only_addr
{
tmpres = dns_c_ctx_settransfersourcev6(currcfg, $2);
......@@ -1076,6 +1090,20 @@ option: /* Empty */
YYABORT;
}
}
| L_TRANSFER_SOURCE_V6 maybe_wild_ip6_only_addr L_PORT maybe_wild_port
{
isc_sockaddr_setport(&$2, $4);
tmpres = dns_c_ctx_settransfersourcev6(currcfg, $2);
if (tmpres == ISC_R_EXISTS) {
parser_error(ISC_FALSE,
"cannot redefine transfer-source-v6");
YYABORT;
} else if (tmpres != ISC_R_SUCCESS) {
parser_error(ISC_FALSE,
"failed to set transfer-source-v6");
YYABORT;
}
}
#ifndef NOMINUM_PUBLIC
| L_ALLOW_NOTIFY L_LBRACE address_match_list L_RBRACE
{
......@@ -3993,6 +4021,24 @@ view_option: L_FORWARD zone_forward_opt
YYABORT;
}
}
| L_TRANSFER_SOURCE maybe_wild_ip4_only_addr L_PORT maybe_wild_port
{
dns_c_view_t *view = dns_c_ctx_getcurrview(currcfg);
INSIST(view != NULL);
isc_sockaddr_setport(&$2, $4);
tmpres = dns_c_view_settransfersource(view, $2);
if (tmpres == ISC_R_EXISTS) {
parser_error(ISC_FALSE,
"cannot redefine view transfer-source");
YYABORT;
} else if (tmpres != ISC_R_SUCCESS) {
parser_error(ISC_FALSE,
"failed to set view transfer-source");
YYABORT;
}
}
| L_TRANSFER_SOURCE_V6 maybe_wild_ip6_only_addr
{
dns_c_view_t *view = dns_c_ctx_getcurrview(currcfg);
......@@ -4011,6 +4057,25 @@ view_option: L_FORWARD zone_forward_opt
YYABORT;
}
}
| L_TRANSFER_SOURCE_V6 maybe_wild_ip6_only_addr L_PORT maybe_wild_port
{
dns_c_view_t *view = dns_c_ctx_getcurrview(currcfg);
INSIST(view != NULL);
isc_sockaddr_setport(&$2, $4);
tmpres = dns_c_view_settransfersourcev6(view, $2);
if (tmpres == ISC_R_EXISTS) {
parser_error(ISC_FALSE,
"cannot redefine view "
"transfer-source-v6");
YYABORT;
} else if (tmpres != ISC_R_SUCCESS) {
parser_error(ISC_FALSE,
"failed to set view transfer-source-v6");
YYABORT;
}
}
| L_MAX_TRANSFER_TIME_OUT L_INTEGER
{
dns_c_view_t *view = dns_c_ctx_getcurrview(currcfg);
......@@ -4875,6 +4940,24 @@ zone_option: L_FILE L_QSTRING
YYABORT;
}
}
| L_TRANSFER_SOURCE maybe_wild_ip4_only_addr L_PORT maybe_wild_port
{
dns_c_zone_t *zone = dns_c_ctx_getcurrzone(currcfg);
INSIST(zone != NULL);
isc_sockaddr_setport(&$2, $4);
tmpres = dns_c_zone_settransfersource(zone, $2);
if (tmpres == ISC_R_EXISTS) {
parser_error(ISC_FALSE,
"cannot redefine zone transfer-source");
YYABORT;
} else if (tmpres != ISC_R_SUCCESS) {
parser_error(ISC_FALSE,
"failed to set zone transfer-source");
YYABORT;
}
}
| L_TRANSFER_SOURCE_V6 maybe_wild_ip6_only_addr
{
dns_c_zone_t *zone = dns_c_ctx_getcurrzone(currcfg);
......@@ -4893,6 +4976,25 @@ zone_option: L_FILE L_QSTRING
YYABORT;
}
}
| L_TRANSFER_SOURCE_V6 maybe_wild_ip6_only_addr L_PORT maybe_wild_port
{
dns_c_zone_t *zone = dns_c_ctx_getcurrzone(currcfg);
INSIST(zone != NULL);
isc_sockaddr_setport(&$2, $4);
tmpres = dns_c_zone_settransfersourcev6(zone, $2);
if (tmpres == ISC_R_EXISTS) {
parser_error(ISC_FALSE,
"cannot redefine zone "
"transfer-source-v6");
YYABORT;
} else if (tmpres != ISC_R_SUCCESS) {
parser_error(ISC_FALSE,
"failed to set zone transfer-source-v6");
YYABORT;
}
}
| L_CHECK_NAMES check_names_opt
{
dns_c_zone_t *zone = dns_c_ctx_getcurrzone(currcfg);
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: request.h,v 1.15 2000/10/06 18:58:25 bwelling Exp $ */
/* $Id: request.h,v 1.16 2000/10/31 01:17:19 marka Exp $ */
#ifndef DNS_REQUEST_H
#define DNS_REQUEST_H 1
......@@ -192,6 +192,42 @@ dns_request_create(dns_requestmgr_t *requestmgr, dns_message_t *message,
* requestp != NULL && *requestp == NULL
*/
isc_result_t
dns_request_createvia(dns_requestmgr_t *requestmgr, dns_message_t *message,
isc_sockaddr_t *srcaddr, isc_sockaddr_t *destaddr,
unsigned int options, dns_tsigkey_t *key,
unsigned int timeout, isc_task_t *task,
isc_taskaction_t action, void *arg,
dns_request_t **requestp);
/*
* Create and send a request.
*
* Notes:
*
* 'message' will be rendered and sent to 'address'. If the
* DNS_REQUESTOPT_TCP option is set, TCP will be used. The request
* will timeout after 'timeout' seconds.
*
* When the request completes, successfully, due to a timeout, or
* because it was canceled, a completion event will be sent to 'task'.
*
* Requires:
*
* 'message' is a valid DNS message.
*
* 'dstaddr' is a valid sockaddr.
*
* 'srcaddr' is a valid sockaddr or NULL.
*
* 'srcaddr' and 'dstaddr' are the same protocol family.
*
* 'timeout' > 0
*
* 'task' is a valid task.
*
* requestp != NULL && *requestp == NULL
*/
isc_result_t
dns_request_createraw(dns_requestmgr_t *requestmgr, isc_buffer_t *msgbuf,
isc_sockaddr_t *srcaddr, isc_sockaddr_t *destaddr,
......@@ -217,7 +253,8 @@ dns_request_createraw(dns_requestmgr_t *requestmgr, isc_buffer_t *msgbuf,
* 'destaddr' is a valid sockaddr.
*
* 'srcaddr' is a valid sockaddr or NULL.
* This is currently not implememted, use NULL.
*
* 'srcaddr' and 'dstaddr' are the same protocol family.
*
* 'timeout' > 0
*
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: request.c,v 1.39 2000/10/30 05:08:06 marka Exp $ */
/* $Id: request.c,v 1.40 2000/10/31 01:17:15 marka Exp $ */
#include <config.h>
......@@ -558,6 +558,11 @@ dns_request_createraw(dns_requestmgr_t *requestmgr, isc_buffer_t *msgbuf,
result = ISC_R_NOTIMPLEMENTED;
goto cleanup;
}
if (disp == NULL) {
result = ISC_R_FAMILYNOSUPPORT;
goto cleanup;
}
dns_dispatch_attach(disp, &request->dispatch);
} else {
unsigned int attrs, attrmask;
attrs = 0;
......@@ -585,15 +590,11 @@ dns_request_createraw(dns_requestmgr_t *requestmgr, isc_buffer_t *msgbuf,
requestmgr->taskmgr,
srcaddr, 4096,
1000, 32768, 16411, 16433,
attrs, attrmask, &disp);
attrs, attrmask,
&request->dispatch);
if (result != ISC_R_SUCCESS)
goto cleanup;
}
if (disp == NULL) {
result = ISC_R_FAMILYNOSUPPORT;
goto cleanup;
}
dns_dispatch_attach(disp, &request->dispatch);
}
socket = dns_dispatch_getsocket(request->dispatch);
INSIST(socket != NULL);
......@@ -694,6 +695,19 @@ dns_request_create(dns_requestmgr_t *requestmgr, dns_message_t *message,
unsigned int timeout, isc_task_t *task,
isc_taskaction_t action, void *arg,
dns_request_t **requestp)
{
return(dns_request_createvia(requestmgr, message, NULL, address,
options, key, timeout, task, action,
arg, requestp));
}
isc_result_t
dns_request_createvia(dns_requestmgr_t *requestmgr, dns_message_t *message,
isc_sockaddr_t *srcaddr, isc_sockaddr_t *destaddr,
unsigned int options, dns_tsigkey_t *key,
unsigned int timeout, isc_task_t *task,
isc_taskaction_t action, void *arg,
dns_request_t **requestp)
{
dns_request_t *request = NULL;
isc_task_t *tclone = NULL;
......@@ -701,6 +715,7 @@ dns_request_create(dns_requestmgr_t *requestmgr, dns_message_t *message,
isc_result_t result;
isc_mem_t *mctx;
isc_sockaddr_t bind_any;
isc_sockaddr_t src;
isc_interval_t interval;
dns_messageid_t id;
isc_time_t expires;
......@@ -708,11 +723,13 @@ dns_request_create(dns_requestmgr_t *requestmgr, dns_message_t *message,
REQUIRE(VALID_REQUESTMGR(requestmgr));
REQUIRE(message != NULL);
REQUIRE(address != NULL);
REQUIRE(destaddr != NULL);
REQUIRE(task != NULL);
REQUIRE(action != NULL);
REQUIRE(requestp != NULL && *requestp == NULL);
REQUIRE(timeout > 0);
if (srcaddr != NULL)
REQUIRE(isc_sockaddr_pf(srcaddr) == isc_sockaddr_pf(destaddr));
mctx = requestmgr->mctx;
......@@ -765,12 +782,19 @@ dns_request_create(dns_requestmgr_t *requestmgr, dns_message_t *message,
use_tcp:
if ((options & DNS_REQUESTOPT_TCP) != 0) {
result = isc_socket_create(requestmgr->socketmgr,
isc_sockaddr_pf(address),
isc_sockaddr_pf(destaddr),
isc_sockettype_tcp, &socket);
if (result != ISC_R_SUCCESS)
goto cleanup;
isc_sockaddr_anyofpf(&bind_any, isc_sockaddr_pf(address));
result = isc_socket_bind(socket, &bind_any);
if (srcaddr == NULL) {
isc_sockaddr_anyofpf(&bind_any,
isc_sockaddr_pf(destaddr));
result = isc_socket_bind(socket, &bind_any);
} else {
src = *srcaddr;
isc_sockaddr_setport(&src, 0);
result = isc_socket_bind(socket, &src);
}
if (result != ISC_R_SUCCESS) {
isc_socket_detach(&socket);
goto cleanup;
......@@ -778,7 +802,7 @@ dns_request_create(dns_requestmgr_t *requestmgr, dns_message_t *message,
attrs = 0;
attrs |= DNS_DISPATCHATTR_TCP;
attrs |= DNS_DISPATCHATTR_PRIVATE;
if (isc_sockaddr_pf(address) == AF_INET)
if (isc_sockaddr_pf(destaddr) == AF_INET)
attrs |= DNS_DISPATCHATTR_IPV4;
else
attrs |= DNS_DISPATCHATTR_IPV6;
......@@ -792,28 +816,61 @@ dns_request_create(dns_requestmgr_t *requestmgr, dns_message_t *message,
goto cleanup;
} else {
dns_dispatch_t *disp = NULL;
switch (isc_sockaddr_pf(address)) {
case PF_INET:
disp = requestmgr->dispatchv4;
break;
if (srcaddr == NULL) {
switch (isc_sockaddr_pf(destaddr)) {
case PF_INET:
disp = requestmgr->dispatchv4;
break;
case PF_INET6:
disp = requestmgr->dispatchv6;
break;
case PF_INET6:
disp = requestmgr->dispatchv6;
break;
default:
result = ISC_R_NOTIMPLEMENTED;
goto cleanup;
}
if (disp == NULL) {
result = ISC_R_FAMILYNOSUPPORT;
goto cleanup;
default:
result = ISC_R_NOTIMPLEMENTED;
goto cleanup;
}
if (disp == NULL) {
result = ISC_R_FAMILYNOSUPPORT;
goto cleanup;
}
dns_dispatch_attach(disp, &request->dispatch);
} else {
unsigned int attrs, attrmask;
attrs = 0;
attrs |= DNS_DISPATCHATTR_UDP;
switch (isc_sockaddr_pf(srcaddr)) {
case PF_INET:
attrs |= DNS_DISPATCHATTR_IPV4;
break;
case PF_INET6:
attrs |= DNS_DISPATCHATTR_IPV6;
break;
default:
result = ISC_R_NOTIMPLEMENTED;
goto cleanup;
}
attrmask = 0;
attrmask |= DNS_DISPATCHATTR_UDP;
attrmask |= DNS_DISPATCHATTR_TCP;
attrmask |= DNS_DISPATCHATTR_IPV4;
attrmask |= DNS_DISPATCHATTR_IPV6;
result = dns_dispatch_getudp(requestmgr->dispatchmgr,
requestmgr->socketmgr,
requestmgr->taskmgr,
srcaddr, 4096,
1000, 32768, 16411, 16433,
attrs, attrmask,
&request->dispatch);
if (result != ISC_R_SUCCESS)
goto cleanup;
}
dns_dispatch_attach(disp, &request->dispatch);
}
socket = dns_dispatch_getsocket(request->dispatch);
INSIST(socket != NULL);
result = dns_dispatch_addresponse(request->dispatch, address, task,
result = dns_dispatch_addresponse(request->dispatch, destaddr, task,
req_response, request, &id,
&request->dispentry);
if (result != ISC_R_SUCCESS)
......@@ -865,13 +922,13 @@ dns_request_create(dns_requestmgr_t *requestmgr, dns_message_t *message,
goto unlink;
if ((options & DNS_REQUESTOPT_TCP) != 0) {
result = isc_socket_connect(socket, address, task,
result = isc_socket_connect(socket, destaddr, task,
req_connected, request);
if (result != ISC_R_SUCCESS)
goto unlink;
request->flags |= DNS_REQUEST_F_CONNECTING|DNS_REQUEST_F_TCP;
} else {
result = req_send(request, task, address);
result = req_send(request, task, destaddr);
if (result != ISC_R_SUCCESS)
goto unlink;
}
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: zone.c,v 1.241 2000/10/30 05:08:07 marka Exp $ */
/* $Id: zone.c,v 1.242 2000/10/31 01:17:17 marka Exp $ */
#include <config.h>
......@@ -3183,6 +3183,7 @@ soa_query(isc_task_t *task, isc_event_t *event) {
isc_netaddr_t masterip;
dns_tsigkey_t *key = NULL;
isc_uint32_t options;
isc_sockaddr_t src;
REQUIRE(DNS_ZONE_VALID(zone));
......@@ -3218,13 +3219,24 @@ soa_query(isc_task_t *task, isc_event_t *event) {
options = DNS_ZONE_FLAG(zone, DNS_ZONEFLG_USEVC) ?
DNS_REQUESTOPT_TCP : 0;
result = dns_request_create(zone->view->requestmgr, message,
&zone->masteraddr, options, key,
15 /* XXX */, zone->task,
refresh_callback, zone, &zone->request);
switch (isc_sockaddr_pf(&zone->masteraddr)) {
case PF_INET:
src = zone->xfrsource4;
break;
case PF_INET6:
src = zone->xfrsource6;
break;
default:
result = ISC_R_NOTIMPLEMENTED;
goto cleanup;
}
result = dns_request_createvia(zone->view->requestmgr, message,
&src, &zone->masteraddr, options, key,
15 /* XXX */, zone->task,
refresh_callback, zone, &zone->request);
if (result != ISC_R_SUCCESS) {
zone_log(zone, me, ISC_LOG_DEBUG(1),
"dns_request_create failed: %s",
"dns_request_createvia failed: %s",
dns_result_totext(result));
goto cleanup;
}
......@@ -3252,6 +3264,7 @@ ns_query(dns_zone_t *zone, dns_rdataset_t *soardataset, dns_stub_t *stub) {
isc_netaddr_t masterip;
dns_tsigkey_t *key = NULL;
dns_dbnode_t *node = NULL;
isc_sockaddr_t src;
REQUIRE(DNS_ZONE_VALID(zone));
REQUIRE((soardataset != NULL && stub == NULL) ||
......@@ -3341,13 +3354,25 @@ ns_query(dns_zone_t *zone, dns_rdataset_t *soardataset, dns_stub_t *stub) {
/*
* Always use TCP so that we shouldn't truncate in additional section.
*/
result = dns_request_create(zone->view->requestmgr, message,
&zone->masteraddr, DNS_REQUESTOPT_TCP, key,
15 /* XXX */, zone->task,
stub_callback, stub, &zone->request);
switch (isc_sockaddr_pf(&zone->masteraddr)) {
case PF_INET:
src = zone->xfrsource4;
break;
case PF_INET6:
src = zone->xfrsource6;
break;
default:
result = ISC_R_NOTIMPLEMENTED;
goto cleanup;
}
result = dns_request_createvia(zone->view->requestmgr, message,
&src, &zone->masteraddr,
DNS_REQUESTOPT_TCP, key, 15 /* XXX */,
zone->task, stub_callback, stub,
&zone->request);
if (result != ISC_R_SUCCESS) {
zone_log(zone, me, ISC_LOG_DEBUG(1),
"dns_request_create failed: %s",
"dns_request_createvia failed: %s",
dns_result_totext(result));
goto cleanup;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment