2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 13:38:26 +00:00

Don't freeze / thaw non-explict in-view zones

This commit is contained in:
Mark Andrews 2021-08-03 15:40:47 +10:00
parent ebc92b799b
commit dcdd9a403a
3 changed files with 21 additions and 9 deletions

View File

@ -160,7 +160,7 @@ dns_zt_asyncload(dns_zt_t *zt, bool newonly, dns_zt_allloaded_t alldone,
*/ */
isc_result_t isc_result_t
dns_zt_freezezones(dns_zt_t *zt, bool freeze); dns_zt_freezezones(dns_zt_t *zt, dns_view_t *view, bool freeze);
/*%< /*%<
* Freeze/thaw updates to master zones. * Freeze/thaw updates to master zones.
* Any pending updates will be flushed. * Any pending updates will be flushed.

View File

@ -1855,7 +1855,7 @@ dns_view_freezezones(dns_view_t *view, bool value) {
REQUIRE(DNS_VIEW_VALID(view)); REQUIRE(DNS_VIEW_VALID(view));
REQUIRE(view->zonetable != NULL); REQUIRE(view->zonetable != NULL);
return (dns_zt_freezezones(view->zonetable, value)); return (dns_zt_freezezones(view->zonetable, view, value));
} }
void void

View File

@ -55,6 +55,11 @@ struct dns_zt {
dns_rbt_t *table; dns_rbt_t *table;
}; };
struct zt_freeze_params {
dns_view_t *view;
bool freeze;
};
#define ZTMAGIC ISC_MAGIC('Z', 'T', 'b', 'l') #define ZTMAGIC ISC_MAGIC('Z', 'T', 'b', 'l')
#define VALID_ZT(zt) ISC_MAGIC_VALID(zt, ZTMAGIC) #define VALID_ZT(zt) ISC_MAGIC_VALID(zt, ZTMAGIC)
@ -375,13 +380,14 @@ asyncload(dns_zone_t *zone, void *zt_) {
} }
isc_result_t isc_result_t
dns_zt_freezezones(dns_zt_t *zt, bool freeze) { dns_zt_freezezones(dns_zt_t *zt, dns_view_t *view, bool freeze) {
isc_result_t result, tresult; isc_result_t result, tresult;
struct zt_freeze_params params = { view, freeze };
REQUIRE(VALID_ZT(zt)); REQUIRE(VALID_ZT(zt));
RWLOCK(&zt->rwlock, isc_rwlocktype_read); RWLOCK(&zt->rwlock, isc_rwlocktype_read);
result = dns_zt_apply(zt, false, &tresult, freezezones, &freeze); result = dns_zt_apply(zt, false, &tresult, freezezones, &params);
RWUNLOCK(&zt->rwlock, isc_rwlocktype_read); RWUNLOCK(&zt->rwlock, isc_rwlocktype_read);
if (tresult == ISC_R_NOTFOUND) { if (tresult == ISC_R_NOTFOUND) {
tresult = ISC_R_SUCCESS; tresult = ISC_R_SUCCESS;
@ -391,7 +397,7 @@ dns_zt_freezezones(dns_zt_t *zt, bool freeze) {
static isc_result_t static isc_result_t
freezezones(dns_zone_t *zone, void *uap) { freezezones(dns_zone_t *zone, void *uap) {
bool freeze = *(bool *)uap; struct zt_freeze_params *params = uap;
bool frozen; bool frozen;
isc_result_t result = ISC_R_SUCCESS; isc_result_t result = ISC_R_SUCCESS;
char classstr[DNS_RDATACLASS_FORMATSIZE]; char classstr[DNS_RDATACLASS_FORMATSIZE];
@ -406,6 +412,12 @@ freezezones(dns_zone_t *zone, void *uap) {
if (raw != NULL) { if (raw != NULL) {
zone = raw; zone = raw;
} }
if (params->view != dns_zone_getview(zone)) {
if (raw != NULL) {
dns_zone_detach(&raw);
}
return (ISC_R_SUCCESS);
}
if (dns_zone_gettype(zone) != dns_zone_master) { if (dns_zone_gettype(zone) != dns_zone_master) {
if (raw != NULL) { if (raw != NULL) {
dns_zone_detach(&raw); dns_zone_detach(&raw);
@ -420,7 +432,7 @@ freezezones(dns_zone_t *zone, void *uap) {
} }
frozen = dns_zone_getupdatedisabled(zone); frozen = dns_zone_getupdatedisabled(zone);
if (freeze) { if (params->freeze) {
if (frozen) { if (frozen) {
result = DNS_R_FROZEN; result = DNS_R_FROZEN;
} }
@ -428,7 +440,7 @@ freezezones(dns_zone_t *zone, void *uap) {
result = dns_zone_flush(zone); result = dns_zone_flush(zone);
} }
if (result == ISC_R_SUCCESS) { if (result == ISC_R_SUCCESS) {
dns_zone_setupdatedisabled(zone, freeze); dns_zone_setupdatedisabled(zone, params->freeze);
} }
} else { } else {
if (frozen) { if (frozen) {
@ -455,8 +467,8 @@ freezezones(dns_zone_t *zone, void *uap) {
level = (result != ISC_R_SUCCESS) ? ISC_LOG_ERROR : ISC_LOG_DEBUG(1); level = (result != ISC_R_SUCCESS) ? ISC_LOG_ERROR : ISC_LOG_DEBUG(1);
isc_log_write(dns_lctx, DNS_LOGCATEGORY_GENERAL, DNS_LOGMODULE_ZONE, isc_log_write(dns_lctx, DNS_LOGCATEGORY_GENERAL, DNS_LOGMODULE_ZONE,
level, "%s zone '%s/%s'%s%s: %s", level, "%s zone '%s/%s'%s%s: %s",
freeze ? "freezing" : "thawing", zonename, classstr, sep, params->freeze ? "freezing" : "thawing", zonename,
vname, isc_result_totext(result)); classstr, sep, vname, isc_result_totext(result));
if (raw != NULL) { if (raw != NULL) {
dns_zone_detach(&raw); dns_zone_detach(&raw);
} }