mirror of
https://github.com/isc-projects/bind9.git
synced 2026-03-13 14:18:48 -04:00
Merge branch '4750-set-loop-on-incoming-transfer-9.18' into 'bind-9.18'
[9.18] Create the new database for AXFR from the dns_zone API See merge request isc-projects/bind9!9075
This commit is contained in:
commit
b51e308dab
3 changed files with 59 additions and 38 deletions
|
|
@ -165,6 +165,19 @@ dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx);
|
|||
*\li #ISC_R_UNEXPECTED
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
dns_zone_makedb(dns_zone_t *zone, dns_db_t **dbp);
|
||||
/*%<
|
||||
* Creates a new empty database for the 'zone'.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'zone' to be a valid zone.
|
||||
*\li 'dbp' to point to NULL pointer.
|
||||
*
|
||||
* Returns:
|
||||
*\li dns_db_create() error codes.
|
||||
*/
|
||||
|
||||
void
|
||||
dns_zone_setclass(dns_zone_t *zone, dns_rdataclass_t rdclass);
|
||||
/*%<
|
||||
|
|
|
|||
|
|
@ -211,8 +211,6 @@ xfrin_create(isc_mem_t *mctx, dns_zone_t *zone, dns_db_t *db, isc_nm_t *netmgr,
|
|||
static isc_result_t
|
||||
axfr_init(dns_xfrin_ctx_t *xfr);
|
||||
static isc_result_t
|
||||
axfr_makedb(dns_xfrin_ctx_t *xfr, dns_db_t **dbp);
|
||||
static isc_result_t
|
||||
axfr_putdata(dns_xfrin_ctx_t *xfr, dns_diffop_t op, dns_name_t *name,
|
||||
dns_ttl_t ttl, dns_rdata_t *rdata);
|
||||
static isc_result_t
|
||||
|
|
@ -288,7 +286,11 @@ axfr_init(dns_xfrin_ctx_t *xfr) {
|
|||
dns_db_detach(&xfr->db);
|
||||
}
|
||||
|
||||
CHECK(axfr_makedb(xfr, &xfr->db));
|
||||
CHECK(dns_zone_makedb(xfr->zone, &xfr->db));
|
||||
|
||||
dns_zone_rpz_enable_db(xfr->zone, xfr->db);
|
||||
dns_zone_catz_enable_db(xfr->zone, xfr->db);
|
||||
|
||||
dns_rdatacallbacks_init(&xfr->axfr);
|
||||
CHECK(dns_db_beginload(xfr->db, &xfr->axfr));
|
||||
result = ISC_R_SUCCESS;
|
||||
|
|
@ -296,22 +298,6 @@ failure:
|
|||
return (result);
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
axfr_makedb(dns_xfrin_ctx_t *xfr, dns_db_t **dbp) {
|
||||
isc_result_t result;
|
||||
|
||||
result = dns_db_create(xfr->mctx, /* XXX */
|
||||
"rbt", /* XXX guess */
|
||||
&xfr->name, dns_dbtype_zone, xfr->rdclass, 0,
|
||||
NULL, /* XXX guess */
|
||||
dbp);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
dns_zone_rpz_enable_db(xfr->zone, *dbp);
|
||||
dns_zone_catz_enable_db(xfr->zone, *dbp);
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
axfr_putdata(dns_xfrin_ctx_t *xfr, dns_diffop_t op, dns_name_t *name,
|
||||
dns_ttl_t ttl, dns_rdata_t *rdata) {
|
||||
|
|
|
|||
|
|
@ -2327,31 +2327,13 @@ zone_load(dns_zone_t *zone, unsigned int flags, bool locked) {
|
|||
dns_zone_logc(zone, DNS_LOGCATEGORY_ZONELOAD, ISC_LOG_DEBUG(1),
|
||||
"starting load");
|
||||
|
||||
result = dns_db_create(zone->mctx, zone->db_argv[0], &zone->origin,
|
||||
(zone->type == dns_zone_stub) ? dns_dbtype_stub
|
||||
: dns_dbtype_zone,
|
||||
zone->rdclass, zone->db_argc - 1,
|
||||
zone->db_argv + 1, &db);
|
||||
|
||||
result = dns_zone_makedb(zone, &db);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
dns_zone_logc(zone, DNS_LOGCATEGORY_ZONELOAD, ISC_LOG_ERROR,
|
||||
"loading zone: creating database: %s",
|
||||
isc_result_totext(result));
|
||||
goto cleanup;
|
||||
}
|
||||
dns_db_settask(db, zone->task, zone->task);
|
||||
|
||||
if (zone->type == dns_zone_primary ||
|
||||
zone->type == dns_zone_secondary || zone->type == dns_zone_mirror)
|
||||
{
|
||||
result = dns_db_setgluecachestats(db, zone->gluecachestats);
|
||||
if (result == ISC_R_NOTIMPLEMENTED) {
|
||||
result = ISC_R_SUCCESS;
|
||||
}
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
if (!dns_db_ispersistent(db)) {
|
||||
if (zone->masterfile != NULL || zone->stream != NULL) {
|
||||
|
|
@ -24224,3 +24206,43 @@ zmgr_tlsctx_attach(dns_zonemgr_t *zmgr, isc_tlsctx_cache_t **ptlsctx_cache) {
|
|||
|
||||
RWUNLOCK(&zmgr->tlsctx_cache_rwlock, isc_rwlocktype_read);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
dns_zone_makedb(dns_zone_t *zone, dns_db_t **dbp) {
|
||||
REQUIRE(DNS_ZONE_VALID(zone));
|
||||
REQUIRE(dbp != NULL && *dbp == NULL);
|
||||
|
||||
dns_db_t *db = NULL;
|
||||
|
||||
isc_result_t result = dns_db_create(
|
||||
zone->mctx, zone->db_argv[0], &zone->origin,
|
||||
(zone->type == dns_zone_stub) ? dns_dbtype_stub
|
||||
: dns_dbtype_zone,
|
||||
zone->rdclass, zone->db_argc - 1, zone->db_argv + 1, &db);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return (result);
|
||||
}
|
||||
|
||||
switch (zone->type) {
|
||||
case dns_zone_primary:
|
||||
case dns_zone_secondary:
|
||||
case dns_zone_mirror:
|
||||
result = dns_db_setgluecachestats(db, zone->gluecachestats);
|
||||
if (result == ISC_R_NOTIMPLEMENTED) {
|
||||
result = ISC_R_SUCCESS;
|
||||
}
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
dns_db_detach(&db);
|
||||
return (result);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
dns_db_settask(db, zone->task, zone->task);
|
||||
|
||||
*dbp = db;
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue