Commit Graph
1632 Commits
Author SHA1 Message Date
Brad Fitzpatrick e90284980b lanscaping: remove some linux router netlink stuff
-rwxr-xr-x@ 1 bradfitz  staff  10209378 Jan 11 11:08 /Users/bradfitz/bin/tailscaled.min
-rwxr-xr-x@ 1 bradfitz  staff  10354840 Jan 11 11:08 /Users/bradfitz/bin/tailscaled.minlinux

Change-Id: Iab8ef086ca00e06ca5c348bf41a8e3b87437c295
Signed-off-by: Brad Fitzpatrick <[email protected]>
2025-01-11 11:08:22 -08:00
Brad Fitzpatrick a3149830f2 lanscaping: remove sockstats
-rwxr-xr-x@ 1 bradfitz  staff  10243186 Jan 11 10:57 /Users/bradfitz/bin/tailscaled.min
-rwxr-xr-x@ 1 bradfitz  staff  10682520 Jan 11 10:57 /Users/bradfitz/bin/tailscaled.minlinux

Change-Id: I08e82ee3b95e4b0f6cd68e0f96c79421486bad4b
Signed-off-by: Brad Fitzpatrick <[email protected]>
2025-01-11 10:57:08 -08:00
Brad Fitzpatrick c299606f3c lanscaping: remove more Drive
-rwxr-xr-x@ 1 bradfitz  staff  11238738 Jan 11 08:06 /Users/bradfitz/bin/tailscaled.min
-rwxr-xr-x@ 1 bradfitz  staff  11862168 Jan 11 08:06 /Users/bradfitz/bin/tailscaled.minlinux

Change-Id: Ie4ea56e56c1c1cfcf75df4cedebb579ba6644cf7
Signed-off-by: Brad Fitzpatrick <[email protected]>
2025-01-11 08:06:08 -08:00
Brad Fitzpatrick a4948db5a3 lanscaping: remove HTTP proxy support
-rwxr-xr-x@ 1 bradfitz  staff  11459922 Jan 11 07:58 /Users/bradfitz/bin/tailscaled.min
-rwxr-xr-x@ 1 bradfitz  staff  11927704 Jan 11 07:58 /Users/bradfitz/bin/tailscaled.minlinux

Change-Id: Ib1a6fea38b277abe93e76e2b4b47ba94aa97e3ba
Signed-off-by: Brad Fitzpatrick <[email protected]>
2025-01-11 07:58:49 -08:00
Brad Fitzpatrick c85d84a099 lanscaping: remove HTTPS/ICMP pings from netcheck
-rwxr-xr-x@ 1 bradfitz  staff  11577042 Jan 11 07:48 /Users/bradfitz/bin/tailscaled.min
-rwxr-xr-x@ 1 bradfitz  staff  12058776 Jan 11 07:48 /Users/bradfitz/bin/tailscaled.minlinux

Change-Id: I71eb4e17245c53c9733a8b0ee844d1883296ec0f
Signed-off-by: Brad Fitzpatrick <[email protected]>
2025-01-11 07:49:08 -08:00
Brad Fitzpatrick 454126075d lanscaping: remove dnscache, dnsfallback
and kubetypes

-rwxr-xr-x@ 1 bradfitz  staff  11695922 Jan 11 07:46 /Users/bradfitz/bin/tailscaled.min
-rwxr-xr-x@ 1 bradfitz  staff  12189848 Jan 11 07:46 /Users/bradfitz/bin/tailscaled.minlinux

Change-Id: Idf7fb24f846b6570b85e1629cca5d7d2a330706f
Signed-off-by: Brad Fitzpatrick <[email protected]>
2025-01-11 07:46:08 -08:00
Brad Fitzpatrick 77d777259c lanscaping: remove debug, all pprof (including tabwriter)
-rwxr-xr-x@ 1 bradfitz  staff  11866178 Jan 11 07:30 /Users/bradfitz/bin/tailscaled.min
-rwxr-xr-x@ 1 bradfitz  staff  12320920 Jan 11 07:30 /Users/bradfitz/bin/tailscaled.minlinux

