wgengine/magicsock,ipn/ipnlocal: store and load homeDERP from cache (#19491)

With netmap caching, the home DERP of the self node was neither saved to
the cache or loaded from it, making nodes not stick to a DERP when
starting without a connection to control.

Instead, make sure that when a cache is available, load that cache,
before looking for DERP servers. This is implemented by allowing a skip
of ReSTUN in setting the DERP map (we must have a DERP map before
setting the home DERP), so the DERP from cache will set itself and be
sticky until a connection to control is established.

Making DERP only change when connected to control is handled by existing
code from f072d017bd.

Updates #19490

Signed-off-by: Claus Lensbøl <claus@tailscale.com>
This commit is contained in:
Claus Lensbøl
2026-04-29 10:24:09 -04:00
committed by GitHub
parent 1841a93ab2
commit 78627c132f
9 changed files with 493 additions and 20 deletions
+7
View File
@@ -80,6 +80,13 @@ type nodeBackend struct {
eventClient *eventbus.Client
derpMapViewPub *eventbus.Publisher[tailcfg.DERPMapView]
// homeDERP lives here temporarily. as long as mapSession is short lived, we
// don't have a location delivering netmaps to local backend that knows our
// homeDERP hence why it is cached here for now.
// TODO(cmol): move this field into a refactored mapSession that is not
// short lived.
homeDERP atomic.Int64
// TODO(nickkhyl): maybe use sync.RWMutex?
mu syncs.Mutex // protects the following fields