From 55ea24d66e4120b3c1370e931897028054caa554 Mon Sep 17 00:00:00 2001 From: Petr Menšík Date: May 21 2021 09:40:57 +0000 Subject: [PATCH 1/2] Remove ISCAPI_TASK_VALID checks Recent BIND 9.16.16 has hidden task structure and public checks. It still checks task validity in each isc_task_* function, which we use for working with tasks. No lesser checking would be done. isc_mem_t still has them, but they were removed in 9.17. Remove those checks as well, work with them just structure undefined pointers. Rely on bind9 library to check them. --- diff --git a/src/ldap_driver.c b/src/ldap_driver.c index 20aa9f0..e9f1005 100644 --- a/src/ldap_driver.c +++ b/src/ldap_driver.c @@ -1026,7 +1026,7 @@ ldapdb_associate(isc_mem_t *mctx, node_name_t *name, dns_dbtype_t type, ldap_instance_t *ldap_inst = driverarg; zone_register_t *zr = NULL; - REQUIRE(ISCAPI_MCTX_VALID(mctx)); + UNUSED(mctx); REQUIRE(type == LDAP_DB_TYPE); REQUIRE(rdclass == LDAP_DB_RDATACLASS); REQUIRE(argc == 0); diff --git a/src/ldap_helper.c b/src/ldap_helper.c index 1c89e54..2fd2da4 100644 --- a/src/ldap_helper.c +++ b/src/ldap_helper.c @@ -1143,7 +1143,7 @@ publish_zone(isc_task_t *task, ldap_instance_t *inst, dns_zone_t *zone) dns_view_t *view_in_zone = NULL; isc_result_t lock_state = ISC_R_IGNORE; - REQUIRE(ISCAPI_TASK_VALID(task)); + UNUSED(task); REQUIRE(inst != NULL); REQUIRE(zone != NULL); diff --git a/src/syncrepl.c b/src/syncrepl.c index b7a7ab8..a406fff 100644 --- a/src/syncrepl.c +++ b/src/syncrepl.c @@ -131,7 +131,6 @@ finish(isc_task_t *task, isc_event_t *event) { sync_barrierev_t *bev = NULL; sync_state_t new_state; - REQUIRE(ISCAPI_TASK_VALID(task)); REQUIRE(event != NULL); bev = (sync_barrierev_t *)event; @@ -206,8 +205,8 @@ barrier_decrement(isc_task_t *task, isc_event_t *event) { sync_barrierev_t *bev = NULL; uint32_t cnt; - REQUIRE(ISCAPI_TASK_VALID(task)); REQUIRE(event != NULL); + UNUSED(task); bev = (sync_barrierev_t *)event; #if LIBDNS_VERSION_MAJOR < 1600 @@ -458,7 +457,6 @@ sync_task_add(sync_ctx_t *sctx, isc_task_t *task) { uint32_t cnt; REQUIRE(sctx != NULL); - REQUIRE(ISCAPI_TASK_VALID(task)); newel = isc_mem_get(sctx->mctx, sizeof(*(newel))); ZERO_PTR(newel); From 956f1f761faf2c67a6fb85d4e8afaadb66a31bbf Mon Sep 17 00:00:00 2001 From: Petr Menšík Date: May 21 2021 09:40:59 +0000 Subject: [PATCH 2/2] Reduce passing tasks in zones activation They are never used from passed parameters, so do not forward them into multiple functions. Ignore them on task endpoint where they always have to be. --- diff --git a/src/ldap_helper.c b/src/ldap_helper.c index 2fd2da4..97a1859 100644 --- a/src/ldap_helper.c +++ b/src/ldap_helper.c @@ -1135,7 +1135,7 @@ cleanup: * Add zone to the view defined in inst->view. */ static isc_result_t ATTR_NONNULLS ATTR_CHECKRESULT -publish_zone(isc_task_t *task, ldap_instance_t *inst, dns_zone_t *zone) +publish_zone(ldap_instance_t *inst, dns_zone_t *zone) { isc_result_t result; bool freeze = false; @@ -1143,7 +1143,6 @@ publish_zone(isc_task_t *task, ldap_instance_t *inst, dns_zone_t *zone) dns_view_t *view_in_zone = NULL; isc_result_t lock_state = ISC_R_IGNORE; - UNUSED(task); REQUIRE(inst != NULL); REQUIRE(zone != NULL); @@ -1199,7 +1198,7 @@ cleanup: * Add zone to view and call dns_zone_load(). */ static isc_result_t ATTR_NONNULLS ATTR_CHECKRESULT -activate_zone(isc_task_t *task, ldap_instance_t *inst, dns_name_t *name) { +activate_zone(ldap_instance_t *inst, dns_name_t *name) { isc_result_t result; dns_zone_t *raw = NULL; dns_zone_t *secure = NULL; @@ -1218,7 +1217,7 @@ activate_zone(isc_task_t *task, ldap_instance_t *inst, dns_name_t *name) { * otherwise it will race with zone->view != NULL check * in zone_maintenance() in zone.c. */ - result = publish_zone(task, inst, toview); + result = publish_zone(inst, toview); if (result != ISC_R_SUCCESS) { dns_zone_log(toview, ISC_LOG_ERROR, "cannot add zone to view: %s", @@ -1247,7 +1246,7 @@ cleanup: * and load zones. */ isc_result_t -activate_zones(isc_task_t *task, ldap_instance_t *inst) { +activate_zones(ldap_instance_t *inst) { isc_result_t result; rbt_iterator_t *iter = NULL; DECLARE_BUFFERED_NAME(name); @@ -1270,7 +1269,7 @@ activate_zones(isc_task_t *task, ldap_instance_t *inst) { ++total_cnt; if (active == true) { ++active_cnt; - result = activate_zone(task, inst, &name); + result = activate_zone(inst, &name); if (result == ISC_R_SUCCESS) ++published_cnt; result = fwd_configure_zone(settings, inst, &name); @@ -2243,7 +2242,7 @@ ldap_parse_master_zoneentry(ldap_entry_t * const entry, dns_db_t * const olddb, toview = (want_secure == true) ? secure : raw; if (isactive == true) { if (new_zone == true || activity_changed == true) - CHECK(publish_zone(task, inst, toview)); + CHECK(publish_zone(inst, toview)); CHECK(load_zone(toview, false)); CHECK(fwd_configure_zone(zone_settings, inst, &entry->fqdn)); } else if (activity_changed == true) { /* Zone was deactivated */ diff --git a/src/ldap_helper.h b/src/ldap_helper.h index 6ac6282..0f90683 100644 --- a/src/ldap_helper.h +++ b/src/ldap_helper.h @@ -84,7 +84,7 @@ const char * ldap_instance_getdbname(ldap_instance_t *ldap_inst) ATTR_NONNULLS; zone_register_t * ldap_instance_getzr(ldap_instance_t *ldap_inst) ATTR_NONNULLS; -isc_result_t activate_zones(isc_task_t *task, ldap_instance_t *inst) ATTR_NONNULLS; +isc_result_t activate_zones(ldap_instance_t *inst) ATTR_NONNULLS; isc_task_t * ldap_instance_gettask(ldap_instance_t *ldap_inst); diff --git a/src/syncrepl.c b/src/syncrepl.c index a406fff..3baeb78 100644 --- a/src/syncrepl.c +++ b/src/syncrepl.c @@ -132,6 +132,7 @@ finish(isc_task_t *task, isc_event_t *event) { sync_state_t new_state; REQUIRE(event != NULL); + UNUSED(task); bev = (sync_barrierev_t *)event; log_debug(1, "sync_barrier_wait(): finish reached"); @@ -155,7 +156,7 @@ finish(isc_task_t *task, isc_event_t *event) { BROADCAST(&bev->sctx->cond); UNLOCK(&bev->sctx->mutex); if (new_state == sync_finished) - activate_zones(task, bev->inst); + activate_zones(bev->inst); if (result != ISC_R_SUCCESS) log_error_r("syncrepl finish() failed");