Do not set qctx->result to DNS_R_SERVFAIL unless necessary
In some cases, setting qctx->result to DNS_R_SERVFAIL causes the value of a 'result' variable containing a more specific failure reason to be effectively discarded. This may cause certain query error log messages to lack specificity despite a more accurate problem cause being determined during query processing. In other cases, qctx->result is set to DNS_R_SERVFAIL even though a more specific error (e.g. ISC_R_NOMEMORY) could be explicitly indicated. Since the response message's RCODE is derived from qctx->result using dns_result_torcode(), which handles a number of possible isc_result_t values and returns SERVFAIL for anything not explicitly listed, it is fine to set qctx->result to something more specific than DNS_R_SERVFAIL (in fact, this is already being done in a few cases). Modify most QUERY_ERROR() calls so that qctx->result is set to a more specific error code when possible. Adjust query_error() so that statistics are still calculated properly. Remove the RECURSE_ERROR() macro which was introduced exactly because qctx->result could be set to DNS_R_SERVFAIL instead of DNS_R_DUPLICATE or DNS_R_DROP, which need special handling. Modify dns_sdlz_putrr() so that it returns DNS_R_SERVFAIL when a DLZ driver returns invalid RDATA, in order to prevent setting RCODE to FORMERR (which is what dns_result_torcode() translates e.g. DNS_R_SYNTAX to) while responding authoritatively.
Showing with 28 additions and 35 deletions