upki (github.com/rustls/upki, shipping in Ubuntu 26.10+) keeps a local
CRLite revocation cache that "upki fetch" refreshes on a timer. Add an
omittable "upki" feature that, after tlsdial's x509 verification
succeeds, checks the leaf against that cache if one is present and
rejects it if revoked. Missing caches, uncovered certs, and cache read
errors all fail open.
The cache is read with github.com/cpu/go-upki, the prototype for the
built-in crypto/tls support proposed in golang/go#82402. That built-in
check wouldn't cover us even once it ships, because crypto/tls skips it
when InsecureSkipVerify is set, and tlsdial always sets that so it can
do its own verification in VerifyConnection.
Updates #22680
Signed-off-by: Brad Fitzpatrick <[email protected]>
Change-Id: Idfa75794cbba9c90039355ffaeb21b5d5824a5fe
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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 #22043Fixes#22632
Change-Id: I48163fcd00e06dea261dfc163c15a839e1077a5f
Signed-off-by: Simon Law <[email protected]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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.
Fixestailscale/corp#47690
Signed-off-by: Taylor McIntyre <[email protected]>
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]>
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]>
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]>
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.
Fixestailscale/corp#51400Fixestailscale/corp#51402
Signed-off-by: Michael Ben-Ami <[email protected]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>