2014-05-29 22:22:53 -07:00
|
|
|
/*
|
|
|
|
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
2021-06-03 08:37:05 +02:00
|
|
|
*
|
2014-05-29 22:22:53 -07:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
2018-02-23 09:53:12 +01:00
|
|
|
*
|
2014-05-29 22:22:53 -07:00
|
|
|
* See the COPYRIGHT file distributed with this work for additional
|
2014-06-18 16:47:22 -07:00
|
|
|
* information regarding copyright ownership.
|
2014-05-29 22:22:53 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*! \file */
|
|
|
|
|
2018-03-28 14:19:37 +02:00
|
|
|
#include <inttypes.h>
|
2018-04-17 08:29:14 -07:00
|
|
|
#include <stdbool.h>
|
2018-03-28 14:19:37 +02:00
|
|
|
|
2022-09-12 16:36:30 +02:00
|
|
|
#include <isc/async.h>
|
2014-06-18 16:47:22 -07:00
|
|
|
#include <isc/buffer.h>
|
2014-05-29 22:22:53 -07:00
|
|
|
#include <isc/log.h>
|
2022-07-26 13:03:40 +02:00
|
|
|
#include <isc/loop.h>
|
2014-05-29 22:22:53 -07:00
|
|
|
#include <isc/mem.h>
|
2021-10-04 17:14:53 +02:00
|
|
|
#include <isc/result.h>
|
2014-05-29 22:22:53 -07:00
|
|
|
#include <isc/rwlock.h>
|
|
|
|
#include <isc/string.h>
|
|
|
|
#include <isc/time.h>
|
2014-06-18 16:47:22 -07:00
|
|
|
#include <isc/timer.h>
|
2014-05-29 22:22:53 -07:00
|
|
|
#include <isc/util.h>
|
|
|
|
|
2014-06-18 16:47:22 -07:00
|
|
|
#include <dns/db.h>
|
2014-05-29 22:22:53 -07:00
|
|
|
#include <dns/fixedname.h>
|
|
|
|
#include <dns/name.h>
|
|
|
|
#include <dns/nta.h>
|
2023-04-05 00:36:37 -07:00
|
|
|
#include <dns/qp.h>
|
2014-06-18 16:47:22 -07:00
|
|
|
#include <dns/rdataset.h>
|
|
|
|
#include <dns/resolver.h>
|
2015-01-12 09:04:16 +05:30
|
|
|
#include <dns/time.h>
|
2014-05-29 22:22:53 -07:00
|
|
|
|
2022-09-12 16:36:30 +02:00
|
|
|
struct dns_ntatable {
|
2014-06-18 16:47:22 -07:00
|
|
|
unsigned int magic;
|
2022-10-03 15:54:12 +02:00
|
|
|
isc_mem_t *mctx;
|
2022-09-12 16:36:30 +02:00
|
|
|
dns_view_t *view;
|
|
|
|
isc_rwlock_t rwlock;
|
|
|
|
isc_refcount_t references;
|
2023-04-05 00:36:37 -07:00
|
|
|
dns_qpmulti_t *table;
|
2022-10-03 15:54:12 +02:00
|
|
|
atomic_bool shuttingdown;
|
2022-09-12 16:36:30 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct dns__nta {
|
|
|
|
unsigned int magic;
|
|
|
|
isc_mem_t *mctx;
|
2023-04-05 00:36:37 -07:00
|
|
|
isc_loop_t *loop;
|
2022-09-12 16:36:30 +02:00
|
|
|
isc_refcount_t references;
|
2014-06-18 16:47:22 -07:00
|
|
|
dns_ntatable_t *ntatable;
|
2018-04-17 08:29:14 -07:00
|
|
|
bool forced;
|
2014-06-18 16:47:22 -07:00
|
|
|
isc_timer_t *timer;
|
|
|
|
dns_fetch_t *fetch;
|
|
|
|
dns_rdataset_t rdataset;
|
|
|
|
dns_rdataset_t sigrdataset;
|
2024-03-13 13:42:57 -07:00
|
|
|
dns_name_t name;
|
2014-06-18 16:47:22 -07:00
|
|
|
isc_stdtime_t expiry;
|
2023-04-05 00:36:37 -07:00
|
|
|
bool shuttingdown;
|
2014-06-18 16:47:22 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#define NTA_MAGIC ISC_MAGIC('N', 'T', 'A', 'n')
|
|
|
|
#define VALID_NTA(nn) ISC_MAGIC_VALID(nn, NTA_MAGIC)
|
|
|
|
|
2014-07-10 10:24:47 +10:00
|
|
|
static void
|
2022-09-12 16:36:30 +02:00
|
|
|
dns__nta_shutdown(dns__nta_t *nta);
|
2014-07-10 10:24:47 +10:00
|
|
|
|
2023-04-05 00:36:37 -07:00
|
|
|
static void
|
|
|
|
qp_attach(void *uctx, void *pval, uint32_t ival);
|
|
|
|
static void
|
|
|
|
qp_detach(void *uctx, void *pval, uint32_t ival);
|
|
|
|
static size_t
|
|
|
|
qp_makekey(dns_qpkey_t key, void *uctx, void *pval, uint32_t ival);
|
|
|
|
static void
|
|
|
|
qp_triename(void *uctx, char *buf, size_t size);
|
|
|
|
|
|
|
|
static dns_qpmethods_t qpmethods = {
|
|
|
|
qp_attach,
|
|
|
|
qp_detach,
|
|
|
|
qp_makekey,
|
|
|
|
qp_triename,
|
|
|
|
};
|
|
|
|
|
2014-05-29 22:22:53 -07:00
|
|
|
static void
|
2022-09-12 16:36:30 +02:00
|
|
|
dns__nta_destroy(dns__nta_t *nta) {
|
|
|
|
REQUIRE(nta->timer == NULL);
|
2023-04-05 00:36:37 -07:00
|
|
|
|
|
|
|
nta->magic = 0;
|
2022-09-12 16:36:30 +02:00
|
|
|
if (dns_rdataset_isassociated(&nta->rdataset)) {
|
|
|
|
dns_rdataset_disassociate(&nta->rdataset);
|
|
|
|
}
|
|
|
|
if (dns_rdataset_isassociated(&nta->sigrdataset)) {
|
|
|
|
dns_rdataset_disassociate(&nta->sigrdataset);
|
2014-05-29 22:22:53 -07:00
|
|
|
}
|
2022-09-12 16:36:30 +02:00
|
|
|
if (nta->fetch != NULL) {
|
|
|
|
dns_resolver_cancelfetch(nta->fetch);
|
|
|
|
dns_resolver_destroyfetch(&nta->fetch);
|
|
|
|
}
|
2022-10-28 01:33:40 -07:00
|
|
|
isc_loop_detach(&nta->loop);
|
2024-03-13 13:42:57 -07:00
|
|
|
dns_name_free(&nta->name, nta->mctx);
|
2022-09-12 16:36:30 +02:00
|
|
|
isc_mem_putanddetach(&nta->mctx, nta, sizeof(*nta));
|
2014-05-29 22:22:53 -07:00
|
|
|
}
|
|
|
|
|
2023-04-05 00:36:37 -07:00
|
|
|
#if DNS_NTA_TRACE
|
|
|
|
ISC_REFCOUNT_TRACE_IMPL(dns__nta, dns__nta_destroy);
|
|
|
|
#else
|
2022-09-12 16:36:30 +02:00
|
|
|
ISC_REFCOUNT_IMPL(dns__nta, dns__nta_destroy);
|
2023-04-05 00:36:37 -07:00
|
|
|
#endif
|
2022-09-12 16:36:30 +02:00
|
|
|
|
2023-04-05 00:36:37 -07:00
|
|
|
void
|
2025-07-14 10:50:21 +02:00
|
|
|
dns_ntatable_create(dns_view_t *view, dns_ntatable_t **ntatablep) {
|
2023-04-05 00:36:37 -07:00
|
|
|
dns_ntatable_t *ntatable = NULL;
|
2014-05-29 22:22:53 -07:00
|
|
|
|
|
|
|
REQUIRE(ntatablep != NULL && *ntatablep == NULL);
|
|
|
|
|
2014-06-18 16:47:22 -07:00
|
|
|
ntatable = isc_mem_get(view->mctx, sizeof(*ntatable));
|
2022-09-12 16:36:30 +02:00
|
|
|
*ntatable = (dns_ntatable_t){
|
2025-07-14 10:50:21 +02:00
|
|
|
.mctx = isc_mem_ref(view->mctx),
|
2022-09-12 16:36:30 +02:00
|
|
|
};
|
2014-05-29 22:22:53 -07:00
|
|
|
|
2022-10-03 15:54:12 +02:00
|
|
|
dns_view_weakattach(view, &ntatable->view);
|
|
|
|
|
Add the reader-writer synchronization with modified C-RW-WP
This changes the internal isc_rwlock implementation to:
Irina Calciu, Dave Dice, Yossi Lev, Victor Luchangco, Virendra
J. Marathe, and Nir Shavit. 2013. NUMA-aware reader-writer locks.
SIGPLAN Not. 48, 8 (August 2013), 157–166.
DOI:https://doi.org/10.1145/2517327.24425
(The full article available from:
http://mcg.cs.tau.ac.il/papers/ppopp2013-rwlocks.pdf)
The implementation is based on the The Writer-Preference Lock (C-RW-WP)
variant (see the 3.4 section of the paper for the rationale).
The implemented algorithm has been modified for simplicity and for usage
patterns in rbtdb.c.
The changes compared to the original algorithm:
* We haven't implemented the cohort locks because that would require a
knowledge of NUMA nodes, instead a simple atomic_bool is used as
synchronization point for writer lock.
* The per-thread reader counters are not being used - this would
require the internal thread id (isc_tid_v) to be always initialized,
even in the utilities; the change has a slight performance penalty,
so we might revisit this change in the future. However, this change
also saves a lot of memory, because cache-line aligned counters were
used, so on 32-core machine, the rwlock would be 4096+ bytes big.
* The readers use a writer_barrier that will raise after a while when
readers lock can't be acquired to prevent readers starvation.
* Separate ingress and egress readers counters queues to reduce both
inter and intra-thread contention.
2021-03-24 17:52:56 +01:00
|
|
|
isc_rwlock_init(&ntatable->rwlock);
|
2023-04-05 00:36:37 -07:00
|
|
|
dns_qpmulti_create(view->mctx, &qpmethods, view, &ntatable->table);
|
2014-05-29 22:22:53 -07:00
|
|
|
|
2019-05-20 16:41:24 +02:00
|
|
|
isc_refcount_init(&ntatable->references, 1);
|
2014-06-18 16:47:22 -07:00
|
|
|
|
2014-05-29 22:22:53 -07:00
|
|
|
ntatable->magic = NTATABLE_MAGIC;
|
|
|
|
*ntatablep = ntatable;
|
|
|
|
}
|
|
|
|
|
2022-09-12 16:36:30 +02:00
|
|
|
static void
|
|
|
|
dns__ntatable_destroy(dns_ntatable_t *ntatable) {
|
|
|
|
ntatable->magic = 0;
|
|
|
|
isc_rwlock_destroy(&ntatable->rwlock);
|
2023-04-05 00:36:37 -07:00
|
|
|
dns_qpmulti_destroy(&ntatable->table);
|
2022-10-03 15:54:12 +02:00
|
|
|
INSIST(ntatable->view == NULL);
|
|
|
|
isc_mem_putanddetach(&ntatable->mctx, ntatable, sizeof(*ntatable));
|
2014-05-29 22:22:53 -07:00
|
|
|
}
|
|
|
|
|
2023-04-05 00:36:37 -07:00
|
|
|
#if DNS_NTA_TRACE
|
|
|
|
ISC_REFCOUNT_TRACE_IMPL(dns_ntatable, dns__ntatable_destroy);
|
|
|
|
#else
|
2022-09-12 16:36:30 +02:00
|
|
|
ISC_REFCOUNT_IMPL(dns_ntatable, dns__ntatable_destroy);
|
2023-04-05 00:36:37 -07:00
|
|
|
#endif
|
2014-06-18 16:47:22 -07:00
|
|
|
|
|
|
|
static void
|
2022-10-28 01:33:40 -07:00
|
|
|
fetch_done(void *arg) {
|
|
|
|
dns_fetchresponse_t *resp = (dns_fetchresponse_t *)arg;
|
|
|
|
dns__nta_t *nta = resp->arg;
|
|
|
|
isc_result_t eresult = resp->result;
|
2014-06-18 16:47:22 -07:00
|
|
|
dns_ntatable_t *ntatable = nta->ntatable;
|
2014-07-10 10:24:47 +10:00
|
|
|
dns_view_t *view = ntatable->view;
|
2023-03-30 21:13:41 +02:00
|
|
|
isc_stdtime_t now = isc_stdtime_now();
|
2014-06-18 16:47:22 -07:00
|
|
|
|
|
|
|
if (dns_rdataset_isassociated(&nta->rdataset)) {
|
|
|
|
dns_rdataset_disassociate(&nta->rdataset);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2014-06-18 16:47:22 -07:00
|
|
|
if (dns_rdataset_isassociated(&nta->sigrdataset)) {
|
|
|
|
dns_rdataset_disassociate(&nta->sigrdataset);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2022-10-28 01:33:40 -07:00
|
|
|
if (nta->fetch == resp->fetch) {
|
2014-10-18 10:07:24 +11:00
|
|
|
nta->fetch = NULL;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2022-10-28 01:33:40 -07:00
|
|
|
dns_resolver_destroyfetch(&resp->fetch);
|
2014-06-18 16:47:22 -07:00
|
|
|
|
2022-10-28 01:33:40 -07:00
|
|
|
if (resp->node != NULL) {
|
Decouple database and node lifetimes by adding node-specific vtables
All databases in the codebase follow the same structure: a database is
an associative container from DNS names to nodes, and each node is an
associative container from RR types to RR data.
Each database implementation (qpzone, qpcache, sdlz, builtin, dyndb) has
its own corresponding node type (qpznode, qpcnode, etc). However, some
code needs to work with nodes generically regardless of their specific
type - for example, to acquire locks, manage references, or
register/unregister slabs from the heap.
Currently, these generic node operations are implemented as methods in
the database vtable, which creates problematic coupling between database
and node lifetimes. If a node outlives its parent database, the node
destructor will destroy all RR data, and each RR data destructor will
try to unregister from heaps by calling a virtual function from the
database vtable. Since the database was already freed, this causes a
crash.
This commit breaks the coupling by standardizing the layout of all
database nodes, adding a dedicated vtable for node operations, and
moving node-specific methods from the database vtable to the node
vtable.
2025-06-05 11:51:29 +02:00
|
|
|
dns_db_detachnode(&resp->node);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2022-10-28 01:33:40 -07:00
|
|
|
if (resp->db != NULL) {
|
|
|
|
dns_db_detach(&resp->db);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2014-06-18 16:47:22 -07:00
|
|
|
|
2024-11-08 18:18:30 +01:00
|
|
|
dns_resolver_freefresp(&resp);
|
2014-06-18 16:47:22 -07:00
|
|
|
|
|
|
|
switch (eresult) {
|
|
|
|
case ISC_R_SUCCESS:
|
|
|
|
case DNS_R_NCACHENXDOMAIN:
|
|
|
|
case DNS_R_NXDOMAIN:
|
|
|
|
case DNS_R_NCACHENXRRSET:
|
|
|
|
case DNS_R_NXRRSET:
|
2022-07-26 13:03:40 +02:00
|
|
|
RWLOCK(&ntatable->rwlock, isc_rwlocktype_write);
|
2017-10-24 09:54:25 +11:00
|
|
|
if (nta->expiry > now) {
|
|
|
|
nta->expiry = now;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2022-07-26 13:03:40 +02:00
|
|
|
RWUNLOCK(&ntatable->rwlock, isc_rwlocktype_write);
|
2014-06-18 16:47:22 -07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we're expiring before the next recheck, we might
|
|
|
|
* as well stop the timer now.
|
|
|
|
*/
|
2022-07-26 13:03:40 +02:00
|
|
|
RWLOCK(&ntatable->rwlock, isc_rwlocktype_read);
|
2018-01-13 00:31:30 +05:30
|
|
|
if (nta->timer != NULL && nta->expiry - now < view->nta_recheck) {
|
2022-09-12 16:36:30 +02:00
|
|
|
isc_timer_stop(nta->timer);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2022-07-26 13:03:40 +02:00
|
|
|
RWUNLOCK(&ntatable->rwlock, isc_rwlocktype_read);
|
|
|
|
|
2022-09-12 16:36:30 +02:00
|
|
|
dns__nta_detach(&nta); /* for dns_resolver_createfetch() */
|
2014-06-18 16:47:22 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-07-26 13:03:40 +02:00
|
|
|
checkbogus(void *arg) {
|
2022-09-12 16:36:30 +02:00
|
|
|
dns__nta_t *nta = arg;
|
2014-06-18 16:47:22 -07:00
|
|
|
dns_ntatable_t *ntatable = nta->ntatable;
|
2022-10-03 15:54:12 +02:00
|
|
|
dns_resolver_t *resolver = NULL;
|
2014-07-10 10:24:47 +10:00
|
|
|
isc_result_t result;
|
2014-06-18 16:47:22 -07:00
|
|
|
|
|
|
|
if (nta->fetch != NULL) {
|
|
|
|
dns_resolver_cancelfetch(nta->fetch);
|
2014-10-18 10:07:24 +11:00
|
|
|
nta->fetch = NULL;
|
2014-06-18 16:47:22 -07:00
|
|
|
}
|
|
|
|
if (dns_rdataset_isassociated(&nta->rdataset)) {
|
|
|
|
dns_rdataset_disassociate(&nta->rdataset);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2014-06-18 16:47:22 -07:00
|
|
|
if (dns_rdataset_isassociated(&nta->sigrdataset)) {
|
|
|
|
dns_rdataset_disassociate(&nta->sigrdataset);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2014-06-18 16:47:22 -07:00
|
|
|
|
2022-10-03 15:54:12 +02:00
|
|
|
if (atomic_load(&ntatable->shuttingdown)) {
|
|
|
|
isc_timer_stop(nta->timer);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
result = dns_view_getresolver(ntatable->view, &resolver);
|
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-09-12 16:36:30 +02:00
|
|
|
dns__nta_ref(nta); /* for dns_resolver_createfetch */
|
2014-07-10 10:24:47 +10:00
|
|
|
result = dns_resolver_createfetch(
|
2024-03-13 13:42:57 -07:00
|
|
|
resolver, &nta->name, dns_rdatatype_nsec, NULL, NULL, NULL,
|
2024-11-11 11:01:50 +01:00
|
|
|
NULL, 0, DNS_FETCHOPT_NONTA, 0, NULL, NULL, nta->loop,
|
2025-01-29 11:11:32 +01:00
|
|
|
fetch_done, nta, NULL, &nta->rdataset, &nta->sigrdataset,
|
2024-11-11 11:01:50 +01:00
|
|
|
&nta->fetch);
|
2014-07-10 10:24:47 +10:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2022-09-12 16:36:30 +02:00
|
|
|
dns__nta_detach(&nta); /* for dns_resolver_createfetch() */
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2022-10-03 15:54:12 +02:00
|
|
|
dns_resolver_detach(&resolver);
|
2014-06-18 16:47:22 -07:00
|
|
|
}
|
|
|
|
|
2022-07-26 13:03:40 +02:00
|
|
|
static void
|
2022-09-12 16:36:30 +02:00
|
|
|
settimer(dns_ntatable_t *ntatable, dns__nta_t *nta, uint32_t lifetime) {
|
2022-07-26 13:03:40 +02:00
|
|
|
dns_view_t *view = NULL;
|
2022-09-12 16:36:30 +02:00
|
|
|
isc_interval_t interval;
|
2014-06-18 16:47:22 -07:00
|
|
|
|
|
|
|
REQUIRE(VALID_NTATABLE(ntatable));
|
|
|
|
REQUIRE(VALID_NTA(nta));
|
|
|
|
|
|
|
|
view = ntatable->view;
|
|
|
|
if (view->nta_recheck == 0 || lifetime <= view->nta_recheck) {
|
2022-07-26 13:03:40 +02:00
|
|
|
return;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2014-06-18 16:47:22 -07:00
|
|
|
|
2022-09-12 16:36:30 +02:00
|
|
|
isc_timer_create(nta->loop, checkbogus, nta, &nta->timer);
|
2014-06-18 16:47:22 -07:00
|
|
|
isc_interval_set(&interval, view->nta_recheck, 0);
|
2022-07-26 13:03:40 +02:00
|
|
|
isc_timer_start(nta->timer, isc_timertype_ticker, &interval);
|
2014-06-18 16:47:22 -07:00
|
|
|
}
|
|
|
|
|
2022-09-12 16:36:30 +02:00
|
|
|
static void
|
2016-12-30 15:45:08 +11:00
|
|
|
nta_create(dns_ntatable_t *ntatable, const dns_name_t *name,
|
2022-09-12 16:36:30 +02:00
|
|
|
dns__nta_t **target) {
|
|
|
|
dns__nta_t *nta = NULL;
|
2014-06-18 16:47:22 -07:00
|
|
|
|
|
|
|
REQUIRE(VALID_NTATABLE(ntatable));
|
|
|
|
REQUIRE(target != NULL && *target == NULL);
|
|
|
|
|
2022-10-03 15:54:12 +02:00
|
|
|
nta = isc_mem_get(ntatable->mctx, sizeof(dns__nta_t));
|
2022-09-12 16:36:30 +02:00
|
|
|
*nta = (dns__nta_t){
|
|
|
|
.ntatable = ntatable,
|
2024-03-13 13:42:57 -07:00
|
|
|
.name = DNS_NAME_INITEMPTY,
|
2022-09-12 16:36:30 +02:00
|
|
|
.magic = NTA_MAGIC,
|
|
|
|
};
|
2022-10-03 15:54:12 +02:00
|
|
|
isc_mem_attach(ntatable->mctx, &nta->mctx);
|
2024-03-26 00:13:45 -07:00
|
|
|
isc_loop_attach(isc_loop(), &nta->loop);
|
2014-06-18 16:47:22 -07:00
|
|
|
|
|
|
|
dns_rdataset_init(&nta->rdataset);
|
|
|
|
dns_rdataset_init(&nta->sigrdataset);
|
|
|
|
|
2022-09-12 16:36:30 +02:00
|
|
|
isc_refcount_init(&nta->references, 1);
|
2014-06-18 16:47:22 -07:00
|
|
|
|
2025-02-21 12:09:28 +01:00
|
|
|
dns_name_dup(name, nta->mctx, &nta->name);
|
2014-06-18 16:47:22 -07:00
|
|
|
|
|
|
|
*target = nta;
|
2014-05-29 22:22:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
isc_result_t
|
2016-12-30 15:45:08 +11:00
|
|
|
dns_ntatable_add(dns_ntatable_t *ntatable, const dns_name_t *name, bool force,
|
2019-09-15 16:36:16 -07:00
|
|
|
isc_stdtime_t now, uint32_t lifetime) {
|
2020-08-07 18:00:41 +10:00
|
|
|
isc_result_t result = ISC_R_SUCCESS;
|
2022-09-12 16:36:30 +02:00
|
|
|
dns__nta_t *nta = NULL;
|
2023-04-05 00:36:37 -07:00
|
|
|
dns_qp_t *qp = NULL;
|
|
|
|
void *pval = NULL;
|
2014-05-29 22:22:53 -07:00
|
|
|
|
|
|
|
REQUIRE(VALID_NTATABLE(ntatable));
|
|
|
|
|
2022-10-03 15:54:12 +02:00
|
|
|
if (atomic_load(&ntatable->shuttingdown)) {
|
|
|
|
return ISC_R_SUCCESS;
|
2020-08-07 18:00:41 +10:00
|
|
|
}
|
|
|
|
|
2022-10-03 15:54:12 +02:00
|
|
|
RWLOCK(&ntatable->rwlock, isc_rwlocktype_write);
|
2023-04-05 00:36:37 -07:00
|
|
|
dns_qpmulti_write(ntatable->table, &qp);
|
2022-09-12 16:36:30 +02:00
|
|
|
nta_create(ntatable, name, &nta);
|
2015-01-12 09:04:16 +05:30
|
|
|
nta->forced = force;
|
2014-05-29 22:22:53 -07:00
|
|
|
|
2023-04-05 00:36:37 -07:00
|
|
|
result = dns_qp_insert(qp, nta, 0);
|
2022-09-12 16:36:30 +02:00
|
|
|
switch (result) {
|
|
|
|
case ISC_R_EXISTS:
|
2025-07-07 11:29:45 +02:00
|
|
|
result = dns_qp_getname(qp, &nta->name, DNS_DBNAMESPACE_NORMAL,
|
|
|
|
&pval, NULL);
|
2023-04-05 00:36:37 -07:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
|
|
|
/*
|
|
|
|
* an NTA already existed: throw away the
|
|
|
|
* new one and update the old one.
|
|
|
|
*/
|
2022-09-12 16:36:30 +02:00
|
|
|
dns__nta_detach(&nta); /* for nta_create */
|
2023-04-05 00:36:37 -07:00
|
|
|
nta = pval;
|
2022-09-12 16:36:30 +02:00
|
|
|
break;
|
|
|
|
}
|
2023-04-05 00:36:37 -07:00
|
|
|
/* update the NTA's timer as if it were new */
|
2022-09-12 16:36:30 +02:00
|
|
|
FALLTHROUGH;
|
|
|
|
case ISC_R_SUCCESS:
|
2023-04-05 00:36:37 -07:00
|
|
|
nta->expiry = now + lifetime;
|
2014-06-18 16:47:22 -07:00
|
|
|
if (!force) {
|
2022-07-26 13:03:40 +02:00
|
|
|
settimer(ntatable, nta, lifetime);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2022-09-12 16:36:30 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2014-05-29 22:22:53 -07:00
|
|
|
}
|
|
|
|
|
2023-04-05 00:36:37 -07:00
|
|
|
dns_qp_compact(qp, DNS_QPGC_MAYBE);
|
|
|
|
dns_qpmulti_commit(ntatable->table, &qp);
|
2014-05-29 22:22:53 -07:00
|
|
|
RWUNLOCK(&ntatable->rwlock, isc_rwlocktype_write);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2023-04-05 00:36:37 -07:00
|
|
|
isc_result_t
|
|
|
|
dns_ntatable_delete(dns_ntatable_t *ntatable, const dns_name_t *name) {
|
2014-05-29 22:22:53 -07:00
|
|
|
isc_result_t result;
|
2023-04-05 00:36:37 -07:00
|
|
|
dns_qp_t *qp = NULL;
|
|
|
|
void *pval = NULL;
|
2014-05-29 22:22:53 -07:00
|
|
|
|
2023-04-05 00:36:37 -07:00
|
|
|
REQUIRE(VALID_NTATABLE(ntatable));
|
|
|
|
REQUIRE(name != NULL);
|
2014-05-29 22:22:53 -07:00
|
|
|
|
2023-04-05 00:36:37 -07:00
|
|
|
dns_qpmulti_write(ntatable->table, &qp);
|
2025-07-07 11:29:45 +02:00
|
|
|
result = dns_qp_deletename(qp, name, DNS_DBNAMESPACE_NORMAL, &pval,
|
|
|
|
NULL);
|
2023-04-05 00:36:37 -07:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
|
|
|
dns__nta_t *n = pval;
|
|
|
|
dns__nta_shutdown(n);
|
|
|
|
dns__nta_detach(&n);
|
2022-09-12 16:36:30 +02:00
|
|
|
}
|
2023-04-05 00:36:37 -07:00
|
|
|
dns_qp_compact(qp, DNS_QPGC_MAYBE);
|
|
|
|
dns_qpmulti_commit(ntatable->table, &qp);
|
|
|
|
|
|
|
|
return result;
|
2014-05-29 22:22:53 -07:00
|
|
|
}
|
|
|
|
|
2023-04-05 00:36:37 -07:00
|
|
|
static void
|
|
|
|
delete_expired(void *arg) {
|
|
|
|
dns__nta_t *nta = arg;
|
|
|
|
dns_ntatable_t *ntatable = nta->ntatable;
|
2014-05-29 22:22:53 -07:00
|
|
|
isc_result_t result;
|
2023-04-05 00:36:37 -07:00
|
|
|
dns_qp_t *qp = NULL;
|
|
|
|
void *pval = NULL;
|
2014-05-29 22:22:53 -07:00
|
|
|
|
2022-09-12 16:36:30 +02:00
|
|
|
REQUIRE(VALID_NTATABLE(ntatable));
|
|
|
|
|
2014-05-29 22:22:53 -07:00
|
|
|
RWLOCK(&ntatable->rwlock, isc_rwlocktype_write);
|
2023-04-05 00:36:37 -07:00
|
|
|
dns_qpmulti_write(ntatable->table, &qp);
|
2025-07-07 11:29:45 +02:00
|
|
|
result = dns_qp_getname(qp, &nta->name, DNS_DBNAMESPACE_NORMAL, &pval,
|
|
|
|
NULL);
|
2023-04-05 00:36:37 -07:00
|
|
|
if (result == ISC_R_SUCCESS &&
|
|
|
|
((dns__nta_t *)pval)->expiry == nta->expiry && !nta->shuttingdown)
|
|
|
|
{
|
|
|
|
char nb[DNS_NAME_FORMATSIZE];
|
2024-03-13 13:42:57 -07:00
|
|
|
dns_name_format(&nta->name, nb, sizeof(nb));
|
2024-08-13 18:20:26 +02:00
|
|
|
isc_log_write(DNS_LOGCATEGORY_DNSSEC, DNS_LOGMODULE_NTA,
|
|
|
|
ISC_LOG_INFO, "deleting expired NTA at %s", nb);
|
2025-07-07 11:29:45 +02:00
|
|
|
dns_qp_deletename(qp, &nta->name, DNS_DBNAMESPACE_NORMAL, NULL,
|
|
|
|
NULL);
|
2023-04-05 00:36:37 -07:00
|
|
|
dns__nta_shutdown(nta);
|
|
|
|
dns__nta_unref(nta);
|
|
|
|
}
|
|
|
|
dns_qp_compact(qp, DNS_QPGC_MAYBE);
|
|
|
|
dns_qpmulti_commit(ntatable->table, &qp);
|
2014-05-29 22:22:53 -07:00
|
|
|
RWUNLOCK(&ntatable->rwlock, isc_rwlocktype_write);
|
2023-04-05 00:36:37 -07:00
|
|
|
dns__nta_detach(&nta);
|
|
|
|
dns_ntatable_detach(&ntatable);
|
2014-05-29 22:22:53 -07:00
|
|
|
}
|
|
|
|
|
2018-04-17 08:29:14 -07:00
|
|
|
bool
|
2014-05-29 22:22:53 -07:00
|
|
|
dns_ntatable_covered(dns_ntatable_t *ntatable, isc_stdtime_t now,
|
2016-12-30 15:45:08 +11:00
|
|
|
const dns_name_t *name, const dns_name_t *anchor) {
|
2014-05-29 22:22:53 -07:00
|
|
|
isc_result_t result;
|
2022-09-12 16:36:30 +02:00
|
|
|
dns__nta_t *nta = NULL;
|
2018-04-17 08:29:14 -07:00
|
|
|
bool answer = false;
|
2023-04-05 00:36:37 -07:00
|
|
|
dns_qpread_t qpr;
|
|
|
|
void *pval = NULL;
|
2014-05-29 22:22:53 -07:00
|
|
|
|
2022-09-12 16:36:30 +02:00
|
|
|
REQUIRE(VALID_NTATABLE(ntatable));
|
2014-05-29 22:22:53 -07:00
|
|
|
REQUIRE(dns_name_isabsolute(name));
|
|
|
|
|
2023-04-05 00:36:37 -07:00
|
|
|
RWLOCK(&ntatable->rwlock, isc_rwlocktype_read);
|
|
|
|
dns_qpmulti_query(ntatable->table, &qpr);
|
2025-07-07 11:29:45 +02:00
|
|
|
result = dns_qp_lookup(&qpr, name, DNS_DBNAMESPACE_NORMAL, NULL, NULL,
|
|
|
|
NULL, &pval, NULL);
|
2023-04-05 00:36:37 -07:00
|
|
|
nta = pval;
|
2014-05-29 22:22:53 -07:00
|
|
|
|
2022-09-12 16:36:30 +02:00
|
|
|
switch (result) {
|
|
|
|
case ISC_R_SUCCESS:
|
2023-04-05 00:36:37 -07:00
|
|
|
/* Exact match */
|
2022-09-12 16:36:30 +02:00
|
|
|
break;
|
|
|
|
case DNS_R_PARTIALMATCH:
|
2023-04-05 00:36:37 -07:00
|
|
|
/*
|
|
|
|
* Found a NTA that's an ancestor of 'name'; we
|
|
|
|
* now have to make sure 'anchor' isn't below it.
|
|
|
|
*/
|
2024-03-13 13:42:57 -07:00
|
|
|
if (!dns_name_issubdomain(&nta->name, anchor)) {
|
2023-04-05 00:36:37 -07:00
|
|
|
goto done;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2023-04-05 00:36:37 -07:00
|
|
|
/* Ancestor match */
|
2022-09-12 16:36:30 +02:00
|
|
|
break;
|
|
|
|
default:
|
2023-04-05 00:36:37 -07:00
|
|
|
/* Found nothing */
|
|
|
|
goto done;
|
2014-05-29 22:22:53 -07:00
|
|
|
}
|
|
|
|
|
2023-04-05 00:36:37 -07:00
|
|
|
if (nta->expiry <= now) {
|
|
|
|
/* NTA is expired */
|
|
|
|
dns__nta_ref(nta);
|
|
|
|
dns_ntatable_ref(nta->ntatable);
|
2024-03-26 02:13:53 -07:00
|
|
|
isc_async_current(delete_expired, nta);
|
2023-04-05 00:36:37 -07:00
|
|
|
goto done;
|
2022-09-12 16:36:30 +02:00
|
|
|
}
|
2014-05-29 22:22:53 -07:00
|
|
|
|
2023-04-05 00:36:37 -07:00
|
|
|
answer = true;
|
|
|
|
done:
|
|
|
|
RWUNLOCK(&ntatable->rwlock, isc_rwlocktype_read);
|
|
|
|
dns_qpread_destroy(ntatable->table, &qpr);
|
2014-05-29 22:22:53 -07:00
|
|
|
return answer;
|
|
|
|
}
|
|
|
|
|
2015-02-05 17:18:15 -08:00
|
|
|
static isc_result_t
|
|
|
|
putstr(isc_buffer_t **b, const char *str) {
|
|
|
|
isc_result_t result;
|
|
|
|
|
2022-12-15 11:54:51 +01:00
|
|
|
result = isc_buffer_reserve(*b, strlen(str));
|
2015-02-05 17:18:15 -08:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
return result;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2015-02-06 23:45:21 +00:00
|
|
|
|
2015-02-05 17:18:15 -08:00
|
|
|
isc_buffer_putstr(*b, str);
|
|
|
|
return ISC_R_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2014-05-29 22:22:53 -07:00
|
|
|
isc_result_t
|
2016-12-06 14:32:47 +00:00
|
|
|
dns_ntatable_totext(dns_ntatable_t *ntatable, const char *view,
|
|
|
|
isc_buffer_t **buf) {
|
2023-04-05 00:36:37 -07:00
|
|
|
isc_result_t result = ISC_R_SUCCESS;
|
2023-03-30 21:13:41 +02:00
|
|
|
isc_stdtime_t now = isc_stdtime_now();
|
2023-04-05 00:36:37 -07:00
|
|
|
dns_qpread_t qpr;
|
|
|
|
dns_qpiter_t iter;
|
|
|
|
bool first = true;
|
|
|
|
void *pval = NULL;
|
2014-05-29 22:22:53 -07:00
|
|
|
|
|
|
|
REQUIRE(VALID_NTATABLE(ntatable));
|
|
|
|
|
|
|
|
RWLOCK(&ntatable->rwlock, isc_rwlocktype_read);
|
2023-04-05 00:36:37 -07:00
|
|
|
dns_qpmulti_query(ntatable->table, &qpr);
|
|
|
|
dns_qpiter_init(&qpr, &iter);
|
|
|
|
|
2023-09-19 00:41:57 -07:00
|
|
|
while (dns_qpiter_next(&iter, NULL, &pval, NULL) == ISC_R_SUCCESS) {
|
2023-04-05 00:36:37 -07:00
|
|
|
dns__nta_t *n = pval;
|
|
|
|
char nbuf[DNS_NAME_FORMATSIZE];
|
|
|
|
char tbuf[ISC_FORMATHTTPTIMESTAMP_SIZE];
|
|
|
|
char obuf[DNS_NAME_FORMATSIZE + ISC_FORMATHTTPTIMESTAMP_SIZE +
|
|
|
|
sizeof("expired: \n")];
|
|
|
|
isc_time_t t;
|
|
|
|
|
2024-03-13 13:42:57 -07:00
|
|
|
dns_name_format(&n->name, nbuf, sizeof(nbuf));
|
2023-04-05 00:36:37 -07:00
|
|
|
|
|
|
|
if (n->expiry != 0xffffffffU) {
|
|
|
|
/* Normal NTA entries */
|
|
|
|
isc_time_set(&t, n->expiry, 0);
|
|
|
|
isc_time_formattimestamp(&t, tbuf, sizeof(tbuf));
|
|
|
|
|
|
|
|
snprintf(obuf, sizeof(obuf), "%s%s%s%s: %s %s",
|
|
|
|
first ? "" : "\n", nbuf,
|
|
|
|
view != NULL ? "/" : "",
|
|
|
|
view != NULL ? view : "",
|
|
|
|
n->expiry <= now ? "expired" : "expiry", tbuf);
|
|
|
|
} else {
|
|
|
|
/* "validate-except" entries */
|
|
|
|
snprintf(obuf, sizeof(obuf), "%s%s%s%s: %s",
|
|
|
|
first ? "" : "\n", nbuf,
|
|
|
|
view != NULL ? "/" : "",
|
|
|
|
view != NULL ? view : "", "permanent");
|
2014-06-18 16:47:22 -07:00
|
|
|
}
|
2023-04-05 00:36:37 -07:00
|
|
|
|
|
|
|
first = false;
|
|
|
|
result = putstr(buf, obuf);
|
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
goto cleanup;
|
2014-06-18 16:47:22 -07:00
|
|
|
}
|
2014-05-29 22:22:53 -07:00
|
|
|
}
|
|
|
|
|
2014-06-18 16:47:22 -07:00
|
|
|
cleanup:
|
2023-04-05 00:36:37 -07:00
|
|
|
dns_qpread_destroy(ntatable->table, &qpr);
|
2014-06-18 16:47:22 -07:00
|
|
|
RWUNLOCK(&ntatable->rwlock, isc_rwlocktype_read);
|
|
|
|
return result;
|
2014-05-29 22:22:53 -07:00
|
|
|
}
|
2015-02-05 17:18:15 -08:00
|
|
|
|
2015-01-12 09:04:16 +05:30
|
|
|
isc_result_t
|
|
|
|
dns_ntatable_save(dns_ntatable_t *ntatable, FILE *fp) {
|
2023-04-05 00:36:37 -07:00
|
|
|
isc_result_t result = ISC_R_SUCCESS;
|
2023-03-30 21:13:41 +02:00
|
|
|
isc_stdtime_t now = isc_stdtime_now();
|
2023-04-05 00:36:37 -07:00
|
|
|
dns_qpread_t qpr;
|
|
|
|
dns_qpiter_t iter;
|
2018-04-17 08:29:14 -07:00
|
|
|
bool written = false;
|
2023-04-05 00:36:37 -07:00
|
|
|
void *pval = NULL;
|
2015-01-12 09:04:16 +05:30
|
|
|
|
|
|
|
REQUIRE(VALID_NTATABLE(ntatable));
|
|
|
|
|
|
|
|
RWLOCK(&ntatable->rwlock, isc_rwlocktype_read);
|
2023-04-05 00:36:37 -07:00
|
|
|
dns_qpmulti_query(ntatable->table, &qpr);
|
|
|
|
dns_qpiter_init(&qpr, &iter);
|
|
|
|
|
2023-09-19 00:41:57 -07:00
|
|
|
while (dns_qpiter_next(&iter, NULL, &pval, NULL) == ISC_R_SUCCESS) {
|
2023-04-05 00:36:37 -07:00
|
|
|
dns__nta_t *n = pval;
|
|
|
|
isc_buffer_t b;
|
|
|
|
char nbuf[DNS_NAME_FORMATSIZE + 1], tbuf[80];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Skip this node if the expiry is already in the
|
|
|
|
* past, or if this is a "validate-except" entry.
|
|
|
|
*/
|
|
|
|
if (n->expiry <= now || n->expiry == 0xffffffffU) {
|
|
|
|
continue;
|
|
|
|
}
|
2015-01-12 09:04:16 +05:30
|
|
|
|
2023-04-05 00:36:37 -07:00
|
|
|
isc_buffer_init(&b, nbuf, sizeof(nbuf));
|
2024-03-13 13:42:57 -07:00
|
|
|
result = dns_name_totext(&n->name, 0, &b);
|
2023-04-05 00:36:37 -07:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
continue;
|
|
|
|
}
|
2015-01-12 09:04:16 +05:30
|
|
|
|
2023-04-05 00:36:37 -07:00
|
|
|
/* Zero terminate */
|
|
|
|
isc_buffer_putuint8(&b, 0);
|
2015-01-12 09:04:16 +05:30
|
|
|
|
2023-04-05 00:36:37 -07:00
|
|
|
isc_buffer_init(&b, tbuf, sizeof(tbuf));
|
|
|
|
dns_time32_totext(n->expiry, &b);
|
2015-02-10 14:01:38 -08:00
|
|
|
|
2023-04-05 00:36:37 -07:00
|
|
|
/* Zero terminate */
|
|
|
|
isc_buffer_putuint8(&b, 0);
|
2018-04-30 16:10:17 -07:00
|
|
|
|
2023-04-05 00:36:37 -07:00
|
|
|
fprintf(fp, "%s %s %s\n", nbuf,
|
|
|
|
n->forced ? "forced" : "regular", tbuf);
|
|
|
|
written = true;
|
2015-01-12 09:04:16 +05:30
|
|
|
}
|
|
|
|
|
2023-04-05 00:36:37 -07:00
|
|
|
dns_qpread_destroy(ntatable->table, &qpr);
|
2015-01-12 09:04:16 +05:30
|
|
|
RWUNLOCK(&ntatable->rwlock, isc_rwlocktype_read);
|
|
|
|
|
2022-09-12 16:36:30 +02:00
|
|
|
if (result == ISC_R_SUCCESS && !written) {
|
|
|
|
result = ISC_R_NOTFOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2023-10-12 14:10:43 +00:00
|
|
|
dns__nta_shutdown_cb(void *arg) {
|
|
|
|
dns__nta_t *nta = arg;
|
|
|
|
|
2022-09-12 16:36:30 +02:00
|
|
|
REQUIRE(VALID_NTA(nta));
|
|
|
|
|
2024-08-13 18:20:26 +02:00
|
|
|
if (isc_log_wouldlog(ISC_LOG_DEBUG(3))) {
|
2023-04-05 00:36:37 -07:00
|
|
|
char nb[DNS_NAME_FORMATSIZE];
|
2024-03-13 13:42:57 -07:00
|
|
|
dns_name_format(&nta->name, nb, sizeof(nb));
|
2024-08-13 18:20:26 +02:00
|
|
|
isc_log_write(DNS_LOGCATEGORY_DNSSEC, DNS_LOGMODULE_NTA,
|
|
|
|
ISC_LOG_DEBUG(3), "shutting down NTA %p at %s",
|
|
|
|
nta, nb);
|
2023-04-05 00:36:37 -07:00
|
|
|
}
|
2022-09-12 16:36:30 +02:00
|
|
|
if (nta->timer) {
|
2022-09-30 10:52:14 +02:00
|
|
|
isc_timer_stop(nta->timer);
|
2022-09-12 16:36:30 +02:00
|
|
|
isc_timer_destroy(&nta->timer);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2022-09-12 16:36:30 +02:00
|
|
|
|
|
|
|
dns__nta_detach(&nta);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dns__nta_shutdown(dns__nta_t *nta) {
|
|
|
|
REQUIRE(VALID_NTA(nta));
|
|
|
|
|
|
|
|
dns__nta_ref(nta);
|
2023-10-12 14:10:43 +00:00
|
|
|
isc_async_run(nta->loop, dns__nta_shutdown_cb, nta);
|
2023-04-05 00:36:37 -07:00
|
|
|
nta->shuttingdown = true;
|
2015-01-12 09:04:16 +05:30
|
|
|
}
|
2020-08-07 18:00:41 +10:00
|
|
|
|
|
|
|
void
|
|
|
|
dns_ntatable_shutdown(dns_ntatable_t *ntatable) {
|
2023-04-05 00:36:37 -07:00
|
|
|
dns_qpread_t qpr;
|
|
|
|
dns_qpiter_t iter;
|
|
|
|
void *pval = NULL;
|
2020-08-07 18:00:41 +10:00
|
|
|
|
|
|
|
REQUIRE(VALID_NTATABLE(ntatable));
|
|
|
|
|
|
|
|
RWLOCK(&ntatable->rwlock, isc_rwlocktype_write);
|
2023-04-05 00:36:37 -07:00
|
|
|
dns_qpmulti_query(ntatable->table, &qpr);
|
2020-08-07 18:00:41 +10:00
|
|
|
ntatable->shuttingdown = true;
|
|
|
|
|
2023-04-05 00:36:37 -07:00
|
|
|
dns_qpiter_init(&qpr, &iter);
|
2023-09-19 00:41:57 -07:00
|
|
|
while (dns_qpiter_next(&iter, NULL, &pval, NULL) == ISC_R_SUCCESS) {
|
2023-04-05 00:36:37 -07:00
|
|
|
dns__nta_t *n = pval;
|
|
|
|
dns__nta_shutdown(n);
|
|
|
|
dns__nta_detach(&n);
|
2020-08-07 18:00:41 +10:00
|
|
|
}
|
|
|
|
|
2023-04-05 00:36:37 -07:00
|
|
|
dns_qpread_destroy(ntatable->table, &qpr);
|
2022-10-03 15:54:12 +02:00
|
|
|
dns_view_weakdetach(&ntatable->view);
|
2020-08-07 18:00:41 +10:00
|
|
|
RWUNLOCK(&ntatable->rwlock, isc_rwlocktype_write);
|
|
|
|
}
|
2023-04-05 00:36:37 -07:00
|
|
|
|
|
|
|
static void
|
|
|
|
qp_attach(void *uctx ISC_ATTR_UNUSED, void *pval,
|
|
|
|
uint32_t ival ISC_ATTR_UNUSED) {
|
|
|
|
dns__nta_t *nta = pval;
|
|
|
|
dns__nta_ref(nta);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
qp_detach(void *uctx ISC_ATTR_UNUSED, void *pval,
|
|
|
|
uint32_t ival ISC_ATTR_UNUSED) {
|
|
|
|
dns__nta_t *nta = pval;
|
|
|
|
dns__nta_detach(&nta);
|
|
|
|
}
|
|
|
|
|
|
|
|
static size_t
|
|
|
|
qp_makekey(dns_qpkey_t key, void *uctx ISC_ATTR_UNUSED, void *pval,
|
|
|
|
uint32_t ival ISC_ATTR_UNUSED) {
|
|
|
|
dns__nta_t *nta = pval;
|
2025-07-07 11:29:45 +02:00
|
|
|
return dns_qpkey_fromname(key, &nta->name, DNS_DBNAMESPACE_NORMAL);
|
2023-04-05 00:36:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
qp_triename(void *uctx, char *buf, size_t size) {
|
|
|
|
dns_view_t *view = uctx;
|
|
|
|
snprintf(buf, size, "view %s forwarder table", view->name);
|
|
|
|
}
|