wgengine/magicsock: fix missing Conn.hasPeerRelayServers.Store() call (#16792)

This commit also extends the updateRelayServersSet unit tests to cover
onNodeViewsUpdate.

Fixes tailscale/corp#31080

Signed-off-by: Jordan Whited <jordan@tailscale.com>
This commit is contained in:
Jordan Whited
2025-08-06 14:57:55 -07:00
committed by GitHub
parent 0374e6d906
commit 4666d4ca2a
2 changed files with 78 additions and 20 deletions

View File

@@ -274,11 +274,9 @@ type Conn struct {
captureHook syncs.AtomicValue[packet.CaptureCallback]
// hasPeerRelayServers is whether [relayManager] is configured with at least
// one peer relay server via [relayManager.handleRelayServersSet]. It is
// only accessed by [Conn.updateRelayServersSet], [endpoint.setDERPHome],
// and [endpoint.discoverUDPRelayPathsLocked]. It exists to suppress
// calls into [relayManager] leading to wasted work involving channel
// operations and goroutine creation.
// one peer relay server via [relayManager.handleRelayServersSet]. It exists
// to suppress calls into [relayManager] leading to wasted work involving
// channel operations and goroutine creation.
hasPeerRelayServers atomic.Bool
// discoPrivate is the private naclbox key used for active
@@ -2998,6 +2996,7 @@ func (c *Conn) onNodeViewsUpdate(update NodeViewsUpdate) {
if peersChanged || relayClientChanged {
if !relayClientEnabled {
c.relayManager.handleRelayServersSet(nil)
c.hasPeerRelayServers.Store(false)
} else {
c.updateRelayServersSet(filt, self, peers)
}