]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
refactor to remove dead code in query_respond_any()
authorEvan Hunt <each@isc.org>
Wed, 19 Sep 2018 19:19:58 +0000 (12:19 -0700)
committerEvan Hunt <each@isc.org>
Thu, 6 Dec 2018 18:29:12 +0000 (10:29 -0800)
lib/ns/include/ns/hooks.h
lib/ns/query.c

index 10c68d2a95fe0e275550cdb25d7ba62deb42610e..f86364ac60bfec3b2224f99a35e1b5677b19deb4 100644 (file)
@@ -179,7 +179,6 @@ typedef enum {
        NS_QUERY_GOT_ANSWER_BEGIN,
        NS_QUERY_RESPOND_ANY_BEGIN,
        NS_QUERY_RESPOND_ANY_FOUND,
-       NS_QUERY_RESPOND_ANY_NOT_FOUND,
        NS_QUERY_RESPOND_BEGIN,
        NS_QUERY_NOTFOUND_BEGIN,
        NS_QUERY_PREP_DELEGATION_BEGIN,
index fd41929ba5bce474faebc2f7a63a6d7498665a2a..3dcf23e7cc0e87dfae0c9f14384a289895260621 100644 (file)
@@ -6748,6 +6748,7 @@ query_respond_any(query_ctx_t *qctx) {
        dns_rdatasetiter_t *rdsiter = NULL;
        isc_result_t result;
        dns_rdatatype_t onetype = 0;    /* type to use for minimal-any */
+       isc_buffer_t b;
 
        CALL_HOOK(NS_QUERY_RESPOND_ANY_BEGIN, qctx);
 
@@ -6908,58 +6909,42 @@ query_respond_any(query_ctx_t *qctx) {
                        dns_message_puttempname(qctx->client->message,
                                                &qctx->fname);
                }
-       } else {
-               CALL_HOOK(NS_QUERY_RESPOND_ANY_NOT_FOUND, qctx);
 
-               if (qctx->fname != NULL) {
-                       dns_message_puttempname(qctx->client->message,
-                                               &qctx->fname);
-               }
+               query_addauth(qctx);
+               return (ns_query_done(qctx));
+       }
 
-               /*
-                * No matching rdatasets found in cache. If we were
-                * searching for RRSIG/SIG, that's probably okay;
-                * otherwise this is an error condition.
-                */
-               if (qctx->qtype == dns_rdatatype_rrsig ||
-                    qctx->qtype == dns_rdatatype_sig)
-               {
-                       isc_buffer_t b;
-                       if (!qctx->is_zone) {
-                               qctx->authoritative = false;
-                               qctx->client->attributes &= ~NS_CLIENTATTR_RA;
-                               query_addauth(qctx);
-                               return (ns_query_done(qctx));
-                       }
+       /*
+        * If we're here, no matching rdatasets were found in
+        * cache. If we were searching for RRSIG/SIG, that
+        * may be okay, but otherwise something's gone wrong.
+        */
+       INSIST(qctx->qtype == dns_rdatatype_rrsig ||
+              qctx->qtype == dns_rdatatype_sig);
 
-                       if (qctx->qtype == dns_rdatatype_rrsig &&
-                           dns_db_issecure(qctx->db)) {
-                               char namebuf[DNS_NAME_FORMATSIZE];
-                               dns_name_format(qctx->client->query.qname,
-                                               namebuf,
-                                               sizeof(namebuf));
-                               ns_client_log(qctx->client,
-                                             DNS_LOGCATEGORY_DNSSEC,
-                                             NS_LOGMODULE_QUERY,
-                                             ISC_LOG_WARNING,
-                                             "missing signature for %s",
-                                             namebuf);
-                       }
+       if (qctx->fname != NULL) {
+               dns_message_puttempname(qctx->client->message,
+                                       &qctx->fname);
+       }
 
-                       qctx->fname = ns_client_newname(qctx->client,
-                                                       qctx->dbuf, &b);
-                       return (query_sign_nodata(qctx));
-               } else {
-                       CCTRACE(ISC_LOG_ERROR,
-                              "query_respond_any: "
-                              "no matching rdatasets in cache");
-                       result = DNS_R_SERVFAIL;
-               }
+       if (!qctx->is_zone) {
+               qctx->authoritative = false;
+               qctx->client->attributes &= ~NS_CLIENTATTR_RA;
+               query_addauth(qctx);
+               return (ns_query_done(qctx));
        }
 
-       query_addauth(qctx);
+       if (qctx->qtype == dns_rdatatype_rrsig && dns_db_issecure(qctx->db)) {
+               char namebuf[DNS_NAME_FORMATSIZE];
+               dns_name_format(qctx->client->query.qname,
+                               namebuf, sizeof(namebuf));
+               ns_client_log(qctx->client, DNS_LOGCATEGORY_DNSSEC,
+                             NS_LOGMODULE_QUERY, ISC_LOG_WARNING,
+                             "missing signature for %s", namebuf);
+       }
 
-       return (ns_query_done(qctx));
+       qctx->fname = ns_client_newname(qctx->client, qctx->dbuf, &b);
+       return (query_sign_nodata(qctx));
 
  cleanup:
        return (result);