aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2022-02-15 13:40:49 -0800
committerDmitri Shuralyov <dmitshur@golang.org>2022-02-17 19:27:56 +0000
commit288ff40bf96f3860c85668c67fa01cdcdd91291f (patch)
treec6dec13aecb569785dedbbb6567015145df9331a
parent2b65cde5868d8245ef8a0b8eba1e361440252d3b (diff)
downloadgo-288ff40bf96f3860c85668c67fa01cdcdd91291f.tar.gz
go-288ff40bf96f3860c85668c67fa01cdcdd91291f.zip
[release-branch.go1.16] net: increase maximum accepted DNS packet to 1232 bytes
The existing value of 512 bytes as is specified by RFC 1035. However, the WSL resolver reportedly sends larger packets without setting the truncation bit, which breaks using the Go resolver. For 1.18 and backports, just increase the accepted packet size. This is what GNU glibc does (they use 65536 bytes). For 1.19 we plan to use EDNS to set the accepted packet size. That will give us more time to test whether that causes any problems. No test because I'm not sure how to write one and it wouldn't really be useful anyhow. For #6464 For #21160 For #44135 For #51127 For #51153 Fixes #51161 Change-Id: I0243f274a06e010ebb714e138a65386086aecf17 Reviewed-on: https://go-review.googlesource.com/c/go/+/386015 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> (cherry picked from commit 6e82ff83cfbef78aa60706c1a7167a31c30e7ef9) Reviewed-on: https://go-review.googlesource.com/c/go/+/386034 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
-rw-r--r--src/net/dnsclient_unix.go6
-rw-r--r--src/net/dnsclient_unix_test.go2
2 files changed, 6 insertions, 2 deletions
diff --git a/src/net/dnsclient_unix.go b/src/net/dnsclient_unix.go
index d7db0c8133..0aa9ad7b93 100644
--- a/src/net/dnsclient_unix.go
+++ b/src/net/dnsclient_unix.go
@@ -29,6 +29,10 @@ const (
// to be used as a useTCP parameter to exchange
useTCPOnly = true
useUDPOrTCP = false
+
+ // Maximum DNS packet size.
+ // Value taken from https://dnsflagday.net/2020/.
+ maxDNSPacketSize = 1232
)
var (
@@ -81,7 +85,7 @@ func dnsPacketRoundTrip(c Conn, id uint16, query dnsmessage.Question, b []byte)
return dnsmessage.Parser{}, dnsmessage.Header{}, err
}
- b = make([]byte, 512) // see RFC 1035
+ b = make([]byte, maxDNSPacketSize)
for {
n, err := c.Read(b)
if err != nil {
diff --git a/src/net/dnsclient_unix_test.go b/src/net/dnsclient_unix_test.go
index e7f7621a09..e8afbbe29e 100644
--- a/src/net/dnsclient_unix_test.go
+++ b/src/net/dnsclient_unix_test.go
@@ -881,7 +881,7 @@ func (f *fakeDNSPacketConn) Close() error {
func TestIgnoreDNSForgeries(t *testing.T) {
c, s := Pipe()
go func() {
- b := make([]byte, 512)
+ b := make([]byte, maxDNSPacketSize)
n, err := s.Read(b)
if err != nil {
t.Error(err)