]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
add NS_QUERY_AUTHZONE_ATTACHED hook
authorColin Vidal <colin@isc.org>
Tue, 10 Jun 2025 14:27:58 +0000 (16:27 +0200)
committerColin Vidal <colin@isc.org>
Tue, 9 Sep 2025 07:42:34 +0000 (09:42 +0200)
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.

lib/ns/include/ns/hooks.h
lib/ns/query.c

index 713b9fb3c61ffcd907742614327b4fab165add40..98508938567c421c707fb2d05b570b081fcb3294 100644 (file)
@@ -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 */
 
index ede3245be1e0bc13d2888c27dfff4400918e6473..123a0a0a32739b8b77509a08afb6e3e34941458e 100644 (file)
@@ -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);
                }