From d5522c3480dc128dc8a5c84a4d7aea9c8d12e0f9 Mon Sep 17 00:00:00 2001 From: George Thessalonikefs Date: Wed, 18 Oct 2023 11:59:41 +0200 Subject: [PATCH] Fixes for dns64 fallback to plain AAAA when no A records: - Cleanup if condition. - Rename variable for readability. --- dns64/dns64.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/dns64/dns64.c b/dns64/dns64.c index 10e7512a9..83fb02779 100644 --- a/dns64/dns64.c +++ b/dns64/dns64.c @@ -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; } -- 2.47.3