diff --git a/lib/dns/include/dns/zt.h b/lib/dns/include/dns/zt.h index ef5982732b..4a1b2639a8 100644 --- a/lib/dns/include/dns/zt.h +++ b/lib/dns/include/dns/zt.h @@ -160,7 +160,7 @@ dns_zt_asyncload(dns_zt_t *zt, bool newonly, dns_zt_allloaded_t alldone, */ 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. * Any pending updates will be flushed. diff --git a/lib/dns/view.c b/lib/dns/view.c index 5de3108d45..27df703811 100644 --- a/lib/dns/view.c +++ b/lib/dns/view.c @@ -1855,7 +1855,7 @@ dns_view_freezezones(dns_view_t *view, bool value) { REQUIRE(DNS_VIEW_VALID(view)); REQUIRE(view->zonetable != NULL); - return (dns_zt_freezezones(view->zonetable, value)); + return (dns_zt_freezezones(view->zonetable, view, value)); } void diff --git a/lib/dns/zt.c b/lib/dns/zt.c index cfe7d31e45..3fde5f16e1 100644 --- a/lib/dns/zt.c +++ b/lib/dns/zt.c @@ -55,6 +55,11 @@ struct dns_zt { dns_rbt_t *table; }; +struct zt_freeze_params { + dns_view_t *view; + bool freeze; +}; + #define ZTMAGIC ISC_MAGIC('Z', 'T', 'b', 'l') #define VALID_ZT(zt) ISC_MAGIC_VALID(zt, ZTMAGIC) @@ -375,13 +380,14 @@ asyncload(dns_zone_t *zone, void *zt_) { } 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; + struct zt_freeze_params params = { view, freeze }; REQUIRE(VALID_ZT(zt)); RWLOCK(&zt->rwlock, isc_rwlocktype_read); - result = dns_zt_apply(zt, false, &tresult, freezezones, &freeze); + result = dns_zt_apply(zt, false, &tresult, freezezones, ¶ms); RWUNLOCK(&zt->rwlock, isc_rwlocktype_read); if (tresult == ISC_R_NOTFOUND) { tresult = ISC_R_SUCCESS; @@ -391,7 +397,7 @@ dns_zt_freezezones(dns_zt_t *zt, bool freeze) { static isc_result_t freezezones(dns_zone_t *zone, void *uap) { - bool freeze = *(bool *)uap; + struct zt_freeze_params *params = uap; bool frozen; isc_result_t result = ISC_R_SUCCESS; char classstr[DNS_RDATACLASS_FORMATSIZE]; @@ -406,6 +412,12 @@ freezezones(dns_zone_t *zone, void *uap) { if (raw != NULL) { 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 (raw != NULL) { dns_zone_detach(&raw); @@ -420,7 +432,7 @@ freezezones(dns_zone_t *zone, void *uap) { } frozen = dns_zone_getupdatedisabled(zone); - if (freeze) { + if (params->freeze) { if (frozen) { result = DNS_R_FROZEN; } @@ -428,7 +440,7 @@ freezezones(dns_zone_t *zone, void *uap) { result = dns_zone_flush(zone); } if (result == ISC_R_SUCCESS) { - dns_zone_setupdatedisabled(zone, freeze); + dns_zone_setupdatedisabled(zone, params->freeze); } } else { 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); isc_log_write(dns_lctx, DNS_LOGCATEGORY_GENERAL, DNS_LOGMODULE_ZONE, level, "%s zone '%s/%s'%s%s: %s", - freeze ? "freezing" : "thawing", zonename, classstr, sep, - vname, isc_result_totext(result)); + params->freeze ? "freezing" : "thawing", zonename, + classstr, sep, vname, isc_result_totext(result)); if (raw != NULL) { dns_zone_detach(&raw); }