Change-Id: Ie46fdd28b41c19413c8bff9878ff4a17ee8d9f4c
Signed-off-by: Brad Fitzpatrick <[email protected]>
2025-01-11 07:30:46 -08:00
Brad Fitzpatrick d6f275fb65 lanscaping: remove ringbuffer package (magicsock endpoint debug)
-rwxr-xr-x@ 1 bradfitz  staff  12473138 Jan 11 06:55 /Users/bradfitz/bin/tailscaled.min
-rwxr-xr-x@ 1 bradfitz  staff  12910744 Jan 11 06:56 /Users/bradfitz/bin/tailscaled.minlinux

Change-Id: I2cc774294814e7711b40fd7ef1a9211b47606a2a
Signed-off-by: Brad Fitzpatrick <[email protected]>
2025-01-11 06:56:18 -08:00
Brad Fitzpatrick 7d9bbf51cd lanscaping: remove DNS
-rwxr-xr-x@ 1 bradfitz  staff  12490098 Jan 11 06:52 /Users/bradfitz/bin/tailscaled.min
-rwxr-xr-x@ 1 bradfitz  staff  12910744 Jan 11 06:52 /Users/bradfitz/bin/tailscaled.minlinux

Change-Id: I8a41e6cf8eebe5f7b40a6560711c6233567f1855
Signed-off-by: Brad Fitzpatrick <[email protected]>
2025-01-11 06:53:16 -08:00
Brad Fitzpatrick 253bf1b360 lanscaping: remove logtail, network logs, stats, packet capture
-rwxr-xr-x@ 1 bradfitz  staff  13098514 Jan 10 22:11 /Users/bradfitz/bin/tailscaled.min
-rwxr-xr-x@ 1 bradfitz  staff  13762712 Jan 10 22:11 /Users/bradfitz/bin/tailscaled.minlinux

Change-Id: I9df1ba86ff080b78d320cb03b075f16b91a51f92
Signed-off-by: Brad Fitzpatrick <[email protected]>
2025-01-10 22:11:54 -08:00
Brad Fitzpatrick 2a4a7f2fc7 lanscaping: remove portmapper (goupnp, xml, ...)
-rwxr-xr-x@ 1 bradfitz  staff  13941426 Jan 10 21:24 /Users/bradfitz/bin/tailscaled.min
-rwxr-xr-x@ 1 bradfitz  staff  15204504 Jan 10 21:24 /Users/bradfitz/bin/tailscaled.minlinux

Change-Id: I3c324d4203ba8543295e0503b84874710b8afeb6
Signed-off-by: Brad Fitzpatrick <[email protected]>
2025-01-10 21:24:37 -08:00
Brad Fitzpatrick 30d682899b lanscaping: butcher out gvisor; 16MB
Change-Id: I8185f5bdfe080e33910a8224de66c97f10e2ed40
Signed-off-by: Brad Fitzpatrick <[email protected]>
2025-01-10 20:04:36 -08:00
Brad Fitzpatrick 515d9689d5 lanscaping: start adding ts_omit_netstack
Change-Id: Iefa404306db4eaaaedbaaf7aaad85a241aff2ae1
Signed-off-by: Brad Fitzpatrick <[email protected]>
2025-01-10 19:39:32 -08:00
James Tucker 2c07f5dfcd wgengine/magicsock: refactor maybeRebindOnError
Remove the platform specificity, it is unnecessary complexity.
Deduplicate repeated code as a result of reduced complexity.
Split out error identification code.
Update call-sites and tests.

Updates #14551
Updates tailscale/corp#25648

Signed-off-by: James Tucker <[email protected]>
2025-01-07 10:46:37 -08:00
James Tucker f4f57b815b wgengine/magicsock: rebind on EPIPE/ECONNRESET
Observed in the wild some macOS machines gain broken sockets coming out
of sleep (we observe "time jumped", followed by EPIPE on sendto). The
cause of this in the platform is unclear, but the fix is clear: always
rebind if the socket is broken. This can also be created artificially on
Linux via `ss -K`, and other conditions or software on a system could
also lead to the same outcomes.

Updates tailscale/corp#25648

Signed-off-by: James Tucker <[email protected]>
2025-01-07 10:02:35 -08:00
Marc Paquette 36ea792f06 Fix various linting, vet & static check issues
Fixes #14492

-----

Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.

Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

Change-Id: I6dc1068d34bbfa7477e7b7a56a4325b3868c92e1
Signed-off-by: Marc Paquette <[email protected]>
2025-01-04 15:11:10 -08:00
Brad Fitzpatrick 1e2e319e7d util/slicesx: add MapKeys and MapValues from golang.org/x/exp/maps
Importing the ~deprecated golang.org/x/exp/maps as "xmaps" to not
shadow the std "maps" was getting ugly.

And using slices.Collect on an iterator is verbose & allocates more.

So copy (x)maps.Keys+Values into our slicesx package instead.

Updates #cleanup
Updates #12912
Updates #14514 (pulled out of that change)

Change-Id: I5e68d12729934de93cf4a9cd87c367645f86123a
Signed-off-by: Brad Fitzpatrick <[email protected]>
2025-01-03 10:48:31 -08:00
Jason Barnett 17b881538a wgengine/router: refactor udm-pro into broader ubnt support
Fixes #14453

Signed-off-by: Jason Barnett <[email protected]>
2025-01-03 13:06:16 -05:00
Jason Barnett 8d4ea4d90c wgengine/router: add ip rules for unifi udm-pro
Fixes: #4038

Signed-off-by: Jason Barnett <[email protected]>
2024-12-21 11:47:20 -05:00
James Tucker 7f9ebc0a83 cmd/tailscale,net/netcheck: add debug feature to force preferred DERP
This provides an interface for a user to force a preferred DERP outcome
for all future netchecks that will take precedence unless the forced
region is unreachable.

The option does not persist and will be lost when the daemon restarts.

Updates tailscale/corp#18997
Updates tailscale/corp#24755

Signed-off-by: James Tucker <[email protected]>
2024-12-04 16:52:56 -08:00
Kristoffer Dalby caba123008 wgengine/magicsock: packet/bytes metrics should not count disco
Updates #13420

Signed-off-by: Kristoffer Dalby <[email protected]>
2024-11-28 15:00:26 +01:00
Nick Khyl 462e1fc503 ipn/{ipnlocal,localapi}, wgengine/netstack: call (*LocalBackend).Shutdown when tests that create them complete
We have several places where LocalBackend instances are created for testing, but they are rarely shut down
when the tests that created them exit.

In this PR, we update newTestLocalBackend and similar functions to use testing.TB.Cleanup(lb.Shutdown)
to ensure LocalBackend instances are properly shut down during test cleanup.

Updates #12687

Signed-off-by: Nick Khyl <[email protected]>
2024-11-22 09:46:11 -06:00
Anton Tolchanov 9f33aeb649 wgengine/filter: actually use the passed CapTestFunc [capver 109]
Initial support for SrcCaps was added in 5ec01bf but it was not actually
working without this.

Updates #12542

Signed-off-by: Anton Tolchanov <[email protected]>
2024-11-19 19:18:35 +00:00
Brad Fitzpatrick 4e0fc037e6 all: use iterators over slice views more
This gets close to all of the remaining ones.

Updates #12912

Change-Id: I9c672bbed2654a6c5cab31e0cbece6c107d8c6fa
Signed-off-by: Brad Fitzpatrick <[email protected]>
2024-11-11 13:22:34 -08:00
Brad Fitzpatrick 634cc2ba4a wgengine/netstack: remove unused taildrive deps
A filesystem was plumbed into netstack in 993acf4475
but hasn't been used since 2d5d6f5403. Remove it.

Noticed while rebasing a Tailscale fork elsewhere.

Updates tailscale/corp#16827

