tailscale/wgengine
Josh Bleecher Snyder 99705aa6b7 net/tstun: split TUN events channel into up/down and MTU
We had a long-standing bug in which our TUN events channel
was being received from simultaneously in two places.

The first is wireguard-go.

At wgengine/userspace.go:366, we pass e.tundev to wireguard-go,
which starts a goroutine (RoutineTUNEventReader)
that receives from that channel and uses events to adjust the MTU
and bring the device up/down.

At wgengine/userspace.go:374, we launch a goroutine that
receives from e.tundev, logs MTU changes, and triggers
state updates when up/down changes occur.

Events were getting delivered haphazardly between the two of them.

We don't really want wireguard-go to receive the up/down events;
we control the state of the device explicitly by calling device.Up.
And the userspace.go loop MTU logging duplicates logging that
wireguard-go does when it received MTU updates.

So this change splits the single TUN events channel into up/down
and other (aka MTU), and sends them to the parties that ought
to receive them.

I'm actually a bit surprised that this hasn't caused more visible trouble.
If a down event went to wireguard-go but the subsequent up event
went to userspace.go, we could end up with the wireguard-go device disappearing.

I believe that this may also (somewhat accidentally) be a fix for #1790.

Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
2021-04-26 17:16:51 -07:00
..
bench wgengine/bench: improved rate selection. 2021-04-26 03:51:13 -04:00
filter net/packet, wgengine/{filter,tstun}: add TSMP ping 2021-03-24 09:50:01 -07:00
magicsock health, wgenegine: fix receive func health checks yet again 2021-04-23 08:42:04 -07:00
monitor wgengine/monitor: reduce Linux log spam on down 2021-04-12 10:38:51 -07:00
netstack wgengine/netstack: log error when acceptUDP fails 2021-04-21 12:25:01 -07:00
router wgengine/router{win}: ignore broadcast routes added by Windows when removing routes. 2021-04-24 14:13:35 -07:00
wgcfg wgengine/wgcfg/nmcfg: consolidate exit node log lines 2021-04-21 11:29:30 -07:00
wglog wgengine/wglog: allow wireguard-go receive routines to log 2021-04-21 12:29:28 -07:00
winnet wgengine/winnet: don't build on non-windows 2021-02-09 21:09:24 -08:00
pendopen.go wgengine: quiet connection failure diagnostics for exit nodes 2021-04-22 08:29:20 -07:00
userspace_ext_test.go cmd/tailscaled, wgengine{,/netstack}: add netstack hybrid mode, add to Windows 2021-04-06 21:37:28 -07:00
userspace_test.go cmd/tailscaled, wgengine{,/netstack}: add netstack hybrid mode, add to Windows 2021-04-06 21:37:28 -07:00
userspace.go net/tstun: split TUN events channel into up/down and MTU 2021-04-26 17:16:51 -07:00
watchdog_test.go wgengine: extend TestWatchdog timeout on macOS 2021-03-27 09:27:11 -07:00
watchdog.go wgengine: take in dns.Config, split out to resolver.Config and dns.OSConfig. 2021-04-02 00:59:44 -07:00
wgengine.go tailcfg: add Endpoint, EndpointType, MapRequest.EndpointType 2021-04-13 10:12:14 -07:00