Repository navigation
magicsock: handle UDP read feedback - #21902
Conversation
0603ce4 to
0837feb
Compare
|
Thanks for picking this up. Adding a data point from iOS in case it helps with testing: iPhone 17, Tailscale iOS 1.102.3, Mullvad exit node, T-Mobile US cellular (IPv6-only with 464XLAT). It reproduces when switching between home Wi-Fi and cellular: the app stays Connected but stops passing traffic until the tunnel is toggled. Happy to test a TestFlight build with this change if that's useful. |
|
Is this related to that #21832? The behavior looks very similar. |
Please reproduce this and provide a bug report BUG- reference so that I can look at the logs. The hand summarized description is insufficient to reproduce/diagnose due to the number of parts involved, but for most occurrences of what I have been able to track down so far, the logs would provide exact data that I need to write a precise fix. |
|
My iOS reproduction and bug-report ID are in #19504 (comment). The report was generated while the tunnel was still broken, before restarting Tailscale. |
|
Have we considered a simpler change in wireguard-go wrt how |
spin how hard? how do we want to pass metrics back over? those kinds of questions make it easier to leave on this side, eventually i want to remove the i/o pump from that side because of related issues. |
No limit, remove the sleep. I will admit it just moves the need for spin protection into magicsock. I'm hoping we can remove the requirement of maintaining an exhaustive list of "temporary" / re-bindable errors that we have to keep learning new behaviors around, vs just treating everything other than close as temporary. |
i'll have a closer look and see. i'm wary of widely classifying things as temporary, lots of stuff like ebadf are definitely fatal. will update once i've had a look |
|
We do need to guard on EBADF and ENOTSOCK, but the set is small. FWIW we just established a precedent for metrics: tailscale/wireguard-go@383e864 |
It's important to note here that the set isn't as small or stable as we might like. There are covered cases already where EDR software has arbitrarily altered the errno meaning and set of errnos that may be returned from socket syscalls. I wish I could create a safe subdivide based on a stable kernel ABI here, and if the kernel defined it's own ABI we could, but alas, EDR's have taken this over and broken those rules, lacking Linus' policing. |
|
@raggi iOS reproduction, with a bug report generated while the tunnel was broken (before toggling):
|
|
Codex helped me prepare this report: Additional reproduction on Tailscale 1.104.2 for iOS. I use Rex by Superlogical, a terminal multiplexer and remote terminal app with an iOS client: Rex connects to remote servers over Tailscale. The macOS and Linux servers inspected during this incident use Rex’s built-in Tailscale integration, so each Rex server joins the tailnet as its own device. Environment:
The Tailscale app displays:
During the captured incident:
The ReceiveIPv4 warning was captured in a screenshot during the failure. Toggling Tailscale off and on has restored connectivity in previous occurrences, but the problem keeps returning. Recovery after this particular diagnostic capture had not yet been verified when I generated the report. The captured incident occurred around October 27, 2026, 23:31–23:45 EDT, corresponding to October 28, 03:31–03:45 UTC. Bug report generated on the affected iPhone at 2026-10-28 03:50:18 UTC: BUG-f3167915d0d43993a7af616efc6716dc58ebfebdc63fd503ceac3d389ab2da00-20261028035018Z-57fe0cd53828a41d Rex is the application in which I notice the failure, but the simultaneous failure of independent Tailscale packet probes and the ReceiveIPv4 warning show that the observed failure extends beyond Rex’s application protocol. This appears consistent with the ReceiveIPv4 failure discussed in this issue. I have not established the underlying trigger. Please let me know whether additional diagnostics or a test build would help. |
|
Another iOS reproduction with a bug report captured while broken (before toggling):
iPhone 12 mini, iOS 27.2, Tailscale 1.104.2, MDM-deployed with VPN On Demand, using a FreeBSD exit node (1.98.5), with a single global nameserver reached via the subnet route. Happens several times a day on a corporate Wi-Fi (mapvarydest=true, netcheck Earlier incident the same day (2026-10-28, UTC), from the client log: 07:59:05 |
|
Note to self: TSS-99056 |
|
Also related: TSS-106924 |
70489d6 to
c43d3ec
Compare
c43d3ec to
e3ce00f
Compare
|
Apologies if already seen, but linking here in case it was missed: I started hitting this issue consistently since updating to macOS 27.2 and it completely breaks P2P in Tailscale. Seems to be due to a conflict/bug with content filtering extensions like Little Snitch: #22082 (comment) I raised a support ticket with the same report as well. |
04ce2f1 to
ef55a9c
Compare
illotum
left a comment
There was a problem hiding this comment.
LGTM aside of one subjective nit.
jwhited
left a comment
There was a problem hiding this comment.
LGTM once Windows bits are moved from neterror_posix.go into neterror_windows.go, including the other pre-existing func. We can use x/sys/windows constants where available.
ef55a9c to
ae6f5b1
Compare
Retry UDP reads returning EHOSTUNREACH or ENETUNREACH, including their Winsock equivalents, without returning those errors to wireguard-go. Count them in magicsock_recv_udp_error_reachability. Other read errors are unchanged. Updates #20616 Updates #19504 Signed-off-by: James Tucker <[email protected]>
ae6f5b1 to
b660c81
Compare
This iterates on the work in #21902, #22100 and tailscale/wireguard-go#116. The new version of wireguard-go discards the deathSpiral loop in favour of allowing Bind's ReceiveFunc to pace read retries. This code is the other side. Add back a backoff for non-feedback errors, and report the receive func as broken to the health tracker once reads have been failing for 30s. The loop only exits once net.ErrClosed is returned. Updates #22097 Change-Id: I9f1134242c3cb5ac2ef3c282cf7bcd7606cb5b9e Signed-off-by: Nick Beirne <[email protected]> . Change-Id: Iccfb5e3746d212856978e9f539f848fccf85058a .
This iterates on the work in #21902, #22100 and tailscale/wireguard-go#116. The new version of wireguard-go discards the deathSpiral loop in favour of allowing Bind's ReceiveFunc to pace read retries. This code is the other side. Add back a backoff for non-feedback errors, and report the receive func as broken to the health tracker once reads have been failing for 30s. The loop only exits once net.ErrClosed is returned. Updates #22097 Change-Id: I9f1134242c3cb5ac2ef3c282cf7bcd7606cb5b9e Signed-off-by: Nick Beirne <[email protected]> . Change-Id: Iccfb5e3746d212856978e9f539f848fccf85058a .
This iterates on the work in #21902, #22100 and tailscale/wireguard-go#116. The new version of wireguard-go discards the deathSpiral loop in favour of allowing Bind's ReceiveFunc to pace read retries. This code is the other side. Add back a backoff for non-feedback errors, and report the receive func as broken to the health tracker once reads have been failing for 30s. The loop only exits once net.ErrClosed is returned. Updates #22097 Change-Id: I9f1134242c3cb5ac2ef3c282cf7bcd7606cb5b9e Signed-off-by: Nick Beirne <[email protected]>
This iterates on the work in #21902, #22100 and tailscale/wireguard-go#116. The new version of wireguard-go discards the deathSpiral loop in favour of allowing Bind's ReceiveFunc to pace read retries. This code is the other side. Add back a backoff for non-feedback errors, and report the receive func as broken to the health tracker once reads have been failing for 30s. The loop only exits once net.ErrClosed is returned. Updates #22097 Change-Id: I9f1134242c3cb5ac2ef3c282cf7bcd7606cb5b9e Signed-off-by: Nick Beirne <[email protected]>
This iterates on the work in #21902, #22100 and tailscale/wireguard-go#116. wireguard-go no longer has a deathSpiral loop; it relies on the Bind's ReceiveFunc to pace read retries. This is the magicsock side of that change. On read errors other than truncation and UDP read feedback, the receive func now sleeps 100ms and retries rather than returning. If reads keep failing for 30s it marks itself broken via ReceiveFuncStats.SetBroken. The next successful read clears that state. Updates #22097 Change-Id: I9f1134242c3cb5ac2ef3c282cf7bcd7606cb5b9e Signed-off-by: Nick Beirne <[email protected]>
Retry UDP reads returning EHOSTUNREACH or ENETUNREACH, including their
Winsock equivalents, without returning those errors to wireguard-go.
Count them in magicsock_recv_udp_error_reachability. Other read errors are unchanged.
Updates #20616
Updates #19504
Signed-off-by: James Tucker [email protected]