tailscale/net
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
..
dns net/dns: work around WSL DNS implementation flaws. 2021-04-26 16:54:50 -07:00
dnscache control/controlclient, net/{dnscache,dnsfallback}: add DNS fallback mechanism 2021-03-01 18:42:03 -08:00
dnsfallback net/dnsfallback: fix infinite loop and limit number of candidates 2021-03-04 19:19:40 -08:00
flowtrack net/packet, wgengine/filter: support SCTP 2021-03-20 21:34:13 -07:00
interfaces net/interfaces: work around race fetching routing table 2021-04-23 13:23:19 -07:00
netcheck net/netcheck: add a few more STUN retries for prior DERP home 2021-03-12 11:46:08 -08:00
netns net/{interfaces,netns}: add some new tests, missed from prior commit 2021-02-14 21:18:27 -08:00
netstat net/netstat: remove a bit more unsafe 2020-11-17 13:49:24 -08:00
nettest net/nettest: make nettest.NewConn pass x/net/nettest.TestConn. 2021-04-06 15:34:29 -07:00
packet net/{packet,tstun}: send peerapi port in TSMP pongs 2021-03-29 15:18:23 -07:00
portmapper net/portmapper: silently handle PCP NOT_AUTHORIZED responses. 2021-03-17 19:44:35 -07:00
socks5 cmd/tailscaled, wgengine: remove --fake, replace with netstack 2021-03-01 11:09:19 -08:00
stun stun fuzzer: Small fix 2021-04-14 08:17:46 -07:00
tlsdial net/tlsdial, derp/derphttp: finish DERPNode.CertName validation 2020-06-01 09:01:37 -07:00
tsaddr net/tsaddr: expand ephemeral nodes range to /64 2021-04-19 15:54:53 -04:00
tshttpproxy net/tshttpproxy: call winhttp calls from a fixed OS thread 2021-03-03 19:16:04 -08:00
tstun net/tstun: split TUN events channel into up/down and MTU 2021-04-26 17:16:51 -07:00