wgengine/magicsock: send out disco keys over TSMP periodically (#19212)
Instead of sending out disco keys via TSMP once, send them out in intervals of 60+ seconds. The trigger is still callmemaaybe and the keys will not be send if no direct connection needs to be established. This fixes a case where a node can have stale keys but have communicated with the other peer before, leading to an infinite DERP state. Updates #12639 Signed-off-by: Claus Lensbøl <claus@tailscale.com>
This commit is contained in:
@@ -1220,7 +1220,7 @@ func (c *Conn) RotateDiscoKey() {
|
||||
connCtx := c.connCtx
|
||||
for _, endpoint := range c.peerMap.byEpAddr {
|
||||
endpoint.ep.mu.Lock()
|
||||
endpoint.ep.sentDiscoKeyAdvertisement = false
|
||||
endpoint.ep.lastDiscoKeyAdvertisement = 0
|
||||
endpoint.ep.mu.Unlock()
|
||||
}
|
||||
c.mu.Unlock()
|
||||
@@ -4335,8 +4335,8 @@ func (c *Conn) maybeSendTSMPDiscoAdvert(de *endpoint) {
|
||||
|
||||
de.mu.Lock()
|
||||
defer de.mu.Unlock()
|
||||
if !de.sentDiscoKeyAdvertisement {
|
||||
de.sentDiscoKeyAdvertisement = true
|
||||
if mono.Now().Sub(de.lastDiscoKeyAdvertisement) > discoKeyAdvertisementInterval {
|
||||
de.lastDiscoKeyAdvertisement = mono.Now()
|
||||
c.tsmpDiscoKeyAvailablePub.Publish(NewDiscoKeyAvailable{
|
||||
NodeFirstAddr: de.nodeAddr,
|
||||
NodeID: de.nodeID,
|
||||
|
||||
Reference in New Issue
Block a user