ipn/ipnlocal: stop netmap expiry timer when resetting control client

This prevents a panic where we synthesize a new netmap in
setClientStatus after we've shut down and nil'd out the controlclient,
since that function expects to be called while connected to control.

Fixes #7392

Signed-off-by: Andrew Dunham <andrew@du.nham.ca>
Change-Id: Ib631eb90f34f6afa008d69bbb386f70da145e102
This commit is contained in:
Andrew Dunham 2023-03-06 09:57:28 -05:00
parent 96a555fc5a
commit df2561f6a2

View File

@ -3682,6 +3682,21 @@ func (b *LocalBackend) resetControlClientLockedAsync() {
if b.cc == nil {
return
}
// When we clear the control client, stop any outstanding netmap expiry
// timer; synthesizing a new netmap while we don't have a control
// client will break things.
//
// See https://github.com/tailscale/tailscale/issues/7392
if b.nmExpiryTimer != nil {
b.nmExpiryTimer.Stop()
b.nmExpiryTimer = nil
// Also bump the epoch to ensure that if the timer started, it
// will abort.
b.numClientStatusCalls.Add(1)
}
go b.cc.Shutdown()
b.cc = nil
b.ccAuto = nil