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 <nickk@tailscale.com>
* 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#22783Fixes#22784
Change-Id: Ided67a2972b81c1a95281cf8ef85eae34fee4a3c
Signed-off-by: chaosinthecrd <tom@tmlabs.co.uk>
* 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 <tom@tmlabs.co.uk>
---------
Signed-off-by: chaosinthecrd <tom@tmlabs.co.uk>
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 <bradfitz@tailscale.com>
Change-Id: I89e8f5899a2fb9a2d477379e0c2c977d48e001a0
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.
Fixestailscale/corp#45537
Updates tailscale/corp#52316
Change-Id: I066480c718b3bfca53a65c54ebf948562bc6ba2b
Signed-off-by: Nick Khyl <nickk@tailscale.com>
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 <nickk@tailscale.com>
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 <nickk@tailscale.com>
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 <nickk@tailscale.com>
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 <bcreane@gmail.com>
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 <mikej@tailscale.com>
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 <60489098+luckydropship@users.noreply.github.com>
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 <bradfitz@tailscale.com>
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 <alex.castillog33@gmail.com>
* 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 <alex.castillog33@gmail.com>
* 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 <alex.castillog33@gmail.com>
---------
Signed-off-by: Alex Castillo <alex.castillog33@gmail.com>
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 <238371241+evan188199-tech@users.noreply.github.com>
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 <nickk@tailscale.com>
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 <nickk@tailscale.com>
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 <nickk@tailscale.com>
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 <bradfitz@tailscale.com>
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 <nickk@tailscale.com>
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 <bradfitz@tailscale.com>
* 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 <tom@tmlabs.co.uk>
* 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 <tom@tmlabs.co.uk>
---------
Signed-off-by: chaosinthecrd <tom@tmlabs.co.uk>
* 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 <tom@tmlabs.co.uk>
* 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 <tom@tmlabs.co.uk>
* kubestore: fix test lint failure
Change-Id: Ia988256dfe611a64b46cdb81d4e1d68bd7873ca4
Signed-off-by: Mike Jensen <mikej@tailscale.com>
---------
Signed-off-by: chaosinthecrd <tom@tmlabs.co.uk>
Signed-off-by: Mike Jensen <mikej@tailscale.com>
Co-authored-by: Mike Jensen <mikej@tailscale.com>
* 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 <tom@tmlabs.co.uk>
* 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 <tom@tmlabs.co.uk>
---------
Signed-off-by: chaosinthecrd <tom@tmlabs.co.uk>
* 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 <tom@tmlabs.co.uk>
* 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 <tom@tmlabs.co.uk>
---------
Signed-off-by: chaosinthecrd <tom@tmlabs.co.uk>
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 <mikej@tailscale.com>
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 <nickk@tailscale.com>
* 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 <abdelrahman.sec@hotmail.com>
* k8s-operator: regenerate manifests and API reference
Signed-off-by: Abdelrahman Rabie <abdelrahman.sec@hotmail.com>
* 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 <abdelrahman.sec@hotmail.com>
---------
Signed-off-by: Abdelrahman Rabie <abdelrahman.sec@hotmail.com>
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 <davidsbond93@gmail.com>
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 <nickk@tailscale.com>
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 <nickk@tailscale.com>
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 <jeremy@shoemoney.com>
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 <mazdak.nasab@gmail.com>
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 <bradfitz@tailscale.com>
Use `pipetcp.Pipe()` which handles this edge case now.
Fixes#20880
Signed-off-by: Naman Sood <mail@nsood.in>
Co-authored-by: Brendan Creane <bcreane@gmail.com>
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 <mazdak.nasab@gmail.com>
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 <francois@tailscale.com>
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 <bradfitz@tailscale.com>
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 <mikeo@tailscale.com>
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 <sfllaw@tailscale.com>
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 <saikumarpola@outlook.com>
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 <bradfitz@tailscale.com>
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 <sfllaw@tailscale.com>
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 <sfllaw@tailscale.com>
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 <bradfitz@tailscale.com>
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 <mail@nsood.in>
Co-authored-by: Brendan Creane <bcreane@tailscale.com>
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 <bradfitz@tailscale.com>