From 1abf2da392fd854865a08b1790d78402a4d3d716 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Thu, 27 Feb 2020 15:06:19 -0800 Subject: [PATCH] wgengine/magicsock: reset favorite address on handshakes Updates #92 (not a complete fix; could be better/faster?) Signed-off-by: Brad Fitzpatrick --- wgengine/magicsock/magicsock.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/wgengine/magicsock/magicsock.go b/wgengine/magicsock/magicsock.go index 9596b9371..268747ded 100644 --- a/wgengine/magicsock/magicsock.go +++ b/wgengine/magicsock/magicsock.go @@ -409,6 +409,11 @@ func appendDests(dsts []*net.UDPAddr, as *AddrSet, b []byte) (_ []*net.UDPAddr, if spray { as.lastSpray = now as.stopSpray = now.Add(sprayPeriod) + + // Reset our favorite route on new handshakes so we + // can downgrade to a worse path if our better path + // goes away. (https://github.com/tailscale/tailscale/issues/92) + as.curAddr = -1 } else if now.Before(as.stopSpray) { // We are in the spray window. If it has been sprayFreq since we // last sprayed a packet, spray this packet.