]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Remove dns_lookup and unused functions in dns_byaddr
authorOndřej Surý <ondrej@isc.org>
Thu, 19 May 2022 11:07:30 +0000 (13:07 +0200)
committerOndřej Surý <ondrej@isc.org>
Wed, 25 May 2022 12:44:32 +0000 (14:44 +0200)
Clean up unused functions from the dns_byaddr API and completely remove
the dns_lookup API.

lib/dns/Makefile.am
lib/dns/byaddr.c
lib/dns/include/dns/byaddr.h
lib/dns/include/dns/lookup.h [deleted file]
lib/dns/include/dns/types.h
lib/dns/lookup.c [deleted file]

index bce920c99fb1734cb184d4dba856ebc1a4d7e2ef..cf49c33b3885bf5436659c80b8e18e11454bd767 100644 (file)
@@ -87,7 +87,6 @@ libdns_la_HEADERS =                   \
        include/dns/keytable.h          \
        include/dns/keyvalues.h         \
        include/dns/librpz.h            \
-       include/dns/lookup.h            \
        include/dns/log.h               \
        include/dns/master.h            \
        include/dns/masterdump.h        \
@@ -186,7 +185,6 @@ libdns_la_SOURCES =                 \
        keymgr.c                        \
        keytable.c                      \
        log.c                           \
-       lookup.c                        \
        master.c                        \
        masterdump.c                    \
        message.c                       \
index d9e998bda1ef23fdfde99e90fe304ebaf4c978d5..1b17b249346c2c9da0c5eddbcf4a8be4deb16828 100644 (file)
@@ -26,7 +26,6 @@
 #include <dns/byaddr.h>
 #include <dns/db.h>
 #include <dns/events.h>
-#include <dns/lookup.h>
 #include <dns/rdata.h>
 #include <dns/rdataset.h>
 #include <dns/rdatastruct.h>
@@ -88,194 +87,3 @@ dns_byaddr_createptrname(const isc_netaddr_t *address, unsigned int options,
        isc_buffer_add(&buffer, len);
        return (dns_name_fromtext(name, &buffer, dns_rootname, 0, NULL));
 }
