ipn/ipnlocal: ensure b.mu is always unlocked in (*LocalBackend).authReconfig

Updates tailscale/corp#27502 (caused a deadlock in a test while working on it)

Signed-off-by: Nick Khyl <nickk@tailscale.com>
This commit is contained in:
Nick Khyl 2025-06-16 17:49:03 -05:00
parent 735f15cb49
commit 0f7e7c333a
No known key found for this signature in database

View File

@ -4857,19 +4857,34 @@ func (b *LocalBackend) readvertiseAppConnectorRoutes() {
// updates are not currently blocked, based on the cached netmap and // updates are not currently blocked, based on the cached netmap and
// user prefs. // user prefs.
func (b *LocalBackend) authReconfig() { func (b *LocalBackend) authReconfig() {
b.mu.Lock() var (
blocked := b.blocked blocked bool
prefs := b.pm.CurrentPrefs() prefs ipn.PrefsView
cn := b.currentNode() hasPAC bool
nm := cn.NetMap() cn *nodeBackend
hasPAC := b.prevIfState.HasPAC() nm *netmap.NetworkMap
disableSubnetsIfPAC := cn.SelfHasCap(tailcfg.NodeAttrDisableSubnetsIfPAC) disableSubnetsIfPAC bool
dohURL, dohURLOK := cn.exitNodeCanProxyDNS(prefs.ExitNodeID()) dohURL string
dcfg := cn.dnsConfigForNetmap(prefs, b.keyExpired, b.logf, version.OS()) dohURLOK bool
// If the current node is an app connector, ensure the app connector machine is started dcfg *dns.Config
b.reconfigAppConnectorLocked(nm, prefs) closing bool
closing := b.shutdownCalled )
b.mu.Unlock()
func() { // make sure b.mu gets unlocked if anything below panics
b.mu.Lock()
defer b.mu.Unlock()
blocked = b.blocked
prefs = b.pm.CurrentPrefs()
cn = b.currentNode()
nm = cn.NetMap()
hasPAC = b.prevIfState.HasPAC()
disableSubnetsIfPAC = cn.SelfHasCap(tailcfg.NodeAttrDisableSubnetsIfPAC)
dohURL, dohURLOK = cn.exitNodeCanProxyDNS(prefs.ExitNodeID())
dcfg = cn.dnsConfigForNetmap(prefs, b.keyExpired, b.logf, version.OS())
// If the current node is an app connector, ensure the app connector machine is started
b.reconfigAppConnectorLocked(nm, prefs)
closing = b.shutdownCalled
}()
if closing { if closing {
b.logf("[v1] authReconfig: skipping because in shutdown") b.logf("[v1] authReconfig: skipping because in shutdown")