wgengine/magicsock: don't call setAddrToDiscoLocked on DERP ping

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/3129/head
Brad Fitzpatrick 3 years ago
parent 569f70abfd
commit f55c2bccf5

@ -1873,6 +1873,8 @@ func (c *Conn) handlePingLocked(dm *disco.Ping, src netaddr.IPPort, di *discoInf
di.lastPingFrom = src di.lastPingFrom = src
di.lastPingTime = time.Now() di.lastPingTime = time.Now()
isDerp := src.IP() == derpMagicIPAddr
// If we got a ping over DERP, then derpNodeSrc is non-zero and we reply // If we got a ping over DERP, then derpNodeSrc is non-zero and we reply
// over DERP (in which case ipDst is also a DERP address). // over DERP (in which case ipDst is also a DERP address).
// But if the ping was over UDP (ipDst is not a DERP address), then dstKey // But if the ping was over UDP (ipDst is not a DERP address), then dstKey
@ -1881,14 +1883,14 @@ func (c *Conn) handlePingLocked(dm *disco.Ping, src netaddr.IPPort, di *discoInf
dstKey := derpNodeSrc dstKey := derpNodeSrc
// Remember this route if not present. // Remember this route if not present.
c.setAddrToDiscoLocked(src, di.discoKey)
var numNodes int var numNodes int
if !derpNodeSrc.IsZero() { if isDerp {
if ep, ok := c.peerMap.endpointForNodeKey(derpNodeSrc); ok { if ep, ok := c.peerMap.endpointForNodeKey(derpNodeSrc); ok {
ep.addCandidateEndpoint(src) ep.addCandidateEndpoint(src)
numNodes = 1 numNodes = 1
} }
} else { } else {
c.setAddrToDiscoLocked(src, di.discoKey)
c.peerMap.forEachEndpointWithDiscoKey(di.discoKey, func(ep *endpoint) { c.peerMap.forEachEndpointWithDiscoKey(di.discoKey, func(ep *endpoint) {
ep.addCandidateEndpoint(src) ep.addCandidateEndpoint(src)
numNodes++ numNodes++

Loading…
Cancel
Save