mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 14:35:26 +00:00
refactor dns_catz to use loop callbacks
catz events are now scheduled using isc_task_async() instead of isc_task_send().
This commit is contained in:
@@ -313,14 +313,20 @@ typedef struct {
|
|||||||
named_server_t *server;
|
named_server_t *server;
|
||||||
} catz_cb_data_t;
|
} catz_cb_data_t;
|
||||||
|
|
||||||
typedef struct catz_chgzone_event {
|
typedef struct catz_chgzone {
|
||||||
ISC_EVENT_COMMON(struct catz_chgzone_event);
|
isc_mem_t *mctx;
|
||||||
dns_catz_entry_t *entry;
|
dns_catz_entry_t *entry;
|
||||||
dns_catz_zone_t *origin;
|
dns_catz_zone_t *origin;
|
||||||
dns_view_t *view;
|
dns_view_t *view;
|
||||||
catz_cb_data_t *cbd;
|
catz_cb_data_t *cbd;
|
||||||
bool mod;
|
bool mod;
|
||||||
} catz_chgzone_event_t;
|
} catz_chgzone_t;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
CATZ_ADDZONE,
|
||||||
|
CATZ_MODZONE,
|
||||||
|
CATZ_DELZONE,
|
||||||
|
} catz_type_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned int magic;
|
unsigned int magic;
|
||||||
@@ -2659,23 +2665,21 @@ configure_rpz(dns_view_t *view, dns_view_t *pview, const cfg_obj_t **maps,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
catz_addmodzone_taskaction(isc_task_t *task, isc_event_t *event0) {
|
catz_addmodzone_cb(void *arg) {
|
||||||
catz_chgzone_event_t *ev = (catz_chgzone_event_t *)event0;
|
catz_chgzone_t *cz = (catz_chgzone_t *)arg;
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
dns_forwarders_t *dnsforwarders = NULL;
|
dns_forwarders_t *dnsforwarders = NULL;
|
||||||
dns_name_t *name = NULL;
|
dns_name_t *name = NULL;
|
||||||
isc_buffer_t namebuf;
|
isc_buffer_t namebuf;
|
||||||
isc_buffer_t *confbuf;
|
isc_buffer_t *confbuf = NULL;
|
||||||
char nameb[DNS_NAME_FORMATSIZE];
|
char nameb[DNS_NAME_FORMATSIZE];
|
||||||
const cfg_obj_t *zlist = NULL;
|
const cfg_obj_t *zlist = NULL;
|
||||||
cfg_obj_t *zoneconf = NULL;
|
cfg_obj_t *zoneconf = NULL;
|
||||||
cfg_obj_t *zoneobj = NULL;
|
cfg_obj_t *zoneobj = NULL;
|
||||||
ns_cfgctx_t *cfg;
|
ns_cfgctx_t *cfg = NULL;
|
||||||
dns_zone_t *zone = NULL;
|
dns_zone_t *zone = NULL;
|
||||||
|
|
||||||
UNUSED(task);
|
cfg = (ns_cfgctx_t *)cz->view->new_zone_config;
|
||||||
|
|
||||||
cfg = (ns_cfgctx_t *)ev->view->new_zone_config;
|
|
||||||
if (cfg == NULL) {
|
if (cfg == NULL) {
|
||||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||||
NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR,
|
NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR,
|
||||||
@@ -2684,29 +2688,29 @@ catz_addmodzone_taskaction(isc_task_t *task, isc_event_t *event0) {
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
name = dns_catz_entry_getname(ev->entry);
|
name = dns_catz_entry_getname(cz->entry);
|
||||||
|
|
||||||
isc_buffer_init(&namebuf, nameb, DNS_NAME_FORMATSIZE);
|
isc_buffer_init(&namebuf, nameb, DNS_NAME_FORMATSIZE);
|
||||||
dns_name_totext(name, true, &namebuf);
|
dns_name_totext(name, true, &namebuf);
|
||||||
isc_buffer_putuint8(&namebuf, 0);
|
isc_buffer_putuint8(&namebuf, 0);
|
||||||
|
|
||||||
result = dns_fwdtable_find(ev->view->fwdtable, name, NULL,
|
result = dns_fwdtable_find(cz->view->fwdtable, name, NULL,
|
||||||
&dnsforwarders);
|
&dnsforwarders);
|
||||||
if (result == ISC_R_SUCCESS &&
|
if (result == ISC_R_SUCCESS &&
|
||||||
dnsforwarders->fwdpolicy == dns_fwdpolicy_only)
|
dnsforwarders->fwdpolicy == dns_fwdpolicy_only)
|
||||||
{
|
{
|
||||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||||
NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING,
|
NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING,
|
||||||
"catz: catz_addmodzone_taskaction: "
|
"catz: catz_addmodzone_cb: "
|
||||||
"zone '%s' will not be processed because of the "
|
"zone '%s' will not be processed because of the "
|
||||||
"explicitly configured forwarding for that zone",
|
"explicitly configured forwarding for that zone",
|
||||||
nameb);
|
nameb);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = dns_zt_find(ev->view->zonetable, name, 0, NULL, &zone);
|
result = dns_zt_find(cz->view->zonetable, name, 0, NULL, &zone);
|
||||||
|
|
||||||
if (ev->mod) {
|
if (cz->mod) {
|
||||||
dns_catz_zone_t *parentcatz;
|
dns_catz_zone_t *parentcatz;
|
||||||
|
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
@@ -2721,7 +2725,7 @@ catz_addmodzone_taskaction(isc_task_t *task, isc_event_t *event0) {
|
|||||||
if (!dns_zone_getadded(zone)) {
|
if (!dns_zone_getadded(zone)) {
|
||||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||||
NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING,
|
NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING,
|
||||||
"catz: catz_addmodzone_taskaction: "
|
"catz: catz_addmodzone_cb: "
|
||||||
"zone '%s' is not a dynamically "
|
"zone '%s' is not a dynamically "
|
||||||
"added zone",
|
"added zone",
|
||||||
nameb);
|
nameb);
|
||||||
@@ -2733,16 +2737,16 @@ catz_addmodzone_taskaction(isc_task_t *task, isc_event_t *event0) {
|
|||||||
if (parentcatz == NULL) {
|
if (parentcatz == NULL) {
|
||||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||||
NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING,
|
NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING,
|
||||||
"catz: catz_addmodzone_taskaction: "
|
"catz: catz_addmodzone_cb: "
|
||||||
"zone '%s' exists and is not added by "
|
"zone '%s' exists and is not added by "
|
||||||
"a catalog zone, so won't be modified",
|
"a catalog zone, so won't be modified",
|
||||||
nameb);
|
nameb);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if (parentcatz != ev->origin) {
|
if (parentcatz != cz->origin) {
|
||||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||||
NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING,
|
NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING,
|
||||||
"catz: catz_addmodzone_taskaction: "
|
"catz: catz_addmodzone_cb: "
|
||||||
"zone '%s' exists in multiple "
|
"zone '%s' exists in multiple "
|
||||||
"catalog zones",
|
"catalog zones",
|
||||||
nameb);
|
nameb);
|
||||||
@@ -2758,7 +2762,7 @@ catz_addmodzone_taskaction(isc_task_t *task, isc_event_t *event0) {
|
|||||||
named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||||
NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING,
|
NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING,
|
||||||
"catz: "
|
"catz: "
|
||||||
"catz_addmodzone_taskaction: "
|
"catz_addmodzone_cb: "
|
||||||
"zone '%s' will not be added "
|
"zone '%s' will not be added "
|
||||||
"because it is an explicitly "
|
"because it is an explicitly "
|
||||||
"configured zone",
|
"configured zone",
|
||||||
@@ -2768,7 +2772,7 @@ catz_addmodzone_taskaction(isc_task_t *task, isc_event_t *event0) {
|
|||||||
named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||||
NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING,
|
NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING,
|
||||||
"catz: "
|
"catz: "
|
||||||
"catz_addmodzone_taskaction: "
|
"catz_addmodzone_cb: "
|
||||||
"zone '%s' will not be added "
|
"zone '%s' will not be added "
|
||||||
"because another catalog zone "
|
"because another catalog zone "
|
||||||
"already contains an entry with "
|
"already contains an entry with "
|
||||||
@@ -2794,7 +2798,7 @@ catz_addmodzone_taskaction(isc_task_t *task, isc_event_t *event0) {
|
|||||||
RUNTIME_CHECK(zone == NULL);
|
RUNTIME_CHECK(zone == NULL);
|
||||||
/* Create a config for new zone */
|
/* Create a config for new zone */
|
||||||
confbuf = NULL;
|
confbuf = NULL;
|
||||||
result = dns_catz_generate_zonecfg(ev->origin, ev->entry, &confbuf);
|
result = dns_catz_generate_zonecfg(cz->origin, cz->entry, &confbuf);
|
||||||
if (result == ISC_R_SUCCESS) {
|
if (result == ISC_R_SUCCESS) {
|
||||||
cfg_parser_reset(cfg->add_parser);
|
cfg_parser_reset(cfg->add_parser);
|
||||||
result = cfg_parse_buffer(cfg->add_parser, confbuf, "catz", 0,
|
result = cfg_parse_buffer(cfg->add_parser, confbuf, "catz", 0,
|
||||||
@@ -2824,12 +2828,12 @@ catz_addmodzone_taskaction(isc_task_t *task, isc_event_t *event0) {
|
|||||||
/* Mark view unfrozen so that zone can be added */
|
/* Mark view unfrozen so that zone can be added */
|
||||||
|
|
||||||
isc_loopmgr_pause(named_g_loopmgr);
|
isc_loopmgr_pause(named_g_loopmgr);
|
||||||
dns_view_thaw(ev->view);
|
dns_view_thaw(cz->view);
|
||||||
result = configure_zone(cfg->config, zoneobj, cfg->vconfig, ev->view,
|
result = configure_zone(cfg->config, zoneobj, cfg->vconfig, cz->view,
|
||||||
&ev->cbd->server->viewlist,
|
&cz->cbd->server->viewlist,
|
||||||
&ev->cbd->server->kasplist, cfg->actx, true,
|
&cz->cbd->server->kasplist, cfg->actx, true,
|
||||||
false, ev->mod);
|
false, cz->mod);
|
||||||
dns_view_freeze(ev->view);
|
dns_view_freeze(cz->view);
|
||||||
isc_loopmgr_resume(named_g_loopmgr);
|
isc_loopmgr_resume(named_g_loopmgr);
|
||||||
|
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
@@ -2841,7 +2845,7 @@ catz_addmodzone_taskaction(isc_task_t *task, isc_event_t *event0) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Is it there yet? */
|
/* Is it there yet? */
|
||||||
CHECK(dns_zt_find(ev->view->zonetable, name, 0, NULL, &zone));
|
CHECK(dns_zt_find(cz->view->zonetable, name, 0, NULL, &zone));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Load the zone from the master file. If this fails, we'll
|
* Load the zone from the master file. If this fails, we'll
|
||||||
@@ -2863,13 +2867,13 @@ catz_addmodzone_taskaction(isc_task_t *task, isc_event_t *event0) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Remove the zone from the zone table */
|
/* Remove the zone from the zone table */
|
||||||
dns_zt_unmount(ev->view->zonetable, zone);
|
dns_zt_unmount(cz->view->zonetable, zone);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Flag the zone as having been added at runtime */
|
/* Flag the zone as having been added at runtime */
|
||||||
dns_zone_setadded(zone, true);
|
dns_zone_setadded(zone, true);
|
||||||
dns_zone_set_parentcatz(zone, ev->origin);
|
dns_zone_set_parentcatz(zone, cz->origin);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (zone != NULL) {
|
if (zone != NULL) {
|
||||||
@@ -2878,33 +2882,31 @@ cleanup:
|
|||||||
if (zoneconf != NULL) {
|
if (zoneconf != NULL) {
|
||||||
cfg_obj_destroy(cfg->add_parser, &zoneconf);
|
cfg_obj_destroy(cfg->add_parser, &zoneconf);
|
||||||
}
|
}
|
||||||
dns_catz_entry_detach(ev->origin, &ev->entry);
|
dns_catz_entry_detach(cz->origin, &cz->entry);
|
||||||
dns_catz_zone_detach(&ev->origin);
|
dns_catz_zone_detach(&cz->origin);
|
||||||
dns_view_detach(&ev->view);
|
dns_view_detach(&cz->view);
|
||||||
isc_event_free(ISC_EVENT_PTR(&ev));
|
isc_mem_putanddetach(&cz->mctx, cz, sizeof(*cz));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
catz_delzone_taskaction(isc_task_t *task, isc_event_t *event0) {
|
catz_delzone_cb(void *arg) {
|
||||||
catz_chgzone_event_t *ev = (catz_chgzone_event_t *)event0;
|
catz_chgzone_t *cz = (catz_chgzone_t *)arg;
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
dns_zone_t *zone = NULL;
|
dns_zone_t *zone = NULL;
|
||||||
dns_db_t *dbp = NULL;
|
dns_db_t *dbp = NULL;
|
||||||
char cname[DNS_NAME_FORMATSIZE];
|
char cname[DNS_NAME_FORMATSIZE];
|
||||||
const char *file;
|
const char *file = NULL;
|
||||||
|
|
||||||
UNUSED(task);
|
|
||||||
|
|
||||||
isc_loopmgr_pause(named_g_loopmgr);
|
isc_loopmgr_pause(named_g_loopmgr);
|
||||||
|
|
||||||
dns_name_format(dns_catz_entry_getname(ev->entry), cname,
|
dns_name_format(dns_catz_entry_getname(cz->entry), cname,
|
||||||
DNS_NAME_FORMATSIZE);
|
DNS_NAME_FORMATSIZE);
|
||||||
result = dns_zt_find(ev->view->zonetable,
|
result = dns_zt_find(cz->view->zonetable,
|
||||||
dns_catz_entry_getname(ev->entry), 0, NULL, &zone);
|
dns_catz_entry_getname(cz->entry), 0, NULL, &zone);
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||||
NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING,
|
NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING,
|
||||||
"catz: catz_delzone_taskaction: "
|
"catz: catz_delzone_cb: "
|
||||||
"zone '%s' not found",
|
"zone '%s' not found",
|
||||||
cname);
|
cname);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@@ -2913,16 +2915,16 @@ catz_delzone_taskaction(isc_task_t *task, isc_event_t *event0) {
|
|||||||
if (!dns_zone_getadded(zone)) {
|
if (!dns_zone_getadded(zone)) {
|
||||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||||
NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING,
|
NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING,
|
||||||
"catz: catz_delzone_taskaction: "
|
"catz: catz_delzone_cb: "
|
||||||
"zone '%s' is not a dynamically added zone",
|
"zone '%s' is not a dynamically added zone",
|
||||||
cname);
|
cname);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dns_zone_get_parentcatz(zone) != ev->origin) {
|
if (dns_zone_get_parentcatz(zone) != cz->origin) {
|
||||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||||
NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING,
|
NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING,
|
||||||
"catz: catz_delzone_taskaction: zone "
|
"catz: catz_delzone_cb: zone "
|
||||||
"'%s' exists in multiple catalog zones",
|
"'%s' exists in multiple catalog zones",
|
||||||
cname);
|
cname);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@@ -2934,7 +2936,7 @@ catz_delzone_taskaction(isc_task_t *task, isc_event_t *event0) {
|
|||||||
dns_zone_unload(zone);
|
dns_zone_unload(zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK(dns_zt_unmount(ev->view->zonetable, zone));
|
CHECK(dns_zt_unmount(cz->view->zonetable, zone));
|
||||||
file = dns_zone_getfile(zone);
|
file = dns_zone_getfile(zone);
|
||||||
if (file != NULL) {
|
if (file != NULL) {
|
||||||
isc_file_remove(file);
|
isc_file_remove(file);
|
||||||
@@ -2946,7 +2948,7 @@ catz_delzone_taskaction(isc_task_t *task, isc_event_t *event0) {
|
|||||||
|
|
||||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||||
NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING,
|
NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING,
|
||||||
"catz: catz_delzone_taskaction: "
|
"catz: catz_delzone_cb: "
|
||||||
"zone '%s' deleted",
|
"zone '%s' deleted",
|
||||||
cname);
|
cname);
|
||||||
cleanup:
|
cleanup:
|
||||||
@@ -2954,77 +2956,63 @@ cleanup:
|
|||||||
if (zone != NULL) {
|
if (zone != NULL) {
|
||||||
dns_zone_detach(&zone);
|
dns_zone_detach(&zone);
|
||||||
}
|
}
|
||||||
dns_catz_entry_detach(ev->origin, &ev->entry);
|
dns_catz_entry_detach(cz->origin, &cz->entry);
|
||||||
dns_catz_zone_detach(&ev->origin);
|
dns_catz_zone_detach(&cz->origin);
|
||||||
dns_view_detach(&ev->view);
|
dns_view_detach(&cz->view);
|
||||||
isc_event_free(ISC_EVENT_PTR(&ev));
|
isc_mem_putanddetach(&cz->mctx, cz, sizeof(*cz));
|
||||||
}
|
}
|
||||||
|
|
||||||
static isc_result_t
|
static isc_result_t
|
||||||
catz_create_chg_task(dns_catz_entry_t *entry, dns_catz_zone_t *origin,
|
catz_run(dns_catz_entry_t *entry, dns_catz_zone_t *origin, dns_view_t *view,
|
||||||
dns_view_t *view, isc_taskmgr_t *taskmgr, void *udata,
|
void *udata, catz_type_t type) {
|
||||||
isc_eventtype_t type) {
|
catz_chgzone_t *cz = NULL;
|
||||||
catz_chgzone_event_t *event = NULL;
|
isc_job_cb action = NULL;
|
||||||
isc_task_t *task = NULL;
|
|
||||||
isc_result_t result;
|
|
||||||
isc_taskaction_t action = NULL;
|
|
||||||
|
|
||||||
result = isc_taskmgr_excltask(taskmgr, &task);
|
|
||||||
if (result != ISC_R_SUCCESS) {
|
|
||||||
return (result);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case DNS_EVENT_CATZADDZONE:
|
case CATZ_ADDZONE:
|
||||||
case DNS_EVENT_CATZMODZONE:
|
case CATZ_MODZONE:
|
||||||
action = catz_addmodzone_taskaction;
|
action = catz_addmodzone_cb;
|
||||||
break;
|
break;
|
||||||
case DNS_EVENT_CATZDELZONE:
|
case CATZ_DELZONE:
|
||||||
action = catz_delzone_taskaction;
|
action = catz_delzone_cb;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
REQUIRE(0);
|
REQUIRE(0);
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
event = (catz_chgzone_event_t *)isc_event_allocate(
|
cz = isc_mem_get(view->mctx, sizeof(*cz));
|
||||||
view->mctx, origin, type, action, NULL, sizeof(*event));
|
*cz = (catz_chgzone_t){
|
||||||
|
.cbd = (catz_cb_data_t *)udata,
|
||||||
|
.mod = (type == CATZ_MODZONE),
|
||||||
|
};
|
||||||
|
isc_mem_attach(view->mctx, &cz->mctx);
|
||||||
|
|
||||||
event->cbd = (catz_cb_data_t *)udata;
|
dns_catz_entry_attach(entry, &cz->entry);
|
||||||
event->entry = NULL;
|
dns_catz_zone_attach(origin, &cz->origin);
|
||||||
event->origin = NULL;
|
dns_view_attach(view, &cz->view);
|
||||||
event->view = NULL;
|
|
||||||
event->mod = (type == DNS_EVENT_CATZMODZONE);
|
|
||||||
|
|
||||||
dns_catz_entry_attach(entry, &event->entry);
|
isc_async_run(named_g_mainloop, action, cz);
|
||||||
dns_catz_zone_attach(origin, &event->origin);
|
|
||||||
dns_view_attach(view, &event->view);
|
|
||||||
|
|
||||||
isc_task_send(task, ISC_EVENT_PTR(&event));
|
|
||||||
isc_task_detach(&task);
|
|
||||||
|
|
||||||
return (ISC_R_SUCCESS);
|
return (ISC_R_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static isc_result_t
|
static isc_result_t
|
||||||
catz_addzone(dns_catz_entry_t *entry, dns_catz_zone_t *origin, dns_view_t *view,
|
catz_addzone(dns_catz_entry_t *entry, dns_catz_zone_t *origin, dns_view_t *view,
|
||||||
isc_taskmgr_t *taskmgr, void *udata) {
|
void *udata) {
|
||||||
return (catz_create_chg_task(entry, origin, view, taskmgr, udata,
|
return (catz_run(entry, origin, view, udata, CATZ_ADDZONE));
|
||||||
DNS_EVENT_CATZADDZONE));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static isc_result_t
|
static isc_result_t
|
||||||
catz_delzone(dns_catz_entry_t *entry, dns_catz_zone_t *origin, dns_view_t *view,
|
catz_delzone(dns_catz_entry_t *entry, dns_catz_zone_t *origin, dns_view_t *view,
|
||||||
isc_taskmgr_t *taskmgr, void *udata) {
|
void *udata) {
|
||||||
return (catz_create_chg_task(entry, origin, view, taskmgr, udata,
|
return (catz_run(entry, origin, view, udata, CATZ_DELZONE));
|
||||||
DNS_EVENT_CATZDELZONE));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static isc_result_t
|
static isc_result_t
|
||||||
catz_modzone(dns_catz_entry_t *entry, dns_catz_zone_t *origin, dns_view_t *view,
|
catz_modzone(dns_catz_entry_t *entry, dns_catz_zone_t *origin, dns_view_t *view,
|
||||||
isc_taskmgr_t *taskmgr, void *udata) {
|
void *udata) {
|
||||||
return (catz_create_chg_task(entry, origin, view, taskmgr, udata,
|
return (catz_run(entry, origin, view, udata, CATZ_MODZONE));
|
||||||
DNS_EVENT_CATZMODZONE));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static isc_result_t
|
static isc_result_t
|
||||||
@@ -3177,8 +3165,8 @@ configure_catz(dns_view_t *view, dns_view_t *pview, const cfg_obj_t *config,
|
|||||||
return (ISC_R_SUCCESS);
|
return (ISC_R_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK(dns_catz_new_zones(&view->catzs, &ns_catz_zonemodmethods,
|
dns_catz_new_zones(&view->catzs, &ns_catz_zonemodmethods, view->mctx,
|
||||||
view->mctx, named_g_taskmgr, named_g_loopmgr));
|
named_g_loopmgr);
|
||||||
|
|
||||||
if (pview != NULL) {
|
if (pview != NULL) {
|
||||||
old = pview->catzs;
|
old = pview->catzs;
|
||||||
|
@@ -520,7 +520,7 @@ status=$((status+ret))
|
|||||||
n=$((n+1))
|
n=$((n+1))
|
||||||
echo_i "checking that unpermitted change of ownership did not happen ($n)"
|
echo_i "checking that unpermitted change of ownership did not happen ($n)"
|
||||||
ret=0
|
ret=0
|
||||||
wait_for_message ns2/named.run "catz_addmodzone_taskaction: zone 'dom2.example' will not be added because another catalog zone already contains an entry with that zone" || ret=1
|
wait_for_message ns2/named.run "catz_addmodzone_cb: zone 'dom2.example' will not be added because another catalog zone already contains an entry with that zone" || ret=1
|
||||||
if [ $ret -ne 0 ]; then echo_i "failed"; fi
|
if [ $ret -ne 0 ]; then echo_i "failed"; fi
|
||||||
status=$((status+ret))
|
status=$((status+ret))
|
||||||
|
|
||||||
@@ -642,7 +642,7 @@ status=$((status+ret))
|
|||||||
n=$((n+1))
|
n=$((n+1))
|
||||||
echo_i "checking that the change of ownership did not happen because version '1' catalog2 zone does not support the 'coo' property ($n)"
|
echo_i "checking that the change of ownership did not happen because version '1' catalog2 zone does not support the 'coo' property ($n)"
|
||||||
ret=0
|
ret=0
|
||||||
wait_for_message ns2/named.run "catz_addmodzone_taskaction: zone 'dom2.example' will not be added because another catalog zone already contains an entry with that zone" || ret=1
|
wait_for_message ns2/named.run "catz_addmodzone_cb: zone 'dom2.example' will not be added because another catalog zone already contains an entry with that zone" || ret=1
|
||||||
if [ $ret -ne 0 ]; then echo_i "failed"; fi
|
if [ $ret -ne 0 ]; then echo_i "failed"; fi
|
||||||
status=$((status+ret))
|
status=$((status+ret))
|
||||||
|
|
||||||
@@ -714,7 +714,7 @@ n=$((n+1))
|
|||||||
echo_i "waiting for secondary to sync up ($n)"
|
echo_i "waiting for secondary to sync up ($n)"
|
||||||
ret=0
|
ret=0
|
||||||
wait_for_message ns2/named.run "catz: adding zone 'dom-existing.example' from catalog 'catalog1.example'" &&
|
wait_for_message ns2/named.run "catz: adding zone 'dom-existing.example' from catalog 'catalog1.example'" &&
|
||||||
wait_for_message ns2/named.run "catz_addmodzone_taskaction: zone 'dom-existing.example' will not be added because it is an explicitly configured zone" || ret=1
|
wait_for_message ns2/named.run "catz_addmodzone_cb: zone 'dom-existing.example' will not be added because it is an explicitly configured zone" || ret=1
|
||||||
if [ $ret -ne 0 ]; then echo_i "failed"; fi
|
if [ $ret -ne 0 ]; then echo_i "failed"; fi
|
||||||
status=$((status+ret))
|
status=$((status+ret))
|
||||||
|
|
||||||
@@ -760,7 +760,7 @@ n=$((n+1))
|
|||||||
echo_i "waiting for secondary to sync up ($n)"
|
echo_i "waiting for secondary to sync up ($n)"
|
||||||
ret=0
|
ret=0
|
||||||
wait_for_message ns2/named.run "catz: adding zone 'dom-existing-forward.example' from catalog 'catalog1.example'" &&
|
wait_for_message ns2/named.run "catz: adding zone 'dom-existing-forward.example' from catalog 'catalog1.example'" &&
|
||||||
wait_for_message ns2/named.run "catz_addmodzone_taskaction: zone 'dom-existing-forward.example' will not be processed because of the explicitly configured forwarding for that zone" || ret=1
|
wait_for_message ns2/named.run "catz_addmodzone_cb: zone 'dom-existing-forward.example' will not be processed because of the explicitly configured forwarding for that zone" || ret=1
|
||||||
if [ $ret -ne 0 ]; then echo_i "failed"; fi
|
if [ $ret -ne 0 ]; then echo_i "failed"; fi
|
||||||
status=$((status+ret))
|
status=$((status+ret))
|
||||||
|
|
||||||
|
@@ -23,7 +23,6 @@
|
|||||||
#include <isc/mem.h>
|
#include <isc/mem.h>
|
||||||
#include <isc/parseint.h>
|
#include <isc/parseint.h>
|
||||||
#include <isc/result.h>
|
#include <isc/result.h>
|
||||||
#include <isc/task.h>
|
|
||||||
#include <isc/util.h>
|
#include <isc/util.h>
|
||||||
|
|
||||||
#include <dns/catz.h>
|
#include <dns/catz.h>
|
||||||
@@ -124,10 +123,9 @@ struct dns_catz_zones {
|
|||||||
isc_refcount_t refs;
|
isc_refcount_t refs;
|
||||||
isc_mutex_t lock;
|
isc_mutex_t lock;
|
||||||
dns_catz_zonemodmethods_t *zmm;
|
dns_catz_zonemodmethods_t *zmm;
|
||||||
isc_taskmgr_t *taskmgr;
|
|
||||||
isc_loopmgr_t *loopmgr;
|
isc_loopmgr_t *loopmgr;
|
||||||
dns_view_t *view;
|
dns_view_t *view;
|
||||||
isc_task_t *updater;
|
isc_loop_t *loop;
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -566,7 +564,6 @@ dns_catz_zones_merge(dns_catz_zone_t *target, dns_catz_zone_t *newzone) {
|
|||||||
zname, pczname, czname);
|
zname, pczname, czname);
|
||||||
result = delzone(nentry, parentcatz,
|
result = delzone(nentry, parentcatz,
|
||||||
parentcatz->catzs->view,
|
parentcatz->catzs->view,
|
||||||
parentcatz->catzs->taskmgr,
|
|
||||||
parentcatz->catzs->zmm->udata);
|
parentcatz->catzs->zmm->udata);
|
||||||
isc_log_write(dns_lctx, DNS_LOGCATEGORY_GENERAL,
|
isc_log_write(dns_lctx, DNS_LOGCATEGORY_GENERAL,
|
||||||
DNS_LOGMODULE_MASTER,
|
DNS_LOGMODULE_MASTER,
|
||||||
@@ -657,7 +654,6 @@ dns_catz_zones_merge(dns_catz_zone_t *target, dns_catz_zone_t *newzone) {
|
|||||||
|
|
||||||
dns_name_format(&entry->name, zname, DNS_NAME_FORMATSIZE);
|
dns_name_format(&entry->name, zname, DNS_NAME_FORMATSIZE);
|
||||||
result = delzone(entry, target, target->catzs->view,
|
result = delzone(entry, target, target->catzs->view,
|
||||||
target->catzs->taskmgr,
|
|
||||||
target->catzs->zmm->udata);
|
target->catzs->zmm->udata);
|
||||||
isc_log_write(dns_lctx, DNS_LOGCATEGORY_GENERAL,
|
isc_log_write(dns_lctx, DNS_LOGCATEGORY_GENERAL,
|
||||||
DNS_LOGMODULE_MASTER, ISC_LOG_INFO,
|
DNS_LOGMODULE_MASTER, ISC_LOG_INFO,
|
||||||
@@ -679,7 +675,6 @@ dns_catz_zones_merge(dns_catz_zone_t *target, dns_catz_zone_t *newzone) {
|
|||||||
|
|
||||||
dns_name_format(&entry->name, zname, DNS_NAME_FORMATSIZE);
|
dns_name_format(&entry->name, zname, DNS_NAME_FORMATSIZE);
|
||||||
result = addzone(entry, target, target->catzs->view,
|
result = addzone(entry, target, target->catzs->view,
|
||||||
target->catzs->taskmgr,
|
|
||||||
target->catzs->zmm->udata);
|
target->catzs->zmm->udata);
|
||||||
isc_log_write(dns_lctx, DNS_LOGCATEGORY_GENERAL,
|
isc_log_write(dns_lctx, DNS_LOGCATEGORY_GENERAL,
|
||||||
DNS_LOGMODULE_MASTER, ISC_LOG_INFO,
|
DNS_LOGMODULE_MASTER, ISC_LOG_INFO,
|
||||||
@@ -696,7 +691,6 @@ dns_catz_zones_merge(dns_catz_zone_t *target, dns_catz_zone_t *newzone) {
|
|||||||
|
|
||||||
dns_name_format(&entry->name, zname, DNS_NAME_FORMATSIZE);
|
dns_name_format(&entry->name, zname, DNS_NAME_FORMATSIZE);
|
||||||
result = modzone(entry, target, target->catzs->view,
|
result = modzone(entry, target, target->catzs->view,
|
||||||
target->catzs->taskmgr,
|
|
||||||
target->catzs->zmm->udata);
|
target->catzs->zmm->udata);
|
||||||
isc_log_write(dns_lctx, DNS_LOGCATEGORY_GENERAL,
|
isc_log_write(dns_lctx, DNS_LOGCATEGORY_GENERAL,
|
||||||
DNS_LOGMODULE_MASTER, ISC_LOG_INFO,
|
DNS_LOGMODULE_MASTER, ISC_LOG_INFO,
|
||||||
@@ -745,12 +739,10 @@ dns_catz_zones_merge(dns_catz_zone_t *target, dns_catz_zone_t *newzone) {
|
|||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_result_t
|
void
|
||||||
dns_catz_new_zones(dns_catz_zones_t **catzsp, dns_catz_zonemodmethods_t *zmm,
|
dns_catz_new_zones(dns_catz_zones_t **catzsp, dns_catz_zonemodmethods_t *zmm,
|
||||||
isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
|
isc_mem_t *mctx, isc_loopmgr_t *loopmgr) {
|
||||||
isc_loopmgr_t *loopmgr) {
|
dns_catz_zones_t *new_zones = NULL;
|
||||||
dns_catz_zones_t *new_zones;
|
|
||||||
isc_result_t result;
|
|
||||||
|
|
||||||
REQUIRE(catzsp != NULL && *catzsp == NULL);
|
REQUIRE(catzsp != NULL && *catzsp == NULL);
|
||||||
REQUIRE(zmm != NULL);
|
REQUIRE(zmm != NULL);
|
||||||
@@ -766,24 +758,11 @@ dns_catz_new_zones(dns_catz_zones_t **catzsp, dns_catz_zonemodmethods_t *zmm,
|
|||||||
isc_mem_attach(mctx, &new_zones->mctx);
|
isc_mem_attach(mctx, &new_zones->mctx);
|
||||||
new_zones->zmm = zmm;
|
new_zones->zmm = zmm;
|
||||||
new_zones->loopmgr = loopmgr;
|
new_zones->loopmgr = loopmgr;
|
||||||
new_zones->taskmgr = taskmgr;
|
new_zones->loop = isc_loop_get(new_zones->loopmgr, 0);
|
||||||
|
|
||||||
result = isc_task_create(taskmgr, &new_zones->updater, 0);
|
|
||||||
if (result != ISC_R_SUCCESS) {
|
|
||||||
goto cleanup_ht;
|
|
||||||
}
|
|
||||||
new_zones->magic = DNS_CATZ_ZONES_MAGIC;
|
new_zones->magic = DNS_CATZ_ZONES_MAGIC;
|
||||||
|
|
||||||
*catzsp = new_zones;
|
*catzsp = new_zones;
|
||||||
return (ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
cleanup_ht:
|
|
||||||
isc_ht_destroy(&new_zones->zones);
|
|
||||||
isc_refcount_destroy(&new_zones->refs);
|
|
||||||
isc_mutex_destroy(&new_zones->lock);
|
|
||||||
isc_mem_put(mctx, new_zones, sizeof(*new_zones));
|
|
||||||
|
|
||||||
return (result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -854,7 +833,7 @@ catz_timer_start(dns_catz_zone_t *zone) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isc_timer_create(isc_loop_current(zone->catzs->loopmgr),
|
isc_timer_create(isc_loop_current(zone->catzs->loopmgr),
|
||||||
dns_catz_update_taskaction, zone, &zone->updatetimer);
|
dns_catz_update_action, zone, &zone->updatetimer);
|
||||||
|
|
||||||
isc_timer_start(zone->updatetimer, isc_timertype_once, &interval);
|
isc_timer_start(zone->updatetimer, isc_timertype_once, &interval);
|
||||||
}
|
}
|
||||||
@@ -1011,7 +990,6 @@ dns_catz_catzs_detach(dns_catz_zones_t **catzsp) {
|
|||||||
|
|
||||||
if (isc_refcount_decrement(&catzs->refs) == 1) {
|
if (isc_refcount_decrement(&catzs->refs) == 1) {
|
||||||
catzs->magic = 0;
|
catzs->magic = 0;
|
||||||
isc_task_detach(&catzs->updater);
|
|
||||||
isc_mutex_destroy(&catzs->lock);
|
isc_mutex_destroy(&catzs->lock);
|
||||||
if (catzs->zones != NULL) {
|
if (catzs->zones != NULL) {
|
||||||
isc_ht_iter_t *iter = NULL;
|
isc_ht_iter_t *iter = NULL;
|
||||||
@@ -2024,7 +2002,7 @@ cleanup:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
dns_catz_update_taskaction(void *arg) {
|
dns_catz_update_action(void *arg) {
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
dns_catz_zone_t *zone = arg;
|
dns_catz_zone_t *zone = arg;
|
||||||
|
|
||||||
|
@@ -309,9 +309,7 @@ dns_catz_generate_zonecfg(dns_catz_zone_t *zone, dns_catz_entry_t *entry,
|
|||||||
/* xxxwpk TODO config! */
|
/* xxxwpk TODO config! */
|
||||||
typedef isc_result_t (*dns_catz_zoneop_fn_t)(dns_catz_entry_t *entry,
|
typedef isc_result_t (*dns_catz_zoneop_fn_t)(dns_catz_entry_t *entry,
|
||||||
dns_catz_zone_t *origin,
|
dns_catz_zone_t *origin,
|
||||||
dns_view_t *view,
|
dns_view_t *view, void *udata);
|
||||||
isc_taskmgr_t *taskmgr,
|
|
||||||
void *udata);
|
|
||||||
struct dns_catz_zonemodmethods {
|
struct dns_catz_zonemodmethods {
|
||||||
dns_catz_zoneop_fn_t addzone;
|
dns_catz_zoneop_fn_t addzone;
|
||||||
dns_catz_zoneop_fn_t modzone;
|
dns_catz_zoneop_fn_t modzone;
|
||||||
@@ -319,10 +317,9 @@ struct dns_catz_zonemodmethods {
|
|||||||
void *udata;
|
void *udata;
|
||||||
};
|
};
|
||||||
|
|
||||||
isc_result_t
|
void
|
||||||
dns_catz_new_zones(dns_catz_zones_t **catzsp, dns_catz_zonemodmethods_t *zmm,
|
dns_catz_new_zones(dns_catz_zones_t **catzsp, dns_catz_zonemodmethods_t *zmm,
|
||||||
isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
|
isc_mem_t *mctx, isc_loopmgr_t *loopmgr);
|
||||||
isc_loopmgr_t *loopmgr);
|
|
||||||
/*%<
|
/*%<
|
||||||
* Allocate a new catz_zones object, a collection storing all catalog zones
|
* Allocate a new catz_zones object, a collection storing all catalog zones
|
||||||
* for a view.
|
* for a view.
|
||||||
@@ -390,8 +387,8 @@ dns_catz_dbupdate_callback(dns_db_t *db, void *fn_arg);
|
|||||||
/*%<
|
/*%<
|
||||||
* Callback for update of catalog zone database.
|
* Callback for update of catalog zone database.
|
||||||
* If there was no catalog zone update recently it launches an
|
* If there was no catalog zone update recently it launches an
|
||||||
* update_taskaction immediately.
|
* update action immediately.
|
||||||
* If there was an update recently it schedules update_taskaction for some time
|
* If there was an update recently it schedules update for some time
|
||||||
* in the future.
|
* in the future.
|
||||||
* If there is an update scheduled it replaces old db version with a new one.
|
* If there is an update scheduled it replaces old db version with a new one.
|
||||||
*
|
*
|
||||||
@@ -401,7 +398,7 @@ dns_catz_dbupdate_callback(dns_db_t *db, void *fn_arg);
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
dns_catz_update_taskaction(void *arg);
|
dns_catz_update_action(void *arg);
|
||||||
/*%<
|
/*%<
|
||||||
* Task that launches dns_catz_update_from_db.
|
* Task that launches dns_catz_update_from_db.
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user