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

x/net/nettest: SupportsIPv6 reports false even IPv6 is enabled #57386

Closed
cuonglm opened this issue Dec 17, 2022 · 12 comments
Closed

x/net/nettest: SupportsIPv6 reports false even IPv6 is enabled #57386

cuonglm opened this issue Dec 17, 2022 · 12 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@cuonglm
Copy link
Member

cuonglm commented Dec 17, 2022

SupportsIPv6 probe the stack by attempting to listen on [::1]:0 to detect if IPv6 was enabled. However, servers may disabled IPv6 on loopback interface (for policies, security reason ...), but still enable for the others.

For IPv6, maybe it's better to use [::]:0 instead.

A better approach is looking for any "UP" interface that we can route ipv4/ipv6 traffic.

@gopherbot gopherbot added this to the Unreleased milestone Dec 17, 2022
@gopherbot
Copy link

Change https://go.dev/cl/458096 mentions this issue: nettest: use [::] for probing ipv6 capability

@thanm thanm added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Dec 19, 2022
@wizardishungry
Copy link

Don't some operating systems (depending on security policy) throw a confirmation dialog when attempting to listen on any interface other than the loopback?

@cuonglm
Copy link
Member Author

cuonglm commented Dec 19, 2022

Don't some operating systems (depending on security policy) throw a confirmation dialog when attempting to listen on any interface other than the loopback?

I don't know about this, I can only tested it on some of my Linux boxes.

The linux-arm* builders also reveal this thing, they support IPv6 but was disabled for loopback (See https://go-review.googlesource.com/c/net/+/458096 for details).

@wizardishungry
Copy link

@bradfitz
Copy link
Contributor

Don't some operating systems (depending on security policy) throw a confirmation dialog when attempting to listen on any interface other than the loopback?

Yes, the loopback listen (for both IPv4 and IPv6) was explicitly done to avoid OS firewall dialog boxes during tests.

@cuonglm
Copy link
Member Author

cuonglm commented Dec 19, 2022

Don't some operating systems (depending on security policy) throw a confirmation dialog when attempting to listen on any interface other than the loopback?

Yes, the loopback listen (for both IPv4 and IPv6) was explicitly done to avoid OS firewall dialog boxes during tests.

Then I think test should just use the RoutedInterface to test if we can do ipv6 on loopback?

@bradfitz
Copy link
Contributor

I think the real problem is that SupportsIPv6 isn't defined well enough.

It says:

SupportsIPv6 reports whether the platform supports IPv6 networking functionality.

Does that mean?

  • has a global unicast IPv6 address that works?
  • can do IPv6 in theory, but might be disabled by a sysctl/OS knob? (so many people turn off their IPv6 for paranoia or while debugging something or from some misguided instructions they read somewhere and then forget they'd turned it off)
  • can do IPv6 but only on certain interfaces ("for security reasons" !?)
  • can do IPv6 on all interfaces

Seems like we'd want to figure out what this function is supposed to be reporting first.

@cuonglm
Copy link
Member Author

cuonglm commented Dec 20, 2022

I think the real problem is that SupportsIPv6 isn't defined well enough.

It says:

SupportsIPv6 reports whether the platform supports IPv6 networking functionality.

Does that mean?

  • has a global unicast IPv6 address that works?

  • can do IPv6 in theory, but might be disabled by a sysctl/OS knob? (so many people turn off their IPv6 for paranoia or while debugging something or from some misguided instructions they read somewhere and then forget they'd turned it off)

  • can do IPv6 but only on certain interfaces ("for security reasons" !?)

  • can do IPv6 on all interfaces

Seems like we'd want to figure out what this function is supposed to be reporting first.

Totally agree!

For me, I'm leaning to report that we can do IPv6 at least on one of all interfaces. That also help us implementing more easily using RoutedInterface.

@cuonglm
Copy link
Member Author

cuonglm commented Dec 20, 2022

For me, I'm leaning to report that we can do IPv6 at least on one of all interfaces. That also help us implementing more easily using RoutedInterface.

Something like this:

diff --git a/nettest/nettest.go b/nettest/nettest.go
index 8cb26a9..9ba5c99 100644
--- a/nettest/nettest.go
+++ b/nettest/nettest.go
@@ -38,10 +38,10 @@ func probeStack() {
                ln.Close()
                ipv4Enabled = true
        }
-       if ln, err := net.Listen("tcp6", "[::]:0"); err == nil {
-               ln.Close()
+       if _, err := RoutedInterface("ip6", net.FlagUp); err == nil {
                ipv6Enabled = true
        }
+
        rawSocketSess = supportsRawSocket()
        switch runtime.GOOS {
        case "aix":

@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Dec 23, 2022
@bcmills bcmills reopened this Jan 5, 2023
@gopherbot
Copy link

Change https://go.dev/cl/460715 mentions this issue: Revert "nettest: use RoutedInterface for probing network stack capability"

@bcmills
Copy link
Contributor

bcmills commented Jan 5, 2023

I've reopened this issue because I've mailed a revert for the fix CL (in https://go.dev/cl/460715) — it caused test failures for dragonfly and js/wasm (#57623).

We can either resolve the problem by implementing RoutedInterface on those platforms, or taking some alternate approach, or applying build constraints to use RoutedInterface only where supported.

@cuonglm
Copy link
Member Author

cuonglm commented Jan 5, 2023

I mailed https://go-review.googlesource.com/c/net/+/460735 for fixing the tests. The problem is not about RoutedInterface, but the code path that rely on old (wrong) behavior needs to be updated.

@cuonglm cuonglm closed this as completed Jan 5, 2023
@golang golang locked and limited conversation to collaborators Jan 5, 2024
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

No branches or pull requests

7 participants