mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 14:07:59 +00:00
add more error logging; add event processing logging
This commit is contained in:
parent
d0ba302028
commit
6a5c8ec2ea
@ -91,21 +91,38 @@ dyndb_init(isc_mem_t *mctx, const char *name, const char *parameters,
|
||||
}
|
||||
|
||||
result = isc_commandline_strtoargv(mctx, s, &argc, &argv, 0);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
log_write(ISC_LOG_ERROR,
|
||||
"dyndb_init: isc_commandline_strtoargv -> %s\n",
|
||||
isc_result_totext(result));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
log_write(ISC_LOG_DEBUG(9),
|
||||
"loading params for dyndb '%s' from %s:%lu",
|
||||
name, file, line);
|
||||
|
||||
/* Finally, create the instance. */
|
||||
CHECK(new_sample_instance(mctx, name, argc, argv, dctx, &sample_inst));
|
||||
result = new_sample_instance(mctx, name, argc, argv, dctx,
|
||||
&sample_inst);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
log_write(ISC_LOG_ERROR,
|
||||
"dyndb_init: new_sample_instance -> %s\n",
|
||||
isc_result_totext(result));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is an example so we create and load zones
|
||||
* right now. This step can be arbitrarily postponed.
|
||||
*/
|
||||
CHECK(load_sample_instance_zones(sample_inst));
|
||||
result = load_sample_instance_zones(sample_inst);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
log_write(ISC_LOG_ERROR,
|
||||
"dyndb_init: load_sample_instance_zones -> %s\n",
|
||||
isc_result_totext(result));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
*instp = sample_inst;
|
||||
|
||||
|
@ -57,8 +57,20 @@ parse_params(isc_mem_t *mctx, int argc, char **argv,
|
||||
result = ISC_R_FAILURE;
|
||||
goto cleanup;
|
||||
}
|
||||
CHECK(dns_name_fromstring2(z1, argv[0], dns_rootname, 0, mctx));
|
||||
CHECK(dns_name_fromstring2(z2, argv[1], dns_rootname, 0, mctx));
|
||||
result = dns_name_fromstring2(z1, argv[0], dns_rootname, 0, mctx);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
log_write(ISC_LOG_ERROR,
|
||||
"parse_params: dns_name_fromstring2 -> %s",
|
||||
isc_result_totext(result));
|
||||
goto cleanup;
|
||||
}
|
||||
result = dns_name_fromstring2(z2, argv[1], dns_rootname, 0, mctx);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
log_write(ISC_LOG_ERROR,
|
||||
"parse_params: dns_name_fromstring2 -> %s",
|
||||
isc_result_totext(result));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
result = ISC_R_SUCCESS;
|
||||
|
||||
@ -93,15 +105,27 @@ new_sample_instance(isc_mem_t *mctx, const char *db_name,
|
||||
inst->zone1_name = dns_fixedname_initname(&inst->zone1_fn);
|
||||
inst->zone2_name = dns_fixedname_initname(&inst->zone2_fn);
|
||||
|
||||
CHECK(parse_params(mctx, argc, argv,
|
||||
inst->zone1_name, inst->zone2_name));
|
||||
result = parse_params(mctx, argc, argv,
|
||||
inst->zone1_name, inst->zone2_name);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
log_write(ISC_LOG_ERROR,
|
||||
"new_sample_instance: parse_params -> %s",
|
||||
isc_result_totext(result));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
dns_view_attach(dctx->view, &inst->view);
|
||||
dns_zonemgr_attach(dctx->zmgr, &inst->zmgr);
|
||||
isc_task_attach(dctx->task, &inst->task);
|
||||
|
||||
/* Register new DNS DB implementation. */
|
||||
CHECK(dns_db_register(db_name, create_db, inst, mctx, &inst->db_imp));
|
||||
result = dns_db_register(db_name, create_db, inst, mctx, &inst->db_imp);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
log_write(ISC_LOG_ERROR,
|
||||
"new_sample_instance: dns_db_register -> %s",
|
||||
isc_result_totext(result));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
*sample_instp = inst;
|
||||
result = ISC_R_SUCCESS;
|
||||
@ -120,11 +144,35 @@ isc_result_t
|
||||
load_sample_instance_zones(sample_instance_t *inst) {
|
||||
isc_result_t result;
|
||||
|
||||
CHECK(create_zone(inst, inst->zone1_name, &inst->zone1));
|
||||
CHECK(activate_zone(inst, inst->zone1));
|
||||
result = create_zone(inst, inst->zone1_name, &inst->zone1);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
log_write(ISC_LOG_ERROR,
|
||||
"load_sample_instance_zones: create_zone -> %s",
|
||||
isc_result_totext(result));
|
||||
goto cleanup;
|
||||
}
|
||||
result = activate_zone(inst, inst->zone1);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
log_write(ISC_LOG_ERROR,
|
||||
"load_sample_instance_zones: activate_zone -> %s",
|
||||
isc_result_totext(result));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
CHECK(create_zone(inst, inst->zone2_name, &inst->zone2));
|
||||
CHECK(activate_zone(inst, inst->zone2));
|
||||
result = create_zone(inst, inst->zone2_name, &inst->zone2);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
log_write(ISC_LOG_ERROR,
|
||||
"load_sample_instance_zones: create_zone -> %s",
|
||||
isc_result_totext(result));
|
||||
goto cleanup;
|
||||
}
|
||||
result = activate_zone(inst, inst->zone2);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
log_write(ISC_LOG_ERROR,
|
||||
"load_sample_instance_zones: activate_zone -> %s",
|
||||
isc_result_totext(result));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
return (result);
|
||||
|
@ -57,9 +57,30 @@ syncptr_write(isc_task_t *task, isc_event_t *event) {
|
||||
|
||||
UNUSED(task);
|
||||
|
||||
CHECK(dns_zone_getdb(pevent->zone, &db));
|
||||
CHECK(dns_db_newversion(db, &version));
|
||||
CHECK(dns_diff_apply(&pevent->diff, db, version));
|
||||
log_write(ISC_LOG_INFO, "ENTER: syncptr_write");
|
||||
|
||||
result = dns_zone_getdb(pevent->zone, &db);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
log_write(ISC_LOG_ERROR,
|
||||
"syncptr_write: dns_zone_getdb -> %s\n",
|
||||
isc_result_totext(result));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
result = dns_db_newversion(db, &version);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
log_write(ISC_LOG_ERROR,
|
||||
"syncptr_write: dns_db_newversion -> %s\n",
|
||||
isc_result_totext(result));
|
||||
goto cleanup;
|
||||
}
|
||||
result = dns_diff_apply(&pevent->diff, db, version);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
log_write(ISC_LOG_ERROR,
|
||||
"syncptr_write: dns_diff_apply -> %s\n",
|
||||
isc_result_totext(result));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
if (db != NULL) {
|
||||
@ -119,18 +140,30 @@ syncptr_find_zone(sample_instance_t *inst, dns_rdata_t *rdata,
|
||||
* @example
|
||||
* 192.168.0.1 -> 1.0.168.192.in-addr.arpa
|
||||
*/
|
||||
CHECK(dns_byaddr_createptrname(&isc_ip, 0, name));
|
||||
result = dns_byaddr_createptrname(&isc_ip, 0, name);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
log_write(ISC_LOG_ERROR,
|
||||
"syncptr_find_zone: dns_byaddr_createptrname -> %s\n",
|
||||
isc_result_totext(result));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Find a zone containing owner name of the PTR record. */
|
||||
result = dns_zt_find(inst->view->zonetable, name, 0, NULL, zone);
|
||||
if (result == DNS_R_PARTIALMATCH)
|
||||
result = ISC_R_SUCCESS;
|
||||
else if (result != ISC_R_SUCCESS)
|
||||
else if (result != ISC_R_SUCCESS) {
|
||||
log_write(ISC_LOG_ERROR,
|
||||
"syncptr_find_zone: dns_zt_find -> %s\n",
|
||||
isc_result_totext(result));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Make sure that the zone is managed by this driver. */
|
||||
if (*zone != inst->zone1 && *zone != inst->zone2) {
|
||||
dns_zone_detach(zone);
|
||||
log_write(ISC_LOG_INFO,
|
||||
"syncptr_find_zone: zone not managed");
|
||||
result = ISC_R_NOTFOUND;
|
||||
}
|
||||
|
||||
@ -202,17 +235,37 @@ syncptr(sample_instance_t *inst, dns_name_t *name,
|
||||
/* Reverse zone is managed by this driver, prepare PTR record */
|
||||
pevent->zone = NULL;
|
||||
dns_zone_attach(ptr_zone, &pevent->zone);
|
||||
CHECK(dns_name_copy(name, dns_fixedname_name(&pevent->ptr_target_name),
|
||||
NULL));
|
||||
result = dns_name_copy(name,
|
||||
dns_fixedname_name(&pevent->ptr_target_name),
|
||||
NULL);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
log_write(ISC_LOG_ERROR,
|
||||
"syncptr: dns_name_copy -> %s\n",
|
||||
isc_result_totext(result));
|
||||
goto cleanup;
|
||||
}
|
||||
dns_name_clone(dns_fixedname_name(&pevent->ptr_target_name),
|
||||
&ptr_struct.ptr);
|
||||
dns_diff_init(inst->mctx, &pevent->diff);
|
||||
CHECK(dns_rdata_fromstruct(&ptr_rdata, dns_rdataclass_in,
|
||||
dns_rdatatype_ptr, &ptr_struct, &pevent->b));
|
||||
result = dns_rdata_fromstruct(&ptr_rdata, dns_rdataclass_in,
|
||||
dns_rdatatype_ptr, &ptr_struct,
|
||||
&pevent->b);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
log_write(ISC_LOG_ERROR,
|
||||
"syncptr: dns_rdata_fromstruct -> %s\n",
|
||||
isc_result_totext(result));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Create diff */
|
||||
CHECK(dns_difftuple_create(mctx, op, dns_fixedname_name(&ptr_name),
|
||||
ttl, &ptr_rdata, &tp));
|
||||
result = dns_difftuple_create(mctx, op, dns_fixedname_name(&ptr_name),
|
||||
ttl, &ptr_rdata, &tp);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
log_write(ISC_LOG_ERROR,
|
||||
"syncptr: dns_difftuple_create -> %s\n",
|
||||
isc_result_totext(result));
|
||||
goto cleanup;
|
||||
}
|
||||
dns_diff_append(&pevent->diff, &tp);
|
||||
|
||||
/*
|
||||
|
@ -43,15 +43,45 @@ create_zone(sample_instance_t * const inst, dns_name_t * const name,
|
||||
|
||||
zone_argv[0] = inst->db_name;
|
||||
|
||||
CHECK(dns_zone_create(&raw, inst->mctx));
|
||||
CHECK(dns_zone_setorigin(raw, name));
|
||||
result = dns_zone_create(&raw, inst->mctx);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
log_write(ISC_LOG_ERROR,
|
||||
"create_zone: dns_zone_create -> %s\n",
|
||||
isc_result_totext(result));
|
||||
goto cleanup;
|
||||
}
|
||||
result = dns_zone_setorigin(raw, name);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
log_write(ISC_LOG_ERROR,
|
||||
"create_zone: dns_zone_setorigin -> %s\n",
|
||||
isc_result_totext(result));
|
||||
goto cleanup;
|
||||
}
|
||||
dns_zone_setclass(raw, dns_rdataclass_in);
|
||||
dns_zone_settype(raw, dns_zone_master);
|
||||
CHECK(dns_zone_setdbtype(raw, 1, zone_argv));
|
||||
CHECK(dns_zonemgr_managezone(inst->zmgr, raw));
|
||||
result = dns_zone_setdbtype(raw, 1, zone_argv);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
log_write(ISC_LOG_ERROR,
|
||||
"create_zone: dns_zone_setdbtype -> %s\n",
|
||||
isc_result_totext(result));
|
||||
goto cleanup;
|
||||
}
|
||||
result = dns_zonemgr_managezone(inst->zmgr, raw);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
log_write(ISC_LOG_ERROR,
|
||||
"create_zone: dns_zonemgr_managezone -> %s\n",
|
||||
isc_result_totext(result));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* This is completely insecure - use some sensible values instead! */
|
||||
CHECK(dns_acl_any(inst->mctx, &acl_any));
|
||||
result = dns_acl_any(inst->mctx, &acl_any);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
log_write(ISC_LOG_ERROR,
|
||||
"create_zone: dns_acl_any -> %s\n",
|
||||
isc_result_totext(result));
|
||||
goto cleanup;
|
||||
}
|
||||
dns_zone_setupdateacl(raw, acl_any);
|
||||
dns_zone_setqueryacl(raw, acl_any);
|
||||
dns_zone_setxfracl(raw, acl_any);
|
||||
@ -129,7 +159,13 @@ publish_zone(sample_instance_t *inst, dns_zone_t *zone) {
|
||||
}
|
||||
|
||||
dns_zone_setview(zone, inst->view);
|
||||
CHECK(dns_view_addzone(inst->view, zone));
|
||||
result = dns_view_addzone(inst->view, zone);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
log_write(ISC_LOG_ERROR,
|
||||
"publish_zone: dns_view_addzone -> %s\n",
|
||||
isc_result_totext(result));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
if (zone_in_view != NULL)
|
||||
@ -157,7 +193,13 @@ load_zone(dns_zone_t *zone) {
|
||||
goto cleanup;
|
||||
zone_dynamic = (result == DNS_R_DYNAMIC);
|
||||
|
||||
CHECK(dns_zone_getserial(zone, &serial));
|
||||
result = dns_zone_getserial(zone, &serial);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
log_write(ISC_LOG_ERROR,
|
||||
"load_zone: dns_zone_getserial -> %s\n",
|
||||
isc_result_totext(result));
|
||||
goto cleanup;
|
||||
}
|
||||
dns_zone_log(zone, ISC_LOG_INFO, "loaded serial %u", serial);
|
||||
|
||||
if (zone_dynamic)
|
||||
@ -187,7 +229,13 @@ activate_zone(sample_instance_t *inst, dns_zone_t *raw) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
CHECK(load_zone(raw));
|
||||
result = load_zone(raw);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
log_write(ISC_LOG_ERROR,
|
||||
"activate_zone: load_zone -> %s\n",
|
||||
isc_result_totext(result));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
return (result);
|
||||
|
Loading…
x
Reference in New Issue
Block a user