You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tailscale/wgengine
Josh Bleecher Snyder 3c543c103a wgengine/magicsock: unify initial bind and rebind
We had two separate code paths for the initial UDP listener bind
and any subsequent rebinds.

IPv6 got left out of the rebind code.
Rather than duplicate it there, unify the two code paths.
Then improve the resulting code:

* Rebind had nested listen attempts to try the user-specified port first,
  and then fall back to :0 if that failed. Convert that into a loop.
* Initial bind tried only the user-specified port.
  Rebind tried the user-specified port and 0.
  But there are actually three ports of interest:
  The one the user specified, the most recent port in use, and 0.
  We now try all three in order, as appropriate.
* In the extremely rare case in which binding to port 0 fails,
  use a dummy net.PacketConn whose reads block until close.
  This will keep the wireguard-go receive func goroutine alive.

As a pleasant side-effect of this, if we decide that
we need to resuscitate #1796, it will now be much easier.

Fixes #1799

Co-authored-by: David Anderson <danderson@tailscale.com>
Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
3 years ago
..
bench wgengine/bench: improved rate selection. 3 years ago
filter net/packet, wgengine/{filter,tstun}: add TSMP ping 3 years ago
magicsock wgengine/magicsock: unify initial bind and rebind 3 years ago
monitor wgengine/monitor: reduce Linux log spam on down 3 years ago
netstack wgengine/netstack: log error when acceptUDP fails 3 years ago
router wgengine/router{win}: ignore broadcast routes added by Windows when removing routes. 3 years ago
wgcfg wgengine/wgcfg/nmcfg: consolidate exit node log lines 3 years ago
wglog wgengine/wglog: allow wireguard-go receive routines to log 3 years ago
winnet wgengine/winnet: don't build on non-windows 3 years ago
pendopen.go wgengine: quiet connection failure diagnostics for exit nodes 3 years ago
userspace.go wgengine: periodically poll engine status for logging side effect 3 years ago
userspace_ext_test.go cmd/tailscaled, wgengine{,/netstack}: add netstack hybrid mode, add to Windows 3 years ago
userspace_test.go cmd/tailscaled, wgengine{,/netstack}: add netstack hybrid mode, add to Windows 3 years ago
watchdog.go wgengine: take in dns.Config, split out to resolver.Config and dns.OSConfig. 3 years ago
watchdog_test.go wgengine: extend TestWatchdog timeout on macOS 3 years ago
wgengine.go tailcfg: add Endpoint, EndpointType, MapRequest.EndpointType 3 years ago