wgengine/magicsock: fix discoEndpoint caching bug when a node key changes

Fixes #1391

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2021-02-23 14:26:29 -08:00
committed by Brad Fitzpatrick
parent f11952ad7f
commit e9e4f1063d
2 changed files with 73 additions and 1 deletions

View File

@@ -2276,8 +2276,12 @@ func (c *Conn) SetNetworkMap(nm *netmap.NetworkMap) {
continue
}
numDisco++
if ep, ok := c.endpointOfDisco[n.DiscoKey]; ok {
if ep, ok := c.endpointOfDisco[n.DiscoKey]; ok && ep.publicKey == n.Key {
ep.updateFromNode(n)
} else if ok {
c.logf("magicsock: disco key %v changed from node key %v to %v", n.DiscoKey, ep.publicKey.ShortString(), n.Key.ShortString())
ep.stopAndReset()
delete(c.endpointOfDisco, n.DiscoKey)
}
}