Commit Graph
11914 Commits
Author SHA1 Message Date
James Tucker f0c37d5807 cmd/tailscale/cli: test known_hosts generation with ML-DSA host keys
Verify that genKnownHosts and golang.org/x/crypto/ssh/knownhosts accept
and validate ssh-mldsa-44 host keys advertised in PeerStatus.SSH_HostKeys
alongside classical Ed25519 keys.

Updates #22864

Change-Id: I7985492c8a4e495764b783ebed9f553974f2e3a9
Signed-off-by: James Tucker <[email protected]>
2026-12-04 12:26:59 -08:00
NazarkinRomanandRoman Nazarkin f8accbe3c4 wgengine/router: accept loopback traffic from Service VIPs (#22702)
In TUN mode the VIPs of a Tailscale Service have to be on a local
interface, so a connection from the node to its own Service runs over
lo with a VIP as both source and destination. ts-input accepts loopback
traffic only from the node's own addresses, so over IPv4 these packets
hit the CGNAT anti-spoofing DROP, and the node cannot reach its own
Service. IPv6 has no such drop and works.

Have the Linux router keep an "-i lo -s <vip> -j ACCEPT" rule for each
address in router.Config.ServiceAddrs, like it does for LocalAddrs,
re-adding them when the netfilter mode changes. The rule matches only
packets that enter on lo, so it has no effect unless the VIP is a local
address.

Fixes #22701

Change-Id: I94563d2b3b989f29a737de1e377ab59f9e25fc2c

Signed-off-by: Roman Nazarkin <[email protected]>
Signed-off-by: Brendan Creane <[email protected]>
Co-authored-by: Roman Nazarkin <[email protected]>
2026-12-04 12:19:31 -08:00
Simon Law f53a1c7ba4 util/linuxfw: correct swapped table and chain names in error message (#22878)
In nftables, when a chain was not found, Tailscale would report:

	chain mangle not found in table OUTPUT

for the OUTPUT chain in the mangle table.

This patch strikes that and reverses it.

It also adds types/structs.RequireKeyedLiterals to prevent this from
happening again to this struct.

Fixes #22877

Change-Id: I930b1c2d66dc658e0486400fd7dc2c93591c3984

Signed-off-by: Simon Law <[email protected]>
2026-12-04 11:21:24 -08:00
Francois Marier ffcc7836f3 cmd/tta,tstest/natlab/vmtest: add vmtest for port mapping deletion
Add a TTA /stop-tailscaled command that sends SIGTERM to tailscaled
and waits for the process to exit.

TestPortmapDelete uses it to check that the tailscale client deletes
its PCP, NAT-PMP or UPnP mapping when it shuts down cleanly.

Fixes #21713

Change-Id: I2dfb6468fbe8dbe2483fefd83590fdda7b2e8fb2
Signed-off-by: Francois Marier <[email protected]>
2026-12-04 12:11:02 -07:00
Mike O'Driscoll 87e4d40046 wgengine/magicsock: send CallMeMaybe to peers whose endpoints we don't know (#22902)
magicsock only sent a CallMeMaybe after disco-pinging at least one of
the peer's endpoints. So if neither node's netmap had the other's
endpoints, neither ever started discovery, and traffic between them
stayed on DERP for good, even though each had the other's disco key and
home DERP and could have told the other its endpoints over DERP.

Control sends Funnel targets to Tailscale's ingress nodes without their
endpoints, and sent the ingress nodes to the targets without endpoints
too, so all Funnel traffic was relayed over DERP.

When we know none of a peer's endpoints, send it a CallMeMaybe anyway,
at most once per discoPingInterval. The peer then pings our endpoints,
which tells us its endpoints, and normal discovery takes over. Only one
of the two nodes needs this change.

Add TestMemnetDirectWithoutEndpoints, which fails without this change.

Updates #22576

Change-Id: I098ca7023f38070eb6e27aff876d3030d9fdbadf

Signed-off-by: Mike O'Driscoll <[email protected]>
2026-12-04 13:43:24 -05:00
Brad Fitzpatrick 63a8c8dd39 tstest/memnettest: test direct/DERP path failover on memnet in synctest
Add a new test-only package, tstest/memnettest, for tests that run
whole nodes and the servers they talk to on a memnet.Network in a
testing/synctest bubble, using the engine's TestOnlyPacketListener and
TestOnlyDERPDialer hooks.

Its first test, TestMemnetPathFailover, runs two nodes, each a full
userspace engine (tstun, wireguard-go, magicsock) with a netstack, plus
a DERP server and a STUN server. A TCP stream between the nodes starts
on a direct UDP path. The test then drops UDP between the nodes, checks
that the stream keeps working once both fall back to DERP, then lets
UDP through again and checks that both return to the direct path. That
covers about 20 seconds of magicsock timers but runs in about 10ms, and
the bubble checks that no goroutines outlive the nodes.

Updates #22831

Change-Id: I04adb4af691302fd012bc8d52193f7e6d4152bc7
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-12-04 09:47:22 -08:00
Mike O'Driscoll 0e8bf23404 control/tsp: let SendMapUpdate send endpoints (#22898)
Add SendMapUpdateOpts.Endpoints so tsp clients can tell control how
peers can reach them directly. cmd/ingressd needs this: without its
endpoints in their netmaps, Funnel nodes never start NAT traversal to
ingressd, and all Funnel traffic is relayed over DERP.

Updates #22576

Change-Id: Ibbae9770dcea6eca0d11b01010151d534a2f700f

Signed-off-by: Mike O'Driscoll <[email protected]>
2026-12-04 11:20:29 -05:00
Brad Fitzpatrick f11f3e9307 cmd/tsvet: add MainWith, skip cgo-generated files, add jsonduration
Other repos building on package tsvet had to modify its analyzers in
place to turn some off or skip some packages, and to not report
problems in files that cgo generates from C declarations.

Add MainWith, which runs exactly the given analyzers, so callers can
filter or wrap Analyzers instead. Drop diagnostics in cgo-generated
files for all analyzers.

deferrecover reported recover in function literals assigned to
variables that are deferred, such as "f := func() { recover() };
defer f()". Treat a function literal assigned to a variable as deferred
if the variable is ever deferred or is used other than by calling it
(including parameters, results, and package-level variables), as it
may then be deferred elsewhere.

Add jsonduration from tailscale/corp, which reports JSON-tagged
time.Duration fields, which need a jsonformat wrapper type to be
encoded the same way by encoding/json/v2. Fields only encoded by v1
encoding/json, as integer nanoseconds, can instead be declared with the
new jsonformat.DurationAsIntegerNanos alias for time.Duration, which
isn't an API change. Do so for the four existing ones.

That makes tailcfg and others depend on jsonformat, so make jsonformat
use encoding/json/v2 directly, rather than go-json-experiment's aliases
for it.

Updates #22811

Change-Id: I53c1bf4febb6b4c223b6697dfd9a502ee2e96051
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-12-04 06:50:29 -08:00
Navid Khan (Ali) 82ba6c3623 cmd/k8s-nameserver: return NOERROR for A queries on IPv6-only names (#22366)
The A branch of handleFunc returned NXDOMAIN whenever a name had no
IPv4 records, without checking IPv6. A name with only AAAA records
therefore both existed and did not exist depending on the query type,
and resolvers that treat NXDOMAIN as final (musl, busybox) failed to
resolve IPv6-only names at all.

Mirror the AAAA branch: only return NXDOMAIN when the name has
neither A nor AAAA records; when only IPv6 records exist, return
NOERROR with no A answers, per RFC 4074.

Fixes #22358

Signed-off-by: Navid Khan (Ali) <[email protected]>
2026-12-04 12:15:17 +00:00
Jeremy Schoemaker 5610fe6b29 cmd/k8s-operator: restrict load-balancer status to LoadBalancer Services (#22712)
The API server rejects load-balancer ingress status on ClusterIP and
NodePort Services. Writing it alongside the configured condition caused
reconciliation to fail once an ingress ProxyGroup backend advertised the
Tailscale Service, so the condition could never become ready.

Only publish load-balancer ingress for LoadBalancer Services. Continue
updating the configured condition for every exposed Service type.

Test the unready, advertising and withdrawn states for all three Service
types, with a fake-client interceptor enforcing the API server's status
validation.

Fixes #22028

Change-Id: I57f0309cb2fce61eef0373641580bf8a3354da61

Signed-off-by: Jeremy Schoemaker <[email protected]>
2026-12-04 12:03:21 +00:00
Nurullah MorshedandClaude Opus 5.5 81fe9507ef cmd/k8s-operator,k8s-operator: apply ProxyClass probes to PeerRelay pods (#22798)
* cmd/k8s-operator,k8s-operator: apply ProxyClass probes to PeerRelay pods

The ProxyClass livenessProbe and readinessProbe from #22461 were applied
only to ProxyGroups. A PeerRelay StatefulSet rolls with RollingUpdate, but
its Pods had no readiness probe, so a template change replaced every
relay within seconds and peers relaying through them fell back to DERP.

The probe helpers move from cmd/k8s-operator to the shared tailscaled
reconciler package, and ApplyProxyClass now applies them to the relay
container. ProxyGroups use the same code, unchanged. With a
readinessProbe set, a PeerRelay rollout waits for each new relay to be
Ready before it replaces the next one.

Fixes #22670

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Nurullah Morshed <[email protected]>

* k8s-operator: report a PeerRelay ProxyClass whose probes can't run

A ProxyGroup reports a ProxyClass that sets probes while its env turns
the /livez and /readyz endpoints off as invalid. A PeerRelay skipped the
probes without saying so.

The check moves to tailscaled.ValidateProbes, shared by both. A PeerRelay
whose ProxyClass fails it gets Ready=False with reason ProxyClassInvalid,
and nothing is created, as for its other invalid specs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Nurullah Morshed <[email protected]>

* k8s-operator/reconciler/tailscaled: rename probes subtest for tsvet

Updates #22670

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Nurullah Morshed <[email protected]>

---------

Signed-off-by: Nurullah Morshed <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-12-04 10:54:35 +00:00
James Tucker 44fc559bf8 ipn/ipnlocal: report client metrics for PQ vs classic Serve TLS handshakes
Add two clientmetric counters in serveTLSConfig when terminating TLS for
Serve and Funnel connections (both HTTPS Serve and TLS-terminated TCP
forwarding), excluding ACME tls-alpn-01 challenge handshakes:

  - serve_tls_pq
  - serve_tls_classic

Updates tailscale/corp#52720

Change-Id: I411a45118adba722ec5bd2f80baf224df611793c
Signed-off-by: James Tucker <[email protected]>
2026-12-04 01:54:09 -08:00
James Tucker 5f104edef0 cmd/derper: report TLS PQ key exchange request and active connection metrics
Add MultiLabelMap metrics alongside derper_tls_request_version and
gauge_derper_tls_active_version to track post-quantum vs classic key
exchange usage across all HTTPS endpoints served by derper:

  - derper_tls_request_key_exchange{pq,group} (counter)
  - derper_tls_active_key_exchange{pq,group} (gauge)

The active gauge reuses hijackTrackingResponseWriter so hijacked
connections (DERP, WebSocket DERP, CONNECT) remain counted until closed.

Updates tailscale/corp#52720

Change-Id: Iea553ee6efd30907d3f719f7e5a7de3573b34533
Signed-off-by: James Tucker <[email protected]>
2026-12-04 01:53:13 -08:00
James Tucker b08899f18c derp/derpserver: report TLS PQ metrics for DERP and WebSocket connections
Track accepted and currently active DERP connections in Server.ExpVar by
transport ("http" vs "websocket"), post-quantum status ("true", "false",
or "none" when r.TLS is nil), and negotiated TLS key exchange group:

  - derp_tls_accepts{transport,pq,group}
  - derp_current_tls_connections{transport,pq,group}

Both derpserver.Handler and derpserver.AddWebSocketSupport inspect r.TLS
before handing off to Server.Accept (without retaining *http.Request on
hijacked goroutines) and decrement the active gauge when Accept returns.

Updates tailscale/corp#52720

Change-Id: I32bdb549c1218654df1f86e91b0217c5a169c566
Signed-off-by: James Tucker <[email protected]>
2026-12-04 01:01:28 -08:00
James Tucker aff6d18f39 derp/derphttp: report client metrics for PQ vs classic TLS connections
Add two clientmetric counters recording whether TLS DERP client
connections (both HTTPS upgrade and WebSocket paths where TLS state is
available) negotiated a post-quantum or classic key exchange:

  - derphttp_connect_tls_pq
  - derphttp_connect_tls_classic

Also propagate res.TLS from websocket.Dial in derphttp/websocket.go so
non-js WebSocket dials populate Client.tlsState and report PQ status.

Updates tailscale/corp#52720

Change-Id: Idcbc7fe4580e515632a4ade7a0bbfe9ae266e4f1
Signed-off-by: James Tucker <[email protected]>
2026-12-04 01:00:12 -08:00
James Tucker f082989ae6 net/tlsdial, control/controlhttp: export IsPQCurve and CurveName helpers
Move post-quantum TLS key exchange classification from control/controlhttp
into net/tlsdial.IsPQCurve so DERP client and server metrics can share the
same classification. Also add net/tlsdial.CurveName to format tls.CurveID
values into bounded metric label strings.

Updates tailscale/corp#52720

Change-Id: Ibfdc787a4afe411364888d61fe2314a4589b4f73
Signed-off-by: James Tucker <[email protected]>
2026-12-04 00:59:13 -08:00
Nick Khyl 5e622e4a4c ipn/ipn{state,local},cmd/tailscale/cli: report the protocol of the last WireGuard session
Add PeerStatus.LastProtocol, the protocol of the WireGuard session
last established with a peer. Unlike Protocol, it is kept after
the session ends. It is forgotten when the peer is removed or
its node key changes, and it is not persisted across tailscaled
restarts.

Use it for the hybrid-pq label in tailscale status --verbose and
on the web status page, so that the label no longer depends on
the session still being up.

Updates #22853
Updates tailscale/corp#50068
Updates tailscale/corp#52622

Signed-off-by: Nick Khyl <[email protected]>
2026-12-03 22:48:46 -08:00
James Tucker 35f4a6e55a control/controlhttp: prefer post-quantum/P-384 HTTPS before HTTP and default HTTPS
Previously, the Noise control dialer preferred plaintext HTTP on port 80
and only fell back to HTTPS on port 443 for middlebox compatibility,
because Noise already encrypted the inner connection with X25519.

To protect control connections against near-term 256-bit ECC / quantum
concerns when the server supports stronger key exchange, without
sacrificing compatibility, dial in three staggered stages:

  1. TLS 1.3 with post-quantum key exchange (hybrid ML-KEM), falling
     back to P-384/P-521 (excluding 256-bit ECC curves X25519 and P-256)
  2. Plaintext HTTP (Noise over HTTP), unless forceNoise443 is set
  3. Default HTTPS using Go's default TLS settings (matching the
     existing Tailscale HTTPS fallback)

Also adds clientmetric counters for the negotiated transport
(controlhttp_dial_pq_https, controlhttp_dial_p384_https,
controlhttp_dial_http, controlhttp_dial_classic_https) and a
TS_DISABLE_NOISE_PQ_HTTPS envknob to restore the legacy HTTP-first order.

Updates #21022
Updates tailscale/corp#52709

Change-Id: I9f1d264ee196a58e75857b4401be8185de4b3e3e
Signed-off-by: James Tucker <[email protected]>
2026-12-03 19:56:27 -08:00
Nick Garlis 85095d76d9 util/linuxfw: remove connmark rules in firewall cleanup (#22417)
The iptables and nftables cleanups didn't remove the connmark rules
from the mangle tables, so they were left behind by --cleanup and
after an unclean exit followed by a switch to another firewall mode.

AddConnmarkSaveRule created mangle/OUTPUT with type filter, which
iptables-nft can't add rules to. Create it with type route, as
iptables-nft does, and at startup delete the old filter-type chain
if nothing else uses it.

Updates #22363

Change-Id: I7b64e8e9894773f1dd88384c3339106603db15ae
Signed-off-by: Nikolaos Gkarlis <[email protected]>
2026-12-03 17:39:29 -08:00
Nick Khyl c069cc6561 various: mark hybrid-pq sessions in tailscale status
Report in ipn.PeerState and ipnstate.PeerStatus whether the current
WireGuard session with a peer was established with a hybrid
post-quantum handshake, and print "hybrid-pq" for such peers
in tailscale status --verbose.

The value comes from wireguard-go's PeerSessionStateFunc,
which now carries it along with the session state.

Updates #22853
Updates tailscale/corp#50068
Updates tailscale/corp#52622

Signed-off-by: Nick Khyl <[email protected]>
2026-12-03 17:18:37 -08:00
James Tucker ec75c026e4 ssh/tailssh: add pure ML-DSA-44 host key support
Go 1.27 (crypto/mldsa, crypto/x509) and golang.org/x/crypto v0.59.0
already implement pure ML-DSA SSH host keys (ssh-mldsa-44, per
draft-sfluhrer-ssh-mldsa-08) and PKCS#8 private key serialization.

Filter host key specs against ssh.SupportedAlgorithms().HostKeys so
builds without ML-DSA support (such as GOFIPS140=v1.0.0) continue to
skip unsupported key types cleanly, and add mldsa44 host key
generation, system key lookup, and handshake/integration test coverage.

Updates #22864
Updates #22807

Change-Id: I191e62a9a3d439db0c999172b283d00d501e1bcc
Signed-off-by: James Tucker <[email protected]>
2026-12-03 14:01:37 -08:00
Brad Fitzpatrick bf353f9754 ssh/tailssh: don't switch host keys when OpenSSH creates new ones
On macOS, launchd's sshd-keygen-wrapper recreates missing system host
keys on any TCP connection to port 22. tailssh preferred system keys
and re-read them on every connection, but only advertised its keys in
Hostinfo at startup or on prefs changes, so peers then failed host key
verification. Keep using host keys tailssh previously generated even
if system keys appear later, and load the keys once per process.

Fixes tailscale/corp#52474

Change-Id: I3ab9d27ecb246b91d184700ca6aabbb366f11023
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-12-03 11:54:26 -08:00
James Tucker 3ab0d50817 cmd/proxy-test-server: use upstream golang.org/x/crypto/acme
proxy-test-server already imports golang.org/x/crypto/acme/autocert and
only uses acme.ALPNProto, so it does not need tailscale.com/tempfork/acme.

Updates #10238

Change-Id: Ife3b33e1ce3164cebeb75041238d04eb808490ba
Signed-off-by: James Tucker <[email protected]>
2026-12-03 11:05:25 -08:00
James Tucker b66743bb05 cmd/derper: use upstream golang.org/x/crypto/acme for IP certs
Upstream golang.org/x/crypto/acme gained issuance profile support in
v0.59.0 (golang/go#73101), so cmd/derper no longer needs
tailscale.com/tempfork/acme. Switch ipcert.go to upstream
golang.org/x/crypto/acme using acme.WithOrderIssuanceProfile.

Also switch from CreateOrderCert to CreateCertFromOrder so order
finalization does not depend on the optional Location header in the
finalize response.

Updates #10238
Updates #22654

Change-Id: I28b4ed7f0af5e496fcc9e56ea9cd1112bbe19bb0
Signed-off-by: James Tucker <[email protected]>
2026-12-03 11:05:00 -08:00
Francois Marier 865435c678 net/portmapper: add metrics on available protocols
We want to measure the relative availability of each port mapping
protocol in the wild in order to more effectively prioritize
work in this area. This weighs active devices more heavily.

Updates tailscale/corp#51202

Change-Id: Iea5908cc3108e602256a9a7bd73c89ec5e3e10ff
Signed-off-by: Francois Marier <[email protected]>
2026-12-03 09:42:57 -07:00
Brendan Creane cd8532f160 ipn/ipnlocal: send one Notify per control status update (#22441)
A full netmap from control produced up to five separate ipn.Notify
messages: LoginFinished, the login prefs, the self node and peers, the
exit node suggestion, and the re-resolved exit node prefs. A GUI that
applied each one on arrival briefly showed the state between them.

setControlClientStatusLocked now collects all of them into one Notify,
sent from a deferred call when any field is set. suggestExitNodeLocked
no longer sends. It records a changed suggestion in a Notify that its
caller passes in, and the caller sends it with its other changes. The
two netmap blocks after the prefs save are merged. Nothing between them
ran unlocked.

Fixes #22206

Signed-off-by: Brendan Creane <[email protected]>
2026-12-03 08:11:18 -08:00
Nick Khyl cb5166bdc7 health: don't publish a stale Change from a superseded visibility timer
The visibility timer's callback only checked that its Warnable was
still unhealthy. If the Warnable was reset just as the timer fired, the
callback published the old Change even though the Warnable was no
longer visible, and removed the new timer from pendingVisibleTimers, so
that SetHealthy could not stop it. Similarly, changing a pending
Warnable's args left the old timer running.

Subscribers such as captive portal detection then received a Change for
a Warnable that was not in CurrentState.

Stop the pending timer when the unhealthy state changes, and make the
callback check that the state it was started for is still current.

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

Signed-off-by: Nick Khyl <[email protected]>
2026-12-03 07:58:51 -08:00
Nick Khyl 94f41e9841 net/{captivedetection,netns}: bind captive portal probes to interfaces on Windows
Without this, we try to send probes through the Tailscale interface when an exit node
is in use. The exit node is usually unreachable until the user signs in to the captive portal,
so the probes get blackholed and we miss the portal.

Updates #1634
Updates #17095
Updates tailscale/corp#21896

Change-Id: I124652d5a4e933089084f4317f7242c3e1470b99
Signed-off-by: Nick Khyl <[email protected]>
2026-12-03 07:18:03 -08:00
Brad Fitzpatrick 5ad3413af4 ipn/ipnlocal: resolve Service ExtraRecords by short name in UserDial
nodeBackend indexed device names under both their FQDN and short name
but DNS.ExtraRecords only under the record name, and control sends
Services only as FQDNs. So with userspace networking, dials of a
Service by its short name fell through to the system resolver and
failed, while TUN clients worked via the OS search domain. Also index
ExtraRecords under the MagicDNS suffix by their short name, if it is a
single label. Device names and literal short-name records still win.

Fixes #22778

Signed-off-by: Brad Fitzpatrick <[email protected]>
Change-Id: I4c03df285a80fcd7093cf47fe9a3eb73de116a13
2026-12-03 05:44:27 -08:00
Brad Fitzpatrick b21f560533 cmd/tsvet: replace cmd/vet, staticcheck, golangci-lint, and checklocks
We ran overlapping checks in four tools at different versions:
golangci-lint only reported problems on changed lines, vet only ran
for linux, and staticcheck took seven CI jobs, each compiling the tree
from scratch.

cmd/tsvet now runs the go vet suite, staticcheck, checklocks, and our
own analyzers as a single vettool, for linux, windows, and darwin, plus
a goimports check of all Go files. Small analyzers replace the
golangci-lint and revive checks that nothing else covered, and
lint:ignore directives work for every check.

CI runs it with the next toolchain (tailscale.go1.28), whose go vet
type checks dependencies instead of compiling them. Pushes to main
save one cache that per-GOOS PR jobs restore, and go test no longer
runs its own vet in jobs that tsvet covers.

Over the past 30 days, these checks cost about 43 runner-minutes per
PR (29 of them staticcheck's). On a 4-core machine, tsvet checks the
whole tree for all three GOOS values in 3m27s from an empty cache and
10s when nothing changed. Its cache for all three is 1.3 GB (176 MB
compressed), versus 5 GB for just linux when vet compiles with Go
1.27. Dropping golangci-lint also removes 161 lines from go.mod.

Fixes #22645
Fixes #22653

Signed-off-by: Brad Fitzpatrick <[email protected]>
Change-Id: Idf8779d8d3e1f5e87a8a431a53949db9c143d236
2026-12-03 05:33:36 -08:00
BeckyPauley 08caf267a0 Add e2e test for upgrading k8s operator (#22360)
* cmd/k8s-operator/e2e: consolidate shared test helpers and fix PeerRelay test

Move the readiness and reachability checks for ingress, ProxyGroup and API
server proxy tests into shared helpers in helpers_test.go so the upcoming
upgrade/downgrade suite can reuse them.

Also change the PeerRelay verify helpers from exact-equality to subset
checks so this does not fail in real clusters once the Service gets a
LoadBalancer address.

Updates tailscale/corp#34562

Signed-off-by: Becky Pauley <[email protected]>

* cmd/k8s-operator/e2e: add test for upgrade/downgrade of the operator

TestOperatorVersionChange installs the operator at one version, performs
baseline checks, changes the operator to another version, and asserts the
resources stay healthy across the change.

Tests can be run as an upgrade, downgrade or a round-trip (upgrade then
rollback). After each version change, the test re-verifies every managed
resource (ingress, egress, ProxyGroup, API server proxy, PeerRelay),
confirms the operator and proxy workloads actually rolled to the new image,
and performs connectivity checks.

Also skip rebuilding and side-loading a kind image when the node already has
the tagged image, matching the existing EnsurePushed logic when using the
--registry path.

Updates tailscale/corp#34836

Change-Id: Id643255f99a06cf9fbabb722dd37293c8f097c61
Signed-off-by: Becky Pauley <[email protected]>

---------

Signed-off-by: Becky Pauley <[email protected]>
2026-12-03 08:53:00 +00:00
Jimmyman1465andBrad Fitzpatrick 945494e329 cmd/tailscaled: skip logtail initialization on --cleanup
The Linux systemd unit runs "tailscaled --cleanup" as ExecStopPost
without $FLAGS, so --no-logs-no-support in FLAGS wasn't seen and
cleanup started logtail on every stop or restart, contacting
log.tailscale.com and falling back to bootstrap DNS. Cleanup only
tears down local DNS and router state, so skip logtail setup for it.

TestCollectPanic relied on --cleanup uploading the previous run's
panic, so it now uploads it from a normal daemon start instead.

Fixes #22836

Change-Id: Ie7a9cbd7be29aae37613b49deac1285f4a0aaa6d
Signed-off-by: Jimmyman1465 <[email protected]>
Co-authored-by: Brad Fitzpatrick <[email protected]>
2026-12-02 20:42:57 -08:00
Brad Fitzpatrick c277dd1791 net/memnet: add UDP support
Add Network.ListenPacket, making Network a nettype.PacketListener with
in-memory UDP sockets. Packets go by exact destination address and
port. Sending never blocks; packets to an address without a socket, or
to a full receive queue, are dropped. An unspecified or empty listen IP
binds the family's loopback address, and port zero picks the next
ephemeral port in rotation, so a just-closed socket's port isn't handed
right back out, as with an OS.

Reads block only on channels and timers, including for read deadlines,
so the sockets work in testing/synctest bubbles. That's for running
magicsock (via its TestOnlyPacketListener) and STUN (via
stuntest.ServeWithPacketListener) on an in-memory network with fake
time.

Updates #22831

Change-Id: Id7043412ca036b075927c6352c663d73f2b8657f
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-12-02 18:06:59 -08:00
Brad Fitzpatrick 24feea8da5 wgengine, wgengine/magicsock, derp/derphttp: add memnet test hooks
To enable synctest across more and more Tailscale tests, this wires up
some existing test-only hooks more, and adds another.

With them and a memnet.Network (and #22833 for memnet UDP support), a
test can run full userspace engines, their DERP server and a STUN
server in a testing/synctest bubble.
 
Updates #22831

Change-Id: I751775a1b3d8c89cbc9d669951f0ec22a00d9696
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-12-02 17:39:02 -08:00
Brad Fitzpatrick ebb46e100d net/memnet: accept tcp4 and tcp6 in Listener.Dial
Listener.Dial checked strings.HasSuffix(network, "tcp"), so it rejected
"tcp4" and "tcp6", which Network.Dial accepts and passes through. A
derphttp region client dials each DERP node with "tcp4" or "tcp6", so
it couldn't reach a DERP server on a memnet Network.

Accept exactly "tcp", "tcp4" and "tcp6".

Updates #22831

Change-Id: I699c40ed9c0b4a41fa3509514bd1f1bf828adb25
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-12-02 16:17:28 -08:00
Mazdak Nasab 667f2ffce4 feature/conn25: enforce the grant's proto/port ranges in the filter (#22605)
A conn25 app grant reaches the connector as a peer capability keyed
tailscale.com/cap/conn25/<app>, and peercap.Conn25Prefix already documents
that each value under such a key is a tailcfg.ProtoPortRange whose union is
what the peer may reach. Nothing implemented that: both consumers only called
PeerCapMap.HasCapability, so once a client had registered a transit IP, the
connector accepted any protocol on any port to any address in the transit
pool.

Decode the values when the client registers a transit IP, store them with the
mapping, and check every inbound packet against them in the connector's
ingress filter hook. A packet from WireGuard addressed to a transit IP always
falls through to IngressAllowHooks, since a transit IP is never in localNets,
so the check sees every packet rather than just TCP SYNs, and a denial gets
the usual RejectedDueToACLs TSMP reply.

Split packetFilterAllow in two along the way. linkLocalAllow keeps the old
pool-membership behaviour, which exists only to lift the filter's blanket drop
of link-local unicast destinations; ingressAllow makes the access decision. A
transit IP with no registered mapping still passes ingressAllow, so that the
datapath can drop it and answer with the TSMP that prompts the client to
re-register. Nothing is forwarded on its behalf.

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

Change-Id: Ic7abc89be12afe2be758fac7700fc21f89465be5

Signed-off-by: Mazdak Nasab <[email protected]>
2026-12-02 13:36:27 -07:00
Nick Khyl e3ddebe50c tstest/integration: fail tests when tailscaled logs an [unexpected] line
tailscaled uses the [unexpected] log prefix for conditions that should
never happen. Record such lines as the log catcher receives them and
report each one as a test error when the test environment shuts down.
Run tailscaled with IN_TS_TEST=1 so logs are uploaded as they are
written, rather than batched every two seconds and partly lost when the
process is killed at the end of the test.

Updates #22307

Signed-off-by: Nick Khyl <[email protected]>
2026-12-02 07:45:55 -08:00
Nick Khyl d55ba7218e tstest/integration/testcontrol: send a ControlTime after the peer expiry epoch
The fixed ControlTime of 2020-08-03 is before the epoch that ipnlocal's
peer expiry code uses to reject implausible control times, so every
tailscaled in the integration suite logged an [unexpected] warning on
each netmap update and skipped peer expiry handling. Move it to
2024-01-01, keeping it fixed so TestControlTimeLogLine can still match
it exactly.

Updates #22307

Signed-off-by: Nick Khyl <[email protected]>
2026-12-02 07:45:55 -08:00
Nick Khyl 54da9f7868 health: don't restart DERP warnables' TimeToVisible while not in map poll
Since bd9725c5f, every self-check made while out of a map poll marked
no-derp-connection and derp-timeout healthy and then unhealthy again,
restarting their TimeToVisible. As failed DERP reconnects and engine
status updates each run a self-check every few seconds,
no-derp-connection rarely became visible, and captive portal detection
was not triggered or had its warning cleared right away.

Determine each DERP warnable's state once per self-check.

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

Change-Id: Id6d43ece267765b064956167c3d359138b0faeff
Signed-off-by: Nick Khyl <[email protected]>
2026-12-02 07:41:23 -08:00
Nick Khyl 45098febab ipn/auditlog: don't restore logs for a profile without an ID
The extension starts a logger when the control client is created,
which for a new profile happens before the profile has an ID.
Start then tried to load stored logs with an empty key and logged
"[unexpected] failed to restore logs: empty key" on every fresh start,
as seen in the Windows integration tests.

A profile without an ID has no stored logs, so skip the restore.

Updates #cleanup
Updates #22309 (the only [unexpected] log line in integration tests)

Signed-off-by: Nick Khyl <[email protected]>
2026-12-02 07:19:55 -08:00
Tom Meadows 7edc089a07 cmd/k8s-operator,k8s-operator: give ProxyGroups the chart imagePullSecrets (#22785)
* cmd/k8s-operator,k8s-operator: give ProxyGroups the chart imagePullSecrets

The operator copies the Helm chart imagePullSecrets value from the proxies
ServiceAccount onto the ServiceAccount of each Service, Ingress, Connector
and PeerRelay proxy, but not onto the one it creates for each ProxyGroup,
so with a private registry ProxyGroup Pods cannot pull the proxy image.
Its update of that ServiceAccount also removed all annotations, while
OpenShift adds an annotation and a pull secret to every ServiceAccount,
adds them again when they are removed, and the operator watches this one.
This fixes this by adding the imagePullSecrets of the proxies
ServiceAccount to the ProxyGroup ServiceAccount and keeping the
annotations and pull secrets that others add. Entries removed from the
chart value stay on existing ProxyGroup ServiceAccounts.

Fixes #22783
Fixes #22784

Change-Id: Ided67a2972b81c1a95281cf8ef85eae34fee4a3c
Signed-off-by: chaosinthecrd <[email protected]>

* cmd/k8s-operator: test ProxyGroup ServiceAccount pull secrets and annotations

Adds a test that egress, ingress and kube-apiserver ProxyGroups get the
imagePullSecrets of the proxies ServiceAccount without losing entries or
annotations that others add, and that kube-apiserver ProxyGroups in auth
mode leave the static ServiceAccount alone. It also checks that reconcile
fails without creating the ServiceAccount when the proxies ServiceAccount
cannot be read.

Updates #22783
Updates #22784

Change-Id: Ibf73086cdf0f622cc7761cc5f0a6cee482a3b5c8
Signed-off-by: chaosinthecrd <[email protected]>

---------

Signed-off-by: chaosinthecrd <[email protected]>
2026-12-02 10:59:06 +00:00
Brad Fitzpatrick ba01cd8c93 all: fix problems found by running vet and staticcheck everywhere
These were hidden because golangci-lint only reported problems on
changed lines and vet never ran for windows or darwin. Among them, a
tsconnect build ignored precompression errors and two printf calls
formatted pointers with %d.

Fixing them first clears the way for an upcoming rework of vet in CI
that unifies our assorted static analysis checkers into one tool.

Fixes #22652
Updates #22653

Signed-off-by: Brad Fitzpatrick <[email protected]>
Change-Id: I89e8f5899a2fb9a2d477379e0c2c977d48e001a0
2026-12-02 02:45:54 -08:00
Nick Khyl cd4f621399 clientupdate: don't uninstall the Windows client after a failed update
If msiexec failed to install an update for any reason, installMSI
assumed it was a downgrade, which msiexec does not permit, uninstalled
the current version and tried again. If the second attempt failed too,
such as when a custom action in the new package kept failing,
the device was left without Tailscale.

Uninstall the current version only if the requested version is older
than it, and do so before running the installer. Otherwise, return
the error and let Windows Installer roll back to the current version.

If the current version has been uninstalled and Windows Installer
is busy with another installation, keep retrying with a backoff
for up to 30 minutes rather than leaving the device without Tailscale.

Fixes tailscale/corp#45537
Updates tailscale/corp#52316

Change-Id: I066480c718b3bfca53a65c54ebf948562bc6ba2b
Signed-off-by: Nick Khyl <[email protected]>
2026-12-01 14:43:23 -08:00
Nick Khyl fbec7529aa cmd/tailscaled: upload the client metrics of the Windows subprocess
On Windows, tailscaled runs as a service that starts a subprocess to do
the actual work. Only the service process uploads logs, and only its own
client metrics went with them, which left out nearly all of the metrics,
as they are counted in the subprocess.

Have the subprocess write the changes in its metrics to its output ahead
of its log lines, and have the service process merge them into its own
metrics with clientmetric.Remote rather than log them.

Stop skipping TestClientMetricsUploaded for the Windows service.

Fixes tailscale/corp#6528

Signed-off-by: Nick Khyl <[email protected]>
2026-12-01 12:13:24 -08:00
Nick Khyl ff9b8a19d9 util/clientmetric: add Remote to merge the metrics of another process
Client metrics are uploaded along with the logs of the process that
has them. A process whose logs are uploaded by another process, such as
the tailscaled subprocess of the Windows service, has no way to report
its metrics.

Add Remote, which applies the deltas encoded by another process to the
metrics of the same names in this one, so that both are reported as one,
by Metric.Value as well as in the logs.

A counter is the sum of its values in both processes, and keeps what
a remote process has added to it after that process exits.

A gauge is set to its value in the remote process, and to zero
when that process exits.

Updates tailscale/corp#6528

Signed-off-by: Nick Khyl <[email protected]>
2026-12-01 12:13:24 -08:00
Nick Khyl e50206add7 tstest/integration: test that client metrics are uploaded
Add a test that waits for a metric counted by the backend to be
uploaded along with the logs.

Skip it if tailscaled runs as a Windows service. The service process
uploads the logs, and only its own metrics with them, while nearly all
of the metrics are counted in its subprocess.

Updates tailscale/corp#6528

Signed-off-by: Nick Khyl <[email protected]>
2026-12-01 12:13:24 -08:00
Brendan Creane ccd15f4ff3 wgengine/router,ipn/ipnlocal: keep Service VIPs in the stale address sweep (#22790)
Since 77d2c87b1, the Linux router removes any Tailscale-range address
on the tunnel interface that is not in LocalAddrs. That deleted the
address of a Tailscale Service served in TUN mode when the operator had
assigned it to the tunnel interface. Pass the Service addresses to the
router as Config.ServiceAddrs so the sweep keeps them, and skip the
sweep while LocalAddrs is empty.

Updates #22701

Signed-off-by: Brendan Creane <[email protected]>
2026-12-01 12:02:39 -08:00
Mike Jensen 4ad3c29228 feature/taildrop: remove Close from FileOps interface (#22792)
In PR #22749 we attempteed to clear up the casting needed for the fileOps for the close action by using the io.Closer interface. This broke the dependency to our android repo.

This change both removes this interface change that breaks compatability, and also removes the closeOps field. After further review this field was no longer necessary after we removed the persistent root behavior.

Updates tailscale/corp#51118

Change-Id: I1870030f130e92950843afb8c306b32f2008fca4

Signed-off-by: Mike Jensen <[email protected]>
2026-12-01 10:46:25 -07:00
tailscale-code-updater[bot]andDep Updater 48bc7bf76b go.mod: bump github.com/tailscale/wireguard-go (#22791)
* github.com/tailscale/wireguard-go: https://github.com/tailscale/wireguard-go/compare/a8c4fbf26d6c...d74d4ff62061

Triggered by @illotum via the bumpdep workflow.

Updates #22298

Signed-off-by: Dep Updater <[email protected]>
Co-authored-by: Dep Updater <[email protected]>
2026-12-01 09:25:36 -07:00
luckydropship 12814dfc26 cmd/k8s-operator,k8s-operator: use errors instead of github.com/pkg/errors (#22369)
These were the last two uses of github.com/pkg/errors in the tree and both
were plain errors.New calls, so they move to the standard library
unchanged. Several dependencies still require the module, so it becomes an
indirect requirement rather than leaving go.mod, and it drops out of
cmd/k8s-operator's binary entirely, so its depaware manifest no longer
lists it.

Moving the require line changes the go.mod fingerprint recorded in
flakehashes.json, so its goModSum is regenerated. The vendor SRI is
unchanged, because the module is still vendored for those other
dependencies.

Updates #cleanup

Change-Id: I6beb0ea2943863a46c56714f2878f3e019d120d2

Signed-off-by: luckydropship <[email protected]>
2026-12-01 15:49:16 +00:00