Commit b5c9a8ca authored by Witold Krecicki's avatar Witold Krecicki Committed by Michał Kępień

Set result to SERVFAIL if upstream responded with FORMERR

Commit ba912435 causes the resolver to
respond to a client query with FORMERR when all upstream queries sent to
the servers authoritative for QNAME elicit FORMERR responses.  This
happens because resolver code returns DNS_R_FORMERR in such a case and
dns_result_torcode() acts as a pass-through for all arguments which are
already a valid RCODE.

The correct RCODE to set in the response returned to the client in the
case described above is SERVFAIL.  Make sure this happens by overriding
the RCODE in query_gotanswer(), on the grounds that any format errors in
the client query itself should be caught long before execution reaches
that point.  This change should not reduce query error logging accuracy
as the resolver code itself reports the exact reason for returning a
DNS_R_FORMERR result using log_formerr().
parent 9fd3c8a9
Pipeline #5553 passed with stages
in 7 minutes and 57 seconds
......@@ -74,6 +74,9 @@ sub handleUDP {
} elsif ($qname eq "") {
$packet->push("answer", new Net::DNS::RR($qname . " 300 A"));
return $packet->data;
} elsif ($qname =~ /\.formerr-to-all$/) {
return $packet->data;
# don't use Net::DNS to construct the header only reply as early
......@@ -24,3 +24,5 @@ NS A
no-questions. NS A
formerr-to-all. NS ns.formerr-to-all.
ns.formerr-to-all. A
......@@ -788,5 +788,13 @@ grep "" dig.ns5.out.${n} > /dev/null && ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
echo_i "checking SERVFAIL is returned when all authoritative servers return FORMERR ($n)"
$DIG $DIGOPTS @ ns.formerr-to-all. a > dig.ns5.out.${n} || ret=1
grep "status: SERVFAIL" dig.ns5.out.${n} > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
echo_i "exit status: $status"
[ $status -eq 0 ] || exit 1
......@@ -6737,6 +6737,10 @@ query_gotanswer(query_ctx_t *qctx, isc_result_t result) {
return (query_dname(qctx));
return (query_done(qctx));
* Something has gone wrong.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment