Commit Graph
10666 Commits
Author SHA1 Message Date
Kabir Sikand 0e8a68fc8d cmd/tailscale/cli: route join-status not-bound diagnostic to stderr
The "this node is not blueprint-bound" exit-1 message was being
written to the same io.Writer as the projection block — which in
production means os.Stdout. The v2 design specifies stderr for that
diagnostic, matching every other CLI command in the package that
exits 1.

Pull the not-bound check up into runJoinStatus and write it via
os.Stderr directly, then call os.Exit(1). The render helpers
assume a bound status and always return 0; their test surface
shrinks accordingly.

Updates #cleanup

Signed-off-by: Kabir Sikand <[email protected]>
2026-05-27 20:21:27 +00:00
Kabir Sikand 78e1e4a4e9 ipn/ipnlocal: move BlueprintConfig copy out of peerStatusFromNode
peerStatusFromNode is shared by both the Self-status path and the
peer iteration in populatePeerStatusLocked, so the BlueprintConfig
copy added in the prior commit was leaking onto peer PeerStatus
entries whenever the server included BlueprintConfig in a peer's
Node record. The ipnstate.PeerStatus.BlueprintConfig docstring and
the v2 design both promise nil on peer entries.

Move the copy into MutateSelfStatus, alongside the other Self-only
fields. BlueprintID stays in the shared helper since both Self and
peers legitimately surface it (the status subcommand filters peers
by it).

Adds TestPeerStatusFromNodeDoesNotCopyBlueprintConfig to lock in
the invariant.

Updates #cleanup

Signed-off-by: Kabir Sikand <[email protected]>
2026-05-27 20:20:29 +00:00
Kabir Sikand 5f79d959d3 cmd/tailscale/cli: render blueprint projection on tailscale leave
Before clearing Prefs.BlueprintID and logging out, capture the
current Status.Self.BlueprintConfig and display it after the logout
completes so the operator can see what configuration the node is
releasing. Best-effort: if the Status fetch fails or the projection
hasn't arrived yet, fall back to the short "Detached from blueprint
bp:<id> and logged out." line. Leave is reversible; we do not block
on a Status fetch.

Extracts two pure helpers (snapshotProjection, renderLeaveMessage)
so the display branches are unit-testable without a live daemon.

Updates #cleanup

Signed-off-by: Kabir Sikand <[email protected]>
2026-05-27 20:07:26 +00:00
Kabir Sikand 20e4bc8fc9 cmd/tailscale/cli: add tailscale join status subcommand
Adds an inspection subcommand under `tailscale join` that renders
the projected BlueprintConfig for the local node plus the list of
peers visible to this node bound to the same Blueprint. Supports
--json for scripting; the JSON shape mirrors `tailscale status
--json`'s "may change between releases" contract.

Peer visibility tracks the tailnet's policy: peers whose binding is
not visible to this node simply do not appear. The output uses the
phrase "visible to this node" deliberately -- absence in the list is
not absence in the tailnet.

Updates #cleanup

Signed-off-by: Kabir Sikand <[email protected]>
2026-05-27 20:02:47 +00:00
Kabir Sikand 0659165c06 cmd/tailscale/cli: render blueprint projection after tailscale join
After a successful join, poll the daemon's Status for up to 30s
waiting for the first map poll to deliver Node.BlueprintConfig, then
print the projection via the shared renderer. On timeout, fall back
to a pointer to `tailscale join status` so the operator knows where
to look. The binding itself is unaffected by the wait outcome; only
the display deadline matters.

Adds cli_blueprint_join_projection_timeout to record the timeout-only
case for observability; metricBlueprintJoinSuccess fires regardless
since the join succeeded.

Updates #cleanup

Signed-off-by: Kabir Sikand <[email protected]>
2026-05-27 19:57:44 +00:00
Kabir Sikand f2b02df99e cmd/tailscale/cli, ipn/ipnstate: add blueprint projection wait helper
Adds a pure waitForBlueprintProjection helper that polls a Status
fetcher until the daemon reports a matching projection or a deadline
elapses. Extracted from runJoin so the wait-loop behavior can be unit
tested without a fake LocalClient.

Also threads PeerStatus.BlueprintConfig (populated only on Self, from
tailcfg.Node.BlueprintConfig) so the helper's success condition can
be expressed in terms of the public Status surface. Peer entries
never read this field; the helper checks only Status.Self.

Updates #cleanup

Signed-off-by: Kabir Sikand <[email protected]>
2026-05-27 19:54:07 +00:00
Kabir Sikand 6eeacb1543 cmd/tailscale/cli: add renderBlueprintConfig formatter
A pure formatter shared by `tailscale join`, `tailscale leave`, and
`tailscale join status`. Takes a blueprint id and an optional
*tailcfg.BlueprintConfig and writes an indented, label-aligned text
block describing the projected configuration. Empty buckets are
omitted; a nil cfg renders a "(projection not yet received)" line so
freshly-joined nodes get a sensible output before the first map poll.

Updates #cleanup

Signed-off-by: Kabir Sikand <[email protected]>
2026-05-27 19:49:23 +00:00
Kabir Sikand 42600800a1 ipn/ipnlocal: copy Node.BlueprintID into PeerStatus.BlueprintID
peerStatusFromNode is the centralized helper that copies fields from
tailcfg.NodeView into ipnstate.PeerStatus for both the local node
(via MutateSelfStatus) and every peer (via populatePeerStatusLocked).
A one-line copy populates the new PeerStatus.BlueprintID field added
in the previous commit, making blueprint bindings visible everywhere
the status surface is read.

