From f49d218cfece682692ff76e96d3d2db796e26fe9 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 1 Oct 2024 20:03:32 -0700 Subject: [PATCH] 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 --- net/dnscache/dnscache.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/dnscache/dnscache.go b/net/dnscache/dnscache.go index 3d061e207..2cbea6c0f 100644 --- a/net/dnscache/dnscache.go +++ b/net/dnscache/dnscache.go @@ -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) }