From af277a6762e8a4e7963cae4a0e590a3201a86e0d Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Thu, 19 Mar 2020 20:45:49 -0700 Subject: [PATCH] controlclient, magicsock: add debug knob to request IPv6 endpoints Add opt-in method to request IPv6 endpoints from the control plane. For now they should just be skipped. A previous version of this CL was unconditional and reportedly had problems that I can't reproduce. So make it a knob until the mystery is solved. Signed-off-by: Brad Fitzpatrick --- control/controlclient/direct.go | 18 ++++++++++++------ wgengine/magicsock/magicsock.go | 4 ++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/control/controlclient/direct.go b/control/controlclient/direct.go index 8e2df94cf..f07c5c803 100644 --- a/control/controlclient/direct.go +++ b/control/controlclient/direct.go @@ -18,6 +18,7 @@ "net/http" "os" "runtime" + "strconv" "strings" "sync" "time" @@ -447,13 +448,18 @@ func (c *Direct) PollNetMap(ctx context.Context, maxPolls int, cb func(*NetworkM allowStream := maxPolls != 1 c.logf("PollNetMap: stream=%v :%v %v\n", maxPolls, localPort, ep) + // TODO(bradfitz): once this is verified to not be problematic, remove this + // knob and hard-code true below. + includeIPv6, _ := strconv.ParseBool(os.Getenv("DEBUG_INCLUDE_IPV6")) + request := tailcfg.MapRequest{ - Version: 4, - KeepAlive: c.keepAlive, - NodeKey: tailcfg.NodeKey(persist.PrivateNodeKey.Public()), - Endpoints: ep, - Stream: allowStream, - Hostinfo: hostinfo, + Version: 4, + IncludeIPv6: includeIPv6, + KeepAlive: c.keepAlive, + NodeKey: tailcfg.NodeKey(persist.PrivateNodeKey.Public()), + Endpoints: ep, + Stream: allowStream, + Hostinfo: hostinfo, } if c.newDecompressor != nil { request.Compress = "zstd" diff --git a/wgengine/magicsock/magicsock.go b/wgengine/magicsock/magicsock.go index 1d4f13f44..346091467 100644 --- a/wgengine/magicsock/magicsock.go +++ b/wgengine/magicsock/magicsock.go @@ -1456,6 +1456,10 @@ func (c *Conn) CreateEndpoint(key [32]byte, addrs string) (conn.Endpoint, error) } if ip4 := addr.IP.To4(); ip4 != nil { addr.IP = ip4 + } else { + // TODO(bradfitz): stop skipping IPv6 ones for now. + c.logf("magicsock: CreateEndpoint: ignoring IPv6 addr %v for now", addr) + continue } a.addrs = append(a.addrs, *addr) }