mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-23 02:28:55 +00:00
dbtable -> zonetable conversion.
delete dns_view_addzonedb(). add dns_view_addzone(). add dns_view_findzone(). add dns_view_findinlist().
This commit is contained in:
parent
6ef838d427
commit
c627721fed
@ -66,11 +66,11 @@ dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, char *name,
|
|||||||
result = ISC_R_UNEXPECTED;
|
result = ISC_R_UNEXPECTED;
|
||||||
goto cleanup_name;
|
goto cleanup_name;
|
||||||
}
|
}
|
||||||
view->dbtable = NULL;
|
view->zonetable = NULL;
|
||||||
result = dns_dbtable_create(mctx, rdclass, &view->dbtable);
|
result = dns_zt_create(mctx, rdclass, &view->zonetable);
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||||
"dns_dbtable_create() failed: %s",
|
"dns_zt_create() failed: %s",
|
||||||
isc_result_totext(result));
|
isc_result_totext(result));
|
||||||
result = ISC_R_UNEXPECTED;
|
result = ISC_R_UNEXPECTED;
|
||||||
goto cleanup_mutex;
|
goto cleanup_mutex;
|
||||||
@ -82,7 +82,7 @@ dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, char *name,
|
|||||||
"dns_rbt_create() failed: %s",
|
"dns_rbt_create() failed: %s",
|
||||||
isc_result_totext(result));
|
isc_result_totext(result));
|
||||||
result = ISC_R_UNEXPECTED;
|
result = ISC_R_UNEXPECTED;
|
||||||
goto cleanup_dbtable;
|
goto cleanup_zt;
|
||||||
}
|
}
|
||||||
|
|
||||||
view->cachedb = NULL;
|
view->cachedb = NULL;
|
||||||
@ -99,8 +99,8 @@ dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, char *name,
|
|||||||
|
|
||||||
return (ISC_R_SUCCESS);
|
return (ISC_R_SUCCESS);
|
||||||
|
|
||||||
cleanup_dbtable:
|
cleanup_zt:
|
||||||
dns_dbtable_detach(&view->dbtable);
|
dns_zt_detach(&view->zonetable);
|
||||||
|
|
||||||
cleanup_mutex:
|
cleanup_mutex:
|
||||||
isc_mutex_destroy(&view->lock);
|
isc_mutex_destroy(&view->lock);
|
||||||
@ -145,8 +145,8 @@ destroy(dns_view_t *view) {
|
|||||||
dns_db_detach(&view->hints);
|
dns_db_detach(&view->hints);
|
||||||
if (view->cachedb != NULL)
|
if (view->cachedb != NULL)
|
||||||
dns_db_detach(&view->cachedb);
|
dns_db_detach(&view->cachedb);
|
||||||
|
dns_zt_detach(&view->zonetable);
|
||||||
dns_rbt_destroy(&view->secroots);
|
dns_rbt_destroy(&view->secroots);
|
||||||
dns_dbtable_detach(&view->dbtable);
|
|
||||||
isc_mutex_destroy(&view->lock);
|
isc_mutex_destroy(&view->lock);
|
||||||
isc_mem_free(view->mctx, view->name);
|
isc_mem_free(view->mctx, view->name);
|
||||||
isc_mem_put(view->mctx, view, sizeof *view);
|
isc_mem_put(view->mctx, view, sizeof *view);
|
||||||
@ -235,23 +235,17 @@ dns_view_sethints(dns_view_t *view, dns_db_t *hints) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
dns_view_addzonedb(dns_view_t *view, dns_db_t *db) {
|
dns_view_addzone(dns_view_t *view, dns_zone_t *zone) {
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add zone database 'db' to 'view'.
|
* Add zone 'zone' to 'view'.
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* WARNING! THIS ROUTINE WILL BE REPLACED WITH dns_view_addzone()
|
|
||||||
* WHEN WE HAVE INTEGRATED ZONE OBJECT SUPPORT INTO THE LIBRARY.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
REQUIRE(DNS_VIEW_VALID(view));
|
REQUIRE(DNS_VIEW_VALID(view));
|
||||||
REQUIRE(dns_db_iszone(db));
|
|
||||||
REQUIRE(!view->frozen);
|
REQUIRE(!view->frozen);
|
||||||
|
|
||||||
result = dns_dbtable_add(view->dbtable, db);
|
result = dns_zt_mount(view->zonetable, zone);
|
||||||
|
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
@ -269,6 +263,24 @@ dns_view_freeze(dns_view_t *view) {
|
|||||||
view->frozen = ISC_TRUE;
|
view->frozen = ISC_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isc_result_t
|
||||||
|
dns_view_findzone(dns_view_t *view, dns_name_t *name, dns_zone_t **zone) {
|
||||||
|
isc_result_t result;
|
||||||
|
dns_zone_t *dummy = NULL;
|
||||||
|
|
||||||
|
REQUIRE(DNS_VIEW_VALID(view));
|
||||||
|
|
||||||
|
result = dns_zt_find(view->zonetable, name, NULL, &dummy);
|
||||||
|
if (result == DNS_R_PARTIALMATCH) {
|
||||||
|
dns_zone_detach(&dummy);
|
||||||
|
result = DNS_R_NOTFOUND;
|
||||||
|
} else if (result == DNS_R_SUCCESS) {
|
||||||
|
dns_zone_attach(dummy, zone);
|
||||||
|
dns_zone_detach(&dummy);
|
||||||
|
}
|
||||||
|
return (result);
|
||||||
|
}
|
||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
dns_view_find(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
|
dns_view_find(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
|
||||||
isc_stdtime_t now, unsigned int options, isc_boolean_t use_hints,
|
isc_stdtime_t now, unsigned int options, isc_boolean_t use_hints,
|
||||||
@ -280,6 +292,7 @@ dns_view_find(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
|
|||||||
dns_dbversion_t *version;
|
dns_dbversion_t *version;
|
||||||
isc_boolean_t is_zone;
|
isc_boolean_t is_zone;
|
||||||
dns_rdataset_t zrdataset, zsigrdataset;
|
dns_rdataset_t zrdataset, zsigrdataset;
|
||||||
|
dns_zone_t *zone;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find an rdataset whose owner name is 'name', and whose type is
|
* Find an rdataset whose owner name is 'name', and whose type is
|
||||||
@ -299,11 +312,18 @@ dns_view_find(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
|
|||||||
/*
|
/*
|
||||||
* Find a database to answer the query.
|
* Find a database to answer the query.
|
||||||
*/
|
*/
|
||||||
|
zone = NULL;
|
||||||
db = NULL;
|
db = NULL;
|
||||||
result = dns_dbtable_find(view->dbtable, name, &db);
|
result = dns_zt_find(view->zonetable, name, NULL, &zone);
|
||||||
if (result == ISC_R_NOTFOUND && view->cachedb != NULL)
|
if (result == ISC_R_SUCCESS || result == DNS_R_PARTIALMATCH) {
|
||||||
|
result = dns_zone_getdb(zone, &db);
|
||||||
|
if (result != DNS_R_SUCCESS && view->cachedb != NULL)
|
||||||
dns_db_attach(view->cachedb, &db);
|
dns_db_attach(view->cachedb, &db);
|
||||||
else if (result != ISC_R_SUCCESS && result != DNS_R_PARTIALMATCH)
|
else if (result != DNS_R_SUCCESS)
|
||||||
|
goto cleanup;
|
||||||
|
} else if (result == ISC_R_NOTFOUND && view->cachedb != NULL)
|
||||||
|
dns_db_attach(view->cachedb, &db);
|
||||||
|
else
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
is_zone = dns_db_iszone(db);
|
is_zone = dns_db_iszone(db);
|
||||||
@ -405,6 +425,24 @@ dns_view_find(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
|
|||||||
}
|
}
|
||||||
if (db != NULL)
|
if (db != NULL)
|
||||||
dns_db_detach(&db);
|
dns_db_detach(&db);
|
||||||
|
if (zone != NULL)
|
||||||
|
dns_zone_detach(&zone);
|
||||||
|
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dns_view_t *
|
||||||
|
dns_view_findinlist(dns_viewlist_t *list, const char *name,
|
||||||
|
dns_rdataclass_t rdclass) {
|
||||||
|
dns_view_t *view;
|
||||||
|
|
||||||
|
REQUIRE(list != NULL);
|
||||||
|
|
||||||
|
view = ISC_LIST_HEAD(*list);
|
||||||
|
while (view != NULL) {
|
||||||
|
if (strcmp(view->name, name) == 0 && view->rdclass == rdclass)
|
||||||
|
break;
|
||||||
|
view = ISC_LIST_NEXT(view, link);
|
||||||
|
}
|
||||||
|
return (view);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user