Commit Graph
4903 Commits
Author SHA1 Message Date
Kristoffer Dalby 1cd93ec432 policy: reduce merged destination prefixes to the node's own addresses
Adjacent node addresses merge into one prefix, and each node's filter
kept all of it. A prefix made only of node addresses now shrinks to the
node's own; a prefix the policy wrote, or one the node routes, stays.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 6dd0656f17 api, policy/v2: refuse route prefixes with host bits
Routes are matched as written, so such a prefix never equals the one a
client announces. The approval APIs answer 400 and autoApprovers refuses
it at load and write, with Tailscale's text.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 05039d3398 policy, state: log only the routes auto-approval adds 2026-11-02 19:15:40 +01:00
Kristoffer Dalby c8b8ce89e8 poll: hold the map session's node as a view 2026-11-02 19:15:40 +01:00
Kristoffer Dalby 836d03dee2 policy/matcher: compare cached policy and node route ranges
Binary-search immutable policy ranges and normalize node routes once.
Large misses and self/via scans improve; small or early matches can slow,
and global policies pay extra normalization and allocation costs.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 452e14d461 policy: look up approved routes in a set when auto-approving
Avoid scanning the growing approval list for every announcement.
Use the sorted current routes when identifying additions.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 71dc0c1c58 types, state: derive and reduce approved routes once
Derive subnet and exit routes together, once each in announcement order.
Reuse matcher membership while preserving HA co-router visibility.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 0e7515eab9 state, policy/v2: classify only effective route changes
Compare announced-and-approved routes only when immutable route inputs
change. Publish Hostinfo without unnecessary peer adjacency rebuilds.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 4342883bd4 policy/v2, state: elect primaries by oldest control session
A router that reconnects joins as a standby; one that kept its session
takes its routes back once available again, as on Tailscale. Both the
global and the via election use it, in place of anti-flap stickiness.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 555caf7c2b types: add when a node's run of control sessions began 2026-11-02 19:15:40 +01:00
Kristoffer Dalby e0717bc116 state, policy/v2: elect available routers and retain unavailable routes
Recompute via elections on health changes and check online state and expiry.
With no available router, retain the previous primary or lowest-ID approver;
exclude routers the prober marked unreachable.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 25a01070e9 state: keep HA health probes active without delaying unrelated routers
Probe lone unhealthy advertisers. Defer results only for routers whose
routes tie them to a router still awaiting its probe.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 8e876eef32 hscontrol, types: strip trailing slashes from server_url 2026-11-02 19:15:40 +01:00
Kristoffer Dalby 41067c7e6e db: bound legacy hash verification and reload verified credentials
Limit the wait for a verification slot and reload the credential after
verification so concurrent revocation or deletion remains effective.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 34653a1bd9 db: disable GORM's prepared statement cache on SQLite
database.gorm.prepare_stmt is now ignored, with a startup warning.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby d4ce109806 policy/v2: refuse check SSH rules with tag sources
A check asks the source's user to log in again, and a tagged node has
none. Tailscale SaaS refuses the rule; headscale accepted it.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 79daa3142f policy/v2: bound grant destination expansion
Require one port or range per grant IP entry. Reject more than 100,000
declared destination/port-range combinations on every parse.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 1c833ba394 policy/v2: evaluate policy tests from compiled snapshots
Parse filters once and index SSH rules by source. Evaluate tests against
user and node snapshots before taking the write lock.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 33b57fdeb2 policy/v2: need every dst node for a tests accept, no range sources
An accept passes only when each node behind the dst is reached, as on
Tailscale SaaS; a deny keeps its rule. A CIDR, "*" or autogroup:tagged
src names no user or host, so its test fails.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 0cdd52068b policy/v2: bound failure reports and name SSH test aliases
Keep source/destination labels and repeated destination occurrences.
Limit reports to 100 lines and labels to 256 bytes.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby cebe5fc903 policy/v2: validate SSH test sources and destinations like SaaS
Reject address-range sources and autogroup:member destinations.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby e6d04cd79a policy/v2: map login 0 to no local user in SSH rules
Every rule that maps root now carries "0": "", as Tailscale SaaS writes
it, also when the policy lists "0".
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 0bfae13d6d policy/v2: normalize emitted ACL and via destinations
Write single-address via destinations bare. Deduplicate repeated ACL
destination/port pairs while preserving grant duplicates.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby f2df44295a state, db: validate and store the current policy before installing it
Reject empty input. Validate without changing live state, then store and
install under one lock; prune old rows only with a successful write.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 4c8330c936 policy/v2: resolve tag owners one hop deep
A user claims only the tags it owns directly, and a tag owns only the
tags that list it, as on Tailscale SaaS. With no walk left, validate
names an undefined owner once, with the tag that lists it.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 6fd3dbd0a2 policy/v2: evaluate sshTests sources through the nodes they cover
A src was expanded to every address it names, so "*" or ::/0 never
finished. Principals are node addresses: keep those plus one stand-in.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 2c7a9a22f6 policy/v2: reuse compiled policy data across rules and nodes
Cache shared source keys, compile SSH rules and principals once, and
resolve groups once on a policy copy.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 361b5e6556 policy/v2: keep via steering bounded across route and user changes
Refresh clients when the last via grant disappears. Match each ACL once,
deduplicate routes, and elect once per route the peer actually serves.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 033dcdf43b state: serialise policy reloads
Load and install the stored policy as one step, so an older
reload cannot install its document over a newer one.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 18791456a3 integration: keep HA cable-pull routers off each other's routes
A router holding the other's route for its docker subnet in table 52
cannot be reattached: docker resolves the gateway through tailscale0.
Replaces the phase 4a wait that covered one case of it.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 99d8997e47 mapper: count only the batcher's goroutines in lifecycle tests
runtime.NumGoroutine deltas moved when goroutines left by earlier
tests exited mid-test. Label the batcher's goroutines and count those.
2026-11-02 16:09:00 +01:00
Kristoffer Dalby 5b578fe95f policy/v2: recapture SSH data captures
Every ssh_results row captured again from SaaS. SaaS now maps login "0"
to no local user in rules that map root, quotes a refused checkPeriod as
written and rewords its tailnet-domain refusal.
2026-11-02 16:09:00 +01:00
Kristoffer Dalby 363ba7be44 hscontrol, servertest: add key list scope golden data
Read-only and key-making OAuth tokens of each tag set list auth keys
with and without all=true, over admin- and token-made keys of every tag
relation, one admin key made after the token-made ones.
2026-11-02 16:09:00 +01:00
Kristoffer Dalby e8b44c653f servertest: add user role dispatch golden data
An admin role change under autogroup:admin, mirrored as a user rename;
peers, filter and frames per node per step, and v2 device users.
2026-11-02 16:09:00 +01:00
Kristoffer Dalby 1318f2802f servertest, state: add node name golden data
Labels under taken hostnames, case-only renames, hostname changes, long
hostnames and a Service's name; API, peer and self per step, and State
labels as a restart would load them.
2026-11-02 16:09:00 +01:00
Kristoffer Dalby a34eb4f535 policy/v2, servertest: add policy generation golden data
One policy over joins, a via router swap, an admin tag, a delete and a
group edit; filter, SSH, peers and routes per step, and the manager
against a fresh one.
2026-11-02 16:09:00 +01:00
Kristoffer Dalby 349c4db600 servertest: add hidden peer and route announcement golden data
What a node hears of peers it cannot see, and what a router's peers hear
of routes it announces; presence, removals, peers and routes per step.
2026-11-02 16:09:00 +01:00
Kristoffer Dalby 20a1855147 servertest: count map frames per client
Counts ControlTime events, so frames that leave the netmap as it was,
or that a delta client applies in place, still show.
2026-11-02 16:09:00 +01:00
Kristoffer Dalby b4217925c9 servertest: recapture map delivery golden data
The probe now bounds snapshot reads and keeps feature refusals as data.
SaaS now sends appc and sshd laptop's unchanged entry on the restore.
2026-11-02 16:09:00 +01:00
Kristoffer Dalby d84c1927f9 servertest: wait for each replayed join before the next
Polls start in the background, so a later router could come online
first and keep the global primary SaaS gave the first.
2026-11-02 16:09:00 +01:00
Kristoffer Dalby 75040798e4 servertest: count deleted nodes in replayed peer views
Only nodes still in State resolved to an alias, so a client that kept
a deleted peer passed the peers and route owner checks.
2026-11-02 16:09:00 +01:00
Kristoffer Dalby f4af5e0286 servertest: recapture via HA failover golden data
The probe now bounds its reads and stops when a step loses data.
Route owners and peers match the first capture at every step.
2026-11-02 16:09:00 +01:00
Kristoffer Dalby c979d82c50 hscontrol, servertest: fail on any unread pending login or expiry entry
Each map serves one capture, so a misspelled capture name never went
stale.
2026-11-02 16:09:00 +01:00
Kristoffer Dalby e4752f06c5 servertest: require a map on each stream an expiry replay opens
The cached netmap outlives a stream, so a refused re-poll passed.
2026-11-02 16:09:00 +01:00
Kristoffer Dalby 99af4aa8a5 servertest: compare filter and SSH rules in expiry replays
Changed-or-not alone let empty rules pass for SaaS's new ones.
2026-11-02 16:09:00 +01:00
Kristoffer Dalby 44c6810b10 servertest: recapture ephemeral, expiry and pending login golden data
The expiry file now holds the shared policy, DNS and observer setup.
Outcomes match the first capture; collection was seen one poll earlier.
2026-11-02 16:09:00 +01:00
Kristoffer Dalby 1d48f67534 servertest: judge ephemeral collection apart from the poll that saw it
Killed nodes are checked once at the last read, for devices left and
whether the observer lost them since the kill.
2026-11-02 16:09:00 +01:00
Kristoffer Dalby 77f0fc921d hscontrol: compare API replay fields per object
One aggregate per field hid a partial fix. Device users are compared,
and headscale's oauthClientId resolves to the SaaS label.
2026-11-02 16:09:00 +01:00
Kristoffer Dalby b69a7e3df7 hscontrol: check API replay outcomes apart from status
A listed status hid a call flipping between allowed and refused, and
validate refusals SaaS answers with 200 went unchecked.
2026-11-02 16:09:00 +01:00
Kristoffer Dalby bd5ae1e0fb servertest: recapture v2 OAuth and policy API golden data
Tag writes are read back once the tags hold, and both files carry a
baseline snapshot. Statuses and read-backs match the first capture.
2026-11-02 16:09:00 +01:00