Commit Graph
4900 Commits
Author SHA1 Message Date
Kristoffer Dalby 048fcefbdb poll: hold the map session's node as a view 2026-11-02 17:46:52 +00:00
Kristoffer Dalby 691d9d6b1e 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 17:46:52 +00:00
Kristoffer Dalby e72476f0ae 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 17:46:52 +00:00
Kristoffer Dalby 1ea702cdbe 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 17:46:52 +00:00
Kristoffer Dalby 5fd173178f 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 17:46:52 +00:00
Kristoffer Dalby edbb1fe9b6 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 17:46:52 +00:00
Kristoffer Dalby 7e5aa85601 types: add when a node's run of control sessions began 2026-11-02 17:46:52 +00:00
Kristoffer Dalby de8a0cc7eb 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 17:46:52 +00:00
Kristoffer Dalby 1c94588bf9 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 17:46:51 +00:00
Kristoffer Dalby f2d4029887 hscontrol, types: strip trailing slashes from server_url 2026-11-02 17:46:51 +00:00
Kristoffer Dalby 789d70f672 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 17:46:51 +00:00
Kristoffer Dalby 05ca808491 db: disable GORM's prepared statement cache on SQLite
database.gorm.prepare_stmt is now ignored, with a startup warning.
2026-11-02 17:46:51 +00:00
Kristoffer Dalby 170ae26ad7 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 17:46:51 +00:00
Kristoffer Dalby e3ecff567e 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 17:46:51 +00:00
Kristoffer Dalby f431dc1e65 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 17:46:51 +00:00
Kristoffer Dalby fa6b46bfd9 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 17:46:51 +00:00
Kristoffer Dalby 5527a30491 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 17:46:51 +00:00
Kristoffer Dalby e254fd798e policy/v2: validate SSH test sources and destinations like SaaS
Reject address-range sources and autogroup:member destinations.
2026-11-02 17:46:51 +00:00
Kristoffer Dalby b56b6dcae1 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 17:46:51 +00:00
Kristoffer Dalby cb706b1999 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 17:46:50 +00:00
Kristoffer Dalby d326143556 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 17:46:50 +00:00
Kristoffer Dalby 89d56419e2 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 17:46:50 +00:00
Kristoffer Dalby 61be050061 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 17:46:50 +00:00
Kristoffer Dalby 5307f64751 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 17:46:50 +00:00
Kristoffer Dalby 1b76d9071a 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 17:46:50 +00:00
Kristoffer Dalby 5db5f85d62 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 15:16:47 +00:00
Kristoffer Dalby 5f9a124174 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 15:16:47 +00: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
Kristoffer Dalby a21d725853 servertest, policy/v2: replay tag owner chain joins through registration
A key login never asks the policy about requested tags, so the joins are
checked where headscale decides them. OAuth mints stay at
TagOwnedByTags.
2026-11-02 16:09:00 +01:00
Kristoffer Dalby 8e3270b180 servertest: recapture re-authentication golden data
The probe now stops a refused login's retries; the replay disconnects
there too. Outcomes match the first capture, and user IDs are labels.
2026-11-02 16:09:00 +01:00
Kristoffer Dalby 70eb9366be servertest: fail on skip entries no lifecycle replay reads
Consumers check entries under their own capture only, so a bare or
misspelled key never went stale.
2026-11-02 16:09:00 +01:00