Commit Graph
11826 Commits
Author SHA1 Message Date
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
Mike O'Driscoll 82cb6f8ba0 wgengine/router: add envknob to disable src_valid_mark (#22591)
Add TS_DEBUG_DISABLE_SRC_VALID_MARK to allow disabling
of net.ipv4.conf.all.src_valid_mark being set.

Updates #3310
Updates #19796

Signed-off-by: Mike O'Driscoll <[email protected]>
2026-11-23 09:59:20 -05:00
Brad Fitzpatrick c3a92572e8 tsnet: wait for control to know s2's DERP home and endpoints in delta tests
TestPingPeerLearnedViaDelta failed on Linux and Windows with

    Ping(disco): error Post ".../localapi/v0/ping?ip=100.64.0.2&size=0&type=disco": context deadline exceeded

and the same for type=TSMP. The disco variant can't be the wireguard-go
duplicate handshake race fixed by #22537, and it still failed on main
with that fix.

The test puts s1 in manual MapResponse mode, starts s2, then copies
control.Node(s2Key) into a PeersChanged delta for s1. startServer only
waits for s2's local home DERP connection, not for s2's lite map update
carrying its HomeDERP and endpoints to reach control. If the snapshot
was taken first, s1 learned an s2 with no DERP home and no endpoints,
and because s1's automatic map responses are suppressed it never got
the later update, so neither disco nor TSMP pings could reach s2.
TestPingSubnetRouteOfDeltaPeer had the same pattern.

Add controlNodeReachable, which polls control until the node has a
HomeDERP and endpoints, and use it for both snapshots.

Injecting a random 0-300ms sleep before controlclient's SendUpdate
makes the original test fail nearly every run with the exact CI
errors (8/8 subtests); with this change 0 failures in 6 runs each of both
tests under the same injection.

flakestress -p 4 -taskset 0-1 -duration 8m, no injection:

    before: 2 failures in 1128 runs (both Ping(disco) deadline)
    after:  0 failures in 1148 runs

Fixes #22562

Change-Id: Ic5f0e1498d566a89102d92c216ae892a293d5472
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-11-23 06:41:04 -08:00
Brad Fitzpatrick 66e3d823c7 tstest/integration: deflake TestClientSideJailing
TestClientSideJailing waited only for each node's netmap to show the
peer with the expected IsJailed bit, then made a single 1s DialTCP for
each direction. But a peer's endpoints, DERP home, and disco key reach
the other node via separate map updates that can land after the peer
first appears in the netmap. If the first dial's WireGuard handshake
initiation is sent before then, magicsock drops it ("Failed to send
handshake initiation: no UDP or DERP addr") and wireguard-go does not
retry for 5s, so every "should succeed" dial in that window fails.
That matches the CI failures on the race-root-integration job: both
dials in not_jailed, and sometimes the uni_jailed n2-to-n1 dial too,
failed with exactly 1s/2s subtest durations.

This is a test bug, not a jail propagation bug: the jailed state and
the data plane peer routes and jailed filter are installed under the
same LocalBackend lock as the netmap the test polls.

Retry the dials that should succeed until they connect (up to 20s).
The dials that should fail still get a single attempt, since a late
path can only make them fail more. Also drop the flakytest.Mark.

The flake didn't reproduce unaided locally (0/192 runs; 0/95 with
-race and 2 CPUs). Delaying testcontrol's processing of endpoint
updates by 200ms reproduces it deterministically:

    before: 95/95 runs failed (with 200ms injected delay)
    after:  0/136 runs failed (with 200ms injected delay)
    after:  0/71 runs failed (-race, taskset 0-1, no injection)

Fixes #17419

Change-Id: I779d173d5d6c01fe878848cdfe049e7f29d20775
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-11-23 05:19:07 -08:00
chaosinthecrd 8c3db134d8 feature/acme: add tests for cert status of invalid cached certs
Covers not-yet-valid, untrusted CA (in date and expired), name mismatch,
cert/key mismatch and bad PEM through the C2N handler and
LocalBackend.CertStatus, and checks that getCertPEM still goes on to
issue a new cert for each unusable cached cert. Also checks that each
certStore returns errCertInvalid for a name mismatch.

Updates #22304

Signed-off-by: chaosinthecrd <[email protected]>
2026-11-23 11:16:53 +00:00
chaosinthecrd f0ce5749d1 feature/acme: report Expired only when a cached cert has expired
validCertPEM returned a bool and every certStore Read turned any failure
into errCertExpired, so the C2N tls-cert-status response and the
localapi cert-status endpoint reported Expired for an in-date cert that
failed verification for another reason (unknown CA, name mismatch,
cert/key mismatch, bad PEM). This fixes this by returning errCertExpired
only when the leaf is past its NotAfter, and otherwise an error wrapping
a new errCertInvalid that carries the verification error into the status
Error field. A cert that is not yet valid now counts as invalid, not
expired. getCertPEM treats errCertInvalid like errCertExpired, so a
cached cert that fails verification is still reissued.

Fixes #22304

Signed-off-by: chaosinthecrd <[email protected]>
2026-11-23 11:16:53 +00:00
Brad Fitzpatrick f7d2828f3a wgengine: stamp Status.AsOf when endpoints are read, strictly increasing
TestTUNDNS failed on Windows CI with:

    waitForPeerReachable([uOLy9]): peer [uOLy9]: no endpoints

The peer had a HomeDERP in control but never any endpoints, for 30s.

userspaceEngine.getStatus snapshotted e.endpoints under e.mu, then
walked the wireguard-go peers (which can block on the device mutex),
and only then set AsOf: time.Now(). RequestStatus lets two goroutines
run getStatus concurrently (for example the magicsock endpoints
callback and the TUN "external route: up" event goroutine). If the
goroutine that read the old, empty endpoints finished last, its status
had the newest AsOf, so LocalBackend.setWgengineStatus's AsOf ordering
check accepted it, reset b.endpoints to empty and sent that to
control. magicsock's endpoints hadn't changed, so nothing ever resent
them. On Windows the monotonic clock is coarse, so two statuses can
also get equal AsOf values, which the strict Before check lets through
in either order.

Take AsOf in the same critical section as the endpoints read and make
it strictly increasing, so a status with older endpoints always has an
older AsOf and is discarded.

Reproduced on Linux by injecting a random 0-20ms sleep in getStatus
between the endpoints read and the wgdev peer walk:

    before: 9 failures in <=48 runs of TestTUNDNS ("no endpoints")
    after:  0 failures in 56 runs

(The natural rate on Linux is too low to measure; the one CI failure
was on Windows.) The other TestTUNDNS failure on the dashboard (Linux,
TSMP ping "context deadline exceeded") was the wireguard-go duplicate
handshake race fixed by the wireguard-go bump in #22537.

Fixes #22563

Change-Id: Id290c7422846dc390d3cd914f7b7cfabe593e739
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-11-22 22:12:16 -08:00
Dep Updater ceccbc303d go.mod: bump 5 modules
* github.com/gokrazy/firmware: https://github.com/gokrazy/firmware/compare/6bd1fd16a2e2...d8b761d7b4ca
* github.com/gokrazy/kernel.amd64: https://github.com/gokrazy/kernel.amd64/compare/eb0ff0075854...17ff614bf8bc
* github.com/gokrazy/kernel.arm64: https://github.com/gokrazy/kernel.arm64/compare/595ae821533a...03045c240b24
* github.com/gokrazy/kernel.rpi: https://github.com/gokrazy/kernel.rpi/compare/85ea215f0624...a4a58496f7f6
* github.com/gokrazy/rpi-eeprom: https://github.com/gokrazy/rpi-eeprom/compare/30711eb43bb5...fb3324aa4fc1
* github.com/gokrazy/breakglass: already current
* github.com/gokrazy/gokrazy: 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-22 21:39:11 -08:00
Brad Fitzpatrick af9bfa07c3 net/tstun, feature/conn25: make app connector hooks safe to set while running
feature/conn25 installs its tstun.Wrapper hooks from its ipnext
extension's Init, which runs from LocalBackend.Start. By then the
wireguard-go device's RoutineReadFromTUN goroutine is already reading
packets and calling filterPacketOutboundToWireGuard, which read the
plain PreFilterPacketOutboundToWireGuardAppConnectorIntercept field
with no synchronization. A packet from the OS TUN in that window was a
data race; under -race, tailscaled in tstest/integration died with
"WARNING: DATA RACE" (conn25.go installHooks write vs wrap.go:797
read), and the test then failed with "running tailscale status: ...
EOF". All six CI logs examined show this same race.

