Make prefetch code use the 'recursions' array

Replace:

  - client->prefetchhandle with HANDLE_RECTYPE_PREFETCH(client)
  - client->query.prefetch with FETCH_RECTYPE_PREFETCH(client)

This is preparatory work for separating prefetch code from RPZ code.
This commit is contained in:
Michał Kępień 2022-06-14 13:13:32 +02:00
parent 0fd787c8b8
commit 30ace0663d
4 changed files with 17 additions and 18 deletions

View file

@ -62,6 +62,7 @@
#include <ns/interfacemgr.h>
#include <ns/log.h>
#include <ns/notify.h>
#include <ns/query.h>
#include <ns/server.h>
#include <ns/stats.h>
#include <ns/update.h>
@ -269,7 +270,7 @@ ns_client_endrequest(ns_client_t *client) {
*/
if (client->recursionquota != NULL) {
isc_quota_detach(&client->recursionquota);
if (client->query.prefetch == NULL) {
if (FETCH_RECTYPE_PREFETCH(client) == NULL) {
ns_stats_decrement(client->manager->sctx->nsstats,
ns_statscounter_recursclients);
}

View file

@ -170,13 +170,12 @@ struct ns_client {
unsigned int attributes;
dns_view_t *view;
dns_dispatch_t *dispatch;
isc_nmhandle_t *handle; /* Permanent pointer to handle */
isc_nmhandle_t *sendhandle; /* Waiting for send callback */
isc_nmhandle_t *reqhandle; /* Waiting for request callback
(query, update, notify) */
isc_nmhandle_t *fetchhandle; /* Waiting for recursive fetch */
isc_nmhandle_t *prefetchhandle; /* Waiting for prefetch / rpzfetch */
isc_nmhandle_t *updatehandle; /* Waiting for update callback */
isc_nmhandle_t *handle; /* Permanent pointer to handle */
isc_nmhandle_t *sendhandle; /* Waiting for send callback */
isc_nmhandle_t *reqhandle; /* Waiting for request callback
(query, update, notify) */
isc_nmhandle_t *fetchhandle; /* Waiting for recursive fetch */
isc_nmhandle_t *updatehandle; /* Waiting for update callback */
unsigned char *tcpbuf;
dns_message_t *message;
unsigned char *sendbuf;

View file

@ -95,7 +95,6 @@ struct ns_query {
bool isreferral;
isc_mutex_t fetchlock;
dns_fetch_t *fetch;
dns_fetch_t *prefetch;
ns_hookasync_t *hookactx;
dns_rpz_st_t *rpz_st;
isc_bufferlist_t namebufs;

View file

@ -2525,9 +2525,9 @@ prefetch_done(isc_task_t *task, isc_event_t *event) {
CTRACE(ISC_LOG_DEBUG(3), "prefetch_done");
LOCK(&client->query.fetchlock);
if (client->query.prefetch != NULL) {
INSIST(devent->fetch == client->query.prefetch);
client->query.prefetch = NULL;
if (FETCH_RECTYPE_PREFETCH(client) != NULL) {
INSIST(devent->fetch == FETCH_RECTYPE_PREFETCH(client));
FETCH_RECTYPE_PREFETCH(client) = NULL;
}
UNLOCK(&client->query.fetchlock);
@ -2537,7 +2537,7 @@ prefetch_done(isc_task_t *task, isc_event_t *event) {
recursionquota_detach(client);
free_devent(client, &event, &devent);
isc_nmhandle_detach(&client->prefetchhandle);
isc_nmhandle_detach(&HANDLE_RECTYPE_PREFETCH(client));
}
/*
@ -2569,16 +2569,16 @@ fetch_and_forget(ns_client_t *client, dns_name_t *qname, dns_rdatatype_t qtype,
peeraddr = NULL;
}
isc_nmhandle_attach(client->handle, &client->prefetchhandle);
isc_nmhandle_attach(client->handle, &HANDLE_RECTYPE_PREFETCH(client));
options = client->query.fetchoptions | extra_fetch_options;
result = dns_resolver_createfetch(
client->view->resolver, qname, qtype, NULL, NULL, NULL,
peeraddr, client->message->id, options, 0, NULL,
client->manager->task, prefetch_done, client, tmprdataset, NULL,
&client->query.prefetch);
&FETCH_RECTYPE_PREFETCH(client));
if (result != ISC_R_SUCCESS) {
ns_client_putrdataset(client, &tmprdataset);
isc_nmhandle_detach(&client->prefetchhandle);
isc_nmhandle_detach(&HANDLE_RECTYPE_PREFETCH(client));
}
}
@ -2587,7 +2587,7 @@ query_prefetch(ns_client_t *client, dns_name_t *qname,
dns_rdataset_t *rdataset) {
CTRACE(ISC_LOG_DEBUG(3), "query_prefetch");
if (client->query.prefetch != NULL ||
if (FETCH_RECTYPE_PREFETCH(client) != NULL ||
client->view->prefetch_trigger == 0U ||
rdataset->ttl > client->view->prefetch_trigger ||
(rdataset->attributes & DNS_RDATASETATTR_PREFETCH) == 0)
@ -2762,7 +2762,7 @@ static void
query_rpzfetch(ns_client_t *client, dns_name_t *qname, dns_rdatatype_t type) {
CTRACE(ISC_LOG_DEBUG(3), "query_rpzfetch");
if (client->query.prefetch != NULL) {
if (FETCH_RECTYPE_PREFETCH(client) != NULL) {
return;
}