Updates #cleanup

Signed-off-by: Kabir Sikand <[email protected]>
2026-05-27 19:45:22 +00:00
Kabir Sikand 846765cb85 ipn/ipnstate: add PeerStatus.BlueprintID
Adds a BlueprintID field to PeerStatus and extends StatusBuilder.AddPeer
to merge it using the same "non-empty wins" pattern as every other
string field on the struct. The field is populated upstream (see the
peerStatusFromNode helper in ipn/ipnlocal/local.go) from
tailcfg.Node.BlueprintID, which is already on the wire as of capver
139, and is consumed by the `tailscale join status` subcommand to
filter peers by their blueprint binding.

Updates #cleanup

Signed-off-by: Kabir Sikand <[email protected]>
2026-05-27 19:41:55 +00:00
Kabir Sikand 4fa56c015b docs/superpowers/plans: add blueprint join/leave/status plan
Bite-sized TDD plan implementing the design in
docs/superpowers/specs/2026-05-27-blueprint-join-status-design.md.
Eight tasks, each ending in a commit; pure helpers extracted for
testability (waitForBlueprintProjection, renderBlueprintConfig,
renderJoinStatus, snapshotProjection, renderLeaveMessage).

Updates #cleanup

Signed-off-by: Kabir Sikand <[email protected]>
2026-05-27 19:35:35 +00:00
Kabir Sikand c8eaf6a543 docs/superpowers/specs: add blueprint join/leave/status design
Captures the design for surfacing the projected BlueprintConfig
in the CLI: rendering it after a successful `tailscale join`,
during `tailscale leave`, and on demand via a new
`tailscale join status` subcommand that also lists peers bound
to the same blueprint when visible per policy.

Updates #cleanup

Signed-off-by: Kabir Sikand <[email protected]>
2026-05-27 19:28:11 +00:00
Kabir Sikand 4cd8636d63 tailcfg, ipn/ipnlocal: wire blueprint serves.apps + serves.services
Closes the corp-side dangling wire fields (corp v2.1 ships
ServeApps/ServeServices in BlueprintConfig but the OSS client
never read them). Adds the missing OSS-side type field plus a
reconciler that maps the resolved blueprint's app + service list
onto local daemon state.

tailcfg.BlueprintConfig gains ServeServices []string (companion
to the existing ServeApps + ServeIPSets). Equal() updated; clone
+ view hand-edits follow the existing pattern (prior agent noted
the corp pin makes go generate awkward, so the cloner/viewer
files are hand-extended with regen sentinels updated).

ipn/ipnlocal/local.go: two new reconcile functions, called from
the tail of setNetMapLocked alongside the existing routes / prefs
reconciles:

  - reconcileBlueprintAppConnectorLocked: flips
    Prefs.AppConnector.Advertise to match presence of any "app:"
    identifier in BlueprintConfig.ServeApps. Silence-equals-OFF
    consistent with the other blueprint prefs. Per-app routing
    rules (which domains/CIDRs each connector handles) remain
    owned by the existing app-connector machinery; the blueprint
    only toggles the node-level advertise bit.

  - reconcileBlueprintServicesLocked: surfaces the projected
    ServeServices list via the daemon log so operators can see
    what services the blueprint expects this node to advertise.
    Full reconcile into the daemon's services machinery is a
    follow-up — translating "svc:<name>" identifiers into actual
    ServeConfig entries depends on the services backend exposing
    a reconcile API, which is out of scope for this commit.

Operationally: after this commit, a blueprint that lists
"serves.apps": ["app:github"] auto-enables the bound node as an
app connector (no need for the operator to also run
`tailscale set --advertise-connector` and have it rejected by the
blueprint-lock); the per-app routing rules still come from the
operator's app-connector configuration in the admin panel.

Updates #cleanup

Signed-off-by: Kabir Sikand <[email protected]>
2026-05-19 22:38:42 +00:00
Kabir Sikand db4e4dfe57 BLUEPRINTS-FOLLOWUPS: pref:funnel permanently removed (v2.1)
Drop the "pref:funnel client-side projection deferred" entry. v2.1
removes pref:funnel from the spec; funnel eligibility for
blueprint-bound nodes flows through tailcfg.NodeAttrFunnel via the
attrs: block, not a Prefs bool. The OSS-side blueprintPrefSetters
table already lists three prefs and is now authoritative.

Updates #cleanup