Change-Id: Ib76deeda205ffe912b77a59b9d22853ebff42813
Signed-off-by: Brad Fitzpatrick <[email protected]>
2024-11-01 13:40:46 -07:00
Renato Aguiar 0ffc7bf38b Fix MagicDNS on OpenBSD
Add OpenBSD to the list of platforms that need DNS reconfigured on link changes.

Signed-off-by: Renato Aguiar <[email protected]>
2024-11-01 10:44:30 -07:00
Anton Tolchanov b4f46c31bb wgengine/magicsock: export packet drop metric for outbound errors
This required sharing the dropped packet metric between two packages
(tstun and magicsock), so I've moved its definition to util/usermetric.

Updates tailscale/corp#22075

Signed-off-by: Anton Tolchanov <[email protected]>
2024-10-31 08:33:24 +00:00
Anton Tolchanov 532b26145a wgengine/magicsock: exclude disco from throughput metrics
The user-facing metrics are intended to track data transmitted at
the overlay network level.

Updates tailscale/corp#22075

Signed-off-by: Anton Tolchanov <[email protected]>
2024-10-31 08:01:19 +00:00
Tim Walters 856ea2376b wgengine/magicsock: log home DERP changes with latency
This adds additional logging on DERP home changes to allow
better troubleshooting.

Updates tailscale/corp#18095

Signed-off-by: Tim Walters <[email protected]>
2024-10-29 16:05:41 -04:00
Anton Tolchanov 11e96760ff wgengine/magicsock: fix stats packet counter on derp egress
Updates tailscale/corp#22075

Signed-off-by: Anton Tolchanov <[email protected]>
2024-10-29 15:07:45 +00:00
Brad Fitzpatrick 6a885dbc36 wgengine/magicsock: fix CI-only test warning of missing health tracker
While looking at deflaking TestTwoDevicePing/ping_1.0.0.2_via_SendPacket,
there were a bunch of distracting:

    WARNING: (non-fatal) nil health.Tracker (being strict in CI): ...

This pacifies those so it's easier to work on actually deflaking the test.

Updates #11762
Updates #11874

Change-Id: I08dcb44511d4996b68d5f1ce5a2619b555a2a773
Signed-off-by: Brad Fitzpatrick <[email protected]>
2024-10-16 09:40:49 -07:00
Kristoffer Dalby e0d711c478 {net/connstats,wgengine/magicsock}: fix packet counting in connstats
connstats currently increments the packet counter whenever it is called
to store a length of data, however when udp batch sending was introduced
we pass the length for a series of packages, and it is only incremented
ones, making it count wrongly if we are on a platform supporting udp
batches.

Updates tailscale/corp#22075

Signed-off-by: Kristoffer Dalby <[email protected]>
2024-10-14 14:17:56 +02:00
Kristoffer Dalby 40c991f6b8 wgengine: instrument with usermetrics
Updates tailscale/corp#22075

Signed-off-by: Kristoffer Dalby <[email protected]>
2024-10-14 11:34:31 +02:00
Brad Fitzpatrick c763b7a7db syncs: delete Map.Range, update callers to iterators
Updates #11038

Change-Id: I2819fed896cc4035aba5e4e141b52c12637373b1
Signed-off-by: Brad Fitzpatrick <[email protected]>
2024-10-09 13:56:13 -07:00
Brad Fitzpatrick c48cc08de2 wgengine: stop conntrack log spam about Canonical net probes
Like we do for the ones on iOS.

As a bonus, this removes a caller of tsaddr.IsTailscaleIP which we
want to revamp/remove soonish.

Updates #13687