-
-struct dns_byaddr {
-       /* Unlocked. */
-       unsigned int magic;
-       isc_mem_t *mctx;
-       isc_mutex_t lock;
-       dns_fixedname_t name;
-       /* Locked by lock. */
-       unsigned int options;
-       dns_lookup_t *lookup;
-       isc_task_t *task;
-       dns_byaddrevent_t *event;
-       bool canceled;
-};
-
-#define BYADDR_MAGIC   ISC_MAGIC('B', 'y', 'A', 'd')
-#define VALID_BYADDR(b) ISC_MAGIC_VALID(b, BYADDR_MAGIC)
-
-#define MAX_RESTARTS 16
-
-static isc_result_t
-copy_ptr_targets(dns_byaddr_t *byaddr, dns_rdataset_t *rdataset) {
-       isc_result_t result;
-       dns_name_t *name;
-       dns_rdata_t rdata = DNS_RDATA_INIT;
-
-       /*
-        * The caller must be holding the byaddr's lock.
-        */
-
-       result = dns_rdataset_first(rdataset);
-       while (result == ISC_R_SUCCESS) {
-               dns_rdata_ptr_t ptr;
-               dns_rdataset_current(rdataset, &rdata);
-               result = dns_rdata_tostruct(&rdata, &ptr, NULL);
-               if (result != ISC_R_SUCCESS) {
-                       return (result);
-               }
-               name = isc_mem_get(byaddr->mctx, sizeof(*name));
-               dns_name_init(name, NULL);
-               dns_name_dup(&ptr.ptr, byaddr->mctx, name);
-               dns_rdata_freestruct(&ptr);
-               ISC_LIST_APPEND(byaddr->event->names, name, link);
-               dns_rdata_reset(&rdata);
-               result = dns_rdataset_next(rdataset);
-       }
-       if (result == ISC_R_NOMORE) {
-               result = ISC_R_SUCCESS;
-       }
-
-       return (result);
-}
-
-static void
-lookup_done(isc_task_t *task, isc_event_t *event) {
-       dns_byaddr_t *byaddr = event->ev_arg;
-       dns_lookupevent_t *levent;
-       isc_result_t result;
-
-       REQUIRE(event->ev_type == DNS_EVENT_LOOKUPDONE);
-       REQUIRE(VALID_BYADDR(byaddr));
-       REQUIRE(byaddr->task == task);
-
-       UNUSED(task);
-
-       levent = (dns_lookupevent_t *)event;
-
-       if (levent->result == ISC_R_SUCCESS) {
-               result = copy_ptr_targets(byaddr, levent->rdataset);
-               byaddr->event->result = result;
-       } else {
-               byaddr->event->result = levent->result;
-       }
-       isc_event_free(&event);
-       isc_task_sendanddetach(&byaddr->task, (isc_event_t **)&byaddr->event);
-}
-
-static void
-bevent_destroy(isc_event_t *event) {
-       dns_byaddrevent_t *bevent;
-       dns_name_t *name, *next_name;
-       isc_mem_t *mctx;
-
-       REQUIRE(event->ev_type == DNS_EVENT_BYADDRDONE);
-       mctx = event->ev_destroy_arg;
-       bevent = (dns_byaddrevent_t *)event;
-
-       for (name = ISC_LIST_HEAD(bevent->names); name != NULL;
-            name = next_name) {
-               next_name = ISC_LIST_NEXT(name, link);
-               ISC_LIST_UNLINK(bevent->names, name, link);
-               dns_name_free(name, mctx);
-               isc_mem_put(mctx, name, sizeof(*name));
-       }
-       isc_mem_put(mctx, event, event->ev_size);
-}
-
-isc_result_t
-dns_byaddr_create(isc_mem_t *mctx, const isc_netaddr_t *address,
-                 dns_view_t *view, unsigned int options, isc_task_t *task,
-                 isc_taskaction_t action, void *arg, dns_byaddr_t **byaddrp) {
-       isc_result_t result;
-       dns_byaddr_t *byaddr;
-       isc_event_t *ievent;
-
-       byaddr = isc_mem_get(mctx, sizeof(*byaddr));
-       byaddr->mctx = NULL;
-       isc_mem_attach(mctx, &byaddr->mctx);
-       byaddr->options = options;
-
-       byaddr->event = isc_mem_get(mctx, sizeof(*byaddr->event));
-       ISC_EVENT_INIT(byaddr->event, sizeof(*byaddr->event), 0, NULL,
-                      DNS_EVENT_BYADDRDONE, action, arg, byaddr,
-                      bevent_destroy, mctx);
-       byaddr->event->result = ISC_R_FAILURE;
-       ISC_LIST_INIT(byaddr->event->names);
-
-       byaddr->task = NULL;
-       isc_task_attach(task, &byaddr->task);
-
-       isc_mutex_init(&byaddr->lock);
-
-       dns_fixedname_init(&byaddr->name);
-
-       result = dns_byaddr_createptrname(address, options,
-                                         dns_fixedname_name(&byaddr->name));
-       if (result != ISC_R_SUCCESS) {
-               goto cleanup_lock;
-       }
-
-       byaddr->lookup = NULL;
-       result = dns_lookup_create(mctx, dns_fixedname_name(&byaddr->name),
-                                  dns_rdatatype_ptr, view, 0, task,
-                                  lookup_done, byaddr, &byaddr->lookup);
-       if (result != ISC_R_SUCCESS) {
-               goto cleanup_lock;
-       }
-
-       byaddr->canceled = false;
-       byaddr->magic = BYADDR_MAGIC;
-
-       *byaddrp = byaddr;
-
-       return (ISC_R_SUCCESS);
-
-cleanup_lock:
-       isc_mutex_destroy(&byaddr->lock);
-
-       ievent = (isc_event_t *)byaddr->event;
-       isc_event_free(&ievent);
-       byaddr->event = NULL;
-
-       isc_task_detach(&byaddr->task);
-
-       isc_mem_putanddetach(&mctx, byaddr, sizeof(*byaddr));
-
-       return (result);
-}
-
-void
-dns_byaddr_cancel(dns_byaddr_t *byaddr) {
-       REQUIRE(VALID_BYADDR(byaddr));
-
-       LOCK(&byaddr->lock);
-
-       if (!byaddr->canceled) {
-               byaddr->canceled = true;
-               if (byaddr->lookup != NULL) {
-                       dns_lookup_cancel(byaddr->lookup);
-               }
-       }
-
-       UNLOCK(&byaddr->lock);
-}
-
-void
-dns_byaddr_destroy(dns_byaddr_t **byaddrp) {
-       dns_byaddr_t *byaddr;
-
-       REQUIRE(byaddrp != NULL);
-       byaddr = *byaddrp;
-       *byaddrp = NULL;
-       REQUIRE(VALID_BYADDR(byaddr));
-       REQUIRE(byaddr->event == NULL);
-       REQUIRE(byaddr->task == NULL);
-       dns_lookup_destroy(&byaddr->lookup);
-
-       isc_mutex_destroy(&byaddr->lock);
-       byaddr->magic = 0;
-       isc_mem_putanddetach(&byaddr->mctx, byaddr, sizeof(*byaddr));
-}
index b92213b6bd8e52541fc8a8ec72530baac3a1741a..20e0f53dd967604ef9161cfb0f7663f92fd3b9f3 100644 (file)
 
 ISC_LANG_BEGINDECLS
 
