2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 14:07:59 +00:00

don't needlessly destroy and recreate zones when doing minor reconfigurations

This commit is contained in:
Andreas Gustafsson
2000-01-21 19:22:35 +00:00
parent 395130717a
commit 6889d57aab
4 changed files with 110 additions and 36 deletions

View File

@@ -31,13 +31,15 @@
* table in 'cctx'. * table in 'cctx'.
*/ */
isc_result_t dns_zone_configure(isc_log_t *lctx, dns_c_ctx_t *ctx, isc_result_t dns_zone_configure(dns_c_ctx_t *ctx, dns_aclconfctx_t *ac,
dns_aclconfctx_t *ac,
dns_c_zone_t *czone, dns_zone_t *zone); dns_c_zone_t *czone, dns_zone_t *zone);
/* /*
* Configure or reconfigure a zone according to the named.conf * Configure or reconfigure a zone according to the named.conf
* data in 'ctx' and 'czone'. * data in 'ctx' and 'czone'.
* *
* The zone origin is not configured, it is assumed to have been set
* at zone creation time.
*
* Require: * Require:
* 'lctx' to be initalised or NULL. * 'lctx' to be initalised or NULL.
* 'ctx' to be initalised or NULL. * 'ctx' to be initalised or NULL.
@@ -46,6 +48,14 @@ isc_result_t dns_zone_configure(isc_log_t *lctx, dns_c_ctx_t *ctx,
* 'zone' to be initalised. * 'zone' to be initalised.
*/ */
isc_boolean_t
dns_zone_reusable(dns_zone_t *zone, dns_c_zone_t *czone);
/*
* If 'zone' can be safely reconfigured according to the configuration
* data in 'czone', return ISC_TRUE. If the configuration data is so
* different from the current zone state that the zone needs to be destroyed
* and recreated, return ISC_FALSE.
*/
ISC_LANG_ENDDECLS ISC_LANG_ENDDECLS

View File

