tailscale/net/dns/resolver
Nick Hill 17335d2104 net/dns/resolver: forward SERVFAIL responses over PeerDNS
As per the docstring, (*forwarder).forwardWithDestChan should either send to responseChan
and returns nil, or returns a non-nil error (without sending to the channel).
However, this does not hold when all upstream DNS servers replied with an error.

We've been handling this special error path in (*Resolver).Query but not in (*Resolver).HandlePeerDNSQuery.
As a result, SERVFAIL responses from upstream servers were being converted into HTTP 503 responses,
instead of being properly forwarded as SERVFAIL within a successful HTTP response, as per RFC 8484, section 4.2.1:
A successful HTTP response with a 2xx status code (see Section 6.3 of [RFC7231]) is used for any valid DNS response,
regardless of the DNS response code. For example, a successful 2xx HTTP status code is used even with a DNS message
whose DNS response code indicates failure, such as SERVFAIL or NXDOMAIN.

In this PR we fix (*forwarder).forwardWithDestChan to no longer return an error when it sends a response to responseChan,
and remove the special handling in (*Resolver).Query, as it is no longer necessary.

Updates #13571

Signed-off-by: Nick Hill <mykola.khyl@gmail.com>
2024-10-11 12:02:27 -05:00
..
debug.go all: use Go 1.22 range-over-int 2024-04-16 15:32:38 -07:00
doh_test.go net/dns/resolver: remove maxDoHInFlight 2023-02-03 17:07:12 -08:00
forwarder_test.go net/dns/resolver: fix dns-sd NXDOMAIN responses from quad-100 2024-09-18 18:43:03 -07:00
forwarder.go net/dns/resolver: forward SERVFAIL responses over PeerDNS 2024-10-11 12:02:27 -05:00
macios_ext.go all: avoid repeated default interface lookups 2023-04-20 15:46:01 -07:00
tsdns_server_test.go all: update copyright and license headers 2023-01-27 15:36:29 -08:00
tsdns_test.go net/dns, health: raise health warning for failing forwarded DNS queries (#12888) 2024-07-29 13:48:46 -04:00
tsdns.go net/dns/resolver: forward SERVFAIL responses over PeerDNS 2024-10-11 12:02:27 -05:00