Extend dns_view_findzone to take an options argument

This is in preparation to allow the few remaining direct
dns_zt_find(view->zonetable, ...) to use it for rcu mediated
access to view->zonetable.
This commit is contained in:
Mark Andrews 2023-05-31 16:03:56 +10:00 committed by Ondřej Surý
parent ceb3264082
commit 8d86fa7135
No known key found for this signature in database
GPG key ID: 2820F37E873DEA41
9 changed files with 42 additions and 29 deletions

View file

@ -2708,7 +2708,7 @@ catz_addmodzone_cb(void *arg) {
goto cleanup;
}
result = dns_view_findzone(cz->view, name, &zone);
result = dns_view_findzone(cz->view, name, DNS_ZTFIND_EXACT, &zone);
if (cz->mod) {
dns_catz_zone_t *parentcatz;
@ -2834,7 +2834,7 @@ catz_addmodzone_cb(void *arg) {
}
/* Is it there yet? */
CHECK(dns_view_findzone(cz->view, name, &zone));
CHECK(dns_view_findzone(cz->view, name, DNS_ZTFIND_EXACT, &zone));
/*
* Load the zone from the master file. If this fails, we'll
@ -2891,7 +2891,7 @@ catz_delzone_cb(void *arg) {
dns_name_format(dns_catz_entry_getname(cz->entry), cname,
DNS_NAME_FORMATSIZE);
result = dns_view_findzone(cz->view, dns_catz_entry_getname(cz->entry),
&zone);
DNS_ZTFIND_EXACT, &zone);
if (result != ISC_R_SUCCESS) {
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING,
@ -3068,7 +3068,8 @@ configure_catz_zone(dns_view_t *view, dns_view_t *pview,
isc_ht_iter_current(it, (void **)&entry);
name = dns_catz_entry_getname(entry);
tresult = dns_view_findzone(pview, name, &dnszone);
tresult = dns_view_findzone(pview, name,
DNS_ZTFIND_EXACT, &dnszone);
if (tresult != ISC_R_SUCCESS) {
continue;
}
@ -5036,7 +5037,8 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
*/
if (view->hints == NULL) {
dns_zone_t *rootzone = NULL;
(void)dns_view_findzone(view, dns_rootname, &rootzone);
(void)dns_view_findzone(view, dns_rootname, DNS_ZTFIND_EXACT,
&rootzone);
if (rootzone != NULL) {
dns_zone_detach(&rootzone);
need_hints = false;
@ -5768,7 +5770,8 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
/*
* This zone already exists.
*/
(void)dns_view_findzone(view, name, &zone);
(void)dns_view_findzone(view, name, DNS_ZTFIND_EXACT,
&zone);
if (zone != NULL) {
dns_zone_detach(&zone);
continue;
@ -5799,7 +5802,8 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
}
if (pview != NULL) {
(void)dns_view_findzone(pview, name, &zone);
(void)dns_view_findzone(
pview, name, DNS_ZTFIND_EXACT, &zone);
dns_view_detach(&pview);
}
@ -5858,7 +5862,8 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
CHECK(dns_name_fromstring(
name, zones[ipv4only_zone].name, 0, NULL));
(void)dns_view_findzone(view, name, &zone);
(void)dns_view_findzone(view, name, DNS_ZTFIND_EXACT,
&zone);
if (zone != NULL) {
dns_zone_detach(&zone);
continue;
@ -5888,7 +5893,8 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
}
if (pview != NULL) {
(void)dns_view_findzone(pview, name, &zone);
(void)dns_view_findzone(
pview, name, DNS_ZTFIND_EXACT, &zone);
dns_view_detach(&pview);
}
@ -6574,7 +6580,8 @@ configure_zone(const cfg_obj_t *config, const cfg_obj_t *zconfig,
goto cleanup;
}
result = dns_view_findzone(otherview, origin, &zone);
result = dns_view_findzone(otherview, origin, DNS_ZTFIND_EXACT,
&zone);
dns_view_detach(&otherview);
if (result != ISC_R_SUCCESS) {
cfg_obj_log(zconfig, named_g_lctx, ISC_LOG_ERROR,
@ -6693,7 +6700,8 @@ configure_zone(const cfg_obj_t *config, const cfg_obj_t *zconfig,
/*
* Check for duplicates in the new zone table.
*/
result = dns_view_findzone(view, origin, &dupzone);
result = dns_view_findzone(view, origin, DNS_ZTFIND_EXACT,
&dupzone);
if (result == ISC_R_SUCCESS) {
/*
* We already have this zone!
@ -6749,7 +6757,8 @@ configure_zone(const cfg_obj_t *config, const cfg_obj_t *zconfig,
goto cleanup;
}
if (pview != NULL) {
result = dns_view_findzone(pview, origin, &zone);
result = dns_view_findzone(pview, origin, DNS_ZTFIND_EXACT,
&zone);
}
if (result != ISC_R_NOTFOUND && result != ISC_R_SUCCESS) {
goto cleanup;
@ -7815,7 +7824,7 @@ configure_zone_setviewcommit(isc_result_t result, const cfg_obj_t *zconfig,
return;
}
result2 = dns_view_findzone(pview, origin, &zone);
result2 = dns_view_findzone(pview, origin, DNS_ZTFIND_EXACT, &zone);
if (result2 != ISC_R_SUCCESS) {
dns_view_detach(&pview);
return;
@ -10571,7 +10580,8 @@ zone_from_args(named_server_t *server, isc_lex_t *lex, const char *zonetxt,
result = ISC_R_NOTFOUND;
}
} else {
result = dns_view_findzone(view, name, zonep);
result = dns_view_findzone(view, name, DNS_ZTFIND_EXACT,
zonep);
}
if (result != ISC_R_SUCCESS) {
snprintf(problem, sizeof(problem),
@ -13438,7 +13448,7 @@ do_addzone(named_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
result = (view->redirect == NULL) ? ISC_R_NOTFOUND
: ISC_R_EXISTS;
} else {
result = dns_view_findzone(view, name, &zone);
result = dns_view_findzone(view, name, DNS_ZTFIND_EXACT, &zone);
if (result == ISC_R_SUCCESS) {
result = ISC_R_EXISTS;
}
@ -13502,7 +13512,7 @@ do_addzone(named_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
}
dns_zone_attach(view->redirect, &zone);
} else {
result = dns_view_findzone(view, name, &zone);
result = dns_view_findzone(view, name, DNS_ZTFIND_EXACT, &zone);
if (result != ISC_R_SUCCESS) {
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR,
@ -13618,7 +13628,7 @@ do_modzone(named_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
result = ISC_R_NOTFOUND;
}
} else {
result = dns_view_findzone(view, name, &zone);
result = dns_view_findzone(view, name, DNS_ZTFIND_EXACT, &zone);
}
if (result != ISC_R_SUCCESS) {
goto cleanup;
@ -13687,7 +13697,7 @@ do_modzone(named_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
}
dns_zone_attach(view->redirect, &zone);
} else {
CHECK(dns_view_findzone(view, name, &zone));
CHECK(dns_view_findzone(view, name, DNS_ZTFIND_EXACT, &zone));
}
#ifndef HAVE_LMDB

View file

@ -139,7 +139,7 @@ publish_zone(sample_instance_t *inst, dns_zone_t *zone) {
/* Return success if the zone is already in the view as expected. */
result = dns_view_findzone(inst->view, dns_zone_getorigin(zone),
&zone_in_view);
DNS_ZTFIND_EXACT, &zone_in_view);
if (result != ISC_R_SUCCESS && result != ISC_R_NOTFOUND) {
goto cleanup;
}

View file

@ -561,7 +561,7 @@ dns__catz_zones_merge(dns_catz_zone_t *catz, dns_catz_zone_t *newcatz) {
/* Try to find the zone in the view */
find_result = dns_view_findzone(catz->catzs->view,
dns_catz_entry_getname(nentry),
&zone);
DNS_ZTFIND_EXACT, &zone);
if (find_result == ISC_R_SUCCESS) {
dns_catz_coo_t *coo = NULL;
char pczname[DNS_NAME_FORMATSIZE];

View file

@ -441,7 +441,7 @@ dns_dlz_writeablezone(dns_view_t *view, dns_dlzdb_t *dlzdb,
}
/* See if the zone already exists */
result = dns_view_findzone(view, origin, &dupzone);
result = dns_view_findzone(view, origin, DNS_ZTFIND_EXACT, &dupzone);
if (result == ISC_R_SUCCESS) {
dns_zone_detach(&dupzone);
result = ISC_R_EXISTS;

View file

@ -761,11 +761,11 @@ dns_viewlist_findzone(dns_viewlist_t *list, const dns_name_t *name,
*/
isc_result_t
dns_view_findzone(dns_view_t *view, const dns_name_t *name, dns_zone_t **zonep);
dns_view_findzone(dns_view_t *view, const dns_name_t *name,
unsigned int options, dns_zone_t **zonep);
/*%<
* Search for the zone 'name' in the zone table of 'view'.
* If found, 'zonep' is (strongly) attached to it. There
* are no partial matches.
* If found, 'zonep' is (strongly) attached to it.
*
* Requires:
*

View file

@ -808,7 +808,7 @@ dns_view_delzone(dns_view_t *view, dns_zone_t *zone) {
isc_result_t
dns_view_findzone(dns_view_t *view, const dns_name_t *name,
dns_zone_t **zonep) {
unsigned int options, dns_zone_t **zonep) {
isc_result_t result;
dns_zt_t *zonetable = NULL;
@ -817,7 +817,7 @@ dns_view_findzone(dns_view_t *view, const dns_name_t *name,
rcu_read_lock();
zonetable = rcu_dereference(view->zonetable);
if (zonetable != NULL) {
result = dns_zt_find(zonetable, name, DNS_ZTFIND_EXACT, zonep);
result = dns_zt_find(zonetable, name, options, zonep);
} else {
result = ISC_R_NOTFOUND;
}

View file

@ -146,7 +146,8 @@ ns_notify_start(ns_client_t *client, isc_nmhandle_t *handle) {
}
dns_name_format(zonename, namebuf, sizeof(namebuf));
result = dns_view_findzone(client->view, zonename, &zone);
result = dns_view_findzone(client->view, zonename, DNS_ZTFIND_EXACT,
&zone);
if (result == ISC_R_SUCCESS) {
dns_zonetype_t zonetype = dns_zone_gettype(zone);

View file

@ -1987,7 +1987,8 @@ ns_update_start(ns_client_t *client, isc_nmhandle_t *handle,
"RRs");
}
result = dns_view_findzone(client->view, zonename, &zone);
result = dns_view_findzone(client->view, zonename, DNS_ZTFIND_EXACT,
&zone);
if (result != ISC_R_SUCCESS) {
FAILN(DNS_R_NOTAUTH, zonename,
"not authoritative for update zone");

View file

@ -795,7 +795,8 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) {
FAILC(DNS_R_FORMERR, "multiple questions");
}
result = dns_view_findzone(client->view, question_name, &zone);
result = dns_view_findzone(client->view, question_name,
DNS_ZTFIND_EXACT, &zone);
if (result != ISC_R_SUCCESS || dns_zone_gettype(zone) == dns_zone_dlz) {
/*
* The normal zone table does not have a match, or this is