@@ -61,8 +61,27 @@ configure_zone_acl(dns_c_zone_t *czone, dns_c_ctx_t *cctx,
} }
} }
static dns_zonetype_t
dns_zonetype_fromconf(dns_c_zonetype_t cztype) {
switch (cztype) {
case dns_c_zone_master:
return dns_zone_master;
case dns_c_zone_forward:
return dns_zone_forward;
case dns_c_zone_slave:
return dns_zone_slave;
case dns_c_zone_stub:
return dns_zone_stub;
case dns_c_zone_hint:
return dns_zone_hint;
}
INSIST(0);
return (dns_zone_none); /*NOTREACHED*/
}
isc_result_t isc_result_t
dns_zone_configure(isc_log_t *lctx, dns_c_ctx_t *ctx, dns_aclconfctx_t *ac, dns_zone_configure(dns_c_ctx_t *ctx, dns_aclconfctx_t *ac,
dns_c_zone_t *czone, dns_zone_t *zone) dns_c_zone_t *czone, dns_zone_t *zone)
{ {
isc_result_t result; isc_result_t result;
@@ -77,24 +96,11 @@ dns_zone_configure(isc_log_t *lctx, dns_c_ctx_t *ctx, 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;
const char *origin;
isc_sockaddr_t sockaddr_any; isc_sockaddr_t sockaddr_any;
ctx = ctx; /* unused */
lctx = lctx; /* XXX unused */
isc_sockaddr_fromin6(&sockaddr_any, &in6addr_any, 0); isc_sockaddr_fromin6(&sockaddr_any, &in6addr_any, 0);
dns_zone_setclass(zone, czone->zclass); dns_zone_setclass(zone, czone->zclass);
origin = NULL;
result = dns_c_zone_getname(czone, &origin);
if (result != DNS_R_SUCCESS)
return (result);
/* XXX casting away const */
result = dns_zone_setorigin(zone, (char *) origin);
if (result != DNS_R_SUCCESS)
return (result);
/* XXX needs to be an zone option */ /* XXX needs to be an zone option */
result = dns_zone_setdbtype(zone, "rbt"); result = dns_zone_setdbtype(zone, "rbt");
if (result != DNS_R_SUCCESS) if (result != DNS_R_SUCCESS)
@@ -414,3 +420,24 @@ dns_zone_configure(isc_log_t *lctx, dns_c_ctx_t *ctx, dns_aclconfctx_t *ac,
return (DNS_R_SUCCESS); return (DNS_R_SUCCESS);
} }
isc_boolean_t
dns_zone_reusable(dns_zone_t *zone, dns_c_zone_t *czone)
{
const char *cfilename;
const char *zfilename;
if (dns_zonetype_fromconf(czone->ztype) != dns_zone_gettype(zone))
return (ISC_FALSE);
cfilename = NULL;
(void) dns_c_zone_getfile(czone, &cfilename);
zfilename = dns_zone_getdatabase(zone);
if (cfilename == NULL || zfilename == NULL ||
strcmp(cfilename, zfilename) != 0)
return (ISC_FALSE);
/* XXX Compare masters, too. */
return (ISC_TRUE);
}

View File

@@ -31,13 +31,15 @@
* table in 'cctx'. * table in 'cctx'.
*/ */
isc_result_t dns_zone_configure(isc_log_t *lctx, dns_c_ctx_t *ctx, isc_result_t dns_zone_configure(dns_c_ctx_t *ctx, dns_aclconfctx_t *ac,
dns_aclconfctx_t *ac,
dns_c_zone_t *czone, dns_zone_t *zone); dns_c_zone_t *czone, dns_zone_t *zone);
/* /*
* Configure or reconfigure a zone according to the named.conf * Configure or reconfigure a zone according to the named.conf
* data in 'ctx' and 'czone'. * data in 'ctx' and 'czone'.
* *
* The zone origin is not configured, it is assumed to have been set
* at zone creation time.
*
* Require: * Require:
* 'lctx' to be initalised or NULL. * 'lctx' to be initalised or NULL.
* 'ctx' to be initalised or NULL. * 'ctx' to be initalised or NULL.
@@ -46,6 +48,14 @@ isc_result_t dns_zone_configure(isc_log_t *lctx, dns_c_ctx_t *ctx,
* 'zone' to be initalised. * 'zone' to be initalised.
*/ */
isc_boolean_t
dns_zone_reusable(dns_zone_t *zone, dns_c_zone_t *czone);
/*
* If 'zone' can be safely reconfigured according to the configuration
* data in 'czone', return ISC_TRUE. If the configuration data is so
* different from the current zone state that the zone needs to be destroyed
* and recreated, return ISC_FALSE.
*/
ISC_LANG_ENDDECLS ISC_LANG_ENDDECLS

View File

@@ -61,8 +61,27 @@ configure_zone_acl(dns_c_zone_t *czone, dns_c_ctx_t *cctx,
} }
} }
static dns_zonetype_t
dns_zonetype_fromconf(dns_c_zonetype_t cztype) {
switch (cztype) {
case dns_c_zone_master:
return dns_zone_master;
case dns_c_zone_forward:
return dns_zone_forward;
case dns_c_zone_slave:
return dns_zone_slave;
case dns_c_zone_stub:
return dns_zone_stub;
case dns_c_zone_hint:
return dns_zone_hint;
}
INSIST(0);
return (dns_zone_none); /*NOTREACHED*/
}
isc_result_t isc_result_t
dns_zone_configure(isc_log_t *lctx, dns_c_ctx_t *ctx, dns_aclconfctx_t *ac, dns_zone_configure(dns_c_ctx_t *ctx, dns_aclconfctx_t *ac,
dns_c_zone_t *czone, dns_zone_t *zone) dns_c_zone_t *czone, dns_zone_t *zone)
{ {
isc_result_t result; isc_result_t result;
@@ -77,24 +96,11 @@ dns_zone_configure(isc_log_t *lctx, dns_c_ctx_t *ctx, 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;
const char *origin;
isc_sockaddr_t sockaddr_any; isc_sockaddr_t sockaddr_any;
ctx = ctx; /* unused */
lctx = lctx; /* XXX unused */
isc_sockaddr_fromin6(&sockaddr_any, &in6addr_any, 0); isc_sockaddr_fromin6(&sockaddr_any, &in6addr_any, 0);
dns_zone_setclass(zone, czone->zclass); dns_zone_setclass(zone, czone->zclass);
origin = NULL;
result = dns_c_zone_getname(czone, &origin);
if (result != DNS_R_SUCCESS)
return (result);
/* XXX casting away const */
result = dns_zone_setorigin(zone, (char *) origin);
if (result != DNS_R_SUCCESS)
return (result);
/* XXX needs to be an zone option */ /* XXX needs to be an zone option */
result = dns_zone_setdbtype(zone, "rbt"); result = dns_zone_setdbtype(zone, "rbt");
if (result != DNS_R_SUCCESS) if (result != DNS_R_SUCCESS)
@@ -414,3 +420,24 @@ dns_zone_configure(isc_log_t *lctx, dns_c_ctx_t *ctx, dns_aclconfctx_t *ac,
return (DNS_R_SUCCESS); return (DNS_R_SUCCESS);
} }
isc_boolean_t
dns_zone_reusable(dns_zone_t *zone, dns_c_zone_t *czone)
{
const char *cfilename;
const char *zfilename;
if (dns_zonetype_fromconf(czone->ztype) != dns_zone_gettype(zone))
return (ISC_FALSE);
cfilename = NULL;
(void) dns_c_zone_getfile(czone, &cfilename);
zfilename = dns_zone_getdatabase(zone);
if (cfilename == NULL || zfilename == NULL ||
strcmp(cfilename, zfilename) != 0)
return (ISC_FALSE);
/* XXX Compare masters, too. */
return (ISC_TRUE);
}