Skip to content

Commit 6e82ff8

Browse files
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. Fixes #6464 Fixes #21160 Fixes #44135 Fixes #51127 For #51153 Change-Id: I0243f274a06e010ebb714e138a65386086aecf17 Reviewed-on: https://go-review.googlesource.com/c/go/+/386015 Trust: Ian Lance Taylor <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> Reviewed-by: Damien Neil <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent d3c9ef5 commit 6e82ff8

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/net/dnsclient_unix.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ const (
3030
// to be used as a useTCP parameter to exchange
3131
useTCPOnly = true
3232
useUDPOrTCP = false
33+
34+
// Maximum DNS packet size.
35+
// Value taken from https://dnsflagday.net/2020/.
36+
maxDNSPacketSize = 1232
3337
)
3438

3539
var (
@@ -82,7 +86,7 @@ func dnsPacketRoundTrip(c Conn, id uint16, query dnsmessage.Question, b []byte)
8286
return dnsmessage.Parser{}, dnsmessage.Header{}, err
8387
}
8488

85-
b = make([]byte, 512) // see RFC 1035
89+
b = make([]byte, maxDNSPacketSize)
8690
for {
8791
n, err := c.Read(b)
8892
if err != nil {

src/net/dnsclient_unix_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ func (f *fakeDNSPacketConn) Close() error {
881881
func TestIgnoreDNSForgeries(t *testing.T) {
882882
c, s := Pipe()
883883
go func() {
884-
b := make([]byte, 512)
884+
b := make([]byte, maxDNSPacketSize)
885885
n, err := s.Read(b)
886886
if err != nil {
887887
t.Error(err)

0 commit comments

Comments
 (0)