Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: Dial always query DNS for both A and AAAA even if network is tcp4 or tcp6 when pure Go resolver is used #45024

Closed
zhangboyang opened this issue Mar 15, 2021 · 4 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@zhangboyang
Copy link
Contributor

When pure Go resolver is used, net.Dial always send two DNS query (one for A record and another for AAAA), even if the network parameter set to one of tcp4, tcp6, udp4, udp6. This will add extra latencies when making IPv4-only or IPv6-only connections. In the worst case, for example, a pure IPv4 host with firewall filtered out all AAAA queries, a dial with tcp4 will have to wait 10 second until AAAA query timed out.

The same problem was also found in cgo resolver (#25947), and it was fixed in c659be4.

My pull request will fix this.

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/301709 mentions this issue: net: make go resolver aware of network parameter

@zhangboyang
Copy link
Contributor Author

Here is my test code: (build it with CGO_ENABLED=0 go build test46.go)

package main

import "net"

func main() {
	net.Dial("tcp4", "golang.org:80")
}

Dump from wireshark:

No.	Time	Source	Destination	Protocol	Length	Info
11	3.196111458	127.0.0.1	127.0.0.53	DNS	70	Standard query 0x668e AAAA golang.org
12	3.196261224	127.0.0.1	127.0.0.53	DNS	70	Standard query 0x5811 A golang.org

@cherrymui cherrymui changed the title net.Dial always query DNS for both A and AAAA even if network is tcp4 or tcp6 when pure Go resolver is used net: Dial always query DNS for both A and AAAA even if network is tcp4 or tcp6 when pure Go resolver is used Mar 15, 2021
@cherrymui cherrymui added this to the Backlog milestone Mar 15, 2021
@cherrymui cherrymui added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Mar 15, 2021
@cherrymui
Copy link
Member

cc @bradfitz

@networkimprov
Copy link

cc @ekalinin

@odeke-em odeke-em modified the milestones: Backlog, Go1.17 Mar 23, 2021
@odeke-em odeke-em added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. labels Mar 23, 2021
@golang golang locked and limited conversation to collaborators Mar 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants