Commit Graph
11849 Commits
Author SHA1 Message Date
Abdelrahman Rabie 03aa2c47f0 k8s-operator: allow setting runtimeClassName via ProxyClass (#22686)
* k8s-operator: allow setting runtimeClassName via ProxyClass

Add a runtimeClassName field to the ProxyClass CRD's pod spec, next to
priorityClassName, and propagate it to the proxy StatefulSet pod spec.
This lets users run proxy pods under a non-default RuntimeClass, for
example one provided by a confidential-computing or sandboxed runtime.

Updates tailscale/tailscale#21843

Signed-off-by: Abdelrahman Rabie <[email protected]>

* k8s-operator: regenerate manifests and API reference

Signed-off-by: Abdelrahman Rabie <[email protected]>

* k8s-operator: use omitzero for ProxyClass runtimeClassName

The vet check requires omitzero on pointer fields that are optional.

Updates #21843

Assisted-by: AI tool
Signed-off-by: Abdelrahman Rabie <[email protected]>

---------

Signed-off-by: Abdelrahman Rabie <[email protected]>
2026-11-30 17:25:53 +00:00
David Bond 2bebbebc9b k8s-operator/sessionrecording/spdy: remove dead error check in test helper (#22728)
The err check after writeHeaderValueBlock in payload could never fire.
It tested the error from zlib.NewWriterLevelDict, which payload already
checks, and writeHeaderValueBlock calls t.Fatalf itself on a write
error. The nilness analyser in go vet flags it as an impossible
condition.

Remove the len(headerM) guard too, because payload returns early when
headerM is empty, and check the error from w.Flush, which was ignored.

Updates #22652

Change-Id: I23ec131d88a599b37364706dd2226f1456574461

Signed-off-by: David Bond <[email protected]>
2026-11-30 13:26:38 +00:00
Dep Updater af75ded1cd go.mod: bump gvisor.dev/gvisor
* gvisor.dev/gvisor: https://github.com/google/gvisor/compare/0303b2605d5e...2c60c87d5cf0

Triggered by @bradfitz via the bumpdep workflow.

Updates #22740

Signed-off-by: Dep Updater <[email protected]>
2026-11-29 22:49:01 -08:00
Dep Updater 8b6f50cccd go.mod: bump 6 modules
* github.com/gokrazy/breakglass: https://github.com/gokrazy/breakglass/compare/0f882c44303e...dde5ec3a2b06
* github.com/gokrazy/firmware: https://github.com/gokrazy/firmware/compare/d8b761d7b4ca...fe094a467208
* github.com/gokrazy/gokrazy: https://github.com/gokrazy/gokrazy/compare/39fe3e5557b8...a7049fa5ff69
* github.com/gokrazy/kernel.amd64: https://github.com/gokrazy/kernel.amd64/compare/17ff614bf8bc...b070e9db2522
* github.com/gokrazy/kernel.arm64: https://github.com/gokrazy/kernel.arm64/compare/03045c240b24...b85bb6b92057
* github.com/gokrazy/kernel.rpi: https://github.com/gokrazy/kernel.rpi/compare/a4a58496f7f6...306cb2ad08ed
* github.com/gokrazy/rpi-eeprom: already current
* github.com/gokrazy/serial-busybox: already current

Triggered by the gokrazy-bump workflow's schedule.

Updates #1866

Signed-off-by: Dep Updater <[email protected]>
2026-11-29 22:27:16 -08:00
Nick Khyl 16ffe73ef4 feature/captiveportal: run detection once per network or connectivity change
Every health change while connectivity remained impacted ran captive
portal detection again, even though nothing about the network had
changed.

Track whether detection is due. It becomes due when connectivity stops
being impacted and when netmon reports a network change that likely
requires a rebind, and is no longer due once detection has run.
Health and pref changes still call maybeDetectCaptivePortal, but it
only runs detection when it is due. Otherwise, it just drops the
warning once connectivity is no longer impacted.

A result can still become wrong without either: the portal may start
intercepting after detection ran, or the user may log in to it while
connectivity remains impacted for other reasons. So detection also
becomes due on a health change while a captive portal is detected,
and on a retry timer that doubles from 2 to 60 seconds while connectivity
remains impacted. With retries, detection no longer waits 2 seconds
before its first run.

Updates #15396
Updates #1634
Updates tailscale/corp#27985

Signed-off-by: Nick Khyl <[email protected]>
2026-11-29 13:36:32 -08:00
Nick Khyl f3adae29e9 feature/captiveportal: coalesce detection requests and run them async
onHealthChange signaled the detection loop over an unbuffered channel.
While the loop was busy running detection, which can take several
seconds per interface, the eventbus subscriber was blocked and reported
as slow. Additionally, every health change while connectivity remained
impacted requested another detection, including the change that
detection itself made to the captive portal warnable.

Replace the loop and the channel with a coalescedop: requests never
block, and those that arrive during a check cause exactly one more
check after it. Ignore changes to the captive portal warnable itself,
and log when detection runs instead of on every health change.

Without a loop to start and stop on backend state changes, detection
is now limited by the WantRunning pref alone, which was already
required. A change to it triggers a check, as does Init.

Updates #15396
Updates #21703

Signed-off-by: Nick Khyl <[email protected]>
2026-11-29 13:15:47 -08:00
frozenprocess 147791366a net/tsdial: block traffic in userspace mode when exit-node is not offered
In userspace mode when an exit node is selected but stops being offered,
drop the traffic.

Fixes tailscale/corp#50584

Signed-off-by: frozenprocess <[email protected]>

Change-Id: I22ccf4c1209cdb346c787851197c9b52967aab56
2026-11-28 09:36:48 -08:00
Jeremy Schoemaker d486755fb9 envknob: make Setenv update RegisterInt knobs
Setenv refreshes the cached values behind RegisterString, RegisterBool,
RegisterOptBool and RegisterDuration, but had no case for RegisterInt.
An int knob kept its old value after Setenv, even though RegisterInt's
doc says mutations happen via Setenv.

Add the missing case and a test.

Fixes #21530

Change-Id: I3213c68a22619c0dd334b00f6eaa1e260ee20827
Signed-off-by: Jeremy Schoemaker <[email protected]>
2026-11-27 21:30:54 -08:00
Mazdak Nasab 091ebe8543 feature/conn25: only admit protocols the datapath can map to a transit IP (#22697)
The connector's ingress filter hook accepts any packet addressed to one
of its transit IP pools, on the understanding that the datapath will
take it from there. For most of what it admits, the datapath does not:
HandlePacketFromWireGuard returns Accept untouched for everything
isSupportedProtocol excludes, so SCTP, GRE, ESP and friends are handed
to the host stack addressed to a transit IP, which is not an address
this node holds.

Nor does the hook ask anything of the sender. A peer holding no conn25
grant at all, having registered no mapping, can send those to any
address in a connector's pool and have the filter wave them through.

Split the ingress hook off into ingressAllow and have it require a
protocol the datapath can map. What is left behind serves only the
link-local hook, which lifts the filter's blanket drop of link-local
destinations rather than accepting anything, so rename it to
linkLocalAllow to match its remaining job and the client's hook of the
same name. A packet to a transit IP still has to pass ingressAllow
either way. packetFilterAllowReason loses its reason to be named after
a packetFilterAllow and becomes transitIPAllowReason.

Non-first fragments are unaffected: Filter.pre accepts ipproto.Fragment
before RunIn consults the hooks at all.

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

Change-Id: I3486377181f406465293902c91f39b873741c6ec

Signed-off-by: Mazdak Nasab <[email protected]>
2026-11-27 15:52:21 -07:00
Brad Fitzpatrick 72a7f41564 tsweb/promvarz, cmd/tailscaled: don't mix other metrics into filtered varz
The promvarz and tailscaled /debug/varz handlers wrap varz.Handler with
metrics it doesn't know about: promvarz writes the Prometheus client's
metrics first, and tailscaled appends clientmetrics. With the match and
interval parameters that varz got in 258b087998 (#22636), that meant
unfiltered metrics around filtered ones, a bad parameter's error after
a 200 and a full dump, and streams that didn't start with a frame. Now
requests with a query string get only varz's own output.

Updates tailscale/corp#47429

Change-Id: I617969401b1ff269db32481b2656841b70355d57
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-11-26 08:58:57 -08:00
Nahum Shalman 3ffce79f7b wgengine/netstack: fix invocation of ping on illumos/solaris 2026-11-26 08:29:27 -08:00
Naman SoodandBrendan Creane f2c476cf17 ipn/ipnlocal: properly half-close PROXY protocol forwarded connections
Use `pipetcp.Pipe()` which handles this edge case now.

Fixes #20880

Signed-off-by: Naman Sood <[email protected]>
Co-authored-by: Brendan Creane <[email protected]>
2026-11-25 16:44:21 -05:00
Mazdak Nasab 08d91f4b90 feature/conn25: use transitIPInPool in connector.packetFilterAllow (#22660)
packetFilterAllow inlined the same per-family transit pool lookup that
transitIPInPool already does. Call that instead.

Also fix a doc comment that said it checked the packet's Src,
but it has always checked Dst.

Updates #cleanup

Change-Id: I1f236c5120168a0a8b16f8125773efcb09426bc8

Signed-off-by: Mazdak Nasab <[email protected]>
2026-11-25 11:02:25 -07:00
Francois Marier 649ca43716 net/portmapper: add Probe metrics for all PCP result codes
Probe only counted the OK, not authorized and address mismatch PCP
result codes. All other codes went to
portmap_pcp_unhandled_response_code.

This adds all RFC 6887 result codes. IANA has allocated more for
RFCs 7652 and 7843, but we are leaving those out since we don't
use authentication or third-party options.

PCP replies with an opcode other than ANNOUNCE now go to a new
portmap_pcp_unhandled_opcode metric instead of
portmap_pcp_unhandled_response_code, same as NAT-PMP.

Updates tailscale/corp#51202

Change-Id: I00bc0309914280c4238cb2aaa322a595fe94d699
Signed-off-by: Francois Marier <[email protected]>
2026-11-25 10:45:03 -07:00
Brad Fitzpatrick 1a3a1da16f misc/git_hook/githook: don't rebuild hooks after every OSS bump
The launcher found the shared HOOK_VERSION via `go list -m -f
'{{.Dir}}' tailscale.com`. But go list -m doesn't download modules, so
after a repo bumps its tailscale.com dependency to a version not yet in
the module cache, Dir is empty, SHARED_VER falls back to 0, and the
launcher rebuilds ts-git-hook-bin even though the shared HOOK_VERSION
didn't change. In corp, which can sometimes bump OSS a few times a
day, that meant a spurious "git-hook: rebuilding ts-git-hook-bin..."
(plus a module download) on the first git operation after most bumps.

If Dir is empty, run `go mod download tailscale.com` and look again.
The rebuild was going to download the module anyway.

Bump HOOK_VERSION so existing installs pick up the new launcher.

Updates tailscale/corp#40381

Change-Id: I6e4720702d7052df3b15dce0c60a8b313c6b48e3
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-11-25 08:54:24 -08:00
Mike O'Driscoll 28f22b0062 derp/derpserver: make writer flood test deterministic (#22629)
TestWriterFloodDoesNotStarveControlFrames raced a flooding goroutine
against a writer goroutine and polled with wall-clock timeouts. Its
original sequence-number bound was wrong under CPU load and was fixed
in #22553, which is what the failures reported in #22614 were
hitting. But the test still depended on scheduling, and so only
sometimes caught a regression: with writePending's per-pass budget
doubled it failed about half its runs.

Make it single-threaded instead. The test runs the writer inline, as
onKeepAliveTimer does, and sends packets as big as the writer's
buffer, so that every packet reaches the fake conn's Write. Write tops
the send queue back up and queues the pong once the writer has sent an
exact number of packets. The pong is queued at each of depth+1
consecutive packet counts, so that a per-pass budget of more than
depth is caught at its worst case whatever it is, and the flood is
bounded so that a writer that starves the pong fails the test rather
than hanging it.

Fixes #22614

Signed-off-by: Mike O'Driscoll <[email protected]>
2026-11-25 11:00:30 -05:00
Simon Law 445df50dcf wgengine/magicsock: avoid copying lock in Test_endpoint_handlePongConnLocked (#22641)
This patch removes an accidental copy of a lock:

	$ ./tool/go vet ./...
	literal copies lock value from pm: tailscale.com/wgengine/magicsock.peerMap contains sync.RWMutex

Updates #22645

Change-Id: Id171051838b66b8dd9dff755d803bbc18142bea4

Signed-off-by: Simon Law <[email protected]>
2026-11-24 23:34:41 -08:00
Sai Kumar Pola e906a6a44b drive/driveimpl: don't require sudo or su to share as the current user
The Taildrive file server for a share is started as the share's user
with sudo, falling back to su. If neither works and tailscaled is root,
userServer.run refuses to start it. On systems that ship neither tool,
such as OpenWrt, a share created by root could therefore never be
served: the run loop kept failing with `"root" is root` and remote
peers saw an empty, unwritable share until sudo was installed.

When the share's user is the user tailscaled is already running as,
there is nothing to switch to, so run the file server directly. This is
what `sudo -u root` already did where sudo is installed. Shares owned
by any other user still go through sudo or su as before.

Fixes #22413

Change-Id: Ied5f51e01183f90ef1f7d2ffc386847d9eea633a
Signed-off-by: Sai Kumar Pola <[email protected]>
2026-11-24 18:34:59 -08:00
Brad Fitzpatrick 258b087998 tsweb/varz: add match filters and streaming to /debug/varz
The new "match" query parameter filters the output by metric name
with Go regexps, and "interval" turns the response into a stream of
frames, a full one first and then deltas with only the changed series,
so monitors can subscribe once instead of re-fetching everything. A
stream matches vars once at setup and then compares plain counters and
gauges without formatting them. The new ReadStream parses the stream.

Updates tailscale/corp#47429

Change-Id: I8751bfe981991b4aca7f1cf52001e093584a258a
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-11-24 18:08:59 -08:00
Simon Law 012baddc17 tsnet: test with a fake host DNS resolver, not the OS resolver (#22635)
When testing DNS resolution in tsnet, we want to test that it falls
back to the host resolver. But each operating system, or even
different versions of the same OS, have subtly different behaviours.
To make testing easier, this patch mocks out the host resolver.

Updates #22043
Fixes #22632

Change-Id: I48163fcd00e06dea261dfc163c15a839e1077a5f
Signed-off-by: Simon Law <[email protected]>
2026-11-24 13:34:05 -08:00
Simon Law 2a097428bc tsnet: fix Server.Close so it can be called repeatedly (#22633)
As reported by #19999, Server.Close was not safe to call while
Server.Start was running, which is not how anyone expects an io.Closer
to behave. In fact, you couldn’t even call Close before Start.

This patch fixes this, so you can call Close safely at any time and
more than once.

This patch fixes Server.Up and Server.Dial so we don’t try to start
the server if their context was already canceled.

As a side effect of closing properly, this patch also replaces
closeOnErrorPool, introduced in PR #5301, which never actually worked.

Updates #19999
Updates tailscale/corp#42776

Change-Id: If17ef36a99f49b86d9db061f3eef0d2d914520a2

Signed-off-by: Simon Law <[email protected]>
2026-11-24 13:25:09 -08:00
Brad Fitzpatrick 1e36c0f2b7 wgengine/magicsock, control/controlclient: handle node keys moving between nodeIDs
When control deletes a node and the machine re-registers with its
persisted node key, the next netmap has the key on a new nodeID and the
old nodeID absent. magicsock upserted the new peer before removing the
old peer's endpoint, saw a conflict and called devPanicf, crashing
unstable builds (corp services) and leaving the new peer without an
endpoint on stable builds. Remove stale endpoints before upserting, and
treat UpsertPeer of a moved key as an implicit removal of the old
nodeID. Two live peers with one key is a control bug, so controlclient
now keeps some random but deterministic one and logs loudly, and
magicsock only logs if some other caller passes duplicates.

Updates tailscale/corp#52092
Updates tailscale/corp#38410
Updates tailscale/corp#27300

Change-Id: Iedfd312aacd0fb8dcc4dcd459ba26f735269147f
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-11-24 12:21:24 -08:00
Naman SoodandBrendan Creane aa0d479294 util/pipetcp: add reusable TCP proxying functionality
We keep running into problems with improperly handling proxying TCP
connections when one side half-closes their write end
(see #20880, #20883, #21522, tailscale/corp#29837, etc).

util/pipetcp now provides Pipe, a function that can be used to
implement TCP proxying while correctly handling that footgun.

Updates #20880

Signed-off-by: Naman Sood <[email protected]>
Co-authored-by: Brendan Creane <[email protected]>
2026-11-24 15:08:07 -05:00
Brad Fitzpatrick 67e092fe7d tsnet: add Server.Tailnet to require a tailnet
Server.Tailnet is a tailcfg.StableTailnetID. It is sent as a required
tailnet at registration, and Up also fails if the node ends up in a
different tailnet, such as from state saved before Tailnet was set.

Fixes #22515
Updates #22093

Change-Id: I44d4e8fb4e5767fa63dce871c3e093f586a7d300
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-11-24 12:04:53 -08:00
Mazdak Nasab 076d07d626 feature/conn25: return extra WireGuard AllowedIPs in a stable order (#22630)
lookupTransitIPsByConnID returned the connector's Transit IPs straight
from a map-backed set, in map-iteration order. set.Set.Slice can't order
them: it only sorts ordered kinds, and netip.Prefix is a struct.

Both ends of the ExtraWireGuardAllowedIPs path require a stable order so
that unchanged entries are detected as no-ops: the hook's contract in
ipnext, and routemanager.Mutation.SetExtraAllowedIPs, whose applyExtras
compares each peer's prefixes with slices.Equal. Without it an unchanged
set looked changed, resyncing the WireGuard device peer for every
connector on every reconfig.

Sort the result, and drop the workaround sort in TestTransitIPConnMapping
that was masking this, so that test asserts the order too.

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

Change-Id: Ie4b17d69fb304a6411f534322314082a7feea542

Signed-off-by: Mazdak Nasab <[email protected]>
2026-11-24 12:36:00 -07:00
Tom Proctor 8bcc919dcf cmd/testwrapper: ensure unfinished tests always trigger failure (#22622)
When packages timed out or panicked, we sometimes marked CI green
despite not running all the tests for that package, and the tests that
started but didn't finish got marked as flaky even though they were not
known to be at fault. For example, all 133 recorded flakes of
ipnlocal.TestNewExtensionHost were really an ipnlocal watchdog panic or
a package timeout on Windows, and 129 of those jobs passed.

Parse the test binary's terminal log line, and check for tests that
started but never finished. If either shows that the test binary didn't
complete, don't retry any of the package's tests, and fail the run. The
log line check also catches a panic in a test's own goroutine, which
the testing package reports as a normal test failure even though the
tests after it never start.

While here, fix some related problems:

- A package that fails with no failed test (e.g. TestMain exits
  non-zero) is now fatal even if another package in the same go test
  invocation has a failed test to retry. Previously the check counted
  the failed tests of the whole batch, not of the package.
- If a test passes on retry but go test still fails (e.g. TestMain
  exits non-zero after the tests run), fail the run. Previously we
  only logged the error and exited 0.
- A data race now drops only the retries of its own package, not of
  every package in the batch.
- If go test fails with nothing to retry, don't exit straight away;
  still retry other batches' failures and write the GitHub step
  summaries, then exit with go test's exit code. The results summary
  now shows unfinished tests as failed instead of passed.

Updates tailscale/corp#52113

Signed-off-by: Tom Proctor <[email protected]>
2026-11-24 18:33:45 +00:00
Brendan Creane 1f20c0bfd5 net/dns,tstest/natlab/vmtest: label resolv.conf temp file before rename (#22516)
In direct mode the restorecon added in #20167 runs after the rename, so
/etc/resolv.conf briefly carries the temp file's etc_t label. A service
that watches /etc with inotify, such as sssd_be, re-arms its watch on the
file inside that window and SELinux denies it. Run restorecon on the temp
file first. The policy file-context regex /etc/resolv\.conf.* matches the
temp name and rename(2) keeps the inode's label, so the file is net_conf_t
from the moment it appears. The post-rename relabel stays for the
backup-restore path.

Add a natlab vmtest on Fedora that records the label at each rename.

Fixes #22418

Signed-off-by: Brendan Creane <[email protected]>
2026-11-24 09:05:32 -08:00
Brendan Creane fcef8e2384 ipn/ipnlocal: update netstack's active Services on every prefs change (#22517)
A config file reload sets prefs through setPrefsLocked, but netstack's set
of active Tailscale Services was only updated from onEditPrefsLocked and
setNetMapLocked. After the operator changed AdvertiseServices in a
ProxyGroup config Secret, netstack kept the old set until the next netmap.
The node still served a withdrawn Service locally instead of sending that
traffic to another host, and did not serve a newly added one.

Move the update into setPrefsLocked so every path that changes prefs
applies it, and add a netstack test that exercises ReloadConfig.

Fixes #22498

Signed-off-by: Brendan Creane <[email protected]>
2026-11-24 09:04:53 -08:00
Taylor 0422c46eb0 ipn/ipnlocal: handle node key expiry after wake (#21186)
Reschedule the netmap expiry timer against wall time when netmon
reports a time jump, so sleep does not delay the transition to
NeedsLogin after the local node key expires.

Ignore stale LoggedIn status while the key remains expired so it
cannot reinstall the previous engine configuration. On macOS, that
configuration can leave the default route pointing at the Tailscale
interface when using an exit node, blackholing internet traffic.

Fixes tailscale/corp#47690

Signed-off-by: Taylor McIntyre <[email protected]>
2026-11-24 11:47:15 -05:00
Francois Marier 69b2b96b2a net/portmapper: clean up comments and log lines
Log the UPnP fallback before attempting it, on both fallback paths.
The old message was only logged after UPnP had also failed, but read
as if the fallback was about to happen. Rename the "ProbePCP" log
prefix to "Probe" since the socket is used for all three probes.

Updates #cleanup

Change-Id: Ic8ceafe6614e30b572add6d023954959c549eefe
Signed-off-by: Francois Marier <[email protected]>
2026-11-24 09:03:58 -07:00
Stefanie Jane 6dce0b2118 cmd/k8s-operator: publish HA Service VIPs for configured IP families (#22061)
HA Services currently advertise only their IPv4 VIP in LoadBalancer
status, even when forwarding is configured only for IPv6. Consumers of
Service status then select an address with no matching backend mapping.

Derive ingress addresses from the configured family mappings. Preserve
IPv4 behavior and readiness withdrawal while publishing IPv6-only and
dual-stack backends correctly.

Fixes #22060

Signed-off-by: Stefanie Jane <[email protected]>
2026-11-24 12:34:25 +00:00
License Updater da6276d770 licenses: update license notices
Signed-off-by: License Updater <[email protected]>
2026-11-23 15:04:11 -08:00
Nick O'Neill b5034b78a5 VERSION.txt: this is v1.107.0 (#22612)
Signed-off-by: Nick O'Neill <[email protected]>
v1.107.0-pre
2026-11-23 13:59:45 -08:00
Fran Bull 3ec7c0cd6c feature/conn25: enforce token verification
When the connector handles a ConnectorTransitIPRequest, it checks there
is a token and that it is valid. If there is not a valid token it
rejects the request.

Updates tailscale/corp#46169

Signed-off-by: Fran Bull <[email protected]>
2026-11-23 13:32:45 -08:00
Michael Ben-Ami 7caf9edb40 appc,feature/conn25: build split DNS routes from the parsed config
On every self node change, conn25 parsed the app connector capability
twice: once in configFromNodeView, and again in appc.AppDNSRoutes to
build the split DNS routes. Build the routes from the config we already
have instead, and move DNSAddrScheme into feature/conn25 along with it.

With appc/conn25.go gone, conn25 no longer depends on appc, so
TestOmitAppConnectors no longer needs to omit conn25 too.

Fixes tailscale/corp#51400
Fixes tailscale/corp#51402

Signed-off-by: Michael Ben-Ami <[email protected]>
2026-11-23 16:05:43 -05:00
Nick Khyl 0afa9614d3 net/dns: stage the new hosts file outside of the etc directory on Windows
atomicfile.WriteFile creates its temporary file next to the target,
and changes in System32\drivers\etc make the DNS Client service reload
the hosts file. Besides the extra reloads, the service may then have
the hosts file open just as we try to replace it.

In this PR, we create the temporary file in System32\drivers instead,
which is on the same volume, and move it into place with
atomicfile.Rename.

Updates #21001
Updates #5753
Updates #8161
Updates #21617
Updates #14327
Updates tailscale/corp#52076

Signed-off-by: Nick Khyl <[email protected]>
2026-11-23 12:48:28 -08:00
Nick Khyl 65c4e36477 net/dns: retry failed hosts file updates in the background on Windows
Replacing the hosts file fails with a sharing violation while another
process, such as the DNS Client service or antivirus software, has it
open. Previously, we retried for about 50ms and then failed SetDNS as
a whole.

In this PR, we move hosts file updates to a CoalescedOp that retries
a failed write with backoff for up to 30 seconds, picking
up newer entries if SetDNS is called again in the meantime. A failure
is logged and no longer fails SetDNS.

Close waits for the entries to be removed.

Fixes #21035
Updates #21001
Updates #5753
Updates #8161
Updates #21617
Updates #14327
Updates tailscale/corp#52076

Signed-off-by: Nick Khyl <[email protected]>
2026-11-23 12:48:28 -08:00
Nick Khyl a115745579 util/coalescedop: add Wait
Wait blocks until no execution is in progress or pending,
so a caller can make sure the requested work is done before
shutting down.

Updates tailscale/corp#52076

Signed-off-by: Nick Khyl <[email protected]>
2026-11-23 12:48:28 -08:00
Mike O'Driscoll 00183293b8 derp/derpserver: add rate limiting exemption by IP (#22610)
Allow for specified IPs to bypass the rate limiter
in derper.

Fixes #22609

Signed-off-by: Mike O'Driscoll <[email protected]>
2026-11-23 15:25:42 -05:00
Brad Fitzpatrick 01f673c426 net/dns/resolver: don't count a torn-down UDP write as an upstream error
TestForwarderRaceLoserNoReadError races an answering resolver against
a silent one 20 times and then waits for 20 losing reads to land in
dns_query_fwd_udp_read_ctx_done or dns_query_fwd_udp_error_read. That
assumed every losing sendUDP was blocked in its read when the winner
ended the query. It isn't always: if the loser's goroutine is slow,
forwardWithDestChan's teardown (cancel, then closeOnCtxDone.Close, or
closePool.Add closing a conn registered after teardown) closes the conn
before WriteToUDPAddrPort. The loser then exits through the write error
path and never reaches a read, so the test waited out its 10s and failed
with "only 19 of 20 losing reads have woken up". Instrumenting the
failure showed udp=40 wrote=39 werr=1 every time.

No losing query leaks; every loser exits. But the write path had the
same miscounting the test was added to stop for reads: it bumped
dns_query_fwd_udp_error_write before checking ctx.Err, so query teardown
showed up as an upstream write failure. Check ctx first.

In the test, the silent upstream now reads UDP without answering
(new HangUDP option), and the answering upstream holds its UDP answer
until the silent one has the query. The loser is then always past its
write when the query ends, so all 20 losers reliably reach the read.

flakestress -p 4 -taskset 0 on Linux:
before: 57 failures in 4143 runs (1.4%)
after: 0 target failures in 31219 runs. The only failures were
247 "bind: address already in use" from loopback ephemeral port
exhaustion caused by other stress jobs on the same machine.

Flakes dashboard: http://flakes/flake?name=tailscale.com%2Fnet%2Fdns%2Fresolver.TestForwarderRaceLoserNoReadError
(115 failures in 7 days, 82 on main.)

Fixes #22549

Change-Id: I9f346aa66a175e63593815dc606b88d961834b01
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-11-23 11:02:09 -08:00
chaosinthecrd 5aed346ad7 cmd/k8s-proxy,cmd/k8s-operator: test k8s-proxy /livez and /readyz
Covers /livez and /readyz with and without tailnet IPs and with the
LocalAPI failing or timing out, and the probes that a ProxyClass enables
on the kube-apiserver ProxyGroup StatefulSet, which stay on port 9002
when the ProxyClass sets TS_LOCAL_ADDR_PORT.

Updates tailscale/corp#38175

Signed-off-by: chaosinthecrd <[email protected]>
2026-11-23 18:20:10 +00:00
chaosinthecrd 0d029cb75a cmd/{k8s-proxy,k8s-operator},k8s-operator: serve k8s-proxy /livez and /readyz
k8s-proxy did not serve /livez or /readyz, so the operator skipped the
probes for the kube-apiserver ProxyGroup even when a ProxyClass set
them. This adds both to k8s-proxy (/livez passes while the LocalAPI
answers, /readyz once the node has its tailnet IPs) and drops the
exception from the operator. k8s-proxy takes its port from the config
file that the operator writes, so its probes always use port 9002 and
ignore TS_LOCAL_ADDR_PORT and TS_ENABLE_HEALTH_CHECK. The local server
now starts before Up, so /livez answers while Up runs and while waiting
for a reissued auth key.

Updates tailscale/corp#38175

Signed-off-by: chaosinthecrd <[email protected]>
2026-11-23 18:20:10 +00:00
Danni Popova b1f550ec56 wif: add identity token auto generation for Azure (#21808)
Extends the ability to auto detect Azure as the provider the client is running on and tries fetch the JWT to use with Workload Identity.

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

Signed-off-by: Danni Popova <[email protected]>
2026-11-23 17:51:43 +00:00
Brad Fitzpatrick 940e4c2c67 ssh/tailssh: write watchdog test PID markers atomically
TestMonitorCloseWatchdogForwardChild occasionally failed on Linux CI
with `invalid helper PID marker ".../forward-pid": ""`.

The re-exec'd helper wrote its PID marker with os.WriteFile, which
creates (and truncates) the file before writing the contents. The test
polls for the marker every 20ms and treats any successful read as
final, so a poll landing between the create and the write saw an empty
file and failed. This is a test-only race; the monitor itself was
fine.

Write the marker to a temp file and rename it into place, so the poll
sees either no file or the full PID.

The natural rate is too low to measure locally (0/168 runs of the
~14s-under-race test in 5m with flakestress -race -p 8 -taskset 0-3),
so the window was widened by injecting a 100ms sleep:
before (sleep between create and write): 3/3 runs failed with the
CI error.
after (sleep between write and rename): 0/3 runs failed.
after, without injection, flakestress -race -p 4, 5m: 0/84 runs.

Fixes #22559

Change-Id: I855d18f006535140bc136ee876b311212f8884b6
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-11-23 08:54:18 -08:00
Brad Fitzpatrick 7294a69dfd tsnet: fail the test instead of panicking when a ping times out in test helpers
setupTwoClientTest and TestDialThroughExitNode used
must.Get(lc.Ping(...)) to wait for the TSMP path to come up. When that
ping timed out, must.Get panicked, killing the whole tsnet test binary.
The flakes dashboard then blamed every test that was running or paused
at the time (TestPacketFilterFromNetmap, TestListenService, TestListen*,
TestDialUDP, ...), not just the one whose ping failed.

Use t.Fatalf instead so a failed ping fails only its own test.

The underlying ping failure was the wireguard-go duplicate handshake
initiation race, fixed by the wireguard-go bump in #22537.

Updates #22551

Change-Id: I227852aaa576e500df036bb1700fe6c7589b0a25
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-11-23 08:50:06 -08:00
fQwQf 0345103edd client/systray: shut down cleanly on termination signals (#22583)
Route SIGINT and SIGTERM through systray.Quit so the native tray loop
returns and invokes the exit callback. Stop signal delivery when Run returns.

Treat watcher cancellation as normal shutdown rather than terminating the
process with log.Fatal, and interrupt the reconnect delay when canceled.
Serialize exit cleanup with menu rebuilds.

Add subprocess tests for SIGINT, SIGTERM and the Quit menu action using a
private session bus and a fake LocalAPI.

Fixes #22582

Change-Id: I2360e203d4cc9bf3f0245133e9535d353b780e2c

Signed-off-by: fQwQf <[email protected]>
2026-11-23 09:25:34 -06:00
Brad Fitzpatrick 693839367f derp/derpserver: count packets, not seqs, in writer flood test
TestWriterFloodDoesNotStarveControlFrames checked that a pong queued
during a packet flood went out within a queue's depth of packets by
requiring the highest sequence number written before the pong to be at
most seqAtPong+depth. But the flood keeps the queue full, so enqueue
drops at the head (dropReasonQueueHead), and whenever the writer is
descheduled the flooder can push hundreds of newer packets through the
ring. The next packets the writer dequeues then carry sequence numbers
far past seqAtPong+depth even though it wrote no more than depth
packets before the pong, e.g.:

    pong written after packet 4573; want no later than packet 4071 (pong queued at 4039, depth 32)

The server's actual guarantee is in packets written: writePending
sends a pending pong before its queue drain, and each drain pass is
capped at perClientSendQueueDepth packets, so at most depth packets
are written between queuePong and the pong. Measure that directly:
read sclient.packetsSent right after queuePong and have the fake conn
record the packet frame count when the first pong is written. Reading
packetsSent after queuePong means a preemption in the test goroutine
can only loosen the bound, never cause a false failure.

The test still guards the anti-starvation property: with writePending's
per-pass budget removed it fails every run ("pong written after 720
more packets; want at most 32"), and with the budget doubled to
2*depth it fails 11 of 20 runs.

flakestress -p 4 -taskset 0-1:
before: 1401 failures / 24665 runs (5.7%)
after:  0 failures / 45896 runs

Fixes #22347

Change-Id: Ia751bae9789d9eb9f36f978ef14088b955b58785
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-11-23 07:21:41 -08:00
Brad Fitzpatrick 7a47412c33 cmd/derper: remove unpublished bootstrap DNS names, validate published ones
Remove --unpublished-bootstrap-dns-names and its TXT record rollout
percentages, unused in production since September. Require every
--bootstrap-dns-names entry to be a name that clients' fallback DNS
will ask for, per the shared net/dnsfallback/fallbacknames policy, so
names can be removed but not added. Queries for names outside the
published set now count as counter_bootstrap_dns_unknown_names.

Updates #21028

Change-Id: If9b7c3f6325de63eaaa3ba5bc9143ac5539af2ab
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-11-23 07:17:55 -08:00
Brad Fitzpatrick c7b017dc17 net/dnsfallback: only resolve Tailscale's own names, and not when offline
Client logs show that most DERP bootstrap DNS attempts come from clients
with no working network, retrying Tailscale's log and control servers,
and that the rest are mostly for names that DERP servers can't answer.
Skip the fallback when netmon says no interface is up, and don't try it
at all (or log about it) for names that aren't Tailscale's, returning
the original DNS error instead via a new dnscache.ErrNoFallback. The
name policy lives in a new leaf package, net/dnsfallback/fallbacknames,
so cmd/derper can share it.

Updates #21028

Change-Id: I25a0e4cc21866837416a24090a986e1b2dd1e78a
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-11-23 07:17:55 -08:00
Brad Fitzpatrick fefe73acf6 .github/workflows: give golangci-lint its own Go build cache
The golangci-lint job's setup-go cache key collided with the CodeQL
workflow's, so PRs restored CodeQL's main-branch build cache, which
lacks the test packages and export data golangci-lint loads. Package
loading thus ran nearly cold every time (~9 of ~10 minutes), and jobs
now regularly hit the 10m timeout. Use a dedicated cache key, and run
on pushes to main so there's a cache for PRs to restore.

Updates #18366
Updates tailscale/corp#28679

Change-Id: I7a23a66dc7198c030d6a378aa2733d558c8c37d9
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-11-23 07:01:16 -08:00