Repository navigation
Conversation
mkReceiveFunc returned any non-truncated ReadBatch error to wireguard-go. In RoutineReceiveIncoming a returned error ends the receive goroutine for good if it is a non-temporary net.Error, or after 10 consecutive errors; only net.ErrClosed is a normal exit, and nothing restarts the goroutine until the Bind is reopened. The tunnel then looks connected but can no longer receive, which only toggling Tailscale recovers from. The health check reports it as "ReceiveIPv4 is not running" (magicsock-receive-func-error) but does not act on it. The send path already heals with maybeRebindOnError. Do the same for receives: for an error other than the Conn or Bind closing, log it, rebind (throttled, now shared with the send path through maybeRebind, which also makes the throttle safe against concurrent callers) and retry the read with a backoff of 50ms doubling to 1s. Closing the Conn or the Bind interrupts the wait. The read error seen on iOS is not known; this is a defensive change. Updates tailscale#17967 Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: lucas persson <[email protected]>
|
@luben93 Trigger: the hotspot briefly drops the interface's IPv4 → |
In not a maintainer i just noticed and posted a bug which seems to have been fixed in the testfligt build posted above |
Makes magicsock recover when a UDP receive fails instead of leaving the tunnel unable to receive.
Symptom
On iOS the tunnel sometimes shows connected but passes no traffic; apps stall mid-stream and only toggling Tailscale recovers. Many reports in #17967 and earlier #14320, often with the health warning "MagicSock function ReceiveIPv4 is not running" (
magicsock-receive-func-error). The iOS and Android apps use this code.Mechanism (from reading the code, not reproduced on a device)
Conn.mkReceiveFuncreturned any non-truncatedReadBatcherror to wireguard-go.RoutineReceiveIncoming, a returned error ends the receive goroutine permanently if it is a non-temporarynet.Error, or after 10 consecutive errors. Onlynet.ErrClosedis a normal exit, and nothing restarts the goroutine until the Bind is reopened.health.checkReceiveFuncsLockeddetects this and sets a warnable but does not recover.maybeRebindOnError; there was no receive-side equivalent.Change
For a read error other than the Conn or Bind closing: log it, rebind (throttled) and retry with a backoff of 50ms doubling to 1s, reset by a successful read. Closing the Conn or the Bind interrupts the wait. The 5s rebind throttle moves into
maybeRebind, shared with the send path and made safe against concurrent callers with a compare-and-swap, since each receive func can now reach it.Evidence level
The read error that occurs on iOS is not known; I could not capture logs at the moment of a stall. This is a defensive change to a path that currently has no recovery. A log line from a stall (
Receive func ... exiting with error) would confirm or refute that this is the trigger. Happy to adjust, or to restrict the rebind to specific errors viashouldRebindif you prefer.Testing
TestReceiveFuncReadError: a fake socket that always fails; the receive func rebinds and keeps reading, and returns when the Bind closes.go test -race -count=3 ./wgengine/magicsock/ ./health/passes.go vetis clean for linux, windows, darwin and js/wasm; plan9 builds. (go vetreports a pre-existing copylocks warning atendpoint_test.go:747, unrelated to this change.)Questions for maintainers
shouldRebindrecognises, or only after N consecutive errors?Updates #17967
🤖 Generated with Claude Code