From c52905abaa57dcc81d4709bb5d3ca8142b225aba Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Thu, 2 Jul 2020 11:37:19 -0700 Subject: [PATCH] wgengine/magicsock: log less on no-op disco route switches Also, renew trustBestAddrUntil even if latency isn't better. --- wgengine/magicsock/magicsock.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/wgengine/magicsock/magicsock.go b/wgengine/magicsock/magicsock.go index eda42da68..707f35613 100644 --- a/wgengine/magicsock/magicsock.go +++ b/wgengine/magicsock/magicsock.go @@ -2880,11 +2880,15 @@ func (de *discoEndpoint) handlePongConnLocked(m *disco.Pong, src netaddr.IPPort) // Promote this pong response to our current best address if it's lower latency. // TODO(bradfitz): decide how latency vs. preference order affects decision if de.bestAddr.IsZero() || delay < de.bestAddrLatency { - de.bestAddr = sp.to + if de.bestAddr != sp.to { + de.c.logf("magicsock: disco: node %v %v now using %v", de.publicKey.ShortString(), de.discoKey.ShortString(), sp.to) + de.bestAddr = sp.to + } + } + if src == de.bestAddr { de.bestAddrLatency = delay de.bestAddrAt = now de.trustBestAddrUntil = now.Add(5 * time.Second) - de.c.logf("magicsock: disco: node %v %v now using %v", de.publicKey.ShortString(), de.discoKey.ShortString(), sp.to) } }