Commit Graph
11672 Commits
Author SHA1 Message Date
Brad Fitzpatrick 57436c4a70 ssh/tailssh, tstest/natlab/vmtest: expand Tailscale SSH test coverage
Add Docker integration tests for TCP and Unix forwarding, pty size,
resize and modes, session env, envknobs, x11 rejection, session
teardown, SessionDuration, policy changes and RuleExpires on active
sessions, Shutdown, host keys and utmp, and run every integrationtest
test in the Dockerfile. Extend the vmtest SSH tests to use real
OpenSSH clients across the tailnet for pty, sftp/scp, agent and port
forwarding, AcceptEnv, ControlMaster, large transfers, banners, user
mapping, revocation, check mode (via a new testcontrol handler),
recording, and the tailscale ssh CLI. Fix make sshintegrationtest,
which only ever tested one image and always exited 0, and trigger the
workflow on go.mod changes and a schedule.

Updates #13038
Updates tailscale/corp#50380

Signed-off-by: Brad Fitzpatrick <[email protected]>
Change-Id: Ie4fffad7e9298b6b77c3ec3a6ae81fd784d182ce
2026-11-10 23:24:32 +00:00
Nick Khyl 3bd67a8085 ipn/ipnlocal,logtail,net/netmon: subscribe to eventbus events by value
The eventbus routes events by exact type, and these three subscribers
took a pointer to an event type that is only ever published by value,
so they never ran. logtail could not detect the network coming back up
after an upload failure, LocalBackend never recorded or announced the
latest client version, and the magicsock portmapper log limiter never
reset after a major link change.

Updates #22307

Signed-off-by: Nick Khyl <[email protected]>
2026-11-10 13:47:01 -08:00
Brad Fitzpatrick e4825bd0db tstime/mono: add AtomicTime, remove Time.LoadAtomic and StoreAtomic
Time.LoadAtomic and StoreAtomic only worked on 32-bit platforms if
the field happened to be 64-bit aligned, which tstun and magicsock
each guarded with a test. AtomicTime wraps an atomic.Int64, so the
compiler guarantees its alignment, and the tests can go. Also use it
for tstime/rate's Limiter.next, which was an atomic.Int64 holding a
mono.Time.

Updates #cleanup
Updates #22290 (where this was discovered)

