Commit Graph
11661 Commits
Author SHA1 Message Date
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 <bradfitz@tailscale.com>
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 <fredrik@fornwall.net>
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 <gabriel@tailscale.com>
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 <bradfitz@tailscale.com>
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 <bradfitz@tailscale.com>
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 <mazdak.nasab@gmail.com>
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 <mazdak.nasab@gmail.com>
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] <support@github.com>
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] <support@github.com>
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] <support@github.com>
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] <support@github.com>
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] <support@github.com>
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] <support@github.com>
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] <support@github.com>
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] <support@github.com>
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 <kari@tailscale.com>
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 <adityamerchant08@gmail.com>
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] <support@github.com>
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 <nickb@tailscale.com>
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 <francois@tailscale.com>
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 <fredrik@fornwall.net>
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 <mario@tailscale.com>
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 <fredrik@fornwall.net>
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 <fredrik@fornwall.net>
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 <fredrik@fornwall.net>
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 <nickk@tailscale.com>
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 <alexvaliushko@tailscale.com>
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 <mikeo@tailscale.com>
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 <nickk@tailscale.com>
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 <nickk@tailscale.com>
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 <nickk@tailscale.com>
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 <bcreane@gmail.com>
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 <mazdak.nasab@gmail.com>
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 <bcreane@gmail.com>
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 <mazdak.nasab@gmail.com>
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 <alex.castillog33@gmail.com>
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 <tom@tmlabs.co.uk>
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 <tom@tmlabs.co.uk>
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 <tom@tmlabs.co.uk>
2026-11-05 17:22:05 +00:00
Brendan Creane ae6c916f0f ipn/ipnlocal: normalize the serve hostname before the config lookup (#22141)
Serve looked up its config with the name exactly as the client sent
it. Config keys are lowercase with no trailing dot, so a plain HTTP
request for "svelte.example.ts.net." or "Svelte.Example.TS.net" got a
404. HTTPS had the same gap for case. TLS rejects a trailing dot in
SNI but does not lowercase it, so a client that sent mixed-case SNI
failed the handshake with "no webserver configured". Browsers and curl
lowercase the hostname before connecting, which hid that path.

Lowercase the name and trim the trailing dot in both branches of
getServeHandler, and lowercase the SNI in the cert callback.

Fixes #21538
Fixes #21986

Signed-off-by: Brendan Creane <bcreane@gmail.com>
2026-11-05 08:32:05 -08:00
Mike O'Driscoll 4dfd5352b9 derp/derpserver: reduce setWriteDeadline calls (#22180)
Each send operation (sendPacket, sendPeerGone, sendPong,
sendKeepAlive, etc) calls SetWriteDeadline on the
underlying connection. This re-arms the netpoll timer
on each packet frame write to the intermidiate lazy
buffer for a socket write that happens later. Not the
actual socket write done by runWriter.

Move the SetWriteDeadline down to the buffer that is pulled
by runWriter for each actual socket write.

Updates tailscale/corp#50628

Signed-off-by: Mike O'Driscoll <mikeo@tailscale.com>
2026-11-05 10:45:38 -05:00
chaosinthecrd 68ec83c60b cmd/k8s-operator: test requeue on optimistic lock errors
Adds tests that a conflict while provisioning a Service, a Service on a
ProxyGroup, a ProxyGroup or a Connector proxy results in a timed
requeue, and that the Connector and ProxyGroup status is set to
creating rather than failed. The test for a Service on a ProxyGroup
fails the update to the shared ingress config ConfigMap, as no watch
maps that ConfigMap back to the Service, so without the requeue the
conflict was never retried.

Updates #22074
Updates #18922

Signed-off-by: chaosinthecrd <tom@tmlabs.co.uk>
2026-11-05 15:27:01 +00:00
chaosinthecrd 9a44f4f69c cmd/k8s-operator,k8s-operator/reconciler: requeue on optimistic lock errors
Reconcilers logged "optimistic lock error, retrying" with the full
conflict error at Info, and Connector, Recorder and ProxyGroup also put
it in their status. That reads like a failure, but a conflict between a
cached read and an update is expected and is retried. The reconcilers
also returned an empty result, so the retry only happened if a watch
event arrived. This fixes this by logging the conflict at Debug as an
update conflict, using a neutral status message and requeueing after a
short delay.

Updates #22074
Updates #18922

Signed-off-by: chaosinthecrd <tom@tmlabs.co.uk>
2026-11-05 15:27:01 +00:00
David Bond 2993b5e6de cmd/k8s-operator: move Recorder reconciler into its own package (#20891)
Move the Recorder reconciler and its object specs into
k8s-operator/reconciler/recorder, following the earlier ProxyClass,
DNSConfig and nameserver moves, and switch it to the shared finalizer,
resource tracker and CreateOrUpdate helpers.

Hoist two duplicated helpers into tailscaled.PrefsFromStateSecret and
reconciler.IsOptimisticLockError, and add
k8s-operator/reconciler/reconcilertest for the test helpers each package
had copied, including one fake Tailscale API client in place of four.

No behaviour change; the Recorder's watches and labels are untouched.

Fixes tailscale/corp#37086

Signed-off-by: David Bond <davidsbond93@gmail.com>
2026-11-05 08:35:13 +00:00
Luo Chen dc69869769 net/netcheck: never prefer a STUN-only region as the home DERP (#21976)
The PreferredDERP selection loop only considers RegionLatency, which
STUN probes populate for STUN-only regions too. When such a region is
the only one with a latency sample (e.g. self-hosted DERP behind a
TCP-only tunnel while a public STUN server is reachable), it gets
selected as the preferred DERP and all relay traffic blackholes, since
the region has no DERP server to relay through.

Filter STUN-only regions in the selection loop by reusing the existing
regionHasDERPNode predicate (renamed to CanServeDERP), which was
already applied to the HTTPS/ICMP fallback probing but not here.

Regions missing from the map, or present without any nodes, keep the
old behavior, as some tests use latency-only DERP maps.

Fixes #21975

Signed-off-by: Luo Chen <luochen1990@gmail.com>
2026-11-04 21:22:51 -08:00
David Anderson a967b7d811 tailcfg: add a nodecap to disable hybrid handshakes
Updates tailscale/corp#50068

Signed-off-by: David Anderson <danderson@tailscale.com>
Change-Id: I07fc56c2eff6ab54ac9eec8ce33ea1d16a6a6964
2026-11-04 16:51:29 -07:00
Mazdak Nasab 274a3f2023 feature/conn25: roll back the address assignment when the send queue is full (#22165)
reserveAddresses inserts the assignment into c.assignments before
enqueueing it, and leaves it there when the enqueue fails. The connector
never learns about such a mapping, and nothing tell it later.
Add addrAssignments.remove and use it to undo the insert and return both
addresses to their pools when enqueueAddressAssignment fails. The caller
still gets a SERVFAIL, but the next DNS query starts from a clean slate.

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

Change-Id: I5a387bdcf5a5e87e2dca44867e88ed6149678729

Signed-off-by: Mazdak Nasab <mazdak.nasab@gmail.com>
2026-11-04 14:14:10 -07:00
David Bond 5455bf6a9f cmd/k8s-operator: require egress Pods in every IP family's EndpointSlice (#22157)
This commit changes the egress ProxyGroup readiness gate to mark a Pod
ready only when, for each egress Service, the Pod is an endpoint in the
EndpointSlice of every IP family that the proxy reports in its egress
status. Before, the gate accepted a Pod that was in either family's
EndpointSlice. On a dual-stack cluster, the StatefulSet rollout could
then move to the next Pod before the other family routed to the new Pod.

The gate reads the families from the proxy's state Secret, because a
proxy older than v1.102 does not report an IPv6 address. Such a proxy
never joins the IPv6 EndpointSlice, so its Pod must not wait for it.

Fixes #21077

Signed-off-by: David Bond <davidsbond93@gmail.com>
2026-11-04 19:00:53 +00:00
David Bond 44066ac026 cmd/k8s-operator: keep ProxyGroup state Secrets until cleanup finishes (#22155)
This commit removes the owner reference from ProxyGroup state Secrets,
also from Secrets that an older operator created. On a Foreground
delete, the garbage collector deleted these Secrets before the
finalizers ran. The finalizers read them to find devices, so cleanup
failed and devices stayed in the tailnet.

The ProxyGroup cleanup now deletes the Secrets after the devices, and
the reconciler watches them by label. The kube-apiserver cleanup finds
its cert resources by label, so it does not need the state Secrets. A
new e2e test covers Foreground deletes.

Fixes #22072

Signed-off-by: David Bond <davidsbond93@gmail.com>
2026-11-04 18:56:58 +00:00
Mike O'Driscoll 4afa0bb36f derp/derpserver: increase pool size to batch writer flushes (#22176)
bufioWriterPool was sized at 2KiB, this limited the number
of packets per TLS record during a push, limiting throughput
and increasing syscalls

Increase the buffer to 16KiB to pass extra DERP frames per
flush and TLS record write.

Update the websocket path to also use the pooled buffer

Updates tailscale/corp#50628

Signed-off-by: Mike O'Driscoll <mikeo@tailscale.com>
2026-11-04 12:44:10 -05:00