Repository navigation
fix(tailscale): take tailscale-rs from git to stop a UDP close panic - #1584
Conversation
tailscale-rs 0.6.1 panics with "handle does not refer to a valid socket" when a UDP socket is closed while a recv is still pending, e.g. after a DNS query through the tailscale outbound times out, or when any UDP flow without a reply ends. tailscale/tailscale-rs@9f7cec0 skips requests whose caller has gone away. Patch `tailscale` to that rev; `ts_netmon` moves from 2c67f76 to the same rev (2 commits later).
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Why
With the
tailscaleoutbound, clash-rs aborts with a smoltcp panic:It happens whenever a UDP socket on the outbound is closed while a receive is still pending. Two common triggers:
nameserver-policy: "+.ts.net": "100.100.100.100#<tailscale proxy>"). tailscale-rs doesn't implement MagicDNS, so the query is never answered, times out, and the socket is dropped.On iOS / Android, where clash-rs runs inside the VPN process, this takes the whole tunnel down.
Root cause, in tailscale-rs 0.6.1 netcore: a
Recvthat returnsWouldBlockis parked inblocked_commands. When the socket is dropped, itsCloseremoves the handle from the smoltcpSocketSet, but the parkedRecvstays queued. The nextpump_blocked_commandscallsSocketSet::get_muton the removed handle, which panics.tailscale/tailscale-rs@9f7cec0 ("netcore: configure requests to cancel on drop", closes tailscale/tailscale-rs#447) skips requests whose caller has gone away. It isn't released yet; crates.io is still at 0.6.1, and the git workspace is still versioned 0.6.1.
Changes
[patch.crates-io]: taketailscalefrom tailscale-rs git at9f7cec0447.ts_netmonmoves from2c67f76eab(added in fix(apple): build clash-lib for iOS/tvOS without patched dependencies #1583) to the same rev, which is 2 commits later. All tailscale-rs crates now come from one rev.ts_netstack_smoltcp*crates into one, so those entries collapse, and smoltcp goes from 0.13.1 to 0.14.0 (the 0.12 copy used elsewhere is untouched).Testing
Live tests on macOS (
clash-rsbinary, mixed inbound, against a real tailnet with subnet routers):100.100.100.100#tailscaleand times outBuilds, all with
--locked:cargo check --workspaceon macOScargo check -p clash-lib --no-default-features -F ring,shadowsocks,tuic,ssh,tun,zero_copy,tailscaleforaarch64-apple-iosand foraarch64-apple-tvos(nightly,-Zbuild-std)cargo test -p clash-lib --lib -F tailscale,tuic tailscale: 10 passedcargo clippy -p clash-lib --all-targets -F tailscale,tuic: clean-F tuicis needed because without it thewind-tuicdev-dependency fails to compile (unresolved import crate::quinn::outbound), the same problem noted in #1583. The tailscale live test (tailscale_live_auth_key_supports_real_tcp_and_udp_traffic) is Linux-only and wasn't run.Risk: the pinned rev is 35 commits past
v0.6.1, and it applies on every platform. The behaviour checked above is TCP/UDP through the netstack, subnet routes, and auth-key login.Summary by CodeRabbit