-/*%
- * A 'dns_byaddrevent_t' is returned when a byaddr completes.
- * The sender field will be set to the byaddr that completed.  If 'result'
- * is ISC_R_SUCCESS, then 'names' will contain a list of names associated
- * with the address.  The recipient of the event must not change the list
- * and must not refer to any of the name data after the event is freed.
- */
-typedef struct dns_byaddrevent {
-       ISC_EVENT_COMMON(struct dns_byaddrevent);
-       isc_result_t   result;
-       dns_namelist_t names;
-} dns_byaddrevent_t;
-
-isc_result_t
-dns_byaddr_create(isc_mem_t *mctx, const isc_netaddr_t *address,
-                 dns_view_t *view, unsigned int options, isc_task_t *task,
-                 isc_taskaction_t action, void *arg, dns_byaddr_t **byaddrp);
-/*%<
- * Find the domain name of 'address'.
- *
- * Notes:
- *
- *\li  There is a reverse lookup format for IPv6 addresses, 'nibble'
- *
- *\li  The 'nibble' format for that address is
- *
- * \code
- *   1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.e.f.ip6.arpa.
- * \endcode
- *
- * Requires:
- *
- *\li  'mctx' is a valid mctx.
- *
- *\li  'address' is a valid IPv4 or IPv6 address.
- *
- *\li  'view' is a valid view which has a resolver.
- *
- *\li  'task' is a valid task.
- *
- *\li  byaddrp != NULL && *byaddrp == NULL
- *
- * Returns:
- *
- *\li  #ISC_R_SUCCESS
- *\li  #ISC_R_NOMEMORY
- *
- *\li  Any resolver-related error (e.g. #ISC_R_SHUTTINGDOWN) may also be
- *     returned.
- */
-
-void
-dns_byaddr_cancel(dns_byaddr_t *byaddr);
-/*%<
- * Cancel 'byaddr'.
- *
- * Notes:
- *
- *\li  If 'byaddr' has not completed, post its #DNS_EVENT_BYADDRDONE
- *     event with a result code of #ISC_R_CANCELED.
- *
- * Requires:
- *
- *\li  'byaddr' is a valid byaddr.
- */
-
-void
-dns_byaddr_destroy(dns_byaddr_t **byaddrp);
-/*%<
- * Destroy 'byaddr'.
- *
- * Requires:
- *
- *\li  '*byaddrp' is a valid byaddr.
- *
- *\li  The caller has received the #DNS_EVENT_BYADDRDONE event (either because
- *     the byaddr completed or because dns_byaddr_cancel() was called).
- *
- * Ensures:
- *
- *\li  *byaddrp == NULL.
- */
-
 isc_result_t
 dns_byaddr_createptrname(const isc_netaddr_t *address, unsigned int options,
                         dns_name_t *name);
