mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-29 05:28:00 +00:00
separate transfer-source addresses for IPv4 and IPv6
This commit is contained in:
parent
994a1996e4
commit
c718c8aa60
@ -96,15 +96,11 @@ dns_zone_configure(dns_c_ctx_t *cctx, dns_aclconfctx_t *ac,
|
|||||||
isc_int32_t maxxfr;
|
isc_int32_t maxxfr;
|
||||||
isc_int32_t idle;
|
isc_int32_t idle;
|
||||||
in_port_t port;
|
in_port_t port;
|
||||||
isc_sockaddr_t sockaddr_any;
|
|
||||||
struct in_addr in4addr_any;
|
struct in_addr in4addr_any;
|
||||||
|
isc_sockaddr_t sockaddr_any4;
|
||||||
|
|
||||||
if (isc_net_probeipv6() == ISC_R_SUCCESS)
|
in4addr_any.s_addr = htonl(INADDR_ANY);
|
||||||
isc_sockaddr_fromin6(&sockaddr_any, &in6addr_any, 0);
|
isc_sockaddr_fromin(&sockaddr_any4, &in4addr_any, 0);
|
||||||
else {
|
|
||||||
in4addr_any.s_addr = INADDR_ANY;
|
|
||||||
isc_sockaddr_fromin(&sockaddr_any, &in4addr_any, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
dns_zone_setclass(zone, czone->zclass);
|
dns_zone_setclass(zone, czone->zclass);
|
||||||
|
|
||||||
@ -253,10 +249,13 @@ dns_zone_configure(dns_c_ctx_t *cctx, dns_aclconfctx_t *ac,
|
|||||||
dns_zone_setmaxxfrin(zone, MAX_XFER_TIME);
|
dns_zone_setmaxxfrin(zone, MAX_XFER_TIME);
|
||||||
|
|
||||||
result = dns_c_zone_gettransfersource(czone, &sockaddr);
|
result = dns_c_zone_gettransfersource(czone, &sockaddr);
|
||||||
if (result == ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS) {
|
||||||
dns_zone_setxfrsource(zone, &sockaddr);
|
result = dns_c_ctx_gettransfersource(cctx, &sockaddr);
|
||||||
else
|
if (result != ISC_R_SUCCESS) {
|
||||||
dns_zone_setxfrsource(zone, &sockaddr_any);
|
sockaddr = sockaddr_any4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dns_zone_setxfrsource4(zone, &sockaddr);
|
||||||
|
|
||||||
result = dns_c_zone_getmaxtransidlein(czone, &idle);
|
result = dns_c_zone_getmaxtransidlein(czone, &idle);
|
||||||
if (result == ISC_R_SUCCESS)
|
if (result == ISC_R_SUCCESS)
|
||||||
@ -323,10 +322,13 @@ dns_zone_configure(dns_c_ctx_t *cctx, dns_aclconfctx_t *ac,
|
|||||||
dns_zone_setmaxxfrin(zone, MAX_XFER_TIME);
|
dns_zone_setmaxxfrin(zone, MAX_XFER_TIME);
|
||||||
|
|
||||||
result = dns_c_zone_gettransfersource(czone, &sockaddr);
|
result = dns_c_zone_gettransfersource(czone, &sockaddr);
|
||||||
if (result == ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS) {
|
||||||
dns_zone_setxfrsource(zone, &sockaddr);
|
result = dns_c_ctx_gettransfersource(cctx, &sockaddr);
|
||||||
else
|
if (result != ISC_R_SUCCESS) {
|
||||||
dns_zone_setxfrsource(zone, &sockaddr_any);
|
sockaddr = sockaddr_any4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dns_zone_setxfrsource4(zone, &sockaddr);
|
||||||
|
|
||||||
result = dns_c_zone_getmaxtransidlein(czone, &idle);
|
result = dns_c_zone_getmaxtransidlein(czone, &idle);
|
||||||
if (result == ISC_R_SUCCESS)
|
if (result == ISC_R_SUCCESS)
|
||||||
|
@ -422,9 +422,9 @@ void dns_zone_setrefresh(dns_zone_t *zone, isc_uint32_t refresh,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
dns_zone_setxfrsource(dns_zone_t *zone, isc_sockaddr_t *xfrsource);
|
dns_zone_setxfrsource4(dns_zone_t *zone, isc_sockaddr_t *xfrsource);
|
||||||
/*
|
/*
|
||||||
* Set the source address to be used in zone transfers.
|
* Set the source address to be used in IPv4 zone transfers.
|
||||||
*
|
*
|
||||||
* Require:
|
* Require:
|
||||||
* 'zone' to be a valid initalised zone.
|
* 'zone' to be a valid initalised zone.
|
||||||
@ -435,10 +435,33 @@ dns_zone_setxfrsource(dns_zone_t *zone, isc_sockaddr_t *xfrsource);
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
isc_sockaddr_t *
|
isc_sockaddr_t *
|
||||||
dns_zone_getxfrsource(dns_zone_t *zone);
|
dns_zone_getxfrsource4(dns_zone_t *zone);
|
||||||
/*
|
/*
|
||||||
* Returns the source address set by a previous dns_zone_setxfrsource
|
* Returns the source address set by a previous dns_zone_setxfrsource4
|
||||||
* call. If dns_zone_setxfrsource the in6addr_any port 0 is returned.
|
* call, or the default of inaddr_any, port 0.
|
||||||
|
*
|
||||||
|
* Require:
|
||||||
|
* 'zone' to be a valid initalised zone.
|
||||||
|
*/
|
||||||
|
|
||||||
|
isc_result_t
|
||||||
|
dns_zone_setxfrsource6(dns_zone_t *zone, isc_sockaddr_t *xfrsource);
|
||||||
|
/*
|
||||||
|
* Set the source address to be used in IPv6 zone transfers.
|
||||||
|
*
|
||||||
|
* Require:
|
||||||
|
* 'zone' to be a valid initalised zone.
|
||||||
|
* 'xfrsource' to contain the address.
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* DNS_R_SUCCESS
|
||||||
|
*/
|
||||||
|
|
||||||
|
isc_sockaddr_t *
|
||||||
|
dns_zone_getxfrsource6(dns_zone_t *zone);
|
||||||
|
/*
|
||||||
|
* Returns the source address set by a previous dns_zone_setxfrsource6
|
||||||
|
* call, or the default of in6addr_any, port 0.
|
||||||
*
|
*
|
||||||
* Require:
|
* Require:
|
||||||
* 'zone' to be a valid initalised zone.
|
* 'zone' to be a valid initalised zone.
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: xfrin.c,v 1.42 2000/01/31 15:10:29 tale Exp $ */
|
/* $Id: xfrin.c,v 1.43 2000/01/31 18:00:05 gson Exp $ */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
@ -666,8 +666,17 @@ xfrin_create(isc_mem_t *mctx,
|
|||||||
xfrin_timeout, xfr, &xfr->timer));
|
xfrin_timeout, xfr, &xfr->timer));
|
||||||
|
|
||||||
xfr->masteraddr = *masteraddr;
|
xfr->masteraddr = *masteraddr;
|
||||||
/* XXX global, too */
|
|
||||||
xfr->sourceaddr = *dns_zone_getxfrsource(zone);
|
switch (isc_sockaddr_pf(masteraddr)) {
|
||||||
|
case PF_INET:
|
||||||
|
xfr->sourceaddr = *dns_zone_getxfrsource4(zone);
|
||||||
|
break;
|
||||||
|
case PF_INET6:
|
||||||
|
xfr->sourceaddr = *dns_zone_getxfrsource6(zone);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
INSIST(0);
|
||||||
|
}
|
||||||
|
|
||||||
isc_buffer_init(&xfr->qbuffer, xfr->qbuffer_data,
|
isc_buffer_init(&xfr->qbuffer, xfr->qbuffer_data,
|
||||||
sizeof(xfr->qbuffer_data),
|
sizeof(xfr->qbuffer_data),
|
||||||
@ -685,7 +694,7 @@ isc_result_t
|
|||||||
xfrin_start(dns_xfrin_ctx_t *xfr) {
|
xfrin_start(dns_xfrin_ctx_t *xfr) {
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
CHECK(isc_socket_create(xfr->socketmgr,
|
CHECK(isc_socket_create(xfr->socketmgr,
|
||||||
isc_sockaddr_pf(&xfr->masteraddr),
|
isc_sockaddr_pf(&xfr->sourceaddr),
|
||||||
isc_sockettype_tcp,
|
isc_sockettype_tcp,
|
||||||
&xfr->socket));
|
&xfr->socket));
|
||||||
CHECK(isc_socket_bind(xfr->socket, &xfr->sourceaddr));
|
CHECK(isc_socket_bind(xfr->socket, &xfr->sourceaddr));
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: zone.c,v 1.74 2000/01/31 07:45:18 marka Exp $ */
|
/* $Id: zone.c,v 1.75 2000/01/31 18:00:02 gson Exp $ */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
@ -142,7 +142,8 @@ struct dns_zone {
|
|||||||
unsigned int notifycnt;
|
unsigned int notifycnt;
|
||||||
isc_sockaddr_t notifyfrom;
|
isc_sockaddr_t notifyfrom;
|
||||||
isc_task_t * task;
|
isc_task_t * task;
|
||||||
isc_sockaddr_t xfrsource;
|
isc_sockaddr_t xfrsource4;
|
||||||
|
isc_sockaddr_t xfrsource6;
|
||||||
dns_xfrin_ctx_t * xfr;
|
dns_xfrin_ctx_t * xfr;
|
||||||
/* Access Control Lists */
|
/* Access Control Lists */
|
||||||
dns_acl_t *update_acl;
|
dns_acl_t *update_acl;
|
||||||
@ -249,12 +250,16 @@ isc_result_t
|
|||||||
dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx) {
|
dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx) {
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
dns_zone_t *zone;
|
dns_zone_t *zone;
|
||||||
isc_sockaddr_t sockaddr_any;
|
isc_sockaddr_t sockaddr_any4;
|
||||||
|
isc_sockaddr_t sockaddr_any6;
|
||||||
|
struct in_addr in4addr_any;
|
||||||
|
|
||||||
REQUIRE(zonep != NULL && *zonep == NULL);
|
REQUIRE(zonep != NULL && *zonep == NULL);
|
||||||
REQUIRE(mctx != NULL);
|
REQUIRE(mctx != NULL);
|
||||||
|
|
||||||
isc_sockaddr_fromin6(&sockaddr_any, &in6addr_any, 0);
|
in4addr_any.s_addr = htonl(INADDR_ANY);
|
||||||
|
isc_sockaddr_fromin(&sockaddr_any4, &in4addr_any, 0);
|
||||||
|
isc_sockaddr_fromin6(&sockaddr_any6, &in6addr_any, 0);
|
||||||
|
|
||||||
zone = isc_mem_get(mctx, sizeof *zone);
|
zone = isc_mem_get(mctx, sizeof *zone);
|
||||||
if (zone == NULL)
|
if (zone == NULL)
|
||||||
@ -316,7 +321,8 @@ dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx) {
|
|||||||
zone->idlein = DNS_DEFAULT_IDLEIN;
|
zone->idlein = DNS_DEFAULT_IDLEIN;
|
||||||
zone->idleout = DNS_DEFAULT_IDLEOUT;
|
zone->idleout = DNS_DEFAULT_IDLEOUT;
|
||||||
ISC_LIST_INIT(zone->checkservers);
|
ISC_LIST_INIT(zone->checkservers);
|
||||||
zone->xfrsource = sockaddr_any;
|
zone->xfrsource4 = sockaddr_any4;
|
||||||
|
zone->xfrsource6 = sockaddr_any6;
|
||||||
zone->xfr = NULL;
|
zone->xfr = NULL;
|
||||||
zone->maxxfrin = MAX_XFER_TIME;
|
zone->maxxfrin = MAX_XFER_TIME;
|
||||||
zone->maxxfrout = MAX_XFER_TIME;
|
zone->maxxfrout = MAX_XFER_TIME;
|
||||||
@ -1389,20 +1395,37 @@ dns_zone_cleardbargs(dns_zone_t *zone) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
dns_zone_setxfrsource(dns_zone_t *zone, isc_sockaddr_t *xfrsource) {
|
dns_zone_setxfrsource4(dns_zone_t *zone, isc_sockaddr_t *xfrsource) {
|
||||||
REQUIRE(DNS_ZONE_VALID(zone));
|
REQUIRE(DNS_ZONE_VALID(zone));
|
||||||
|
|
||||||
LOCK(&zone->lock);
|
LOCK(&zone->lock);
|
||||||
zone->xfrsource = *xfrsource;
|
zone->xfrsource4 = *xfrsource;
|
||||||
UNLOCK(&zone->lock);
|
UNLOCK(&zone->lock);
|
||||||
|
|
||||||
return (DNS_R_SUCCESS);
|
return (DNS_R_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_sockaddr_t *
|
isc_sockaddr_t *
|
||||||
dns_zone_getxfrsource(dns_zone_t *zone) {
|
dns_zone_getxfrsource4(dns_zone_t *zone) {
|
||||||
REQUIRE(DNS_ZONE_VALID(zone));
|
REQUIRE(DNS_ZONE_VALID(zone));
|
||||||
return (&zone->xfrsource);
|
return (&zone->xfrsource4);
|
||||||
|
}
|
||||||
|
|
||||||
|
isc_result_t
|
||||||
|
dns_zone_setxfrsource6(dns_zone_t *zone, isc_sockaddr_t *xfrsource) {
|
||||||
|
REQUIRE(DNS_ZONE_VALID(zone));
|
||||||
|
|
||||||
|
LOCK(&zone->lock);
|
||||||
|
zone->xfrsource6 = *xfrsource;
|
||||||
|
UNLOCK(&zone->lock);
|
||||||
|
|
||||||
|
return (DNS_R_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
isc_sockaddr_t *
|
||||||
|
dns_zone_getxfrsource6(dns_zone_t *zone) {
|
||||||
|
REQUIRE(DNS_ZONE_VALID(zone));
|
||||||
|
return (&zone->xfrsource6);
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
@ -1859,8 +1882,9 @@ dns_zone_notify(dns_zone_t *zone) {
|
|||||||
* Enqueue notify request.
|
* Enqueue notify request.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < zone->notifycnt; i++) {
|
for (i = 0; i < zone->notifycnt; i++) {
|
||||||
|
/* XXX IPv6 */
|
||||||
(void)dns_notify(origin, &zone->notify[i], dns_rdatatype_soa,
|
(void)dns_notify(origin, &zone->notify[i], dns_rdatatype_soa,
|
||||||
zone->rdclass, &zone->xfrsource, zone->mctx);
|
zone->rdclass, &zone->xfrsource4, zone->mctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
dns_db_currentversion(zone->top, &version);
|
dns_db_currentversion(zone->top, &version);
|
||||||
@ -1915,10 +1939,11 @@ dns_zone_notify(dns_zone_t *zone) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (i == zone->notifycnt) {
|
if (i == zone->notifycnt) {
|
||||||
|
/* XXX IPv6 */
|
||||||
(void)dns_notify(origin, &addr,
|
(void)dns_notify(origin, &addr,
|
||||||
dns_rdatatype_soa,
|
dns_rdatatype_soa,
|
||||||
zone->rdclass,
|
zone->rdclass,
|
||||||
&zone->xfrsource, zone->mctx);
|
&zone->xfrsource4, zone->mctx);
|
||||||
}
|
}
|
||||||
result = dns_rdataset_next(&ardset);
|
result = dns_rdataset_next(&ardset);
|
||||||
}
|
}
|
||||||
@ -2780,7 +2805,10 @@ dns_zone_equal(dns_zone_t *oldzone, dns_zone_t *newzone) {
|
|||||||
if (strcmp(oldzone->db_argv[i], newzone->db_argv[i]) != 0)
|
if (strcmp(oldzone->db_argv[i], newzone->db_argv[i]) != 0)
|
||||||
goto false;
|
goto false;
|
||||||
|
|
||||||
if (!isc_sockaddr_equal(&oldzone->xfrsource, &newzone->xfrsource))
|
if (!isc_sockaddr_equal(&oldzone->xfrsource4, &newzone->xfrsource4))
|
||||||
|
goto false;
|
||||||
|
|
||||||
|
if (!isc_sockaddr_equal(&oldzone->xfrsource6, &newzone->xfrsource6))
|
||||||
goto false;
|
goto false;
|
||||||
|
|
||||||
for (i = 0; i < oldzone->notifycnt; i++)
|
for (i = 0; i < oldzone->notifycnt; i++)
|
||||||
|
@ -96,15 +96,11 @@ dns_zone_configure(dns_c_ctx_t *cctx, dns_aclconfctx_t *ac,
|
|||||||
isc_int32_t maxxfr;
|
isc_int32_t maxxfr;
|
||||||
isc_int32_t idle;
|
isc_int32_t idle;
|
||||||
in_port_t port;
|
in_port_t port;
|
||||||
isc_sockaddr_t sockaddr_any;
|
|
||||||
struct in_addr in4addr_any;
|
struct in_addr in4addr_any;
|
||||||
|
isc_sockaddr_t sockaddr_any4;
|
||||||
|
|
||||||
if (isc_net_probeipv6() == ISC_R_SUCCESS)
|
in4addr_any.s_addr = htonl(INADDR_ANY);
|
||||||
isc_sockaddr_fromin6(&sockaddr_any, &in6addr_any, 0);
|
isc_sockaddr_fromin(&sockaddr_any4, &in4addr_any, 0);
|
||||||
else {
|
|
||||||
in4addr_any.s_addr = INADDR_ANY;
|
|
||||||
isc_sockaddr_fromin(&sockaddr_any, &in4addr_any, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
dns_zone_setclass(zone, czone->zclass);
|
dns_zone_setclass(zone, czone->zclass);
|
||||||
|
|
||||||
@ -253,10 +249,13 @@ dns_zone_configure(dns_c_ctx_t *cctx, dns_aclconfctx_t *ac,
|
|||||||
dns_zone_setmaxxfrin(zone, MAX_XFER_TIME);
|
dns_zone_setmaxxfrin(zone, MAX_XFER_TIME);
|
||||||
|
|
||||||
result = dns_c_zone_gettransfersource(czone, &sockaddr);
|
result = dns_c_zone_gettransfersource(czone, &sockaddr);
|
||||||
if (result == ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS) {
|
||||||
dns_zone_setxfrsource(zone, &sockaddr);
|
result = dns_c_ctx_gettransfersource(cctx, &sockaddr);
|
||||||
else
|
if (result != ISC_R_SUCCESS) {
|
||||||
dns_zone_setxfrsource(zone, &sockaddr_any);
|
sockaddr = sockaddr_any4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dns_zone_setxfrsource4(zone, &sockaddr);
|
||||||
|
|
||||||
result = dns_c_zone_getmaxtransidlein(czone, &idle);
|
result = dns_c_zone_getmaxtransidlein(czone, &idle);
|
||||||
if (result == ISC_R_SUCCESS)
|
if (result == ISC_R_SUCCESS)
|
||||||
@ -323,10 +322,13 @@ dns_zone_configure(dns_c_ctx_t *cctx, dns_aclconfctx_t *ac,
|
|||||||
dns_zone_setmaxxfrin(zone, MAX_XFER_TIME);
|
dns_zone_setmaxxfrin(zone, MAX_XFER_TIME);
|
||||||
|
|
||||||
result = dns_c_zone_gettransfersource(czone, &sockaddr);
|
result = dns_c_zone_gettransfersource(czone, &sockaddr);
|
||||||
if (result == ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS) {
|
||||||
dns_zone_setxfrsource(zone, &sockaddr);
|
result = dns_c_ctx_gettransfersource(cctx, &sockaddr);
|
||||||
else
|
if (result != ISC_R_SUCCESS) {
|
||||||
dns_zone_setxfrsource(zone, &sockaddr_any);
|
sockaddr = sockaddr_any4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dns_zone_setxfrsource4(zone, &sockaddr);
|
||||||
|
|
||||||
result = dns_c_zone_getmaxtransidlein(czone, &idle);
|
result = dns_c_zone_getmaxtransidlein(czone, &idle);
|
||||||
if (result == ISC_R_SUCCESS)
|
if (result == ISC_R_SUCCESS)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user