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:
Claus Lensbøl
2026-04-01 17:20:03 -04:00
committed by GitHub
parent 5b62f98894
commit c76113ac75
3 changed files with 53 additions and 4 deletions
+6 -1
View File
@@ -40,6 +40,11 @@ import (
var mtuProbePingSizesV4 []int
var mtuProbePingSizesV6 []int
// discoKeyAdvertisementInterval tells how often a disco update via TSMP can
// happen. The update is triggered via enqueueCallMeMaybe, and thus it will
// only be sent if the magicsock is in a state to send out CallMeMaybe.
const discoKeyAdvertisementInterval = time.Second * 60
func init() {
for _, m := range tstun.WireMTUsToProbe {
mtuProbePingSizesV4 = append(mtuProbePingSizesV4, pktLenToPingSize(m, false))
@@ -80,7 +85,7 @@ type endpoint struct {
lastSendAny mono.Time // last time there were outgoing packets sent this peer from any trigger, internal or external to magicsock
lastFullPing mono.Time // last time we pinged all disco or wireguard only endpoints
lastUDPRelayPathDiscovery mono.Time // last time we ran UDP relay path discovery
sentDiscoKeyAdvertisement bool // whether we sent a TSMPDiscoAdvertisement or not to this endpoint
lastDiscoKeyAdvertisement mono.Time // last time we sent a TSMPDiscoAdvertisement or not to this endpoint
derpAddr netip.AddrPort // fallback/bootstrap path, if non-zero (non-zero for well-behaved clients)
bestAddr addrQuality // best non-DERP path; zero if none; mutate via setBestAddrLocked()