diff --git a/lib/dns/include/dns/lookup.h b/lib/dns/include/dns/lookup.h
deleted file mode 100644 (file)
index 777a7d7..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * SPDX-License-Identifier: MPL-2.0
- *
- * 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/.
- *
- * See the COPYRIGHT file distributed with this work for additional
- * information regarding copyright ownership.
- */
-
-#pragma once
-
-/*****
-***** Module Info
-*****/
-
-/*! \file dns/lookup.h
- * \brief
- * The lookup module performs simple DNS lookups.  It implements
- * the full resolver algorithm, both looking for local data and
- * resolving external names as necessary.
- *
- * MP:
- *\li  The module ensures appropriate synchronization of data structures it
- *     creates and manipulates.
- *
- * Reliability:
- *\li  No anticipated impact.
- *
- * Resources:
- *\li  TBS
- *
- * Security:
- *\li  No anticipated impact.
- *
- * Standards:
- *\li  RFCs:   1034, 1035, 2181, TBS
- *\li  Drafts: TBS
- */
-
-#include <isc/event.h>
-#include <isc/lang.h>
-
-#include <dns/types.h>
-
-ISC_LANG_BEGINDECLS
-
-/*%
- * A 'dns_lookupevent_t' is returned when a lookup completes.
- * The sender field will be set to the lookup that completed.  If 'result'
- * is ISC_R_SUCCESS, then 'names' will contain a list of names associated
- * with the address.  The recipient of the event must not change the list
- * and must not refer to any of the name data after the event is freed.
- */
-typedef struct dns_lookupevent {
-       ISC_EVENT_COMMON(struct dns_lookupevent);
-       isc_result_t    result;
-       dns_name_t         *name;
-       dns_rdataset_t *rdataset;
-       dns_rdataset_t *sigrdataset;
-       dns_db_t         *db;
-       dns_dbnode_t   *node;
-} dns_lookupevent_t;
-
-isc_result_t
-dns_lookup_create(isc_mem_t *mctx, const dns_name_t *name, dns_rdatatype_t type,
-                 dns_view_t *view, unsigned int options, isc_task_t *task,
-                 isc_taskaction_t action, void *arg, dns_lookup_t **lookupp);
-/*%<
- * Finds the rrsets matching 'name' and 'type'.
- *
- * Requires:
- *
- *\li  'mctx' is a valid mctx.
- *
- *\li  'name' is a valid name.
- *
- *\li  'view' is a valid view which has a resolver.
- *
- *\li  'task' is a valid task.
- *
- *\li  lookupp != NULL && *lookupp == NULL
- *
- * Returns:
- *
- *\li  ISC_R_SUCCESS
- *\li  ISC_R_NOMEMORY
- *
- *\li  Any resolver-related error (e.g. ISC_R_SHUTTINGDOWN) may also be
- *     returned.
- */
-
-void
-dns_lookup_cancel(dns_lookup_t *lookup);
-/*%<
- * Cancel 'lookup'.
- *
- * Notes:
- *
- *\li  If 'lookup' has not completed, post its LOOKUPDONE event with a
- *     result code of ISC_R_CANCELED.
- *
- * Requires:
- *
- *\li  'lookup' is a valid lookup.
- */
-
-void
-dns_lookup_destroy(dns_lookup_t **lookupp);
-/*%<
- * Destroy 'lookup'.
- *
- * Requires:
- *
- *\li  '*lookupp' is a valid lookup.
- *
- *\li  The caller has received the LOOKUPDONE event (either because the
- *     lookup completed or because dns_lookup_cancel() was called).
- *
- * Ensures:
- *
- *\li  *lookupp == NULL.
- */
-
-ISC_LANG_ENDDECLS
index 6465962bd4119454d9271674cbc2c1a6cd5994d0..eece8448d3780ae8c464bac992c7bbb668506cea 100644 (file)
@@ -108,7 +108,6 @@ typedef uint64_t               dns_masterstyle_flags_t;
 typedef struct dns_message        dns_message_t;
 typedef uint16_t                  dns_messageid_t;
 typedef isc_region_t              dns_label_t;
