net/dnscache: don't fall back to an IPv6 dial if we don't have IPv6

I noticed while debugging a test failure elsewhere that our failure
logs (when verbosity is cranked up) were uselessly attributing dial
failures to failure to dial an invalid IP address (this IPv6 address
we didn't have), rather than showing me the actual IPv4 connection
failure.

Updates #13597 (tangentially)

Change-Id: I45ffbefbc7e25ebfb15768006413a705b941dae5
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/13657/head
Brad Fitzpatrick 2 months ago committed by Brad Fitzpatrick
parent 30f0fa95d9
commit f49d218cfe

@ -416,10 +416,10 @@ func (d *dialer) DialContext(ctx context.Context, network, address string) (retC
if len(i4s) < 2 {
d.dnsCache.dlogf("dialing %s, %s for %s", network, ip, address)
c, err := dc.dialOne(ctx, ip.Unmap())
if err == nil || ctx.Err() != nil {
if err == nil || ctx.Err() != nil || !ip6.IsValid() {
return c, err
}
// Fall back to trying IPv6, if any.
// Fall back to trying IPv6.
return dc.dialOne(ctx, ip6)
}

Loading…
Cancel
Save