Files
tailscale/cmd/tailscaled
Brad Fitzpatrick 26b87db042 wgengine, cmd/tailscaled: fix a kernel mode key race, and clean up its device
Running real tailscaled in kernel mode on EC2, as a subnet router with 37
peers, found two bugs:

The kernel data plane's reconcile loop recorded the private key as
pushed by re-reading k.privKey after pushing, so a setPrivateKey during
a reconcile (as at startup, while it pushed dozens of peers) made the
new key look pushed when it wasn't. Those nodes' kernel devices never
got a private key, couldn't handshake, and carried no traffic. Record
the key that was actually pushed.

The engine's Close never closed the kernel data plane, so tailscaled left
its tswg device (and loopback bridge and event socket) behind on exit, and
a tailscaled in TUN mode after it failed: tstun.New("tailscale0"): invalid
argument. Close it, before magicsock. And before creating a TUN device,
delete a leftover tswg device of the same name, as a crashed tailscaled
would leave.

Also gofmt endpoint.go.

Updates #426

Signed-off-by: Brad Fitzpatrick <[email protected]>
Change-Id: Ib2bf8de26e585d08173bc034c3a4872f9dd4f5bb
2026-11-09 15:47:37 +00:00
..