wgengine/magicsock: fix rebind debouncing (#17282)

On platforms that are causing EPIPE at a high frequency this is
resulting in non-working connections, for example when Apple decides to
forcefully close UDP sockets due to an unsoliced packet rejection in the
firewall.

Too frequent rebinds cause a failure to solicit the endpoints triggering
the rebinds, that would normally happen via CallMeMaybe.

Updates #14551
Updates tailscale/corp#25648

Signed-off-by: James Tucker <james@tailscale.com>
This commit is contained in:
James Tucker
2025-09-26 08:06:39 -07:00
committed by GitHub
parent 41a2aaf1da
commit 8b3e88cd09
2 changed files with 30 additions and 11 deletions
+1
View File
@@ -1563,6 +1563,7 @@ func (c *Conn) maybeRebindOnError(err error) {
if c.lastErrRebind.Load().Before(time.Now().Add(-5 * time.Second)) {
c.logf("magicsock: performing rebind due to %q", reason)
c.lastErrRebind.Store(time.Now())
c.Rebind()
go c.ReSTUN(reason)
} else {