ipn/ipnlocal: pass capability set, not netmap, to two helpers
setWebClientAtomicBoolLocked and setDebugLogsByCapabilityLocked each only need the node capabilities to decide what to do, so take a set.Set[tailcfg.NodeCapability] directly as part of getting rid of netmap.NetworkMap. Updates #12542 Change-Id: If7c30b6354fd42dfe82ed6d2e2fe3439de401315 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
87cb2a8d1e
commit
dd1df38200
+13
-8
@@ -2046,7 +2046,7 @@ func (b *LocalBackend) setControlClientStatusLocked(c controlclient.Client, st c
|
|||||||
// Perform all reconfiguration based on the netmap here.
|
// Perform all reconfiguration based on the netmap here.
|
||||||
if st.NetMap != nil {
|
if st.NetMap != nil {
|
||||||
b.capTailnetLock = st.NetMap.HasCap(tailcfg.CapabilityTailnetLock)
|
b.capTailnetLock = st.NetMap.HasCap(tailcfg.CapabilityTailnetLock)
|
||||||
b.setWebClientAtomicBoolLocked(st.NetMap)
|
b.setWebClientAtomicBoolLocked(st.NetMap.AllCaps)
|
||||||
|
|
||||||
b.mu.Unlock() // respect locking rules for tkaSyncIfNeeded
|
b.mu.Unlock() // respect locking rules for tkaSyncIfNeeded
|
||||||
if err := b.tkaSyncIfNeeded(st.NetMap, prefs.View()); err != nil {
|
if err := b.tkaSyncIfNeeded(st.NetMap, prefs.View()); err != nil {
|
||||||
@@ -7042,13 +7042,14 @@ func (b *LocalBackend) ShouldExposeRemoteWebClient() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// setWebClientAtomicBoolLocked sets webClientAtomicBool based on whether
|
// setWebClientAtomicBoolLocked sets webClientAtomicBool based on whether
|
||||||
// tailcfg.NodeAttrDisableWebClient has been set in the netmap.NetworkMap.
|
// tailcfg.NodeAttrDisableWebClient is present in caps. caps may be nil
|
||||||
|
// if the caller has no netmap.
|
||||||
//
|
//
|
||||||
// b.mu must be held.
|
// b.mu must be held.
|
||||||
func (b *LocalBackend) setWebClientAtomicBoolLocked(nm *netmap.NetworkMap) {
|
func (b *LocalBackend) setWebClientAtomicBoolLocked(caps set.Set[tailcfg.NodeCapability]) {
|
||||||
syncs.RequiresMutex(&b.mu)
|
syncs.RequiresMutex(&b.mu)
|
||||||
|
|
||||||
shouldRun := !nm.HasCap(tailcfg.NodeAttrDisableWebClient)
|
shouldRun := !caps.Contains(tailcfg.NodeAttrDisableWebClient)
|
||||||
wasRunning := b.webClientAtomicBool.Swap(shouldRun)
|
wasRunning := b.webClientAtomicBool.Swap(shouldRun)
|
||||||
if wasRunning && !shouldRun {
|
if wasRunning && !shouldRun {
|
||||||
b.goTracker.Go(b.webClientShutdown) // stop web client
|
b.goTracker.Go(b.webClientShutdown) // stop web client
|
||||||
@@ -7364,7 +7365,11 @@ func (b *LocalBackend) setNetMapLocked(nm *netmap.NetworkMap) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if buildfeatures.HasDebug {
|
if buildfeatures.HasDebug {
|
||||||
b.setDebugLogsByCapabilityLocked(nm)
|
var caps set.Set[tailcfg.NodeCapability]
|
||||||
|
if nm != nil {
|
||||||
|
caps = nm.AllCaps
|
||||||
|
}
|
||||||
|
b.setDebugLogsByCapabilityLocked(caps)
|
||||||
}
|
}
|
||||||
|
|
||||||
// See the netns package for documentation on what these capability do.
|
// See the netns package for documentation on what these capability do.
|
||||||
@@ -7500,11 +7505,11 @@ func roundTraffic(bytes int64) float64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// setDebugLogsByCapabilityLocked sets debug logging based on the self node's
|
// setDebugLogsByCapabilityLocked sets debug logging based on the self node's
|
||||||
// capabilities in the provided NetMap.
|
// capabilities. caps may be nil if the caller has no netmap.
|
||||||
func (b *LocalBackend) setDebugLogsByCapabilityLocked(nm *netmap.NetworkMap) {
|
func (b *LocalBackend) setDebugLogsByCapabilityLocked(caps set.Set[tailcfg.NodeCapability]) {
|
||||||
// These are sufficiently cheap (atomic bools) that we don't need to
|
// These are sufficiently cheap (atomic bools) that we don't need to
|
||||||
// store state and compare.
|
// store state and compare.
|
||||||
if nm.HasCap(tailcfg.CapabilityDebugTSDNSResolution) {
|
if caps.Contains(tailcfg.CapabilityDebugTSDNSResolution) {
|
||||||
dnscache.SetDebugLoggingEnabled(true)
|
dnscache.SetDebugLoggingEnabled(true)
|
||||||
} else {
|
} else {
|
||||||
dnscache.SetDebugLoggingEnabled(false)
|
dnscache.SetDebugLoggingEnabled(false)
|
||||||
|
|||||||
Reference in New Issue
Block a user