-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: ipv4 chosen first when both ipv4 and ipv6 are available #54928
Comments
When connecting to an endpoint that resolves to ipv4 and ipv6 addresses, ensure that ipv6 addresses are tried first, as per happy eyeballs RFC. Currently whether ipv4 or ipv6 addresses are tried first depends on the dns resolution speed. If the A resolution returned first, it would be first in the address list, and partition() uses the label of the first result to build the primaries category. Fixes golang#54928
Change https://go.dev/cl/429075 mentions this issue: |
CC @neild |
You are correct that the behaviour is different to the first Happy Eyeballs RFC (RFC 6555), but it does match Happy Eyeballs v2 (RFC 8305) which removes the preference for IPv6. The important thing is to try both address families in parallel. If the winner happens to be IPv4, then so be it. Maybe the |
Ah, interesting. Didn't realize there were two versions. In that case, it seems compliant. It is unfortunate however that we can't seem to influence the sorting order of these addresses/families. DNS resolution time does not always correlate to the best addresses to try first. Should I just update the documentation? |
This is incorrect. RFC 8305 section 3 says:
Go currently implements Happy Eyeballs v1, not v2.
This is probably only true for the Go resolver. Not sure how it's like on macOS, but on Linux and macOS, without explicitly disabling CGO, Happy Eyeballs works as expected, because the system's name resolution API takes care of sorting the addresses for you. Both To make Happy Eyeballs work with the Go resolver, the resolver would need a new API to stream results back to the caller. |
It seems that in some environments Debian Linux host:
debian image running in docker container in the linux host above:
MacOS host:
Debian linux container running on Docker in MacOS host:
At least in container environments ipv4 addresses seem to be returned first? |
Did you run your container with |
It seems you are indeed correct, using the host network ipv6 addresses are returned first. Do you know, by any chance, how to configure The configured precedences already prioritize ipv6... Thanks. |
Closing since Go seems to be working as expected after all. |
For me, that is not working as expection, still handle ipv4 first. go version go1.20.4 linux/amd64 |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Connect to a host that resolves both to ipv4 and ipv6 addresses.
What did you expect to see?
According to https://github.com/golang/go/blob/master/src/net/dial.go#L71, with the default
FallbackDelay
of 300ms, ipv6 should be tried first and only after the configured delay ipv4 should be attempted.What did you see instead?
ipv4 was chosen first.
The partition function uses the label of the first result, which is the DNS result that resolved first (A vs AAAA). If the A response was received first, then the primary address(es) will be ipv4, which contradicts the purpose of the Happy Eyeballs RFC.
The text was updated successfully, but these errors were encountered: