-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: make Dial(listener.Addr().String()) always work, even if machine's IPv6 config is not ideal #18806
Comments
I vaguely remember some problem with a Go code when I was using a linux kernel with IPv6 disabled. |
@bradfitz I'm pretty sure that's how it worked originally. |
@rsc, I'll try older Go versions to see when/if it changed. |
That's precisely why you shouldn't remove We've been trying to stomp out this configuration across Google machines because it's a pain to work around. |
But in terms of a practical workaround, Go could probably interpret dialing
Replacing it with |
Paul, I didn't manually do anything to this machine. It started life as a default GCE VM and has remained untouched networking wise. |
Does |
Again, this was just a GCE instance I created for development about a year ago and occasionally turn off and turn back on. |
http://b/18777177 was fixed in April 2016, so your GCE image likely predates it. This was the relevant config change: andsens/bootstrap-vz@15c7d1c |
@pmarks-net, regardless, this bug is about whether Go guarantees my posted program at top is always valid. I don't want those guarantees to depend on your But for the record,
I only have that one line in:
But looks sane, and like something somebody might write. I see no reason Go shouldn't be consistent even on such a machine. |
CL https://golang.org/cl/42496 mentions this issue. |
Dialing the 0.0.0.0 address (as returned by net.Addr().String() for a net.Listen("tcp", ":1") address) is not yet guaranteed to work. It's currently OS-dependent. For some reason it works on Go 1.8+, but it hasn't yet been defined to work reliably. Fix the tests for now (since we need to support older Go releases), even if this might work in the future. Updates golang/go#18806 Change-Id: I2f0476b1d4f2673ab64ffedfa733f2d92fceb6ff Reviewed-on: https://go-review.googlesource.com/42496 Run-TryBot: Brad Fitzpatrick <[email protected]> Run-TryBot: Han-Wen Nienhuys <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Han-Wen Nienhuys <[email protected]>
@ianlancetaylor and I looked into this. What @pmarks-net said in #18806 (comment) looks doable. I'll send a change. |
CL https://golang.org/cl/45088 mentions this issue. |
It listens on all addresses, which users might not want. Updates #18806 (follow-up to feedback from CL 45088) Change-Id: I51de2d3fc3cd88a61eb3c63018c47aea920c0549 Reviewed-on: https://go-review.googlesource.com/45157 Run-TryBot: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Mikio Hara <[email protected]>
Dialing the 0.0.0.0 address (as returned by net.Addr().String() for a net.Listen("tcp", ":1") address) is not yet guaranteed to work. It's currently OS-dependent. For some reason it works on Go 1.8+, but it hasn't yet been defined to work reliably. Fix the tests for now (since we need to support older Go releases), even if this might work in the future. Updates golang/go#18806 Change-Id: I2f0476b1d4f2673ab64ffedfa733f2d92fceb6ff Reviewed-on: https://go-review.googlesource.com/42496 Run-TryBot: Brad Fitzpatrick <[email protected]> Run-TryBot: Han-Wen Nienhuys <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Han-Wen Nienhuys <[email protected]>
This change clarifies the documentation on Dial and its variants to avoid unnecessary confusion about how the arguments for the connection setup functions are used to make connections. Also replaces "name" or "hostname" with "host name" when the term implies the use of DNS. Updates #17613. Fixes #17614. Fixes #17738. Fixes #17956. Updates #18806. Change-Id: I6adb3f2ae04a3bf83b96016ed73d8e59926f3e8a Reviewed-on: https://go-review.googlesource.com/34875 Reviewed-by: Ian Lance Taylor <[email protected]>
…::]:n ResolveTCPAddr, ResolveUDPAddr, and ResolveIPAddr return at most one address. When given a name like "golang.org" to resolve that might have more than 1 address, the net package has historically preferred IPv4 addresses, with the assumption that many users don't yet have IPv6 connectivity and randomly selecting between an IPv4 address and an IPv6 address at runtime wouldn't be a good experience for IPv4-only users. In CL 45088 (78cf0e5) I modified the resolution of the unspecified/empty address to internally resolve to both IPv6 "::" and 0.0.0.0 to fix issue #18806. That code has 3 other callers I hadn't considered, though: the Resolve*Addr functions. Since they preferred IPv4, any Resolve*Addr of "[::]:port" or "::" (for ResolveIPAddr) would internally resolve both "::" and 0.0.0.0 and then prefer 0.0.0.0, even though the user was looking up an IPv6 literal. Add tests and fix it, not by undoing the fix to #18806 but by selecting the preference function for Resolve*Addr more explicitly: we still prefer IPv4, but if the address being looked up was an IPv6 literal, prefer IPv6. The tests are skipped on machines without IPv6. Fixes #20911 Change-Id: Ib7036cc43182ae4118cd1390c254e17c04a251a3 Reviewed-on: https://go-review.googlesource.com/47554 Run-TryBot: Brad Fitzpatrick <[email protected]> Reviewed-by: Russ Cox <[email protected]>
Fixes kubernetes#47304. Workarounds golang/go#18806 (fixed in Go 1.9+).
Fixes kubernetes#47304. Workarounds golang/go#18806 (fixed in Go 1.9+).
Fixes kubernetes#47304. Workarounds golang/go#18806 (fixed in Go 1.9+).
Fixes kubernetes#47304. Workarounds golang/go#18806 (fixed in Go 1.9+).
Change https://golang.org/cl/47554 mentions this issue: |
Fixes kubernetes/kubernetes#47304. Workarounds golang/go#18806 (fixed in Go 1.9+).
* Run test on machine without IPV6 on older go versions References golang/go#18806 * Added InternalTemp, LineFrequency and OutputVoltage
I just hit a problem in grpc-go (grpc/grpc-go#1058) where their tests were assuming they could write code like this:
The code looks reasonable, and often works (on both Go 1.7 and Go 1.8, on Linux and Darwin).
But not always.
lis.Addr().String()
returns[::]:NNNNN
, which looks like an IPv6 address literal for all zeros (like 0.0.0.0), regardless of whether the machine has IPv6.And if a machine doesn't have an IPv6 address on the loopback interface, then
net.Dial("tcp", "[::]:12345")
fails.But it passes otherwise.
The net.Dial documentation (https://beta.golang.org/pkg/net/#Dial) is kinda fuzzy on whether dialing the all zero address works. It does document and implement this behavior this, though:
Thus, the solution for gRPC's tests and anybody else is apparently adding something hacky like:
But that's kinda lame and tedious.
Maybe we should just treat a
net.Dial
of[::]
or0.0.0.0
the same as an empty string for the host part?/cc @mikioh @rsc @ianlancetaylor @MakMukhi
The text was updated successfully, but these errors were encountered: