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.
Fixestailscale/corp#6528
Signed-off-by: Nick Khyl <[email protected]>
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]>
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]>
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]>
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]>
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]>
Commit 54a4fecaf made nodeAddrForNetwork copy the node's addresses
into a heap-allocated slice on every device-name dial. Use a small
stack buffer instead, and add a test that it doesn't allocate.
Updates #22261
Signed-off-by: Brad Fitzpatrick <[email protected]>
Change-Id: Id7d68b3db954d56193b80a3a1f1d7977f17b001a
* k8s-operator/reconciler/recorder: requeue Recorders when their Tailnet changes
A Recorder whose spec.tailnet refers to a Tailnet that is not ready yet is
marked RecorderReady=False and not requeued. Watch Tailnet resources and
enqueue the Recorders that refer to the changed Tailnet.
Fixes#22457
Signed-off-by: Alex Castillo <[email protected]>
* k8s-operator/reconciler/recorder: requeue when the Tailnet client is not ready
The Tailnet reconciler writes Ready and its finalizer before it marks the
client ready, and both writes enqueue Recorders. A reconcile in that window
still sees the tailnet as unavailable. Return the existing short requeue so
that case retries without waiting for another Tailnet event.
Move the Tailnet watch mapping test next to the other recorder tests.
Updates #22457
Signed-off-by: Alex Castillo <[email protected]>
* k8s-operator/reconciler/recorder: use FakeClientProvider in the ready test
TestRecorderProvisionsWhenTailnetBecomesReady had its own client provider,
a copy of reconcilertest.FakeClientProvider. Run two reconcilers on the
same fake client instead: the first fails to resolve the tailnet, and the
second resolves it with NewFakeClientProvider.
Updates #22457
Signed-off-by: Alex Castillo <[email protected]>
---------
Signed-off-by: Alex Castillo <[email protected]>
nodeBackend rebuilt extraDNS from DNS.ExtraRecords as a
map[string]netip.Addr, so a Service's A and AAAA records under the
same name overwrote each other and only the last one (the AAAA,
i.e. the IPv6 VIP) survived. resolveMagicDNS then returned only the
IPv6 VIP for UserDial dials of the Service name, with no IPv4
fallback, and a tcp4 dial of the name failed outright.
Keep every address per name (map[string][]netip.Addr) and select
among them with the same addrForNetwork helper used for device
names, which prefers IPv4 for unqualified networks and honors
tcp4/tcp6. This makes outbound HTTP proxy, SOCKS5, and 'tailscale
nc' dials of Service names reach the IPv4 VIP in IPv4-only
deployments (e.g. Kubernetes operator ingress ProxyGroups).
Fixes#22261
Signed-off-by: evan188199-tech <[email protected]>
linkChange only reconfigured the router after a network change
if LAN access was allowed, but the router config depends on
the local interfaces whenever an exit node is in use.
Fixes#22739
Signed-off-by: Nick Khyl <[email protected]>
authRoutine reported login attempts canceled by a pause, shutdown or
new login, such as when LocalBackend is restarting, to the health
tracker. A cancelation is either irrelevant, or it replaces an earlier
error and masks a real issue. Don't report errors once the attempt's
context is done, as is already the case for status updates.
login-state is then unhealthy only when logging in to the control plane
fails, so mark it as impacting connectivity. Among other things, that
lets it trigger captive portal detection.
Updates #12991
Updates #20078
Updates #18116
Updates #13378
Updates #1634
Updates tailscale/corp#27985
Updates #12701
Updates #14126
Signed-off-by: Nick Khyl <[email protected]>
In this PR, we make ExitNodeID, ExitNodeIP, ExitNode.AllowOverride,
AllowedSuggestedExitNodes, ExitNodeAllowLANAccess, EnableDNSRegistration,
UseTailscaleDNSSettings, UseTailscaleSubnets and ReconnectAfter profile
settings, so they can be configured by a policy source in the current
profile's scope as well as for the device.
We also make the current profile's scope the default one, so that tailscaled
uses settings from such sources. Device settings still take precedence,
and nothing changes until a profile-scoped source is registered.
Updates tailscale/corp#51945
Change-Id: I472595eb723cd3419003a02de8c66b0d8ebf9417
Signed-off-by: Nick Khyl <[email protected]>
crypto/tls sends no SNI for an IP address ServerName, so the
ConnectionState.ServerName seen by our VerifyConnection hook was empty.
x509 verification with an empty DNSName skips the name check, so any
cert from a trusted CA was accepted when dialing by IP, such as a DERP
node whose HostName is an IP using a LetsEncrypt IP cert. Fall back to
the IP in the tls.Config's ServerName, and fail if there's no name
to check, which includes net/http dials by IP.
Also, stop clearing RootCAs in Config, so SetConfigExpectedCert (used
for DERPNode.CertName) no longer drops the caller's extra roots.
Updates #11776
Updates #8085
Signed-off-by: Brad Fitzpatrick <[email protected]>
Change-Id: I3c810277895ba18f16f0b5de229b7d4fd972a802
Registering, replacing or unregistering a store, or calling Policy.Reload,
waited for the policy change callbacks to return, deadlocking if the caller
held a lock that a callback acquires, such as LocalBackend.mu.
Invoke the callbacks from an execqueue instead. The effective policy is
still updated by the time these calls return.
Updates tailscale/corp#51945
Change-Id: I4afa36b9acaa0e0104e4e420c561eab076d06c80
Signed-off-by: Nick Khyl <[email protected]>
Bump plan9netshell for go4org/plan9netshell@f7dfc18b3a,
which fixes interactive shells (broken since Go 1.25 by syscall.Exec),
^C, and hangup on disconnect.
Also stop creating the Plan 9 incubator with exec.CommandContext, which
killed it on any disconnect, unlike the graceful disconnect semantics
the Unix monitor path now has. For PTY sessions that orphaned the shell
and its foreground job. Now closing its stdio makes netshell hang up
the shell instead.
Updates #5794
Change-Id: I95cbca4997a6700c14d022fbf0d0c42486840782
Signed-off-by: Brad Fitzpatrick <[email protected]>
* cmd/k8s-proxy,ipn/ipnlocal,k8s-operator/api-proxy: drop PROXY protocol
The API server proxy in cmd/k8s-proxy took the caller's address from the
PROXY protocol header on its localhost listener, which any local process
could write. This fixes this by removing the header from both sides, and
making serve register each non-Funnel TCP forward to a loopback address
with the proxy mapper (as netstack does), so WhoIs on the connection's
real remote address returns the caller.
Updates tailscale/corp#48697
Thank you Winfunc for reporting
Signed-off-by: chaosinthecrd <[email protected]>
* ipn/ipnlocal,k8s-operator/api-proxy: add WhoIs and forged header tests
Adds a test that WhoIs on the backend side of a serve TCP forward returns
the source node while the forward is open and fails after it closes, for
IPv4, IPv6 and localhost targets, and that a Funnel flow or a backend on
a non-loopback address gets no node. Also adds a test that the API server
proxy's plain HTTP listener does not take the caller from a PROXY header
that a local client writes.
Updates tailscale/corp#48697
Signed-off-by: chaosinthecrd <[email protected]>
---------
Signed-off-by: chaosinthecrd <[email protected]>
* cmd/k8s-operator,k8s-operator,ipn/store/kubestore: add per-proxy RBAC
Proxies for Services, Ingresses, Connectors and PeerRelays run as the
shared proxies ServiceAccount, whose Role allows every verb on every
Secret in the operator namespace, so each proxy can read and change the
Secrets of the operator and of other proxies. This fixes this by giving
each of those proxies its own ServiceAccount, Role and RoleBinding, where
the Role names only that proxy's state Secrets, and the chart no longer
installs the proxies Role. It also removes the list and watch on every
Secret from ProxyGroup Roles, and the Secret rule with no resourceNames
that ProxyGroup and Recorder Roles got at zero replicas, so kubestore
read replicas now get cert Secrets by name. Existing proxy Pods restart
once on upgrade.
Updates tailscale/corp#51011
Signed-off-by: chaosinthecrd <[email protected]>
* cmd/k8s-operator,k8s-operator,ipn/store/kubestore: test per-proxy RBAC
Adds tests for the ServiceAccount, Role and RoleBinding that each Service
proxy and PeerRelay gets, including copied imagePullSecrets, and for the
ProxyGroup Role rules, including zero replicas. Adds an e2e test that
uses SubjectAccessReviews to check that a Service proxy and a ProxyGroup
can get their own state Secret, but cannot get the operator's OAuth
Secret or each other's state Secret, and cannot list Secrets. Also adds
tests for reloading shared TLS certs by name on read replicas, including
a cert Secret that is deleted and then recreated, and removes the test
for the Secret list that read replicas no longer do.
Updates tailscale/corp#51011
Signed-off-by: chaosinthecrd <[email protected]>
* kubestore: fix test lint failure
Change-Id: Ia988256dfe611a64b46cdb81d4e1d68bd7873ca4
Signed-off-by: Mike Jensen <[email protected]>
---------
Signed-off-by: chaosinthecrd <[email protected]>
Signed-off-by: Mike Jensen <[email protected]>
Co-authored-by: Mike Jensen <[email protected]>
* k8s-operator/sessionrecording: harden recording upload end handling
The session recording hijacker treated a recording upload that ended
without an error as finished, whether or not its session had ended.
This fixes this by checking that the session's connection was closed
first, and otherwise handling the end like an upload error (so the
session's recording failure policy applies), as ssh/tailssh does.
Updates tailscale/corp#51365
Change-Id: I909c6e48f43dc295b7c4b1e5762abe4e8aa6a484
Signed-off-by: chaosinthecrd <[email protected]>
* k8s-operator/sessionrecording: test recording upload end handling
This adds Test_Hijacker cases for a recording upload that ends without an
error, both after the session's connection was closed and while it is
still open, for each recording failure policy.
Updates tailscale/corp#51365
Change-Id: If021c7fa8fea52301dde058a481d84cad23fd185
Signed-off-by: chaosinthecrd <[email protected]>
---------
Signed-off-by: chaosinthecrd <[email protected]>
* k8s-operator/api-proxy: reject cross-origin browser requests in auth mode
In auth mode the API server proxy sets the caller's identity from their
tailnet address and does not check Origin. Browsers do not apply the
same-origin policy to WebSocket, so a page a tailnet user opened could
open exec, attach or watch WebSockets through the proxy and have them run
as that user.
This fixes this by rejecting cross-origin browser requests on every
route, as browsers also send simple cross-site POSTs without a
preflight. Requests with an Origin are checked on Sec-Fetch-Site first,
where same-origin and none pass and any other value is rejected, and if
the browser does not send it the Origin host must match Host. kubectl
and client-go send no Origin and the Python and fabric8 clients send one
that matches Host, so they still work, as do web UIs whose own proxy
rewrites Host, such as kubectl proxy, Headlamp and Backstage. Headlamp
desktop, whose file:// page is cross-site to its backend, now gets 403
for writes and WebSockets. noauth mode is unchanged as it has no
identity to borrow.
Updates tailscale/corp#51482
Signed-off-by: chaosinthecrd <[email protected]>
* k8s-operator/api-proxy: add test for cross-origin requests in auth mode
Adds a test that sends exec, attach and watch WebSocket upgrades and a
plain POST through the proxy with and without a foreign Origin and
Sec-Fetch-Site, and checks that in auth mode only requests with no Origin,
the proxy's own origin or Sec-Fetch-Site same-origin reach the API server.
Updates tailscale/corp#51482
Signed-off-by: chaosinthecrd <[email protected]>
---------
Signed-off-by: chaosinthecrd <[email protected]>
This change confines Taildrop filesystem operations to a persistent os.Root, preventing symlinks or receive-directory replacement from redirecting file access outside the intended directory. It also closes extension-owned roots during manager replacement and shutdown.
Fixestailscale/corp#51118
Credit to Aditya @adios-404 for reporting
Change-Id: Ica39b3603221b3c7ba4460b176aae9b67eb64556
Signed-off-by: Mike Jensen <[email protected]>
The Windowed UI depends on the Windows App Runtime, which cannot be
installed unless app sideloading or Developer Mode is enabled.
Sideloading is disabled by default on Windows builds older than 19041,
and can be disabled by the user or by policy on newer ones.
Add winutil.GetSideloadingState to read the settings, log the result
when tailscaled starts, and add gauges for sideloading being disabled
by policy, by the user or by default. Builds older than 17763 cannot
run the Windows App Runtime at all, so they are reported as unsupported
and do not count towards any of the gauges.
Updates tailscale/corp#52316
Signed-off-by: Nick Khyl <[email protected]>
* k8s-operator: allow setting runtimeClassName via ProxyClass
Add a runtimeClassName field to the ProxyClass CRD's pod spec, next to
priorityClassName, and propagate it to the proxy StatefulSet pod spec.
This lets users run proxy pods under a non-default RuntimeClass, for
example one provided by a confidential-computing or sandboxed runtime.
Updates tailscale/tailscale#21843
Signed-off-by: Abdelrahman Rabie <[email protected]>
* k8s-operator: regenerate manifests and API reference
Signed-off-by: Abdelrahman Rabie <[email protected]>
* k8s-operator: use omitzero for ProxyClass runtimeClassName
The vet check requires omitzero on pointer fields that are optional.
Updates #21843
Assisted-by: AI tool
Signed-off-by: Abdelrahman Rabie <[email protected]>
---------
Signed-off-by: Abdelrahman Rabie <[email protected]>
The err check after writeHeaderValueBlock in payload could never fire.
It tested the error from zlib.NewWriterLevelDict, which payload already
checks, and writeHeaderValueBlock calls t.Fatalf itself on a write
error. The nilness analyser in go vet flags it as an impossible
condition.
Remove the len(headerM) guard too, because payload returns early when
headerM is empty, and check the error from w.Flush, which was ignored.
Updates #22652
Change-Id: I23ec131d88a599b37364706dd2226f1456574461
Signed-off-by: David Bond <[email protected]>
Every health change while connectivity remained impacted ran captive
portal detection again, even though nothing about the network had
changed.
Track whether detection is due. It becomes due when connectivity stops
being impacted and when netmon reports a network change that likely
requires a rebind, and is no longer due once detection has run.
Health and pref changes still call maybeDetectCaptivePortal, but it
only runs detection when it is due. Otherwise, it just drops the
warning once connectivity is no longer impacted.
A result can still become wrong without either: the portal may start
intercepting after detection ran, or the user may log in to it while
connectivity remains impacted for other reasons. So detection also
becomes due on a health change while a captive portal is detected,
and on a retry timer that doubles from 2 to 60 seconds while connectivity
remains impacted. With retries, detection no longer waits 2 seconds
before its first run.
Updates #15396
Updates #1634
Updates tailscale/corp#27985
Signed-off-by: Nick Khyl <[email protected]>
onHealthChange signaled the detection loop over an unbuffered channel.
While the loop was busy running detection, which can take several
seconds per interface, the eventbus subscriber was blocked and reported
as slow. Additionally, every health change while connectivity remained
impacted requested another detection, including the change that
detection itself made to the captive portal warnable.
Replace the loop and the channel with a coalescedop: requests never
block, and those that arrive during a check cause exactly one more
check after it. Ignore changes to the captive portal warnable itself,
and log when detection runs instead of on every health change.
Without a loop to start and stop on backend state changes, detection
is now limited by the WantRunning pref alone, which was already
required. A change to it triggers a check, as does Init.
Updates #15396
Updates #21703
Signed-off-by: Nick Khyl <[email protected]>
In userspace mode when an exit node is selected but stops being offered,
drop the traffic.
Fixestailscale/corp#50584
Signed-off-by: frozenprocess <[email protected]>
Change-Id: I22ccf4c1209cdb346c787851197c9b52967aab56
Setenv refreshes the cached values behind RegisterString, RegisterBool,
RegisterOptBool and RegisterDuration, but had no case for RegisterInt.
An int knob kept its old value after Setenv, even though RegisterInt's
doc says mutations happen via Setenv.
Add the missing case and a test.
Fixes#21530
Change-Id: I3213c68a22619c0dd334b00f6eaa1e260ee20827
Signed-off-by: Jeremy Schoemaker <[email protected]>
The connector's ingress filter hook accepts any packet addressed to one
of its transit IP pools, on the understanding that the datapath will
take it from there. For most of what it admits, the datapath does not:
HandlePacketFromWireGuard returns Accept untouched for everything
isSupportedProtocol excludes, so SCTP, GRE, ESP and friends are handed
to the host stack addressed to a transit IP, which is not an address
this node holds.
Nor does the hook ask anything of the sender. A peer holding no conn25
grant at all, having registered no mapping, can send those to any
address in a connector's pool and have the filter wave them through.
Split the ingress hook off into ingressAllow and have it require a
protocol the datapath can map. What is left behind serves only the
link-local hook, which lifts the filter's blanket drop of link-local
destinations rather than accepting anything, so rename it to
linkLocalAllow to match its remaining job and the client's hook of the
same name. A packet to a transit IP still has to pass ingressAllow
either way. packetFilterAllowReason loses its reason to be named after
a packetFilterAllow and becomes transitIPAllowReason.
Non-first fragments are unaffected: Filter.pre accepts ipproto.Fragment
before RunIn consults the hooks at all.
Updates https://github.com/tailscale/corp/issues/50118
Change-Id: I3486377181f406465293902c91f39b873741c6ec
Signed-off-by: Mazdak Nasab <[email protected]>
The promvarz and tailscaled /debug/varz handlers wrap varz.Handler with
metrics it doesn't know about: promvarz writes the Prometheus client's
metrics first, and tailscaled appends clientmetrics. With the match and
interval parameters that varz got in 258b087998 (#22636), that meant
unfiltered metrics around filtered ones, a bad parameter's error after
a 200 and a full dump, and streams that didn't start with a frame. Now
requests with a query string get only varz's own output.
Updates tailscale/corp#47429
Change-Id: I617969401b1ff269db32481b2656841b70355d57
Signed-off-by: Brad Fitzpatrick <[email protected]>
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]>