When the host or dig programs see a malformed packet from a resolver when using UDP, they fall back to using TCP. The net package resolver does not do this; it simply ignores the malformed packet (in (*dnsPacketConn).dnsRoundTrip in net/dnsclient_unix.go). This was done for #13281. I suggest that we do the same.
This is showing up right now for me when I run go test -test.run=TestLookupLongTXT net. I see this:
--- FAIL: TestLookupLongTXT (10.00s)
lookup_test.go:334: lookup golang.rsc.io on 127.0.0.1:53: read udp 127.0.0.1:39779->127.0.0.1:53: i/o timeout
FAIL
FAIL net 10.023s
If I run dig -t txt golang.rsc.io the output starts with
;; Warning: Message parser reports malformed message packet.
;; Truncated, retrying in TCP mode.
I suggest that we keep the current behavior for the !resp.IsResponseTo(query) case but change the behavior for an Unpack failure to drop right back to TCP.
CC @mdempsky
When the
hostordigprograms see a malformed packet from a resolver when using UDP, they fall back to using TCP. The net package resolver does not do this; it simply ignores the malformed packet (in(*dnsPacketConn).dnsRoundTripin net/dnsclient_unix.go). This was done for #13281. I suggest that we do the same.This is showing up right now for me when I run
go test -test.run=TestLookupLongTXT net. I see this:If I run
dig -t txt golang.rsc.iothe output starts withI suggest that we keep the current behavior for the
!resp.IsResponseTo(query)case but change the behavior for anUnpackfailure to drop right back to TCP.CC @mdempsky