Make the three hooks conn25 sets after startup
(PreFilterPacketOutboundToWireGuardAppConnectorIntercept,
PostFilterPacketInboundFromWireGuardAppConnector and
OnUnmappedTransitIPMessage) syncs.AtomicValues.

Add TestSetAppConnectorHooksWhileRunning, which installs the hooks
while packets flow in both directions and reproduces the CI race at
the same wrap.go line.

flakestress -race TestSetAppConnectorHooksWhileRunning:
before: 12564/12564 runs failed; after: 0/1176 runs.

The integration flake was too rare to measure locally (a few failures a
week in CI). It was blamed on tstest/integration TestTUNMode,
TestMagicDNS and TestSplitDNS.

Fixes #22557

Change-Id: Iff618c18c11f84dcbae27805024e908403031a08
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-11-22 16:46:06 -08:00
Loz Brown 678b3be66b feature/androidbin: register Android cgo fallback
Enable the existing Android-safe interface fallback in cgo
builds. Keep androidbin out of condregister for Android cgo
applications, which provide their own interface getter; embedded
consumers can opt in by importing androidbin directly.

Updates #17311

Change-Id: Ia26706d9757525c1bc619935574797808b693034
Signed-off-by: Loz Brown <[email protected]>
2026-11-22 15:06:36 -08:00
Brad Fitzpatrick 87b3a5ff26 control/ts2021, net/netutil: fail early if net/http's HTTP/2 is disabled
The ts2021 protocol speaks HTTP/2 inside the Noise stream. With
GODEBUG=http2client=0 (or the nethttpomithttp2 build tag), net/http
can't, and http.DefaultTransport also never gets a TLSClientConfig,
which made controlhttp crash tailscaled with a nil pointer dereference.
Return a clear user-visible error from ts2021.NewClient instead, and
make netutil.NewDefaultTransport always return a non-nil
TLSClientConfig.

Fixes #22578

Change-Id: I119c6ebbd6f1bbb5c693fb44a577862b98e688f3
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-11-22 07:57:32 -08:00
Brad Fitzpatrick a54bdf2bf2 .github/actions/go-cache: cache the cigocacher binary
Building cigocacher took most of the ~15-27s "Set up cigocacher" step
on every Windows job. Cache the binary in actions/cache, keyed on
cmd/cigocacher, go.mod, and go.sum, and add a test that cigocacher has
no other tailscale.com dependencies so that key stays complete.

Updates tailscale/corp#34812
Updates tailscale/corp#28679

Change-Id: I2def6f28a045249b2e87331a1f42c621e161031f
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-11-22 07:02:10 -08:00
Brad Fitzpatrick a33097932f net/dnsfallback, net/captivedetection: drop decommissioned DERP 6a, make test hermetic
The static fallback DERP map embedded in net/dnsfallback still lists
node 6a at 68.183.90.120 (an old Bangalore DigitalOcean IP). That IP
is no longer a Tailscale DERP server: it now belongs to an unrelated
nginx host that either times out or answers /generate_204 with "404
Not Found". Captive portal detection treats any 404 as a captive
portal.

This is a production bug, not just a test bug: a client without a
DERP map yet (fresh start, no on-disk cache) falls back to this static
map, so a detection that picks 6a wrongly warns the user about a
captive portal. It also made TestDetectCaptivePortalReturnsFalse,
which probed five random nodes from that map, flaky whenever 6a was
picked and nginx happened to answer.

