summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@tailscale.com>2023-04-22 17:39:11 -0700
committerBrad Fitzpatrick <brad@danga.com>2023-04-22 17:53:39 -0700
commit90ba26cea1b4ddea7314cebafc27d033bda1d772 (patch)
treeb4128cf972abdeed0d1fd8229dc36331220f6f4a
parent7778d708a6a443dc03f8afc342f1b310b019b662 (diff)
downloadtailscale-90ba26cea1b4ddea7314cebafc27d033bda1d772.tar.xz
tailscale-90ba26cea1b4ddea7314cebafc27d033bda1d772.zip
net/netcheck: fix crash when IPv6 kinda but not really works
Looks like on some systems there's an IPv6 address, but then opening a IPv6 UDP socket fails later. Probably some firewall. Tolerate it better and don't crash. To repro: check the "udp6" to something like "udp7" (something that'll fail) and run "go run ./cmd/tailscale netcheck" on a machine with active IPv6. It used to crash and now it doesn't. Fixes #7949 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
-rw-r--r--net/netcheck/netcheck.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/net/netcheck/netcheck.go b/net/netcheck/netcheck.go
index a61343ebe..603fa3a41 100644
--- a/net/netcheck/netcheck.go
+++ b/net/netcheck/netcheck.go
@@ -40,6 +40,7 @@ import (
"tailscale.com/types/logger"
"tailscale.com/types/nettype"
"tailscale.com/types/opt"
+ "tailscale.com/types/ptr"
"tailscale.com/util/clientmetric"
"tailscale.com/util/mak"
)
@@ -943,6 +944,16 @@ func (c *Client) GetReport(ctx context.Context, dm *tailcfg.DERPMap) (_ *Report,
go c.readPackets(ctx, u6)
}
}
+
+ // If our interfaces.State suggested we have IPv6 support but then we
+ // failed to get an IPv6 sending socket (as in
+ // https://github.com/tailscale/tailscale/issues/7949), then change
+ // ifState.HaveV6 before we make a probe plan that involves sending IPv6
+ // packets and thus assuming rs.pc6 is non-nil.
+ if rs.pc6 == nil {
+ ifState = ptr.To(*ifState) // shallow clone
+ ifState.HaveV6 = false
+ }
}
plan := makeProbePlan(dm, ifState, last)