Signed-off-by: Kabir Sikand <[email protected]>
2026-05-19 22:19:04 +00:00
Kabir Sikand a86a228350 ipn/ipnlocal: drop shields-up + webclient from blueprint prefs allowlist
Brings the client-side blueprint pref projection to spec v2. The v1
table had five entries (accept-dns, accept-routes, ssh, shields-up,
webclient); the latest spec (§6 in-scope #10, §13) lists four
(accept-dns, accept-routes, ssh, funnel). The v1.1-era shields-up and
webclient were retracted; pref:funnel is added in concept but has no
ipn.Prefs boolean to project onto — funnel eligibility today flows
through tailcfg.NodeAttrFunnel via the existing nodecap path, not
through ipn.Prefs.

For the client reconciler that means three rows:

  pref:accept-dns    -> Prefs.CorpDNS
  pref:accept-routes -> Prefs.RouteAll
  pref:ssh           -> Prefs.RunSSH

pref:funnel falls through as an "unknown pref" on the projection side;
the compile-time allowlist in corp still accepts it. The gap is
documented in BLUEPRINTS-FOLLOWUPS.md so a future change adding a
first-class Prefs.FunnelEligible bool can plug the table cleanly.

Tests:

  - TestReconcileBlueprintPrefs_PresenceIsOnAbsenceIsOff loses its
    ShieldsUp/RunWebClient columns and gains funnel + v1-legacy
    coverage rows.
  - New TestReconcileBlueprintPrefs_LegacyPrefsLeaveLocalFieldsAlone
    pins the distinguishing behavior: pref:shields-up and
    pref:webclient must not flip the corresponding bool either way
    (no silence-forces-OFF, no presence-forces-ON), even if a
    blueprint still lists them. That catches a regression where
    someone re-adds the v1 setters by accident.

Updates #cleanup

Signed-off-by: Kabir Sikand <[email protected]>
2026-05-19 15:34:07 +00:00
Kabir Sikand 3617eb33af cmd/tailscale/cli: drop node-local prefs from blueprint locked-fields
Brings the v1 locked-field set to spec v2 (§11). The v1 list inherited
ten entries from the v1.1-era KB doc; the latest spec narrowed the set
to fields the blueprint actually owns, dropping:

  - hostname / operator: node-local concerns the blueprint has no
    opinion on, per the join-flag rationale at the bottom of §11.
  - shields-up / webclient: not in the v2 prefs allowlist (the v1
    projection also drops them; see the followup commit).

Six entries remain: advertise-tags, advertise-routes,
advertise-connector, ssh, accept-dns, accept-routes. advertise-routes
also covers advertise-exit-node, since exit-node advertisement is
stored as the v4+v6 default routes in Prefs.AdvertiseRoutes and shares
its MaskedPrefs bit.

TestCheckBlueprintSetLocked_AllLockedFields shrinks accordingly. A new
TestCheckBlueprintSetLocked_NodeLocalFieldsAllowed pins the negative
contract: each of the four dropped fields must NOT be rejected on a
bound node, so a future regression can't silently re-add them.

Updates #cleanup

Signed-off-by: Kabir Sikand <[email protected]>
2026-05-19 15:30:54 +00:00
Kabir Sikand c3721ba263 tailcfg, ipn/ipnlocal, cmd/tailscale/cli: drive node prefs from blueprint
Paired OSS side for the corp v1.1 "blueprint prefs" work. Three
changes:

  1. tailcfg.BlueprintConfig grows a Prefs []string field. The wire
     format intentionally uses strings rather than a typed bool
     struct so the control plane can add new supported prefs
     without a capver bump on the client; unrecognized entries are
     ignored by older clients. Clone, view, and Equal hand-edited
     to keep the regen sentinels green (corp pin makes go generate
     awkward; follows the prior commits' pattern).

  2. ipn/ipnlocal grows reconcileBlueprintPrefsLocked, called from
     setNetMapLocked right after the existing routes reconcile.
     For each entry in a small per-pref table (id, getter, setter,
     metric) the loop forces the matching ipn.Prefs bool to true
     when the pref appears in BlueprintConfig.Prefs and to false
     when it does not. Silence equals OFF: the blueprint is the
     source of truth and overrides any pre-existing local setting
     on every netmap apply. Persists only when something actually
     flipped. One clientmetric counter per pref bumps each time
     the reconcile turns the field ON.

     Supported prefs in this revision:

       pref:accept-dns    -> Prefs.CorpDNS
       pref:accept-routes -> Prefs.RouteAll
       pref:ssh           -> Prefs.RunSSH
       pref:shields-up    -> Prefs.ShieldsUp
       pref:webclient     -> Prefs.RunWebClient

     Unknown pref ids in the projection are ignored silently
     (forward-compat: a newer control plane may reference a pref
     this client does not yet implement).

  3. cmd/tailscale/cli/blueprint_lock.go extends the locked-field
     list to reject `tailscale set --accept-routes`,
     `--shields-up`, and `--webclient` on blueprint-bound nodes
     with the same v1 error template. --accept-dns and --ssh were
     already locked.

Tests added:

  - ipn/ipnlocal/blueprint_prefs_test.go exercises the reconcile
    function across the matrix of all-on, partial, silence-equals-off
    (overrides prior local), unknown-pref-ignored, and the no-op
    paths for unbound nodes and nil netmaps.
  - cmd/tailscale/cli/blueprint_lock_test.go gains rows for each
    new locked field.

Updates #cleanup

Signed-off-by: Kabir Sikand <[email protected]>
2026-05-19 00:10:42 +00:00
Kabir Sikand e194328a98 cmd/tailscale/cli: accept blueprint as positional or flag, with or without bp:
tailscale join previously required --blueprint=bp:<id>. Operators
running the command interactively find it natural to drop the
prefix, and SRE scripts that already construct the id elsewhere
find it natural to pass it positionally. Accept all four forms and
normalize them client-side:

  tailscale join --blueprint=bp:foo --auth-key=...
  tailscale join --blueprint=foo    --auth-key=...
  tailscale join bp:foo             --auth-key=...
  tailscale join foo                --auth-key=...

The four forms produce identical requests to the control plane.
Mismatched positional and --blueprint values are rejected with an
error naming both inputs in their normalized "bp:<id>" form; agreed
duplicates are accepted silently. Validation (letter-start,
alphanumerics + dashes) still flows through the existing
blueprintIDFromFlag, so the empty-after-strip and bad-character
errors are unchanged.

Updates #cleanup

Signed-off-by: Kabir Sikand <[email protected]>
2026-05-18 23:45:04 +00:00
Kabir Sikand 6d016c0c33 ipn/ipnlocal: reconcile blueprint routes into AdvertiseRoutes
When the netmap's SelfNode carries a BlueprintConfig with non-empty
Routes, treat those routes as the source of truth for the local
Prefs.AdvertiseRoutes. tailscale set --advertise-routes is already
rejected for blueprint-bound nodes (see
cmd/tailscale/cli/blueprint_lock.go) so the prefs slot is
effectively under the blueprint's control; rewriting it from the
netmap is the right thing to do.

Reconciliation runs at the tail of setNetMapLocked. When it spots
a delta, it persists the new prefs via b.pm.SetPrefs, refreshes
b.hostinfo through the existing applyPrefsToHostinfoLocked path,
and pushes the new Hostinfo to controlclient via
doSetHostinfoFilterServices. The result is that the admin
Machines page sees the freshly-advertised subnets within one
map-poll of an ACL save touching the blueprint's serves.ipsets --
no leave/rejoin required.

Updates #cleanup

Signed-off-by: Kabir Sikand <[email protected]>
2026-05-18 18:03:17 +00:00
Kabir Sikand 0fdc0dc6c9 tailcfg: add BlueprintConfig.Routes for advertised subnet routes
ServeIPSets carries the symbolic "ipset:foo" names from the
blueprint definition, which is useful for operator debugging but
useless to the client: the client never sees the policy's
top-level "ipSets" block and therefore cannot resolve those names
to concrete prefixes. As a result Blueprints v1 quietly accepted
"serves.ipsets" in the ACL, projected the names, and the bound
node advertised nothing.

Add a sibling Routes []netip.Prefix that the control plane
populates by resolving each ipset name to its prefixes at
projection time. The bound client reads Routes (not ServeIPSets)
when reconciling Prefs.AdvertiseRoutes, and ServeIPSets stays on
the wire purely for operator visibility.

Regenerate the Clone and View helpers (hand-edited; corp pin
predates the matching cloner/viewer pass).

Updates #cleanup

Signed-off-by: Kabir Sikand <[email protected]>
2026-05-18 18:02:33 +00:00
Kabir Sikand 15652c4e27 cmd/tailscale/cli: kick off login after Start in tailscale join
LocalClient.Start applies prefs and stashes the auth key but does
not actually drive a login: when the daemon has no node key it
transitions NoState -> NeedsLogin and waits. tailscale up handles
this by calling StartLoginInteractive immediately after Start when
HaveNodeKey is false (see cmd/tailscale/cli/up.go:683-688). join
omitted that call, so the join command would print "Bound to
blueprint bp:<id>" while the daemon silently sat in NeedsLogin
without ever registering the node against the control plane.

Always kick the login from join. The earlier status check refuses
to run if BackendState is Running, so by the time we reach Start
we know we are doing a fresh registration; there is no
HaveNodeKey case worth preserving.

Updates #cleanup

Signed-off-by: Kabir Sikand <[email protected]>
2026-05-18 17:48:42 +00:00
Kabir Sikand 7e5619aee8 cmd/tailscale/cli: add --login-server to tailscale join
Without this flag the operator has to "tailscale up
--login-server=URL --force-reauth" first, then "tailscale logout",
then "tailscale join" -- because join allocates fresh Prefs via
ipn.NewPrefs() whose ControlURL defaults to controlplane.tailscale.com
and "tailscale set" intentionally does not expose ControlURL. That
sequence is awkward and easy to forget when iterating against a
devcontrol on a non-default URL.

Add the flag directly to join. When set, it populates the new
Prefs.ControlURL the daemon will use to register the node;
defaulting to empty preserves the existing "use whatever the daemon
already has configured" behaviour.

The flag is independent of the "?baseURL=" attribute on the OAuth
client secret, which routes the auth-key exchange step. Both are
needed when the dev control plane sits on a non-default URL.

Updates #cleanup

Signed-off-by: Kabir Sikand <[email protected]>
2026-05-18 17:33:02 +00:00
Kabir Sikand a3467e680f cmd/tailscale/cli: synthesize tag:bp//<id> for join's authkey exchange
HookResolveAuthKey requires a non-empty tag set on the OAuth-client-
secret to auth-key exchange (see feature/oauthkey/oauthkey.go), but
"tailscale join" intentionally omits --advertise-tags: the blueprint
owns the node's tag set. The join command therefore hit the hook's
"oauth authkeys require --advertise-tags" rejection before the auth
key was ever requested from the control plane.

Fill the tag in at the join call site from the resolved blueprint id:
the auto-generated tag for blueprint <id> is "tag:bp//<id>" (see
tailcfg.BlueprintTagNamespacePrefix), which is exactly the AuthTag
the paired OAuth client server-side is scoped to. The hook accepts
the request and the existing scope-mismatch validator on the corp
side catches any later drift.

Updates #cleanup

Signed-off-by: Kabir Sikand <[email protected]>
2026-05-18 16:46:21 +00:00
Kabir Sikand 2d93449efa control/controlclient: handle Node BlueprintID/BlueprintConfig in peerChangeDiff
peerChangeDiff iterates every Node field reflectively and panics if
it encounters one it does not know how to compare. After
tailcfg.Node grew BlueprintID and BlueprintConfig (capver 139), it
needed cases for both. Any change to either field forces a peer
re-fetch rather than producing a delta PeerChange, matching how
other identity-shaping fields like Tags and MachineAuthorized are
handled.

Updates tailscale/corp#cleanup

Signed-off-by: Kabir Sikand <[email protected]>
2026-05-15 22:21:52 +00:00
Kabir Sikand 3ac573cc85 BLUEPRINTS-FOLLOWUPS: capture client-side v1 deferred items
Surfaced during v1 build:

  * tailscale leave does not blocking-wait for server-side reaping.
  * No GUI client surface; v1 is CLI-only by design.
  * tailscale set rejection is CLI-only; LocalAPI EditPrefs can
    still bypass the lock. Loopback-only, so the threat is local
    root, but defense-in-depth would push the check into the daemon.
  * clientmetric doesn't support labels, so the join-attempts
    fine-grained breakdown is flat counters rather than labeled.

Updates #cleanup

Signed-off-by: Kabir Sikand <[email protected]>
2026-05-15 19:53:21 +00:00
Kabir Sikand 951ea09722 BLUEPRINTS: add user-facing v1 documentation
Document the OSS client surface for v1: which files implement which
piece (tag namespace, Node fields, capver bump, Prefs.BlueprintID,
join/leave/set), which client metrics exist, and what the v1
limitations are.

Companion to BLUEPRINTS-CHECKLIST.md (engineering tracking) and
BLUEPRINTS-NOTES.md (recon). The corp half of v1 has its own
BLUEPRINTS.md covering the control-plane side.

Updates #cleanup

Signed-off-by: Kabir Sikand <[email protected]>
2026-05-15 19:51:45 +00:00
Kabir Sikand 3223269303 ipn,cmd/tailscale/cli: add tailscale join/leave and blueprint locking
Three pieces, intentionally landed together because the join->set lock
contract is what makes blueprint-bound nodes safe:

  - ipn.Prefs grows a BlueprintID field plus a MaskedPrefs.BlueprintIDSet
    mask bit. A node brought up via "tailscale join" carries BlueprintID
    for the lifetime of the binding; "tailscale leave" clears it.
    Prefs.IsBlueprintBound is a one-line read for callers that just
    need the bit.

  - cmd/tailscale/cli adds the "join" and "leave" subcommands. join
    accepts --blueprint=bp:<id> and --auth-key=<oauth-secret>; under
    the hood it reuses the existing HookResolveAuthKey exchange path
    (OAuth client secret -> auth key) and then calls Start with a
    Prefs whose BlueprintID is set. leave clears BlueprintID and
    logs the node out, matching the spec's "ephemeral when bound"
    semantics.

  - cmd/tailscale/cli/blueprint_lock.go enforces the spec's
    locked-field rejection on "tailscale set" for any blueprint-bound
    node. The error message is the verbatim spec text, varying only
    by which field was touched (Routes, Advertised tags, SSH, etc).
    Inserted in runSet right after curPrefs is fetched so it fires
    before any local validation work.

Client metrics (clientmetric) cover the v1 join/leave/set-rejected
counters and the blueprint_bound gauge so we can answer "is anyone
using this" without server-side correlation.

Updates #cleanup

Signed-off-by: Kabir Sikand <[email protected]>
2026-05-15 19:43:19 +00:00
Kabir Sikand 7339d10649 tailcfg: add Node.BlueprintID + BlueprintConfig and bump capver
A blueprint-bound node carries a projection of the bound Blueprint's
ACL definition delivered via the existing MapResponse poll. Add
Node.BlueprintID (the bound blueprint's name) and Node.BlueprintConfig
(the projected v1 subset: tags, serves.apps, serves.ipsets, attrs) so
the control plane has somewhere to put the projection and the client
has somewhere to read it from.

BlueprintConfig.Equal is required so the client can detect when a
re-projection changes anything and re-apply local state. Node.Equal is
extended to include both new fields.

The viewer/cloner codegen directives now include BlueprintConfig so
the generated NodeView/Clone treat it as a first-class field.

Bump CurrentCapabilityVersion to 139 so the server can avoid sending
these fields to clients that would ignore them.

Updates #cleanup

Signed-off-by: Kabir Sikand <[email protected]>
2026-05-15 19:13:53 +00:00
Kabir Sikand 2c4e1f0907 tailcfg: add tag:bp// blueprint tag namespace
Recognize the new "tag:bp//<id>" tag namespace introduced by the
Blueprints feature. The double slash is intentional: it visually
marks tags whose provenance is a blueprint rather than a
user-authored tagOwners entry, so operators can tell at a glance
which tags came from a blueprint binding.

The <id> portion uses the same character rules as a regular tag name
(letter-start, alphanumerics, and dashes). The "bp//" namespace prefix
itself is matched exactly: "tag:BP//foo" and "tag:bpx//foo" are
rejected.

Add helpers IsBlueprintTag and BlueprintIDFromTag so the rest of the
code base can branch on the new namespace without re-implementing the
parse.

Updates #cleanup

Signed-off-by: Kabir Sikand <[email protected]>
2026-05-15 18:23:35 +00:00
Kabir Sikand df1f497a92 BLUEPRINTS: add v1 working docs
Working scratch documents for the Blueprints v1 implementation:

* BLUEPRINTS-CHECKLIST.md: enumerates every spec requirement that must
  be true before v1 is done, so progress is auditable.
* BLUEPRINTS-NOTES.md: read-only reconnaissance of the existing OSS
  systems that Blueprints touches (CheckTag, CLI structure, set
  validation, ipnlocal/prefs, tailcfg types, clientmetric). Captured
  before any production change to avoid re-reading the same files
  later.
* BLUEPRINTS-FOLLOWUPS.md: deferred-to-v2 list, primed from the spec.
  Anything tempting that surfaces during the build gets appended here
  instead of expanding scope.

Updates #cleanup

Signed-off-by: Kabir Sikand <[email protected]>
2026-05-15 18:18:52 +00:00
Noel O'Brien 894ff5d8ee cmd/hello: split css and js into separate files (#19771)
Move the inline CSS and JS into separate files to be more friendly
to Content Security Policies. ServeHTTP is updated to serve these
assets from the '/static/' path.

Updates tailscale/corp#32398

Signed-off-by: Noel O'Brien <[email protected]>
2026-05-15 09:37:22 -07:00
Alex Chan 0cb432ed84 all: update more references to Tailnet/Network Lock
Updates tailscale/corp#37904

Change-Id: I09e73b3248b9ddf86dafe33dfb621bd560f6596d
Signed-off-by: Alex Chan <[email protected]>
2026-05-15 16:23:50 +01:00
Fernando Serboncini c355618e73 wgengine/router/osrouter: skip netfilter add-ons when chain setup fails (#19757)
linuxRouter has two blocks (connmark rules and the CGNAT drop rule) that
gate on cfg.NetfilterMode, the requested config state. This may cause an
error when setNetfilterModeLocked fails, since it may keep assuming this
config is valid.

We now gate both blocks on r.netfilterMode, matching the pattern used by
SNAT, stateful, and loopback paths.

Fixes #19737

Change-Id: Ia6003a082db99c376e662132d725661afbac0ee9

Signed-off-by: Fernando Serboncini <[email protected]>
2026-05-15 09:32:30 -04:00
License Updater 1d3562b314 licenses: update license notices
Signed-off-by: License Updater <[email protected]>
2026-05-14 21:04:41 -07:00
Brad Fitzpatrick ef1bb5ac16 util/cibuild, cache_key_test: skip TestTsgoRevInCacheKey outside Tailscale CI
cibuild.On() returns true for any CI environment that sets CI=true,
including Alpine Linux's package build CI. TestTsgoRevInCacheKey was
guarded by cibuild.On() (or use of tsgo), so it ran under Alpine's CI
with stock Go, where go.toolchain.rev isn't blended into build cache
keys, and unsurprisingly failed.

Add cibuild.OnTailscaleCI, which keys off GITHUB_REPOSITORY_OWNER to
distinguish tailscale/tailscale's own GitHub Actions CI from arbitrary
downstream CI, and use it in TestTsgoRevInCacheKey.

Fixes #19754

Change-Id: Id31cfe71903a235f1460dca1e2fdf334e3ba1ee5
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-05-14 15:55:05 -07:00
Brad Fitzpatrick fa49009eee wgengine: simplify ResetAndStop, drop drain loop
Since f343b496c3 ("wgengine, all: remove LazyWG, use wireguard-go
callback API for on-demand peers"), Reconfig is fully synchronous:
magicConn.UpdatePeers, wgdev.RemovePeer, router.Set, and dns.Set all
return when the work is done, and the peer list is updated under
wgLock before Reconfig returns. So after Reconfig with empty configs,
len(st.Peers) is already 0.

The old loop also waited for st.DERPs to drain to 0, but UpdatePeers
only edits maps; active DERP connections idle out on their own
timeout. The sole caller (LocalBackend.stopEngineAndWait) doesn't
inspect st.DERPs anyway; it just hands the Status to
setWgengineStatusLocked. So the drain-wait was for nothing observable
and could theoretically (or at least appear to readers to) loop
forever holding b.mu. Remove that reader confusion by removing
the backoff loop entirely.

Updates #19759

Change-Id: Ibfac3f0baabcad7604b713c934a8fc37932e0a50
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-05-14 15:45:38 -07:00
Brad Fitzpatrick 93440604e0 tstest/natlab/vmtest: add TestPeerRelay
Add a VM-based natlab test that exercises the peer-relay feature
(feature/relayserver) end-to-end across three Tailscale nodes whose
network topology makes a direct A<->B UDP path impossible: both peers
are behind HardNAT (FreeBSD/pfSense-style endpoint-dependent NAT) with
no port-mapping services, while the relay node is behind One2OneNAT so
its STUN-discovered WAN endpoint is reachable from both peers. The
test enables the relay server via EditPrefs, then waits for an a->b
PingDisco whose PingResult.PeerRelay is set (proving magicsock chose
the peer-relay path, not DERP), and finally asserts that the relay's
DebugPeerRelaySessions LocalAPI reports the session.

The existing TestPeerRelayPing in tstest/integration runs three
tailscaled processes on the loopback interface with no NATs; this new
vmtest covers peer relay through real per-VM kernels and NATs.

To wire control-server capabilities into vmtest, also add a
PeerRelayGrants() EnvOption (sibling of AllOnline,
SameTailnetUser) that flips testcontrol.Server.PeerRelayGrants so the
wildcard packet filter grants tailcfg.PeerCapabilityRelay and
PeerCapabilityRelayTarget; without those caps magicsock won't consider
any peer a candidate relay.

Updates #13038

Change-Id: Ib3440b83ec442da0d3b89ffa48ceea9398ea9062
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-05-14 14:47:29 -07:00
Andrew Lytvynov 9437a634e6 scripts/installer.sh: handle Zorin OS versions separately from Ubuntu (#19758)
Their version scheme is different, even though the OS is based on
Ubuntu. We need to check Zorin's version numbers to pick the right
APT_KEY_TYPE.

Updates #18925

Signed-off-by: Andrew Lytvynov <[email protected]>
2026-05-14 14:04:04 -07:00
M. J. Fromberger 4eb977413a tstest/natlab/vmtest: add helpers for fatal step errors (#19753)
In a lot of places, we construct an error to End a step, then immediately log
it to the governing test as test fatal. Save ourselves a bit of boilerplate by
putting methods on Step for that.

There are a couple cases this doesn't cover, e.g., where we construct the Step
outside a subtest that wants to fail individually, but it helps enough to pay
for its lines.

Updates #13038

Change-Id: I71f9900942962de16609b6b198d3ba13d6958a5f
Signed-off-by: M. J. Fromberger <[email protected]>
2026-05-14 09:24:47 -07:00
Claus Lensbøl 8203edc099 .github/workflows: change natlab test trigger label (#19750)
The label "natlab" is a bit confusing and also used for other things.
Instead, change the trigger label to "run-natlab-tests".

Updates #13038

Signed-off-by: Claus Lensbøl <[email protected]>
2026-05-14 11:53:13 -04:00
Fernando Serboncini 2a06fb66d0 cmd/cloner: preserve nil-valued entries when cloning map (#19749)
The codegen path for map-of-slice-of-pointer fields, skipped
nil-valued entries. That dropped the key from the map.

This broke how dns.Config.Routes uses nil values sentinels.

Fixes #19730
Fixes #19732
Fixes #19746
Fixes #19744

Change-Id: Ic6400227f4ab21b3ca0e8c0eeecf9b83d145a9ab

Signed-off-by: Fernando Serboncini <[email protected]>
2026-05-14 10:30:59 -04:00
Mike O'Driscoll 48919f708b util/linuxfw: fix nftables endianness and add connmark conditional check (#19725)
Fix the following issues:

1. Endianness Bug: The nftables runner used hardcoded
   big-endian byte arrays for firewall mark values (0xff0000, etc.), breaking
   bitwise operations on little-endian systems (all x86/x64, ARM). This caused
   connmark save/restore rules to silently fail. Fixed by using
   binary.NativeEndian to generate correct byte order for the host system.

2. Connmark Restore Conditional Check: The connmark restore
   mechanism unconditionally overwrote packet marks, even when Tailscale
   hadn't set any mark bits in conntrack. This destroyed mark bits set by
   other systems (VPNs, policy routing, vendor flags), breaking coexistence.
   Fixed by adding a conditional check to only restore when (ct mark &
   0xff0000) != 0, preventing the worst case of wiping all marks to zero.

Changes:
- util/linuxfw/linuxfw.go: Added nativeEndianUint32() helper and updated
  all mask functions to use native byte order instead of hardcoded bytes
- util/linuxfw/nftables_runner.go: Added conditional check in
  makeConnmarkRestoreExprs() to only restore when ct mark has Tailscale
  bits set; added detailed comment about bit preservation limitations
- util/linuxfw/iptables_runner.go: Added conditional check using -m
  connmark ! --mark to match nftables behavior
- Tests updated: Fixed byte-level regression tests to expect little-endian
  byte sequences and verify the new conditional check

Note: Perfect bit preservation in nftables remains challenging
due to nftables expression VM limitations. The current implementation
prevents the critical case of wiping marks with zero.

Updates #3310
Fixes #11803
Related to #8555

Signed-off-by: Mike O'Driscoll <[email protected]>
2026-05-14 09:11:24 -04:00
James Tucker e7415e6393 util/eventbus: unify Subscriber/SubscriberFunc cores; structural symmetry
Brings Subscriber[T] in line with the same non-generic-core pattern already
applied to SubscriberFunc[T] and Publisher[T]:

  - Renames subscriberFuncCore to subscriberCore and shares it between
    Subscriber[T] and SubscriberFunc[T]. Both typed facades hold a
    *subscriberCore plus their respective per-T delivery state
    (Subscriber: chan T; SubscriberFunc: nothing, the user callback is
    captured in the dispatch closure).

  - The bus's outputs map and subscriber-interface itab key on
    *subscriberCore for both subscriber kinds, so adding a new Subscribe[T]
    call site no longer pays a per-T itab, dictionary, or equality function
    for the subscriber-interface side.

  - Subscribe[T] now hoists the non-generic constructor portion into
    newSubscriberCore (timer setup, core allocation, cached type/typeName,
    unregister method-value), matching SubscribeFunc.

The dispatch loop is intentionally NOT extracted to a non-generic helper for
Subscriber[T], unlike SubscriberFunc[T]. The reason is the typed channel send
'case s.read <- t:' must appear lexically inside the select; the only way to
lift it into a non-generic loop is to bridge typed and untyped via a per-event
goroutine, which costs ~2.7x throughput on BenchmarkBasicThroughput. We keep
dispatchTyped on the generic facade and accept the per-shape stencil cost as
the cheaper alternative.

Symbol-level effect on tailscaled (linux/amd64, measured via
`go tool nm -size`):

  Before:
    (*Subscriber[T]).dispatch
      2 shape stencils:        1,682 + 1,549 = 3,231 B
      3 thin per-T wrappers:   124 B each   =   372 B
      2 deferwrap1 helpers:    62 B each    =   124 B
      total:                                 3,727 B

  After:
    (*Subscriber[T]).dispatchTyped
      2 shape stencils:        1,678 + 1,582 = 3,260 B
      0 per-T wrappers (replaced by closure stored on core)
      2 deferwrap1 helpers:    62 B each    =   124 B
      total:                                 3,384 B

  dispatch path .text delta:                   -343 B (-9.2%)

Per-shape stencils are ~1,600 B (.text body) + ~1,100 B (pclntab) =
~2,700 B each on production tailscaled. The shape count matches before/after
(two distinct GC shapes for the Subscriber[T] event types in this binary).
What changes is that the per-T thin wrappers are eliminated because
Subscriber[T] no longer implements the subscriber interface directly.

Whole-binary section deltas:

  .text:        -2,304 B  (includes the dispatch savings plus other
                            small downstream effects)
  .rodata:        +512 B  (additional closure-type metadata)
  .gopclntab:   -2,981 B  (fewer per-T compiled functions => less metadata)

Stripped tailscaled (linux/amd64): no change at the file level (the savings
fall below the linker's section-alignment boundary). Unstripped builds shrink
by ~2,900 B.

Behavior is unchanged:
  BenchmarkBasicThroughput:       2,161 ns/op,  0 B/op,  0 allocs/op
  BenchmarkBasicFuncThroughput:   2,493 ns/op, 144 B/op, 2 allocs/op
  BenchmarkSubsThroughput:        3,727 ns/op,  0 B/op,  0 allocs/op

Updates #12614

Change-Id: I97918ec68bd2cdb15958bbfd7687592b39663efe
Signed-off-by: James Tucker <[email protected]>
2026-05-13 17:36:30 -07:00
Brad Fitzpatrick dc323b1351 derp/derpserver: collapse clients and clientsAtomic into one hashtriemap
Server.clientsAtomic was introduced in 6b729795c3 as a lock-free
mirror of Server.clients to skip Server.mu on the packet send hot
path. This drops the non-concurrent map and makes all the existing
callers of the old plain map just use the concurrent map, but still
holding Server.mu.

BenchmarkLookupDestHashTrie is unchanged at ~2ns/op.

Fixes #19726

Signed-off-by: Brad Fitzpatrick <[email protected]>
Change-Id: I0894e4d86914d152b9b5fef969a3184bcb96f678
2026-05-13 16:57:26 -07:00
Nick Khyl 4d68493144 health: avoid publishing health.Change when warnable visibility remains unchanged
Warnables with a non-zero TimeToVisible are only published on the eventbus when
they remain unhealthy long enough to become visible.

However, we still publish a health.Change when a warning that was never visible
(and was never published to the eventbus) becomes healthy.

This PR fixes that and reduces churn when there is no actual state change. In
particular, it avoids unnecessary IPN bus notifications sent to GUI/CLI clients,
captive portal detection, etc.

Updates tailscale/corp#39759 (noticed while working on it)

Signed-off-by: Nick Khyl <[email protected]>
2026-05-13 17:02:35 -05:00
Adriano Sela Aviles 41286c2b56 ipn/ipnlocal,tsd: add NoiseRoundTripper to tsd.Sys
Adds a new NoiseRoundTripper field to tsd.Sys
to expose an http.RoundTripper to make requests
over the control plane Noise connection.

This will be used in PAM use cases soon.

Updates tailscale/corp#41800

Signed-off-by: Adriano Sela Aviles <[email protected]>
2026-05-13 14:56:28 -07:00
Nick Khyl 32f984f54c net/dns: create a new hosts file if it doesn't exist on Windows
A missing hosts file is not a fatal error. We should log it, but still proceed
and create a new one instead of failing the DNS reconfiguration completely.

Fixes #19733

Signed-off-by: Nick Khyl <[email protected]>
2026-05-13 16:10:36 -05:00
Claus Lensbøl bb47ea2c6b tstest/natlab/vmtest: start migrating old natlab tests to vmtest (#19727)
Instead of having two entry points for running natlab tests, start
converting the connectivity tests to use the vmtest framework.

Grid and pair tests have yet to be moved over.

Updates #13038

Signed-off-by: Claus Lensbøl <[email protected]>
2026-05-13 16:44:53 -04:00
Fran Bull 3a6261b79b feature/conn25: keep addrAssignments through pool reconfig
Fixes tailscale/corp#40250

Signed-off-by: Fran Bull <[email protected]>
2026-05-13 11:00:47 -07:00
Simon Law e4e59a2af0 wgengine/netstack: stop inject goroutine from leaking in Impl.Start (#19721)
This patch fixes a data race in wgengine/netstack that surfaced while
running both TestTCPForwardLimits and TestTCPForwardLimits_PerClient.
Because these two tests both setup the TS_DEBUG_NETSTACK envknob, a
race happens because netstack.Impl.Close leaked its inject goroutine.
The inject goroutine also reads the TS_DEBUG_NETSTACK envknob, so if
it is still running when the next test starts, then it will break.

This patch also cleans up the tests a bit, ensuring that neither of
them run in T.Parallel. It also adds a T.Cleanup call to clear the
envknob.

Fixes #19720

Signed-off-by: Simon Law <[email protected]>
2026-05-13 08:13:40 -07:00
Simon Law 6467f0d067 ipn/ipnlocal: fix minor typo in shouldUseOneCGNATRoute (#19719)
This fixes a log message where ipn/ipnlocal.shouldUseOneCGNATRoute
would claim that an android machines was actually macOS.

Updates #cleanup
Updates #19652

Signed-off-by: Simon Law <[email protected]>
2026-05-12 21:55:29 -07:00