From: Colin Vidal Date: Tue, 10 Jun 2025 14:27:58 +0000 (+0200) Subject: add NS_QUERY_AUTHZONE_ATTACHED hook X-Git-Tag: v9.21.14~56^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1566634fae9bb9672fb7d54de6a9673d471e1b12;p=thirdparty%2Fbind9.git add NS_QUERY_AUTHZONE_ATTACHED hook Add a new query hook called `NS_QUERY_AUTHZONE_ATTACHED`. This hook is called whenever an authoritative zone is found and attached during a query answer. From code level, this hook is called when `qctx->client->query->authzone` is attached during a query. This enables zone-specific plugins to initialize specific states whenever a local zone is found that can answer a query. --- diff --git a/lib/ns/include/ns/hooks.h b/lib/ns/include/ns/hooks.h index 713b9fb3c61..98508938567 100644 --- a/lib/ns/include/ns/hooks.h +++ b/lib/ns/include/ns/hooks.h @@ -402,6 +402,7 @@ typedef enum { NS_QUERY_PREP_RESPONSE_BEGIN, NS_QUERY_DONE_BEGIN, NS_QUERY_DONE_SEND, + NS_QUERY_AUTHZONE_ATTACHED, /* XXX other files could be added later */ diff --git a/lib/ns/query.c b/lib/ns/query.c index ede3245be1e..123a0a0a327 100644 --- a/lib/ns/query.c +++ b/lib/ns/query.c @@ -317,8 +317,8 @@ static ns_hooktable_t * ns__zone_hooktab(query_ctx_t *qctx) { ns_hooktable_t *hooktab = NULL; - if (qctx && qctx->zone) { - hooktab = dns_zone_gethooktable(qctx->zone); + if (qctx != NULL && qctx->client->query.authzone != NULL) { + hooktab = dns_zone_gethooktable(qctx->client->query.authzone); } return hooktab; @@ -328,7 +328,7 @@ static ns_hooktable_t * ns__view_hooktab(query_ctx_t *qctx) { ns_hooktable_t *hooktab = NULL; - if (qctx && qctx->view) { + if (qctx != NULL && qctx->view != NULL) { hooktab = qctx->view->hooktable; } @@ -5668,6 +5668,7 @@ ns__query_start(query_ctx_t *qctx) { */ dns_zone_attach(qctx->zone, &qctx->client->query.authzone); + CALL_HOOK(NS_QUERY_AUTHZONE_ATTACHED, qctx); } dns_db_attach(qctx->db, &qctx->client->query.authdb); }