Change-Id: I02807906ed9be59446456853bccece6e32e472ed
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-11-10 13:04:27 -08:00
License Updater 3ff72edcd8 licenses: update license notices
Signed-off-by: License Updater <[email protected]>
2026-11-10 12:39:33 -08:00
Brad Fitzpatrick 5b6c39b94d tstime/rate: deny without locking while a Limiter has no tokens
wgengine/filter asks its accept-logging Limiter about every accepted
packet, so with tailscaled's TUN and UDP queues spread over CPUs
(tailscale/tailscale#22188), that Limiter's mutex took 11% of a subnet
router's CPU on a 128-CPU host, most of it contended. On a denial,
record when the next token is due, and deny before then without taking
the mutex. A denial with a backwards timestamp no longer rewinds the
bucket's last update time, which credited it with tokens it never
earned.

             │      old       │                 new                  │
             │     sec/op     │    sec/op     vs base                │
    AllowN       13.550n ± 0%    1.143n ± 2%  -91.56% (p=0.000 n=10)
    AllowN-8   108.6500n ± 4%   0.1497n ± 4%  -99.86% (p=0.000 n=10)
    geomean       38.37n        0.4137n       -98.92%

Updates #22188

Signed-off-by: Brad Fitzpatrick <[email protected]>
Change-Id: I928f64d3df7b51c6cac0da7dafe9ef5e71acaa05
2026-11-10 10:45:13 -08:00
Brad FitzpatrickandFredrik Fornwall 501037640d tsnet: build with minimal feature tags, add test
tsnet called the serve LocalAPI client and LocalBackend methods
unconditionally, so it didn't build with ts_omit_serve, which every
minimal feature set includes. Make those methods return
feature.ErrUnavailable when serve is omitted, as ListenFunnel and
ListenService now do too.

Declare tsnet's minimum feature set (netstack) as
featuretags.TSNetMin, add cmd/featuretags --tsnet to keep it, and add
a test that type-checks tsnet with it and a few other small feature
sets.

Fixes #22282
Updates #22283

Change-Id: I866fa34d052bfd437b1c9d3309063999d7ebb02c
Co-Authored-By: Fredrik Fornwall <[email protected]>
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-11-10 10:17:13 -08:00
kari-ts f6eb3f9dc7 ipn, feature/guivisibility: send incremental gui visibility updates (#22067)
This moves HiddenNetworkDvice policy out of ipnlocal and into an optional ipnext.
This adds a per-session notification hook that uses each watcher's effective policy snapshot to populate NodeGUIVisibility.
A full visibility snapshot is sent on initialization and policy changes, and on subsequent peer updates, only changed peers are evaluated.
The extension populates Notify.NodeGUIVisibility with the hidden peers
among the nodes the Notify covers: all peers when it carries Policy
(initially and on policy change), or the PeersChanged peers otherwise.
Absent means visible, so a Policy-bearing Notify replaces the client's
visibility state and a peer-change Notify updates only the changed peers.
No NodeGUIVisibilityChanges/Removed fields and no per-session node state
are needed: removed peers simply leave the client's peer set, and full
netmap updates already resend every peer alongside SelfChange.

When the feature isn't linked, the hook slice is empty and the fast path
in notifyForSessionLocked is unchanged. When the policy isn't configured,
the hook costs a snapshot lookup per session per Notify and sends nothing.

Updates tailscale/corp#44104

Signed-off-by: kari <[email protected]>
Signed-off-by: Nick Khyl <[email protected]>
2026-11-10 10:05:32 -08:00
chaosinthecrd 408f0d2b36 ipn,feature/acme,client/local: add tests for the cert-status localapi endpoint
Tests that the localapi cert-status/ handler checks read access and returns
the status as JSON, that LocalBackend.CertStatus goes through the hook, and
that feature/acme's hook reports the same missing, valid and expired results
as the C2N /tls-cert-status handler. Also tests that Client.CertStatus
returns ErrCertStatusUnsupported for a 404 and not for other errors.

Updates tailscale/corp#38175

Signed-off-by: chaosinthecrd <[email protected]>
2026-11-10 17:37:53 +00:00
chaosinthecrd a986bbfac2 ipn,feature/acme,client/local: add a read-only cert-status localapi endpoint
The localapi cert/ endpoint fetches a cert when none is cached, so polling it
triggers issuance. feature/acme can already report a cached cert without
contacting the CA, but only over the C2N /tls-cert-status path. This moves
that check into an extension method and serves it as localapi cert-status/,
with a matching Client.CertStatus, reporting Missing on a cache miss instead
of issuing. Client.CertStatus returns ErrCertStatusUnsupported (wrapping
errors.ErrUnsupported) when tailscaled has no cert-status endpoint.

Updates tailscale/corp#38175

Signed-off-by: chaosinthecrd <[email protected]>
2026-11-10 17:37:53 +00:00
dependabot[bot] 05930082da build(deps-dev): bump vite from 6.4.5 to 6.4.6 in /client/web
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.4.5 to 6.4.6.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v6.4.6/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v6.4.6/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-version: 6.4.3
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-11-10 09:56:08 -07:00
Mazdak Nasab ad8bad6114 feature/conn25: make client flow cleanups idempotent (#22280)
The cleanup returned by flowCreated decremented activeFlowCount on every
call, and its documented contract pushed the burden of calling it exactly
once onto the datapath. A caller that lost track and ran a cleanup twice
would undercount the flows still forwarding over the assignment, letting
popExpired reclaim both of its addresses back to the pools mid-connection,
or drive the count to -1, which can never again satisfy popExpired's
zero-flow test and so pins the assignment in the expiry heap and leaks
both addresses for the life of the process.

The cleanup now releases its hold at most once, guarded by a bool read and
written under c.mu alongside the decrement it protects. Repeat calls are
no-ops. The Conn25Datapath docs no longer ask callers to guarantee this.

No such double-call is reachable through FlowTable today: removeFlowLocked
deletes both cache entries, so NewFlow's second lookup misses, and the
capacity eviction takes lru.Back(), never the flow just pushed to the
front. This removes the class rather than a live bug.

Updates https://github.com/tailscale/corp/issues/50760

Change-Id: I1888f36eb8fdec9b219ccfd2d290dc4eb19c55a0

Signed-off-by: Mazdak Nasab <[email protected]>
2026-11-10 09:19:22 -07:00
Brad Fitzpatrick 444baf1ef5 ipn: make ServeConfig.IsFunnelOn false in ts_omit_serve builds
Funnel can't be on without serve. With the HasServe check, the
compiler reduces the method to a constant and inlines it, so the
linker drops it from those builds.

Updates #22283

Change-Id: Idd5da9c1e4f8f41a828a3774f5c4d44872eb1dda
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-11-10 07:24:48 -08:00
Fredrik Fornwall b9d5ff3ae7 ipn/ipnlocal: don't apply netmap from a replaced control client
setControlClientStatusLocked releases b.mu around tkaSyncIfNeeded. If
Logout replaced the control client meanwhile, the old client's netmap
was applied to the new profile, leaving it Stopped with the old IPs.

Fixes #22274

Change-Id: If4e9fdd5477db7f97b0362c5632c280dba4c18f5
Signed-off-by: Fredrik Fornwall <[email protected]>
2026-11-10 07:10:18 -08:00
Gabriel von Winckler 9476be9403 release/dist/unixpkgs: set file modes explicitly in deb and rpm packages (#22203)
The deb and rpm contents set no mode, so nfpm copied each file's mode
from the source file on disk and the result depended on where the build
ran. Since the release logic moved to OSS in fc4b25d9 (2023-02), corp
builds read the configs and systemd units from the read-only Go module
cache and ship them as 0444, where 1.36 shipped 0644. A checkout with
umask 002 instead gives group-writable 0664 files and 0775 binaries.

Set the modes explicitly, as the tarballs already do: 0755 for the
binaries and 0644 for the systemd units and /etc/default/tailscaled.
Configs return to 0644; binaries are unchanged.

Tested by building the amd64 deb and rpm under umask 002 and 022 and
checking the modes with dpkg-deb -c and rpm -qplv; package metadata is
otherwise unchanged.

Fixes #22202

Change-Id: I14acbd075b2f680720fdec47ce5e4e6033c363f7

Signed-off-by: Gabriel von Winckler <[email protected]>
2026-11-10 10:39:16 +00:00
Brad Fitzpatrick d566ac8ac9 ipn/ipnlocal, feature/acme: fix ts_omit_serve build with acme
feature/acme uses LocalBackend.ServeConfig to find hostnames needing
cert refresh, which broke builds with ts_omit_serve but not
ts_omit_acme. The serveConfig field it reads exists in all builds, so
move the method out of the serve-only file rather than making acme
depend on serve, and skip the refresh loop hook when serve is omitted
so the linker can drop it.

Updates #22283

Change-Id: I2cef6683cd6e6144306ddec95255d606f7a539ae
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-11-09 16:12:07 -08:00
Brad Fitzpatrick f49c53f166 util/clientmetric: add NewGaugeFunc and DisableDeltas omit stubs
net/sockstats uses both on darwin, ios, and android, so those builds
failed with ts_omit_clientmetrics.

Updates #22283

Change-Id: Ib242334dbcba639603fbf57a3b016efdecaea3d5
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-11-09 16:09:45 -08:00
Mazdak Nasab 7ed0138541 feature/conn25: match client flow removals to the assignment they counted (#22142)
flowRemoved identified an address assignment by transit IP alone, but a
transit IP does not identify an assignment for the lifetime of a flow.
An assignment can be dropped while a flow created against it is still in
the client flow table, and the pools then hand the same transit IP back
out to an unrelated assignment. The stale removal was charged to that
stranger, dropping its activeFlowCount while its own flows were still
forwarding, so popExpired reclaimed both of its addresses back to the
pools mid-connection. If the stranger had no flows of its own the count
went to -1, which can never again satisfy popExpired's zero-flow test,
pinning it in the expiry heap and leaking both addresses for the life of
the process.

flowCreated now returns a function, which the datapath calls on removal
to clean up the flow.

Fixes https://github.com/tailscale/corp/issues/50760

Change-Id: I3693c487b1031737763b5e49f8f8400c72848e8e

Signed-off-by: Mazdak Nasab <[email protected]>
2026-11-09 15:23:33 -07:00
Mazdak Nasab 6372b9a43a feature/conn25: shut the address assignment queue down from the sender side (#22269)
extension.Shutdown closed client.addrsCh, but the hooks that feed that
channel are still live at that point. LocalBackend.shutdown shuts the
extension host down before closing the engine, and nothing unregisters
what installHooks registered on the DNS manager and the tun device, so a
DNS response arriving during the shutdown window still reaches
mapDNSResponse -> rewriteDNSResponse -> reserveAddresses ->
enqueueAddressAssignment, and sends on the closed channel. That's a
panic, not a dropped assignment.

Every send already happens under c.mu, so the client can shut its own
queue down: client.shutdown takes the lock, sets a closed flag and
drains the queue, and enqueueAddressAssignment refuses with
errClientShutdown from then on.

A late DNS response now fails the reservation instead of queueing it for
a sendLoop that is gone. reserveAddresses rolls back, returning the
magic and transit IPs to their pools, and the query servfails rather
than being answered with a magic IP that no connector will ever hear
about.

Fixes https://github.com/tailscale/corp/issues/51235

Change-Id: I712ba8493e77b8176e133decc6097efb52b1b4ab

Signed-off-by: Mazdak Nasab <[email protected]>
2026-11-09 13:37:58 -07:00
dependabot[bot] 1e2c689b6b build(deps): bump @babel/core from 7.23.3 to 7.29.13 in /client/web
Bumps [@babel/core](https://github.com/babel/babel/tree/HEAD/packages/babel-core) from 7.23.3 to 7.29.13.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.29.13/packages/babel-core)

---
updated-dependencies:
- dependency-name: "@babel/core"
  dependency-version: 7.29.7
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-11-09 13:29:48 -07:00
dependabot[bot] f33f387639 build(deps): bump form-data from 4.0.4 to 4.0.6 in /client/web
Bumps [form-data](https://github.com/form-data/form-data) from 4.0.4 to 4.0.6.
- [Changelog](https://github.com/form-data/form-data/blob/master/CHANGELOG.md)
- [Commits](https://github.com/form-data/form-data/compare/v4.0.4...v4.0.6)

---
updated-dependencies:
- dependency-name: form-data
  dependency-version: 4.0.6
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-11-09 13:21:23 -07:00
dependabot[bot] ab3d3b18d5 build(deps-dev): bump vite from 5.4.21 to 6.4.5 in /client/web
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.4.21 to 6.4.5.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v6.4.5/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v6.4.5/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-version: 6.4.4
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-11-09 13:05:16 -07:00
dependabot[bot] 2bd6251010 build(deps): bump lodash from 4.17.23 to 4.18.1 in /client/web
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.23 to 4.18.1.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.23...4.18.1)

---
updated-dependencies:
- dependency-name: lodash
  dependency-version: 4.18.1
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-11-09 13:04:42 -07:00
dependabot[bot] d5012e6983 build(deps): bump nanoid from 3.3.11 to 3.3.18 in /client/web
Bumps [nanoid](https://github.com/ai/nanoid) from 3.3.11 to 3.3.18.
- [Release notes](https://github.com/ai/nanoid/releases)
- [Changelog](https://github.com/ai/nanoid/blob/3.3.18/CHANGELOG.md)
- [Commits](https://github.com/ai/nanoid/compare/3.3.11...3.3.18)

---
updated-dependencies:
- dependency-name: nanoid
  dependency-version: 3.3.18
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-11-09 12:46:44 -07:00
dependabot[bot] 30e6fee5af build(deps): bump browserslist from 4.22.1 to 4.28.8 in /client/web
Bumps [browserslist](https://github.com/browserslist/browserslist) from 4.22.1 to 4.28.8.
- [Release notes](https://github.com/browserslist/browserslist/releases)
- [Changelog](https://github.com/browserslist/browserslist/blob/main/CHANGELOG.md)
- [Commits](https://github.com/browserslist/browserslist/compare/4.22.1...4.28.8)

---
updated-dependencies:
- dependency-name: browserslist
  dependency-version: 4.28.8
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-11-09 12:46:28 -07:00
dependabot[bot] f79cb91562 build(deps): bump js-yaml from 4.1.1 to 4.3.2 in /client/web
Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 4.1.1 to 4.3.2.
- [Changelog](https://github.com/nodeca/js-yaml/blob/4.3.2/CHANGELOG.md)
- [Commits](https://github.com/nodeca/js-yaml/compare/4.1.1...4.3.2)

---
updated-dependencies:
- dependency-name: js-yaml
  dependency-version: 4.3.2
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-11-09 12:45:32 -07:00
dependabot[bot] 8fbc196681 build(deps): bump source-map-js from 1.2.1 to 1.2.2 in /client/web
Bumps [source-map-js](https://github.com/7rulnik/source-map-js) from 1.2.1 to 1.2.2.
- [Release notes](https://github.com/7rulnik/source-map-js/releases)
- [Changelog](https://github.com/7rulnik/source-map-js/blob/main/CHANGELOG.md)
- [Commits](https://github.com/7rulnik/source-map-js/compare/v1.2.1...v1.2.2)

---
updated-dependencies:
- dependency-name: source-map-js
  dependency-version: 1.2.2
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-11-09 12:45:17 -07:00
kari-ts 211f737bb4 ipn/ipnlocal: add shared login bootstrap orchestration (#21857)
Apple and Android both implement their own login orchestration, coordinating preference updates, backend startup, and interative login. This requires the clients to understand details about the backend lifecycle and has led to duplicated logic and ordering issues.

Android needs to avoid setting WantRunning=true via EditPrefs before calling Start, because doing so triggers Login on the existing control client, which Start then tears down, potentially canceling an in-flight registration before an authentication URL is returned (see https://github.com/tailscale/tailscale-android/commit/83057865e13b8f116a0871a3c6d6adf46f5c3d32). Apple has similar orchestration, including separate handling for auth keys, custom control servers, and reauth.

This adds a LocalBackend helper that accepts optional masked prefs and an auth key, prepares the desired startup prefs, and initiates or resumes auth. This avoids unnecessary control client resets, preserves the existing control client and auth url when the login configuration hasn't changed, and ensures WantRunning is applied as part of Start when restarting the backend. This can be used for:
-first time login with a custom control url or auth key
-resuming an existing interactive login without losing auth url
-retrying login without unnecessarily resetting the control client
-reauth without restarting the backend

A followup will expose this through localapi.

Updates tailscale/tailscale#18304

Signed-off-by: kari-ts <[email protected]>
2026-11-09 11:34:27 -08:00
Aditya Merchant c38365bcff ipn/ipnlocal: don't follow symlinks out of served directories (#22215)
When a Serve or Funnel handler serves a path, serveFileOrDirectory
used os.Stat and os.Open on it, and http.FileServer(http.Dir(dir)) for
a directory. All of these follow symlinks, so a symlink in place of a
served file or directory, or inside a served directory, could make
tailscaled serve any file it can read from elsewhere on the host.
Those directories may be writable by local users who can't configure
Serve, and a symlink placed there is followed at request time.

Resolve the configured path through an os.Root of its parent
directory, and serve a directory through an os.Root of its own.
os.Root refuses symlinks whose target leaves the root, and absolute
symlinks, and still follows relative symlinks that stay inside it. A
refused path inside a served directory is reported as not found, like
a missing file. A refused configured path is logged and reported as a
server error, like other errors reading it.

This changes behavior for setups that serve such symlinks on purpose,
including absolute symlinks and Windows junctions: a configured file
or directory that is one, or that points out of its parent directory,
now fails, and such links inside a served directory now return 404.
Symlinks higher up the configured path are still followed, and a
filesystem root can still be served. Opening the parent directory
needs read permission on it, where os.Stat only needed search
permission. Hardlinks are not covered, since os.Root can't tell them
apart from regular files.

RELNOTE: tailscale serve stops following symlinks out of served directories

Updates tailscale/corp#51116

Signed-off-by: Aditya Merchant <[email protected]>
2026-11-09 12:15:34 -07:00
dependabot[bot] d1570617f6 build(deps): bump postcss-selector-parser in /client/web
Bumps [postcss-selector-parser](https://github.com/postcss/postcss-selector-parser) from 6.0.13 to 6.1.5.
- [Release notes](https://github.com/postcss/postcss-selector-parser/releases)
- [Changelog](https://github.com/postcss/postcss-selector-parser/blob/6.1.5/CHANGELOG.md)
- [Commits](https://github.com/postcss/postcss-selector-parser/compare/v6.0.13...6.1.5)

---
updated-dependencies:
- dependency-name: postcss-selector-parser
  dependency-version: 6.1.5
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-11-09 11:45:49 -07:00
Nick Beirne 2c663f0d84 wgengine/magicsock: retry UDP reads on EADDRNOTAVAIL
A customer noticed that UDP reads returned EADDRNOTAVAIL during a link
change while the interface had no IPv4 address. magicsock returned the
error to wireguard-go, which treated it as permanent and shut down the
receive loop.

magicsock now retries the read when EADDRNOTAVAIL is returned on Unix.
Each error is counted in the magicsock_recv_udp_error_unknown metric.

EADDRNOTAVAIL isn't a documented result of a UDP recv. We suspect that
certain macOS network extensions return it while the network interface
is mid-change and has no address. We expect the error to stop once the
interface has an address again. A short delay between retries prevents
magicsock from spinning when the address doesn't come back right away.

Updates #22097

Change-Id: I70790f78d9488999ce00f9685aec3f0fabc15699
Signed-off-by: Nick Beirne <[email protected]>
2026-11-09 11:59:03 -05:00
François Marier 3ac0005aa2 tstest/natlab/vnet: add portmapping test for renewals (#22182)
This includes vmtests to test that the tailscale client
renews PCP and NAT-PMP portmaps correctly, and unit
tests for the natlab server implementation. UPnP will
require a different approach since the client doesn't
currently have a way to notice that its requested
lifetime was capped.

It also makes TestPortmapCreate parallel. Both
portmapping tests run within 2.5min on my laptop.
TestPortmapRenew is gated behind `--run-slow-tests`.

Updates #21713

Change-Id: Ie2a5f5e906c1f4eda8d10f5d4eff28b159b455cc
Signed-off-by: Francois Marier <[email protected]>
2026-11-09 09:03:22 -07:00
Fredrik Fornwall 3c19e6d2a7 util/clientmetric: define Type unconditionally
Move Type and its constants to an unconditional file so syspolicy, and
its dependents such as tsnet, compile with ts_omit_clientmetrics.

Fixes #22252

Change-Id: Ib9ca1c192e3e1c570aa32d41650d72fbff1aff0c
Signed-off-by: Fredrik Fornwall <[email protected]>
2026-11-09 07:51:50 -08:00
Mario Minardi 019ab096f5 util/backoff: allow specifying initialBackoff for backoff
Add initialBackoff to backoff struct. Add option pattern style
configuration for specifying the initial backoff in NewBackoff.

Updates https://github.com/tailscale/tailscale/issues/20339

Signed-off-by: Mario Minardi <[email protected]>
2026-11-09 08:06:32 -07:00
Fredrik Fornwall 62d055f4c3 ipn/ipnlocal: skip log directory lookup when logtail is omitted
Avoid a startup panic when no log directory is available and the
sockstat logger is disabled by ts_omit_logtail.

Fixes #22246

Change-Id: I06efea76cdaf6cda4b454dbede8cf2e69bbd588d
Signed-off-by: Fredrik Fornwall <[email protected]>
2026-11-08 15:27:51 -08:00
Fredrik Fornwall 48f559c113 tsnet: skip logger setup when logtail is omitted
Avoid creating or reading tailscaled.log.conf with ts_omit_logtail.

Fixes #22244

Change-Id: If1ac073501aa6a42e4b7d9757980d2bb79fbabac
Signed-off-by: Fredrik Fornwall <[email protected]>
2026-11-08 13:49:02 -08:00
Fredrik Fornwall 3a72a686cb tsnet: fix ts_omit_acme build
Gate certificate fetching on ACME support and return an error when omitted.

Fixes #22250

Change-Id: I709928f1fe11b7f20cc854d299175ca3048c037e
Signed-off-by: Fredrik Fornwall <[email protected]>
2026-11-08 13:47:45 -08:00
Nick Khyl 503010831e net/{netmon,tstun},tsconst: avoid enumerating all interfaces when retrieving the default
GetWindowsDefault called GetAdaptersAddresses to build a map of every
adapter before walking the routing table. Enumerating adapters is
expensive on Windows and, since the call doesn't skip DNS info, it also
goes through the DNS Client service, which on recent Windows builds
enumerates every interface for each DNS server on each adapter.

In this PR, we query only what we need: the routing table, the metric
of each interface with a default route, and the interface row for routes
that beat the current best. We also identify the Tailscale interface by
its Wintun GUID rather than by its description, and move the GUID to
tsconst so that net/tstun and net/netmon share it.

Updates #17772
Updates #21885

Change-Id: I4c6a9d9ed791788fb0567154ee1dbe0f6a2c52a2
Signed-off-by: Nick Khyl <[email protected]>
2026-11-07 12:29:01 -08:00
Alex Valiushko dc46358ecf go.mod: fix duplicate handshake response in wireguard-go (#22221)
Updates tailscale/corp#50867
Updates tailscale/tailscale#21884

Change-Id: If04dcde13681fc27e0e756ed465f165c6a6a6964
Signed-off-by: Alex Valiushko <[email protected]>
2026-11-07 11:35:32 -07:00
Mike O'Driscoll 6183501e99 flake.nix: resolve deprecation warning (#22234)
Resolve stdenv.isLinux is deprecated warning

Signed-off-by: Mike O'Driscoll <[email protected]>
2026-11-07 10:17:56 -05:00
Nick Khyl b31eb1c9bc ipn/ipnlocal,ipn/localapi: fix flaky TestResumeIPNBus
The test resumed a live session, so notifications already
on the wire (notably, spurious health change notifications)
could arrive ahead of the initial status.

In this PR, we add LocalBackend.SuspendWatchNotifications,
which suspends a session as if it had fallen behind,
and update the test to suspend the session and drain
pending notifications before resuming it.

Updates tailscale/corp#51067
Updates tailscale/corp#50256
Updates tailscale/corp#50907

Signed-off-by: Nick Khyl <[email protected]>
2026-11-06 19:31:20 -08:00
Nick Khyl 46f938791d go.mod: bump github.com/klauspost/compress for govulncheck
Resolves GO-2026-6865
Updates tailscale/corp#9497

Change-Id: I5aa46a03de75e4c51baa7662d1573a08f338467b
Signed-off-by: Nick Khyl <[email protected]>
2026-11-06 15:38:10 -08:00
Nick Khyl b706df603a ipn,client/local: let IPN bus watchers be suspended instead of disconnected
Since edcc2c94, tailscaled closes the watch when a subscriber falls
behind. That doesn't work well for GUIs where closing the watch has side
effects. On Windows, the last client disconnecting can reset the backend
state unless unattended or always-on mode is enabled. On Android and
Apple platforms, nothing restarts a watch that ended this way, so the
UI silently stops updating.

Add ipn.NotifySuspendWhenBehind. A watcher that sets it stays connected
when it falls behind, but gets a Notify with Suspended set and nothing
else until the client resumes the session via the new resume-ipn-bus
LocalAPI endpoint or LocalBackend.ResumeWatchNotifications. Resuming
replays the initial Notify and new notifications follow from there.

Updates tailscale/corp#51067
Updates tailscale/corp#50256
Updates tailscale/corp#50907

Signed-off-by: Nick Khyl <[email protected]>
2026-11-06 14:33:01 -08:00
Brendan Creane b7c3386649 net/dns,tstest/natlab/vmtest: accept a silent openresolv listing as no snippets (#22211)
openresolv before 3.13 exits 1 from "resolvconf -i" when its interface
directory holds no snippets. FreeBSD ships openresolv 3.9.2 in its base
system, so on FreeBSD hosts with static network configuration that status
aborted every DNS reconfiguration. A listing that prints nothing on stdout
or stderr now yields an empty base config whatever its exit status, which
also covers the exit status 2 that openresolv 3.17 returns.

The natlab DNSOpenresolv mode now provisions FreeBSD guests as well, by
deregistering the snippets dhclient added, and the openresolv VM tests run
on FreeBSD too. Without the net/dns change, the new FreeBSD test fails with
the health error reported in #11907.

Updates #11907
Updates #11129

Signed-off-by: Brendan Creane <[email protected]>
2026-11-06 14:15:57 -08:00
Mazdak Nasab 3dbb215e57 feature/conn25: drop address assignments queued before a client.reset (#22210)
Give the client a generation counter, bump it in reset, and stamp each
assignment with it as it is queued. insertTransitConnMapping rejects
assignments from an older generation; because that check happens under
c.mu it is exclusive with reset, which is what actually closes the
window. handleAddressAssignment also checks before sending, so an
assignment invalidated while it was still queued doesn't reach a
connector at all.

Fixes https://github.com/tailscale/corp/issues/51125

Change-Id: Ib524324b6e8a196fdcb5b4cd307854f61c7a0f04

Signed-off-by: Mazdak Nasab <[email protected]>
2026-11-06 12:04:36 -07:00
Brendan Creane e906e6934d ipn/ipnlocal: resolve exit node when it arrives by netmap delta (#22184)
Since aa5da2e5f, a peer that control adds to a running client arrives as a
netmap delta rather than a full netmap. The delta path never re-resolved
the exit node prefs. An exit node selected by IP before it was in the
netmap stayed unresolved, and an auto exit node stayed on the blackhole
route, until tailscaled restarted or a full netmap arrived.

Re-resolve the exit node in UpdateNetmapDelta when the delta can change
the result. Any upserted peer qualifies while an ExitNodeIP is set. An
exit node being upserted or coming online qualifies while an auto exit
node is unresolved. The selected auto exit node going offline, losing its
exit routes, or being removed qualifies once one is selected. The last
case replaces the separate offline check, so the exit node is resolved
once per delta. The auto exit node check walks every peer, so it only
runs in those cases.

On the delta path, the resolved prefs ride in the same Notify as the peer
changes, sent while b.mu is held. resolveExitNodeLocked no longer sends a
Notify; its callers do. The full-netmap path still sends the prefs in a
separate Notify after the netmap.

Fixes #22012
Updates #22206

Signed-off-by: Brendan Creane <[email protected]>
2026-11-05 16:28:01 -08:00
Mazdak Nasab 8aa18b518f feature/conn25: drain the address assignment queue in client.reset (#22186)
client.reset clears the IP pools, assignments and byConnKey, but leaves
addrsCh alone. The channel is buffered, so assignments queued before the
reset are still delivered by sendLoop afterwards: each one POSTs to a
connector from the profile we just left, registering a transit IP this
client no longer knows about, and then fails in addTransitIPForConnector
because the assignment is gone from c.assignments.

Drain addrsCh at the end of reset. The drain is non-blocking, so holding
c.mu can't deadlock against reserveAddresses, which enqueues under the
same lock, or against sendLoop, which receives without it.

Fixes https://github.com/tailscale/tailscale/issues/22185

Change-Id: I579131bc54e82d2c797b4741ccaf6cbe7abfdc4a

Signed-off-by: Mazdak Nasab <[email protected]>
2026-11-05 12:16:06 -07:00
alexcastgonz 01fa3caf30 ipn/ipnlocal: fix redirect for nested directories in serve (#22118)
ipn/ipnlocal: resolve serve file redirects against the request path

http.FileServer sends a Location relative to the request URL, such as
"nested/" or "../file". fixLocationHeaderResponseWriter prefixed that
value with the mount point, which dropped every directory between the
mount point and the target. A request for /doc/subdir/nested was
redirected to /doc/nested/.

Resolve the relative Location against the original request path
instead. Collapse leading slashes in the result so a request path like
//host/dir cannot produce a protocol-relative Location.

Fixes #22049

Signed-off-by: Alex Castillo González <[email protected]>
2026-11-05 11:14:35 -08:00
chaosinthecrd 1d9de5f81a k8s-operator/reconciler: test ProxyClass metrics for PeerRelay
This adds a test that walks a PeerRelay through the ProxyClass spec.metrics settings and checks the metrics Service, ServiceMonitor and TS_ENABLE_METRICS at each step, and a case for a PeerRelay waiting on a ProxyClass that is not ready. It also checks that ApplyProxyClass leaves one entry per env name when the ProxyClass sets an env var the operator also sets.

Updates #22034

Signed-off-by: chaosinthecrd <[email protected]>
2026-11-05 17:22:05 +00:00
chaosinthecrd 9eea2c890c cmd/k8s-operator,k8s-operator: support ProxyClass metrics for PeerRelay
The PeerRelay reconciler ignored a ProxyClass's spec.metrics, so enabling metrics created no metrics Service or ServiceMonitor and the relay Pods never served /metrics. This fixes this by setting TS_ENABLE_METRICS in ApplyProxyClass and calling tailscaled.EnsureMetricsResources for PeerRelay. PeerRelay now also waits for its ProxyClass to be ready before creating anything, as the other proxies do, so the existing ProxyClass test fixture is marked ready.

ApplyProxyClass now replaces an env var that the ProxyClass also sets instead of appending a second one. The PeerRelay StatefulSet is applied with server-side apply, which rejects duplicate env names, so a ProxyClass that sets an env var the operator also sets, such as TS_ENABLE_METRICS, would stop the StatefulSet from being applied.

Updates #22034

Signed-off-by: chaosinthecrd <[email protected]>
2026-11-05 17:22:05 +00:00
chaosinthecrd 31652c9978 cmd/k8s-operator,k8s-operator/reconciler: move metrics handling to tailscaled
The metrics Service and ServiceMonitor handling lived in cmd/k8s-operator,
and the ProxyClass reconciler kept its own copy of the ServiceMonitor CRD
check, so reconcilers in k8s-operator/reconciler could not share it. This
moves it into the tailscaled package as EnsureMetricsResources and
EnsureMetricsResourcesDeleted, which take the proxy type and parent, and
switches cmd/k8s-operator and the ProxyClass reconciler over to it. No
behaviour change.

Updates #22034

Signed-off-by: chaosinthecrd <[email protected]>
2026-11-05 17:22:05 +00:00