tailcfg,ipn/ipnlocal: regulate netmap caching via a node attribute (#19117)

Add a new tailcfg.NodeCapability (NodeAttrCacheNetworkMaps) to control whether
a node with support for caching network maps will attempt to do so. Update the
capability version to reflect this change (mainly as a safety measure, as the
control plane does not currently need to know about it).

Use the presence (or absence) of the node attribute to decide whether to create
and update a netmap cache for each profile. If caching is disabled, discard the
cached data; this allows us to use the presence of a cached netmap as an
indicator it should be used (unless explicitly overridden). Add a test that
verifies the attribute is respected. Reverse the sense of the environment knob
to be true by default, with an override to disable caching at the client
regardless what the node attribute says.

Move the creation/update of the netmap cache (when enabled) until after
successfully applying the network map, to reduce the possibility that we will
cache (and thus reuse after a restart) a network map that fails to correctly
configure the client.

Updates #12639

Change-Id: I1df4dd791fdb485c6472a9f741037db6ed20c47e
Signed-off-by: M. J. Fromberger <fromberger@tailscale.com>
This commit is contained in:
M. J. Fromberger
2026-04-01 15:02:53 -07:00
committed by GitHub
parent c76113ac75
commit 211ef67222
6 changed files with 189 additions and 9 deletions
+9 -1
View File
@@ -181,7 +181,8 @@ type CapabilityVersion int
// - 132: 2026-02-13: client respects [NodeAttrDisableHostsFileUpdates]
// - 133: 2026-02-17: client understands [NodeAttrForceRegisterMagicDNSIPv4Only]; MagicDNS IPv6 registered w/ OS by default
// - 134: 2026-03-09: Client understands [NodeAttrDisableAndroidBindToActiveNetwork]
const CurrentCapabilityVersion CapabilityVersion = 134
// - 135: 2026-03-30: Client understands [NodeAttrCacheNetworkMaps]
const CurrentCapabilityVersion CapabilityVersion = 135
// ID is an integer ID for a user, node, or login allocated by the
// control plane.
@@ -2770,6 +2771,13 @@ const (
// See https://github.com/tailscale/tailscale/issues/15404.
// TODO(bradfitz): remove this a few releases after 2026-02-16.
NodeAttrForceRegisterMagicDNSIPv4Only NodeCapability = "force-register-magicdns-ipv4-only"
// NodeAttrCacheNetworkMaps instructs the node to persistently cache network
// maps and use them to establish peer connectivity on start, if doing so is
// supported by the client and storage is available. When this attribute is
// absent (or removed), a node that supports netmap caching will ignore and
// discard existing cached maps, and will not store any.
NodeAttrCacheNetworkMaps NodeCapability = "cache-network-maps"
)
// SetDNSRequest is a request to add a DNS record.