Region 6's only node, 6a, is dead, so remove region 6 entirely. The
DERP server at that IP was retired when region 6 moved from
DigitalOcean Bangalore to Linode Mumbai (tailscale/corp#50435,
tailscale/corp#51314). Region 6 still exists in the control-sent DERP
map, but its new nodes are deliberately not added here: the list is
not regenerated or grown, as we're moving away from DERP servers
acting as bootstrap DNS servers (#21028). If a cached DERP map from
control has a region 6, GetDERPMap still merges it in whole, as it
does for any region missing from the static map.

Also make the test hermetic. It now runs Detect against five local
derpserver.ServeNoContent servers on 127.0.0.1. Five is enough that
the controlplane/login.tailscale.com endpoints sorted after them are
never tried. The servers listen on tcp4 explicitly, because when
httptest falls back to [::1] the challenge "ts_[::1]:port" is
rejected by isChallengeChar. Add TestDetectCaptivePortalReturnsTrue,
where one server answers 404 like the stale node did. Both tests skip
if no local server got a request (no usable non-loopback interface).
TestEndpointsAreUpAndReturnExpectedResponse still covers the real
endpoints.

Failures were seen on Linux and Windows, on main and many branches
(37 on the flakes dashboard since 2026-11-13):
http://flakes/flake?name=tailscale.com%2Fnet%2Fcaptivedetection.TestDetectCaptivePortalReturnsFalse

flakestress -p 4, before: 48/418 runs failed (11.5%), all with
"want=204, got=404". After: 0/4250 runs of TestDetectCaptivePortal*
(throttled to 2 workers with 100ms pauses; unthrottled stress of a
10ms test uses up local ephemeral ports in TIME_WAIT and fails in
bind instead).

Fixes #22550
Updates #21028

Change-Id: I2a45e7fb3e21b887bfd0952a846c98d68b03f89c
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-11-21 21:00:56 -08:00
Nick Khyl 1a4f4eb6ce net/netmon: don't hold mu while closing the OS monitor
On Windows, winMon.Close unregisters the route/address/interface change
callbacks and waits for in-flight ones to return. Those callbacks call
Monitor.isActive, which takes m.mu. Monitor.Close held m.mu across
om.Close, so a change notification arriving during Close deadlocked
with it, and the test binary hung until the timeout.

Release m.mu before calling om.Close. m.closed is already set under the
lock, so late callbacks see the monitor as inactive and return.

This is also the root cause of the Windows "ipnlocal: watchdog timeout"
panics that kill the ipn/ipnlocal and wgengine/netstack test binaries.

Add TestMonitorCloseWaitsForOSCallback, which uses a fake osMon whose
Close, like winipcfg's Unregister, waits for a callback that needs
m.mu. That reproduces the deadlock on any OS.

flakestress TestMonitorCloseWaitsForOSCallback, -p 4, linux:
  before: 16/16 runs deadlocked
  after:  0/135569 runs

Fixes #22228
Fixes #22548

Change-Id: Ibe7740ca23a1ab375d37c280838942f49b4a6a8f
Signed-off-by: Nick Khyl <[email protected]>
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-11-21 16:16:23 -08:00
Dep Updater 1cc8632af3 go.mod: bump github.com/tailscale/wireguard-go
* github.com/tailscale/wireguard-go: https://github.com/tailscale/wireguard-go/compare/330f55178f24...a8c4fbf26d6c

Triggered by @raggi via the bumpdep workflow.

Updates #22475

Signed-off-by: Dep Updater <[email protected]>
2026-11-21 15:55:16 -08:00
Brad Fitzpatrick 1db8e79a8b .github: use gomodfs for the Go module cache on Windows CI
Instead of restoring the module cache from actions/cache, the Windows
jobs now install WinFsp and mount a gomodfs remote store (on the Azure
VNet, at vars.GOMODFS_AZURE_URL, defaulting to ci-gocached-azure-1:8090)
on M:, which also provides the tsgo toolchain via ~/.cache/tsgo. gomodfs
is started via ShellExecute so it doesn't inherit the step's pipes,
which would make the runner kill it at the end of the step, and a
separate step checks that it survived before pointing GOMODCACHE at it.
If anything fails, the jobs warn and fall back to downloading modules
and the toolchain directly.

Updates tailscale/corp#34812

Change-Id: I26cea9cfa483d5fb3fd51b1d0f87a9204f792690
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-11-21 11:12:52 -08:00
Brad Fitzpatrick ee7324a20e ipn/ipnlocal: deflake TestServeAppCapsConcurrentStreams on Windows
The test started 400 requests at once, each proxied over a fresh
loopback connection to one httptest server. On Windows, the dials that
overflow the listen backlog are refused, the proxy returns an empty 502,
and the test reported that as "/ops: capabilities header missing". Cap
the requests in flight at 8 and report non-200 responses as such.

Reproduced on Linux in a network namespace with net.core.somaxconn=128
and tcp_abort_on_overflow=1 (12 of 200 runs failed). With the fix, 0 of
5000 failed there, and 0 of 2000 with somaxconn=8. With the original
bug fix from 566f89e0f reverted, the test still fails 50 of 50 runs.

Flakes analysis: http://flakes/analyze-test?name=tailscale.com%2Fipn%2Fipnlocal.TestServeAppCapsConcurrentStreams

Fixes tailscale/tailscale#22543

Change-Id: Ia3f74832d958744442b837d928a21aafa0445772
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-11-21 10:34:47 -08:00
Alex Valiushko 36780d60ef magicsock,tstun: add gauges for the number of open queues and sockets (#22535)
Updates tailscale/corp#48168
Updates tailscale/corp#37878

Change-Id: I8bedbc5043dccf0a2aecd77dfb76899c6a6a6964
Signed-off-by: Alex Valiushko <[email protected]>
2026-11-20 16:05:40 -07:00
Mazdak Nasab 8dc50105e4 feature/conn25: do not lock mu in packetFilterAllow (#22534)
packetFilterAllow holds c.mu while touching nothing it protects.
It only calls getIPSets, a func field assigned once in newConn25
that reads the config out of an atomic pointer.
Its siblings transitIPInPool and destinationInPools already call
it unlocked. Drop the acquisition, which besides being dead
was a lock-ordering hazard if getIPSets ever grows a lock of its own.

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

Change-Id: I2942a9b0a6a57378473393c62611c557f07e71b3

Signed-off-by: Mazdak Nasab <[email protected]>
2026-11-20 15:24:05 -07:00
Mazdak Nasab 4f7439b415 feature/conn25: name lock-requiring methods Locked (#22532)
Two methods read or write state guarded by their receiver's mutex without
taking it, relying on every caller to hold it, but were not named to say
so. enqueueAddressAssignment documented the requirement in prose only;
lookupAddrBySrcIPAndTransitIP had no doc comment at all. Rename both with
the Locked suffix the package already uses for drainAddrsLocked,
transitIPRoutableLocked and removeFlowLocked, and give the connector
lookup a doc comment stating the requirement.

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

Change-Id: Ib8bcaf5809ae6f982a504ae554ad1304dbb53018

Signed-off-by: Mazdak Nasab <[email protected]>
2026-11-20 14:48:51 -07:00
Brad Fitzpatrick 05abd5d73e 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-20 12:44:01 -08:00
Nick Khyl 262640ff4e util/syspolicy/source: notify sessions when a forced read finds a change
A Reader is shared by all effective policies that include its source.
A forced read through one of them updated the Reader's cached snapshot
and marked it up to date, but didn't notify the other sessions, so
their policies kept the old settings.

Since a89b32904, "tailscale syspolicy reload" reloads the caller's user
policy rather than the device policy used by LocalBackend. On Windows,
a registry change made without a Group Policy refresh was therefore
reported as configured by the CLI but never applied by the backend.

Updates tailscale/corp#51820

Signed-off-by: Nick Khyl <[email protected]>
2026-11-20 11:48:47 -08:00
Nick Khyl b837008974 clientupdate: don't exit tailscaled when starting the Windows installer
When an update is requested via LocalAPI, updateWindows runs inside
tailscaled, and its os.Exit(0) after launching the tailscale.exe copy
made the service restart the tailscaled child process immediately.

Exit only when running as tailscale.exe. In tailscaled.exe,
wait for the installer instead, which stops the service as part
of the upgrade. As a side effect, an install that fails before
stopping the service is now reported as a failed update.

Updates tailscale/corp#40430

Change-Id: I8af60fa12740dafceb7c9ea4f50d87c1cad27fa4
Signed-off-by: Nick Khyl <[email protected]>
2026-11-20 11:10:50 -08:00
Fran Bull b21a970437 feature/conn25: mint tokens for DNS responses
Implement the new peerapi hook and add the tokens authenticating that
the destination IP addresses were seen by this connector when forwarding
a DNS query for the given app.

Updates tailscale/corp#46169

Signed-off-by: Fran Bull <[email protected]>
2026-11-20 10:49:42 -08:00