Change-Id: Iab576a0c48e9005c7844ab52a0aba5ba343b750e
Signed-off-by: Brad Fitzpatrick <[email protected]>
2024-10-05 12:51:55 -07:00
Irbe Krumina 9bd158cc09 cmd/containerboot,util/linuxfw: create a SNAT rule for dst/src only once, clean up if needed (#13658)
The AddSNATRuleForDst rule was adding a new rule each time it was called including:
- if a rule already existed
- if a rule matching the destination, but with different desired source already existed

This was causing issues especially for the in-progress egress HA proxies work,
where the rules are now refreshed more frequently, so more redundant rules
were being created.

This change:
- only creates the rule if it doesn't already exist
- if a rule for the same dst, but different source is found, delete it
- also ensures that egress proxies refresh firewall rules
if the node's tailnet IP changes

Updates tailscale/tailscale#13406

Signed-off-by: Irbe Krumina <[email protected]>
2024-10-03 20:15:00 +01:00
Brad Fitzpatrick 5f88b65764 wgengine/netstack: check userspace ping success on Windows
Hacky temporary workaround until we do #13654 correctly.

Updates #13654

Change-Id: I764eaedbb112fb3a34dddb89572fec1b2543fd4a
Signed-off-by: Brad Fitzpatrick <[email protected]>
2024-10-03 09:07:39 -07:00
Brad Fitzpatrick 6f694da912 wgengine/magicsock: avoid log spam from ReceiveFunc on shutdown
The new logging in 2dd71e64ac is spammy at shutdown:

    Receive func ReceiveIPv6 exiting with error: *net.OpError, read udp [::]:38869: raw-read udp6 [::]:38869: use of closed network connection
    Receive func ReceiveIPv4 exiting with error: *net.OpError, read udp 0.0.0.0:36123: raw-read udp4 0.0.0.0:36123: use of closed network connection

Skip it if we're in the process of shutting down.

Updates #10976

Change-Id: I4f6d1c68465557eb9ffe335d43d740e499ba9786
Signed-off-by: Brad Fitzpatrick <[email protected]>
2024-10-02 20:22:12 -07:00
Irbe Krumina 096b090caf cmd/containerboot,kube,util/linuxfw: configure kube egress proxies to route to 1+ tailnet targets (#13531)
* cmd/containerboot,kube,util/linuxfw: configure kube egress proxies to route to 1+ tailnet targets

This commit is first part of the work to allow running multiple
replicas of the Kubernetes operator egress proxies per tailnet service +
to allow exposing multiple tailnet services via each proxy replica.

This expands the existing iptables/nftables-based proxy configuration
mechanism.

A proxy can now be configured to route to one or more tailnet targets
via a (mounted) config file that, for each tailnet target, specifies:
- the target's tailnet IP or FQDN
- mappings of container ports to which cluster workloads will send traffic to
tailnet target ports where the traffic should be forwarded.

Example configfile contents:
{
  "some-svc": {"tailnetTarget":{"fqdn":"foo.tailnetxyz.ts.net","ports"{"tcp:4006:80":{"protocol":"tcp","matchPort":4006,"targetPort":80},"tcp:4007:443":{"protocol":"tcp","matchPort":4007,"targetPort":443}}}}
}

A proxy that is configured with this config file will configure firewall rules
to route cluster traffic to the tailnet targets. It will then watch the config file
for updates as well as monitor relevant netmap updates and reconfigure firewall
as needed.

This adds a bunch of new iptables/nftables functionality to make it easier to dynamically update
the firewall rules without needing to restart the proxy Pod as well as to make
it easier to debug/understand the rules:

- for iptables, each portmapping is a DNAT rule with a comment pointing
at the 'service',i.e:

-A PREROUTING ! -i tailscale0 -p tcp -m tcp --dport 4006 -m comment --comment "some-svc:tcp:4006 -> tcp:80" -j DNAT --to-destination 100.64.1.18:80
Additionally there is a SNAT rule for each tailnet target, to mask the source address.

- for nftables, a separate prerouting chain is created for each tailnet target
and all the portmapping rules are placed in that chain. This makes it easier
to look up rules and delete services when no longer needed.
(nftables allows hooking a custom chain to a prerouting hook, so no extra work
is needed to ensure that the rules in the service chains are evaluated).

The next steps will be to get the Kubernetes Operator to generate
the configfile and ensure it is mounted to the relevant proxy nodes.

Updates tailscale/tailscale#13406

Signed-off-by: Irbe Krumina <[email protected]>
2024-09-29 16:30:53 +01:00
Kristoffer Dalby 5550a17391 wgengine: make opts.Metrics mandatory
Fixes #13582

Signed-off-by: Kristoffer Dalby <[email protected]>
2024-09-26 13:09:47 +02:00
James Tucker 9eb59c72c1 wgengine/magicsock: fix check for EPERM on macOS
Like Linux, macOS will reply to sendto(2) with EPERM if the firewall is
currently blocking writes, though this behavior is like Linux
undocumented. This is often caused by a faulting network extension or
content filter from EDR software.

Updates #11710
Updates #12891
Updates #13511

Signed-off-by: James Tucker <[email protected]>
2024-09-25 16:33:36 -07:00
Adrian Dewhurst 2fdbcbdf86 wgengine/magicsock: only used cached results for GetLastNetcheckReport
When querying for an exit node suggestion, occasionally it triggers a
new report concurrently with an existing report in progress. Generally,
there should always be a recent report or one in progress, so it is
redundant to start one there, and it causes concurrency issues.

Fixes #12643

Change-Id: I66ab9003972f673e5d4416f40eccd7c6676272a5
Signed-off-by: Adrian Dewhurst <[email protected]>
2024-09-25 16:50:33 -04:00
Kristoffer Dalby 0e0e53d3b3 util/usermetrics: make usermetrics non-global
this commit changes usermetrics to be non-global, this is a building
block for correct metrics if a go process runs multiple tsnets or
in tests.

Updates #13420
Updates tailscale/corp#22075

Signed-off-by: Kristoffer Dalby <[email protected]>
2024-09-25 15:57:00 +02:00
Jordan Whited 951884b077 net/netcheck,wgengine/magicsock: plumb OnlyTCP443 controlknob through netcheck (#13491)
Updates tailscale/corp#17879

Signed-off-by: Jordan Whited <[email protected]>
2024-09-17 12:24:42 -07:00
Jordan Whited 5f4a4c6744 wgengine/magicsock: fix sendUDPStd docs (#13490)
Updates #cleanup

Signed-off-by: Jordan Whited <[email protected]>
2024-09-16 19:28:00 -07:00
Jordan Whited 4084c6186d wgengine/magicsock: add side-effect-free function for netcheck UDP sends (#13487)
Updates #13484
Updates tailscale/corp#17879

Signed-off-by: Jordan Whited <[email protected]>
2024-09-16 19:00:12 -07:00
Andrew Dunham 40833a7524 wgengine/magicsock: disable raw disco by default; add envknob to enable
Updates #13140

Signed-off-by: Andrew Dunham <[email protected]>
Change-Id: Ica85b2ac8ac7eab4ec5413b212f004aecc453279
2024-09-16 11:06:33 -07:00
Jordan Whited afec2d41b4 wgengine/magicsock: remove redundant deadline from netcheck report call (#13395)
netcheck.Client.GetReport() applies its own deadlines. This 2s deadline
was causing GetReport() to never fall back to HTTPS/ICMP measurements
as it was shorter than netcheck.stunProbeTimeout, leaving no time
for fallbacks.

Updates #13394
Updates #6187

Signed-off-by: Jordan Whited <[email protected]>
2024-09-13 10:51:30 -07:00
Brad FitzpatrickandMaisem Ali 9f9470fc10 ipnlocal,proxymap,wgengine/netstack: add optional WhoIs/proxymap debug
Updates tailscale/corp#20600

Change-Id: I2bb17af0f40603ada1ba4cecc087443e00f9392a
Co-authored-by: Maisem Ali <[email protected]>
Signed-off-by: Brad Fitzpatrick <[email protected]>
2024-09-10 14:23:33 -07:00
Jordan Whited 7aa766ee65 net/tstun: probe TCP GRO (#13376)
Disable TCP & UDP GRO if the probe fails.

torvalds/linux@e269d79c7d broke virtio_net
TCP & UDP GRO causing GRO writes to return EINVAL. The bug was then
resolved later in
torvalds/linux@89add40066. The offending
commit was pulled into various LTS releases.

Updates #13041

Signed-off-by: Jordan Whited <[email protected]>
2024-09-05 09:59:31 -07:00