Repository navigation
Description
Summary
When both machines also run Tailscale, tailcat can choose the peer's Tailscale address (in fd7a:115c:a1e0::/48 or 100.64.0.0/10) as its "direct" path. Its WireGuard then runs inside Tailscale's WireGuard, through a tun device with a 1280-byte MTU.
On that path, data sent from a Linux peer crawls at 12 to 18 KB/s, while the other direction runs at 25 MB/s. Starting the Linux side with TS_DEBUG_DISABLE_UDP_GSO=true brings it to 15 to 20 MB/s. So the Linux UDP GSO send path loses tailcat's packets when they go out a 1280-MTU interface.
There are two problems:
- tailcat uses a peer's Tailscale address as a direct endpoint. Sending WireGuard through another WireGuard tunnel to a peer on the same LAN is never better than the plain LAN address. It adds a layer of encryption, a smaller MTU and a hop through tailscaled. Here magicsock also switches between the LAN IPv4 address and the peer's Tailscale IPv6 address about every 60 s, and stays on the IPv6 one most of the time.
- On Linux, batched (GSO) sends over a route with MTU 1280 crawl. With tailcat's MTU of 1360, each WireGuard packet is about 1440 bytes on the wire (1360 + 80 bytes of overhead), which is larger than the 1280 MTU. Plain, unbatched UDP of the same size over the same route arrives fine (see the measurements). Batched sends of those packets mostly do not. Only small packets get through, and the inner TCP falls back to retransmission timeouts. Nothing about this shows in
--verboselogs.
Either fix alone would have avoided this. Problem 2 may also hit any Linux peer whose real path MTU is below about 1440, not only through Tailscale.
Environment
- tailcat v0.6.0, the same build on both ends.
- Server: Linux (Arch, kernel 7.2), on Wi-Fi, running Tailscale (
tailscale0, MTU 1280). - Client: macOS, on the same Wi-Fi LAN, running Tailscale (utun, MTU 1280).
- Both machines reach each other directly over the LAN, and directly over Tailscale.
- How the Tailscale address gets learned in this setup: the Linux machine's Wi-Fi interface has no global IPv6 address of its own, but it is on-link for the router's IPv6 /64, where the Mac has a global address. When Linux sends to the Mac's global IPv6 address, source address selection picks its own Tailscale ULA (
fd7a:115c:a1e0::…) as the source. The Mac then learns that ULA as a direct endpoint for the peer and answers it through Tailscale. After that both sides report "now using" the other's Tailscale address.
Reproduction
On the Linux machine (server), serve a port that sends 30 MB:
socat TCP-LISTEN:47811,bind=127.0.0.1,reuseaddr,fork SYSTEM:"head -c 30000000 /dev/zero" &
TAILCAT_ADDR_FILE=./addr tailcat --verbose serve --key=new --full-address 47811On the macOS machine (client), forward it and time a download:
tailcat --key=new --verbose forward --bind=127.0.0.1 "$(cat addr)" 47911:47811 2> client.log &
time socat -u TCP:127.0.0.1:47911 /dev/null # 30 MB; on the bad path this takes about 30 minutes, so stop it after 20 s and count the bytes
grep 'now using' client.logThe client log shows the endpoint switching between the LAN address and the peer's Tailscale address:
magicsock: disco: node [xxxxx] ... now using <LAN IPv4>:<port> mtu=1360 ...
magicsock: disco: node [xxxxx] ... now using [fd7a:115c:a1e0::xxxx:xxxx]:<port> mtu=1360 ...
The server log shows the same thing in the other direction (it is "now using" the client's fd7a:115c:a1e0::… address).
Then restart only the server with GSO turned off and repeat the download:
TS_DEBUG_DISABLE_UDP_GSO=true TAILCAT_ADDR_FILE=./addr tailcat --verbose serve --key=new --full-address 47811Measurements
All on the same two machines, the same day, with fresh ephemeral keys for each run:
| Test | Throughput |
|---|---|
| Plain TCP over Tailscale (kernel path, no tailcat) | 40 MB/s |
| tailcat download, Linux → macOS, on the peer's Tailscale IPv6 path | 12 to 18 KB/s (4 runs) |
| tailcat upload, macOS → Linux, same path | 25.7 MB/s (385 MB in 15 s) |
tailcat download, Linux → macOS, same path, server started with TS_DEBUG_DISABLE_UDP_GSO=true |
15 to 20 MB/s (2 runs, 30 MB each) |
tailcat download, forced over DERP (TS_DEBUG_ALWAYS_USE_DERP=1 on the client) |
591 KB/s (about 106 ms to the DERP server) |
| Plain UDP, Linux → macOS Tailscale IPv6, 1180-byte datagrams, unbatched, 20 MB/s offered | 33,880 of 33,880 received |
| Plain UDP, Linux → macOS Tailscale IPv6, 1392-byte datagrams (fragmented), unbatched, 23 MB/s offered | 32,786 of 33,020 received (0.7% loss) |
The plain UDP rows show that the Tailscale path itself carries datagrams larger than its MTU (fragmented) without trouble. Only tailcat's batched sends from Linux fail. I did not trace exactly where the kernel drops the batched packets.
Workaround
Start tailcat on Linux with TS_DEBUG_DISABLE_UDP_GSO=true. It's a debug setting, so we'd rather not depend on it long term.
Suggested fixes
- Don't use a peer's Tailscale addresses (
100.64.0.0/10,fd7a:115c:a1e0::/48) as direct-path candidates, or rank them below every other direct path. Tailscale itself already leaves its own interface out when it gathers local endpoints. The problem here is that the peer's Tailscale address gets learned from packets arriving from it. - When batched sends go out a route whose MTU is smaller than the segment size, fall back to unbatched sends (or lower the size), the way magicsock already turns GSO off on some send errors.
Activity