2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 05:28:00 +00:00

Add new recursion type for refreshing stale RRset

Refreshing a stale RRset is similar to a prefetch query, so we can
refactor this code to use the new recursion types introduced in !5883.
This commit is contained in:
Matthijs Mekking 2022-09-28 15:13:11 +02:00
parent d4df60179a
commit 5fb8e555bc
2 changed files with 34 additions and 4 deletions

View File

@ -46,6 +46,7 @@ typedef enum {
RECTYPE_NORMAL,
RECTYPE_PREFETCH,
RECTYPE_RPZ,
RECTYPE_STALE_REFRESH,
RECTYPE_HOOK,
RECTYPE_COUNT,
} ns_query_rectype_t;
@ -60,6 +61,8 @@ typedef enum {
((client)->query.recursions[RECTYPE_PREFETCH].handle)
#define HANDLE_RECTYPE_RPZ(client) \
((client)->query.recursions[RECTYPE_RPZ].handle)
#define HANDLE_RECTYPE_STALE_REFRESH(client) \
((client)->query.recursions[RECTYPE_STALE_REFRESH].handle)
#define HANDLE_RECTYPE_HOOK(client) \
((client)->query.recursions[RECTYPE_HOOK].handle)
@ -73,6 +76,8 @@ typedef enum {
((client)->query.recursions[RECTYPE_PREFETCH].fetch)
#define FETCH_RECTYPE_RPZ(client) \
((client)->query.recursions[RECTYPE_RPZ].fetch)
#define FETCH_RECTYPE_STALE_REFRESH(client) \
((client)->query.recursions[RECTYPE_STALE_REFRESH].fetch)
#define FETCH_RECTYPE_HOOK(client) \
((client)->query.recursions[RECTYPE_HOOK].fetch)
@ -86,6 +91,8 @@ typedef enum {
((client)->query.recursions[RECTYPE_PREFETCH].quota)
#define QUOTA_RECTYPE_RPZ(client) \
((client)->query.recursions[RECTYPE_RPZ].quota)
#define QUOTA_RECTYPE_STALE_REFRESH(client) \
((client)->query.recursions[RECTYPE_STALE_REFRESH].quota)
#define QUOTA_RECTYPE_HOOK(client) \
((client)->query.recursions[RECTYPE_HOOK].quota)

View File

@ -2523,7 +2523,7 @@ recursionquotatype_detach(ns_client_t *client,
}
static void
cleanup_after_fetch(isc_task_t *task, isc_event_t *event,
cleanup_after_fetch(isc_task_t *task, isc_event_t *event, const char *ctracestr,
ns_query_rectype_t recursion_type) {
dns_fetchevent_t *devent = (dns_fetchevent_t *)event;
isc_nmhandle_t **handlep;
@ -2537,7 +2537,7 @@ cleanup_after_fetch(isc_task_t *task, isc_event_t *event,
REQUIRE(NS_CLIENT_VALID(client));
REQUIRE(task == client->manager->task);
CTRACE(ISC_LOG_DEBUG(3), "prefetch_done");
CTRACE(ISC_LOG_DEBUG(3), ctracestr);
handlep = &client->query.recursions[recursion_type].handle;
fetchp = &client->query.recursions[recursion_type].fetch;
@ -2557,12 +2557,17 @@ cleanup_after_fetch(isc_task_t *task, isc_event_t *event,
static void
prefetch_done(isc_task_t *task, isc_event_t *event) {
cleanup_after_fetch(task, event, RECTYPE_PREFETCH);
cleanup_after_fetch(task, event, "prefetch_done", RECTYPE_PREFETCH);
}
static void
rpzfetch_done(isc_task_t *task, isc_event_t *event) {
cleanup_after_fetch(task, event, RECTYPE_RPZ);
cleanup_after_fetch(task, event, "rpzfetch_done", RECTYPE_RPZ);
}
static void
refresh_done(isc_task_t *task, isc_event_t *event) {
cleanup_after_fetch(task, event, "refresh_done", RECTYPE_REFRESH);
}
/*
@ -2606,6 +2611,10 @@ fetch_and_forget(ns_client_t *client, dns_name_t *qname, dns_rdatatype_t qtype,
options = client->query.fetchoptions;
action = rpzfetch_done;
break;
case RECTYPE_REFRESH:
options = client->query.fetchoptions;
action = refresh_done;
break;
default:
UNREACHABLE();
}
@ -2646,6 +2655,20 @@ query_prefetch(ns_client_t *client, dns_name_t *qname,
ns_statscounter_prefetch);
}
/*
static void
query_refresh(ns_client_t *client, dns_name_t *qname,
dns_rdataset_t *rdataset) {
CTRACE(ISC_LOG_DEBUG(3), "query_refresh");
if (FETCH_RECTYPE_REFRESH(client) != NULL) {
return;
}
fetch_and_forget(client, qname, rdataset->type, RECTYPE_REFRESH);
}
*/
static void
rpz_clean(dns_zone_t **zonep, dns_db_t **dbp, dns_dbnode_t **nodep,
dns_rdataset_t **rdatasetp) {