-typedef struct dns_lookup         dns_lookup_t;
 typedef struct dns_name                   dns_name_t;
 typedef ISC_LIST(dns_name_t) dns_namelist_t;
 typedef struct dns_nta           dns_nta_t;
diff --git a/lib/dns/lookup.c b/lib/dns/lookup.c
deleted file mode 100644 (file)
index 1cb7fed..0000000
+++ /dev/null
@@ -1,445 +0,0 @@
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * SPDX-License-Identifier: MPL-2.0
- *
- * 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/.
- *
- * See the COPYRIGHT file distributed with this work for additional
- * information regarding copyright ownership.
- */
-
-/*! \file */
-
-#include <stdbool.h>
-
-#include <isc/mem.h>
-#include <isc/netaddr.h>
-#include <isc/result.h>
-#include <isc/string.h>
-#include <isc/task.h>
-#include <isc/util.h>
-
-#include <dns/db.h>
-#include <dns/events.h>
-#include <dns/lookup.h>
-#include <dns/rdata.h>
-#include <dns/rdataset.h>
-#include <dns/rdatastruct.h>
-#include <dns/resolver.h>
-#include <dns/view.h>
-
-struct dns_lookup {
-       /* Unlocked. */
-       unsigned int magic;
-       isc_mem_t *mctx;
-       isc_mutex_t lock;
-       dns_rdatatype_t type;
-       dns_fixedname_t name;
-       /* Locked by lock. */
-       unsigned int options;
-       isc_task_t *task;
-       dns_view_t *view;
-       dns_lookupevent_t *event;
-       dns_fetch_t *fetch;
-       unsigned int restarts;
-       bool canceled;
-       dns_rdataset_t rdataset;
-       dns_rdataset_t sigrdataset;
-};
-
-#define LOOKUP_MAGIC   ISC_MAGIC('l', 'o', 'o', 'k')
-#define VALID_LOOKUP(l) ISC_MAGIC_VALID((l), LOOKUP_MAGIC)
-
-#define MAX_RESTARTS 16
-
-static void
-lookup_find(dns_lookup_t *lookup, dns_fetchevent_t *event);
-
-static void
-fetch_done(isc_task_t *task, isc_event_t *event) {
-       dns_lookup_t *lookup = event->ev_arg;
-       dns_fetchevent_t *fevent;
-
-       UNUSED(task);
-       REQUIRE(event->ev_type == DNS_EVENT_FETCHDONE);
-       REQUIRE(VALID_LOOKUP(lookup));
-       REQUIRE(lookup->task == task);
-       fevent = (dns_fetchevent_t *)event;
-       REQUIRE(fevent->fetch == lookup->fetch);
-
-       lookup_find(lookup, fevent);
-}
-
-static isc_result_t
-start_fetch(dns_lookup_t *lookup) {
-       isc_result_t result;
-
-       /*
-        * The caller must be holding the lookup's lock.
-        */
-
-       REQUIRE(lookup->fetch == NULL);
-
-       result = dns_resolver_createfetch(
-               lookup->view->resolver, dns_fixedname_name(&lookup->name),
-               lookup->type, NULL, NULL, NULL, NULL, 0, 0, 0, NULL,
-               lookup->task, fetch_done, lookup, &lookup->rdataset,
-               &lookup->sigrdataset, &lookup->fetch);
-
-       return (result);
-}
-
-static void
-build_event(dns_lookup_t *lookup) {
-       dns_name_t *name = NULL;
-       dns_rdataset_t *rdataset = NULL;
-       dns_rdataset_t *sigrdataset = NULL;
-
-       name = isc_mem_get(lookup->mctx, sizeof(dns_name_t));
-       dns_name_init(name, NULL);
-       dns_name_dup(dns_fixedname_name(&lookup->name), lookup->mctx, name);
-
-       if (dns_rdataset_isassociated(&lookup->rdataset)) {
-               rdataset = isc_mem_get(lookup->mctx, sizeof(dns_rdataset_t));
-               dns_rdataset_init(rdataset);
-               dns_rdataset_clone(&lookup->rdataset, rdataset);
-       }
-
-       if (dns_rdataset_isassociated(&lookup->sigrdataset)) {
-               sigrdataset = isc_mem_get(lookup->mctx, sizeof(dns_rdataset_t));
-               dns_rdataset_init(sigrdataset);
-               dns_rdataset_clone(&lookup->sigrdataset, sigrdataset);
-       }
-
-       lookup->event->name = name;
-       lookup->event->rdataset = rdataset;
-       lookup->event->sigrdataset = sigrdataset;
-}
-
-static isc_result_t
-view_find(dns_lookup_t *lookup, dns_name_t *foundname) {
-       isc_result_t result;
-       dns_name_t *name = dns_fixedname_name(&lookup->name);
-       dns_rdatatype_t type;
-
-       if (lookup->type == dns_rdatatype_rrsig) {
-               type = dns_rdatatype_any;
-       } else {
-               type = lookup->type;
-       }
-
-       result = dns_view_find(lookup->view, name, type, 0, 0, false, false,
-                              &lookup->event->db, &lookup->event->node,
-                              foundname, &lookup->rdataset,
-                              &lookup->sigrdataset);
-       return (result);
-}
-
-static void
-lookup_find(dns_lookup_t *lookup, dns_fetchevent_t *event) {
-       isc_result_t result = ISC_R_SUCCESS;
-       bool want_restart;
-       bool send_event;
-       dns_name_t *name = NULL, *fname = NULL, *prefix = NULL;
-       dns_fixedname_t foundname, fixed;
-       dns_rdata_t rdata = DNS_RDATA_INIT;
-       unsigned int nlabels;
-       int order;
-       dns_namereln_t namereln;
-       dns_rdata_cname_t cname;
-       dns_rdata_dname_t dname;
-
-       REQUIRE(VALID_LOOKUP(lookup));
-
-       LOCK(&lookup->lock);
-
-       name = dns_fixedname_name(&lookup->name);
-
-       do {
-               lookup->restarts++;
-               want_restart = false;
-               send_event = true;
-
-               if (event == NULL && !lookup->canceled) {
-                       fname = dns_fixedname_initname(&foundname);
-                       INSIST(!dns_rdataset_isassociated(&lookup->rdataset));
-                       INSIST(!dns_rdataset_isassociated(
-                               &lookup->sigrdataset));
-                       /*
-                        * If we have restarted then clear the old node.
-                        */
-                       if (lookup->event->node != NULL) {
-                               INSIST(lookup->event->db != NULL);
-                               dns_db_detachnode(lookup->event->db,
-                                                 &lookup->event->node);
-                       }
-                       if (lookup->event->db != NULL) {
-                               dns_db_detach(&lookup->event->db);
-                       }
-                       result = view_find(lookup, fname);
-                       if (result == ISC_R_NOTFOUND) {
-                               /*
-                                * We don't know anything about the name.
-                                * Launch a fetch.
-                                */
-                               if (lookup->event->node != NULL) {
-                                       INSIST(lookup->event->db != NULL);
-                                       dns_db_detachnode(lookup->event->db,
-                                                         &lookup->event->node);
-                               }
-                               if (lookup->event->db != NULL) {
-                                       dns_db_detach(&lookup->event->db);
-                               }
-                               result = start_fetch(lookup);
-                               if (result == ISC_R_SUCCESS) {
-                                       send_event = false;
-                               }
-                               goto done;
-                       }
-               } else if (event != NULL) {
-                       result = event->result;
-                       fname = event->foundname;
-                       dns_resolver_destroyfetch(&lookup->fetch);
-                       INSIST(event->rdataset == &lookup->rdataset);
-                       INSIST(event->sigrdataset == &lookup->sigrdataset);
-               }
-
-               /*
-                * If we've been canceled, forget about the result.
-                */
-               if (lookup->canceled) {
-                       result = ISC_R_CANCELED;
-               }
-
-               switch (result) {
-               case ISC_R_SUCCESS:
-                       build_event(lookup);
-                       if (event == NULL) {
-                               break;
-                       }
-                       if (event->db != NULL) {
-                               dns_db_attach(event->db, &lookup->event->db);
-                       }
-                       if (event->node != NULL) {
-                               dns_db_attachnode(lookup->event->db,
-                                                 event->node,
-                                                 &lookup->event->node);
-                       }
-                       break;
-               case DNS_R_CNAME:
-                       /*
-                        * Copy the CNAME's target into the lookup's
-                        * query name and start over.
-                        */
-                       result = dns_rdataset_first(&lookup->rdataset);
-                       if (result != ISC_R_SUCCESS) {
-                               break;
-                       }
-                       dns_rdataset_current(&lookup->rdataset, &rdata);
-                       result = dns_rdata_tostruct(&rdata, &cname, NULL);
-                       dns_rdata_reset(&rdata);
-                       if (result != ISC_R_SUCCESS) {
-                               break;
-                       }
-                       dns_name_copy(&cname.cname, name);
-                       dns_rdata_freestruct(&cname);
-                       want_restart = true;
-                       send_event = false;
-                       break;
-               case DNS_R_DNAME:
-                       namereln = dns_name_fullcompare(name, fname, &order,
-                                                       &nlabels);
-                       INSIST(namereln == dns_namereln_subdomain);
-                       /*
-                        * Get the target name of the DNAME.
-                        */
-                       result = dns_rdataset_first(&lookup->rdataset);
-                       if (result != ISC_R_SUCCESS) {
-                               break;
-                       }
-                       dns_rdataset_current(&lookup->rdataset, &rdata);
-                       result = dns_rdata_tostruct(&rdata, &dname, NULL);
-                       dns_rdata_reset(&rdata);
-                       if (result != ISC_R_SUCCESS) {
-                               break;
-                       }
-                       /*
-                        * Construct the new query name and start over.
-                        */
-                       prefix = dns_fixedname_initname(&fixed);
-                       dns_name_split(name, nlabels, prefix, NULL);
-                       result = dns_name_concatenate(prefix, &dname.dname,
-                                                     name, NULL);
-                       dns_rdata_freestruct(&dname);
-                       if (result == ISC_R_SUCCESS) {
-                               want_restart = true;
-                               send_event = false;
-                       }
-                       break;
-               default:
-                       send_event = true;
-               }
-
-               if (dns_rdataset_isassociated(&lookup->rdataset)) {
-                       dns_rdataset_disassociate(&lookup->rdataset);
-               }
-               if (dns_rdataset_isassociated(&lookup->sigrdataset)) {
-                       dns_rdataset_disassociate(&lookup->sigrdataset);
-               }
-
-       done:
-               if (event != NULL) {
-                       if (event->node != NULL) {
-                               dns_db_detachnode(event->db, &event->node);
-                       }
-                       if (event->db != NULL) {
-                               dns_db_detach(&event->db);
-                       }
-                       isc_event_free(ISC_EVENT_PTR(&event));
-               }
-
-               /*
-                * Limit the number of restarts.
-                */
-               if (want_restart && lookup->restarts == MAX_RESTARTS) {
-                       want_restart = false;
-                       result = ISC_R_QUOTA;
-                       send_event = true;
-               }
-       } while (want_restart);
-
-       if (send_event) {
-               lookup->event->result = result;
-               lookup->event->ev_sender = lookup;
-               isc_task_sendanddetach(&lookup->task,
-                                      (isc_event_t **)&lookup->event);
-               dns_view_detach(&lookup->view);
-       }
-
-       UNLOCK(&lookup->lock);
-}
-
-static void
-levent_destroy(isc_event_t *event) {
-       dns_lookupevent_t *levent;
-       isc_mem_t *mctx;
-
-       REQUIRE(event->ev_type == DNS_EVENT_LOOKUPDONE);
-       mctx = event->ev_destroy_arg;
-       levent = (dns_lookupevent_t *)event;
-
-       if (levent->name != NULL) {
-               if (dns_name_dynamic(levent->name)) {
-                       dns_name_free(levent->name, mctx);
-               }
-               isc_mem_put(mctx, levent->name, sizeof(dns_name_t));
-       }
-       if (levent->rdataset != NULL) {
-               dns_rdataset_disassociate(levent->rdataset);
-               isc_mem_put(mctx, levent->rdataset, sizeof(dns_rdataset_t));
-       }
-       if (levent->sigrdataset != NULL) {
-               dns_rdataset_disassociate(levent->sigrdataset);
-               isc_mem_put(mctx, levent->sigrdataset, sizeof(dns_rdataset_t));
-       }
-       if (levent->node != NULL) {
-               dns_db_detachnode(levent->db, &levent->node);
-       }
-       if (levent->db != NULL) {
-               dns_db_detach(&levent->db);
-       }
-       isc_mem_put(mctx, event, event->ev_size);
-}
-
-isc_result_t
-dns_lookup_create(isc_mem_t *mctx, const dns_name_t *name, dns_rdatatype_t type,
-                 dns_view_t *view, unsigned int options, isc_task_t *task,
-                 isc_taskaction_t action, void *arg, dns_lookup_t **lookupp) {
-       dns_lookup_t *lookup;
-       isc_event_t *ievent;
-
-       lookup = isc_mem_get(mctx, sizeof(*lookup));
-       lookup->mctx = NULL;
-       isc_mem_attach(mctx, &lookup->mctx);
-       lookup->options = options;
-
-       ievent = isc_event_allocate(mctx, lookup, DNS_EVENT_LOOKUPDONE, action,
-                                   arg, sizeof(*lookup->event));
-       lookup->event = (dns_lookupevent_t *)ievent;
-       lookup->event->ev_destroy = levent_destroy;
-       lookup->event->ev_destroy_arg = mctx;
-       lookup->event->result = ISC_R_FAILURE;
-       lookup->event->name = NULL;
-       lookup->event->rdataset = NULL;
-       lookup->event->sigrdataset = NULL;
-       lookup->event->db = NULL;
-       lookup->event->node = NULL;
-
-       lookup->task = NULL;
-       isc_task_attach(task, &lookup->task);
-
-       isc_mutex_init(&lookup->lock);
-
-       dns_fixedname_init(&lookup->name);
-
-       dns_name_copy(name, dns_fixedname_name(&lookup->name));
-
-       lookup->type = type;
-       lookup->view = NULL;
-       dns_view_attach(view, &lookup->view);
-       lookup->fetch = NULL;
-       lookup->restarts = 0;
-       lookup->canceled = false;
-       dns_rdataset_init(&lookup->rdataset);
-       dns_rdataset_init(&lookup->sigrdataset);
-       lookup->magic = LOOKUP_MAGIC;
-
-       *lookupp = lookup;
-
-       lookup_find(lookup, NULL);
-
-       return (ISC_R_SUCCESS);
-}
-
-void
-dns_lookup_cancel(dns_lookup_t *lookup) {
-       REQUIRE(VALID_LOOKUP(lookup));
-
-       LOCK(&lookup->lock);
-
-       if (!lookup->canceled) {
-               lookup->canceled = true;
-               if (lookup->fetch != NULL) {
-                       INSIST(lookup->view != NULL);
-                       dns_resolver_cancelfetch(lookup->fetch);
-               }
-       }
-
-       UNLOCK(&lookup->lock);
-}
-
-void
-dns_lookup_destroy(dns_lookup_t **lookupp) {
-       dns_lookup_t *lookup;
-
-       REQUIRE(lookupp != NULL);
-       lookup = *lookupp;
-       *lookupp = NULL;
-       REQUIRE(VALID_LOOKUP(lookup));
-       REQUIRE(lookup->event == NULL);
-       REQUIRE(lookup->task == NULL);
-       REQUIRE(lookup->view == NULL);
-       if (dns_rdataset_isassociated(&lookup->rdataset)) {
-               dns_rdataset_disassociate(&lookup->rdataset);
-       }
-       if (dns_rdataset_isassociated(&lookup->sigrdataset)) {
-               dns_rdataset_disassociate(&lookup->sigrdataset);
-       }
-
-       isc_mutex_destroy(&lookup->lock);
-       lookup->magic = 0;
-       isc_mem_putanddetach(&lookup->mctx, lookup, sizeof(*lookup));
-}