diff --git a/cmd/tailscaled/depaware.txt b/cmd/tailscaled/depaware.txt index 91321b316..94e44ddd8 100644 --- a/cmd/tailscaled/depaware.txt +++ b/cmd/tailscaled/depaware.txt @@ -315,7 +315,7 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de tailscale.com/types/netlogtype from tailscale.com/net/connstats+ tailscale.com/types/netmap from tailscale.com/control/controlclient+ tailscale.com/types/nettype from tailscale.com/wgengine/magicsock+ - tailscale.com/types/opt from tailscale.com/control/controlclient+ + tailscale.com/types/opt from tailscale.com/client/tailscale+ tailscale.com/types/persist from tailscale.com/control/controlclient+ tailscale.com/types/preftype from tailscale.com/ipn+ tailscale.com/types/ptr from tailscale.com/hostinfo+ diff --git a/control/controlclient/direct.go b/control/controlclient/direct.go index 5f23733a7..64ffa5de9 100644 --- a/control/controlclient/direct.go +++ b/control/controlclient/direct.go @@ -49,7 +49,6 @@ import ( "tailscale.com/types/key" "tailscale.com/types/logger" "tailscale.com/types/netmap" - "tailscale.com/types/opt" "tailscale.com/types/persist" "tailscale.com/types/ptr" "tailscale.com/types/tkatype" @@ -1304,49 +1303,6 @@ func initDevKnob() devKnobs { var clock tstime.Clock = tstime.StdClock{} -func (ms *mapSession) setControlKnobsFromNodeAttrs(selfNodeAttrs []string) { - k := ms.controlKnobs - if k == nil { - return - } - var ( - keepFullWG bool - disableDRPO bool - disableUPnP bool - randomizeClientPort bool - disableDeltaUpdates bool - oneCGNAT opt.Bool - forceBackgroundSTUN bool - ) - for _, attr := range selfNodeAttrs { - switch attr { - case tailcfg.NodeAttrDebugDisableWGTrim: - keepFullWG = true - case tailcfg.NodeAttrDebugDisableDRPO: - disableDRPO = true - case tailcfg.NodeAttrDisableUPnP: - disableUPnP = true - case tailcfg.NodeAttrRandomizeClientPort: - randomizeClientPort = true - case tailcfg.NodeAttrOneCGNATEnable: - oneCGNAT.Set(true) - case tailcfg.NodeAttrOneCGNATDisable: - oneCGNAT.Set(false) - case tailcfg.NodeAttrDebugForceBackgroundSTUN: - forceBackgroundSTUN = true - case tailcfg.NodeAttrDisableDeltaUpdates: - disableDeltaUpdates = true - } - } - k.KeepFullWGConfig.Store(keepFullWG) - k.DisableDRPO.Store(disableDRPO) - k.DisableUPnP.Store(disableUPnP) - k.RandomizeClientPort.Store(randomizeClientPort) - k.OneCGNAT.Store(oneCGNAT) - k.ForceBackgroundSTUN.Store(forceBackgroundSTUN) - k.DisableDeltaUpdates.Store(disableDeltaUpdates) -} - // ipForwardingBroken reports whether the system's IP forwarding is disabled // and will definitely not work for the routes provided. // diff --git a/control/controlclient/map.go b/control/controlclient/map.go index a54007232..72f23b012 100644 --- a/control/controlclient/map.go +++ b/control/controlclient/map.go @@ -188,7 +188,7 @@ func (ms *mapSession) HandleNonKeepAliveMapResponse(ctx context.Context, resp *t if DevKnob.StripCaps() { resp.Node.Capabilities = nil } - ms.setControlKnobsFromNodeAttrs(resp.Node.Capabilities) + ms.controlKnobs.UpdateFromNodeAttributes(resp.Node.Capabilities) } // Call Node.InitDisplayNames on any changed nodes. diff --git a/control/controlknobs/controlknobs.go b/control/controlknobs/controlknobs.go index 96c284dca..b5b49e150 100644 --- a/control/controlknobs/controlknobs.go +++ b/control/controlknobs/controlknobs.go @@ -9,6 +9,7 @@ import ( "sync/atomic" "tailscale.com/syncs" + "tailscale.com/tailcfg" "tailscale.com/types/opt" ) @@ -45,6 +46,50 @@ type Knobs struct { DisableDeltaUpdates atomic.Bool } +// UpdateFromNodeAttributes updates k (if non-nil) based on the provided self +// node attributes (Node.Capabilities). +func (k *Knobs) UpdateFromNodeAttributes(selfNodeAttrs []string) { + if k == nil { + return + } + var ( + keepFullWG bool + disableDRPO bool + disableUPnP bool + randomizeClientPort bool + disableDeltaUpdates bool + oneCGNAT opt.Bool + forceBackgroundSTUN bool + ) + for _, attr := range selfNodeAttrs { + switch attr { + case tailcfg.NodeAttrDebugDisableWGTrim: + keepFullWG = true + case tailcfg.NodeAttrDebugDisableDRPO: + disableDRPO = true + case tailcfg.NodeAttrDisableUPnP: + disableUPnP = true + case tailcfg.NodeAttrRandomizeClientPort: + randomizeClientPort = true + case tailcfg.NodeAttrOneCGNATEnable: + oneCGNAT.Set(true) + case tailcfg.NodeAttrOneCGNATDisable: + oneCGNAT.Set(false) + case tailcfg.NodeAttrDebugForceBackgroundSTUN: + forceBackgroundSTUN = true + case tailcfg.NodeAttrDisableDeltaUpdates: + disableDeltaUpdates = true + } + } + k.KeepFullWGConfig.Store(keepFullWG) + k.DisableDRPO.Store(disableDRPO) + k.DisableUPnP.Store(disableUPnP) + k.RandomizeClientPort.Store(randomizeClientPort) + k.OneCGNAT.Store(oneCGNAT) + k.ForceBackgroundSTUN.Store(forceBackgroundSTUN) + k.DisableDeltaUpdates.Store(disableDeltaUpdates) +} + // AsDebugJSON returns k as something that can be marshalled with json.Marshal // for debug. func (k *Knobs) AsDebugJSON() map[string]any {