]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
Fixes for dns64 fallback to plain AAAA when no A records:
authorGeorge Thessalonikefs <yorgos@nlnetlabs.nl>
Wed, 18 Oct 2023 09:59:41 +0000 (11:59 +0200)
committerGeorge Thessalonikefs <yorgos@nlnetlabs.nl>
Wed, 18 Oct 2023 10:03:40 +0000 (12:03 +0200)
- Cleanup if condition.
- Rename variable for readability.

dns64/dns64.c

index 10e7512a9a72887f7d5dabc57eb2ffa709a0d13e..83fb027790e01c2dc1ec0e501cff76a917e1d721 100644 (file)
@@ -633,7 +633,7 @@ handle_event_moddone(struct module_qstate* qstate, int id)
         * synthesis. We skip queries with DNSSEC enabled (!CD) and
         * ones generated by us to retrive the A/PTR record to use for
         * synth. */
-       int want_synth =
+       int could_synth =
                qstate->qinfo.qtype == LDNS_RR_TYPE_AAAA &&
                (!iq || iq->state != DNS64_INTERNAL_QUERY) &&
                !(qstate->query_flags & BIT_CD);
@@ -643,7 +643,7 @@ handle_event_moddone(struct module_qstate* qstate, int id)
                reply_find_answer_rrset(&qstate->qinfo, qstate->return_msg->rep);
        int synth_qname = 0;
 
-       if(want_synth &&
+       if(could_synth &&
                (!has_data ||
                (synth_qname=dns64_always_synth_for_qname(qstate, id)))) {
                if(synth_qname)
@@ -975,20 +975,18 @@ dns64_inform_super(struct module_qstate* qstate, int id,
        }
        super_dq->state = DNS64_SUBQUERY_FINISHED;
 
-       /* If there is no successful answer, we're done. */
-       if (qstate->return_rcode != LDNS_RCODE_NOERROR
-           || !qstate->return_msg
-           || !qstate->return_msg->rep) {
+       /* If there is no successful answer, we're done.
+        * Guarantee that we have at least a NOERROR reply further on. */
+       if(qstate->return_rcode != LDNS_RCODE_NOERROR
+               || !qstate->return_msg
+               || !qstate->return_msg->rep) {
                return;
        }
 
        /* When no A record is found for synthesis fall back to AAAA again. */
-       if (qstate->qinfo.qtype == LDNS_RR_TYPE_A &&
-           qstate->return_rcode == LDNS_RCODE_NOERROR &&
-           !( qstate->return_msg &&
-              qstate->return_msg->rep &&
-              reply_find_answer_rrset(&qstate->qinfo, qstate->return_msg->rep)))
-       {
+       if(qstate->qinfo.qtype == LDNS_RR_TYPE_A &&
+               !reply_find_answer_rrset(&qstate->qinfo,
+                       qstate->return_msg->rep)) {
                super_dq->state = DNS64_INTERNAL_QUERY;
                return;
        }