diff --git a/ipn/ipnlocal/local.go b/ipn/ipnlocal/local.go index 836075d26..7e0aa648e 100644 --- a/ipn/ipnlocal/local.go +++ b/ipn/ipnlocal/local.go @@ -806,7 +806,7 @@ func (b *LocalBackend) setClientStatus(st controlclient.Status) { } if st.NetMap != nil { b.mu.Unlock() // respect locking rules for tkaSyncIfNeeded - if err := b.tkaSyncIfNeeded(st.NetMap); err != nil { + if err := b.tkaSyncIfNeeded(st.NetMap, prefs.View()); err != nil { b.logf("[v1] TKA sync error: %v", err) } b.mu.Lock() diff --git a/ipn/ipnlocal/network-lock.go b/ipn/ipnlocal/network-lock.go index bf2b9221a..2c7f48fe9 100644 --- a/ipn/ipnlocal/network-lock.go +++ b/ipn/ipnlocal/network-lock.go @@ -17,6 +17,7 @@ import ( "time" "tailscale.com/envknob" + "tailscale.com/ipn" "tailscale.com/ipn/ipnstate" "tailscale.com/tailcfg" "tailscale.com/tka" @@ -89,7 +90,7 @@ func (b *LocalBackend) tkaFilterNetmapLocked(nm *netmap.NetworkMap) { // // tkaSyncIfNeeded immediately takes b.takeSyncLock which is held throughout, // and may take b.mu as required. -func (b *LocalBackend) tkaSyncIfNeeded(nm *netmap.NetworkMap) error { +func (b *LocalBackend) tkaSyncIfNeeded(nm *netmap.NetworkMap, prefs ipn.PrefsView) error { if !envknob.UseWIPCode() { // If the feature flag is not enabled, pretend we don't exist. return nil @@ -100,7 +101,7 @@ func (b *LocalBackend) tkaSyncIfNeeded(nm *netmap.NetworkMap) error { b.mu.Lock() // take mu to protect access to synchronized fields. defer b.mu.Unlock() - ourNodeKey := b.prefs.Persist().PublicNodeKey() + ourNodeKey := prefs.Persist().PublicNodeKey() isEnabled := b.tka != nil wantEnabled := nm.TKAEnabled diff --git a/ipn/ipnlocal/network-lock_test.go b/ipn/ipnlocal/network-lock_test.go index eac318b74..214d79633 100644 --- a/ipn/ipnlocal/network-lock_test.go +++ b/ipn/ipnlocal/network-lock_test.go @@ -130,7 +130,7 @@ func TestTKAEnablementFlow(t *testing.T) { err = b.tkaSyncIfNeeded(&netmap.NetworkMap{ TKAEnabled: true, TKAHead: a1.Head(), - }) + }, b.prefs) if err != nil { t.Errorf("tkaSyncIfNeededLocked() failed: %v", err) } @@ -229,7 +229,7 @@ func TestTKADisablementFlow(t *testing.T) { err = b.tkaSyncIfNeeded(&netmap.NetworkMap{ TKAEnabled: false, TKAHead: authority.Head(), - }) + }, b.prefs) if err != nil { t.Errorf("tkaSyncIfNeededLocked() failed: %v", err) } @@ -242,7 +242,7 @@ func TestTKADisablementFlow(t *testing.T) { err = b.tkaSyncIfNeeded(&netmap.NetworkMap{ TKAEnabled: false, TKAHead: authority.Head(), - }) + }, b.prefs) if err != nil { t.Errorf("tkaSyncIfNeededLocked() failed: %v", err) } @@ -465,7 +465,7 @@ func TestTKASync(t *testing.T) { err = b.tkaSyncIfNeeded(&netmap.NetworkMap{ TKAEnabled: true, TKAHead: controlAuthority.Head(), - }) + }, b.prefs) if err != nil { t.Errorf("tkaSyncIfNeededLocked() failed: %v", err) }