tailscale/net
Claus Lensbøl 85bb5f84a5
wgengine/magicsock,control/controlclient: do not overwrite discokey with old key (#18606)
When a client starts up without being able to connect to control, it
sends its discoKey to other nodes it wants to communicate with over
TSMP. This disco key will be a newer key than the one control knows
about.

If the client that can connect to control gets a full netmap, ensure
that the disco key for the node not connected to control is not
overwritten with the stale key control knows about.

This is implemented through keeping track of mapSession and use that for
the discokey injection if it is available. This ensures that we are not
constantly resetting the wireguard connection when getting the wrong
keys from control.

This is implemented as:
 - If the key is received via TSMP:
   - Set lastSeen for the peer to now()
   - Set online for the peer to false
 - When processing new keys, only accept keys where either:
   - Peer is online
   - lastSeen is newer than existing last seen

If mapSession is not available, as in we are not yet connected to
control, punt down the disco key injection to magicsock.

Ideally, we will want to have mapSession be long lived at some point in
the near future so we only need to inject keys in one location and then
also use that for testing and loading the cache, but that is a yak for
another PR.

Updates #12639

Signed-off-by: Claus Lensbøl <claus@tailscale.com>
2026-03-20 08:56:27 -04:00
..
ace all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
art all: use Go 1.26 things, run most gofix modernizers 2026-03-06 13:32:03 -08:00
bakedroots all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
batching net/batching: eliminate gso helper func indirection 2026-03-18 10:11:33 -07:00
captivedetection all: use Go 1.26 things, run most gofix modernizers 2026-03-06 13:32:03 -08:00
connectproxy all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
dns net/dns: use the correct separator for multiple servers in the same NRPT rule on Windows 2026-03-19 09:07:39 -05:00
dnscache all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
dnsfallback all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
flowtrack all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
ipset all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
ktimeout all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
memnet all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
netaddr all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
netcheck all: use Go 1.26 things, run most gofix modernizers 2026-03-06 13:32:03 -08:00
neterror all: use Go 1.26 things, run most gofix modernizers 2026-03-06 13:32:03 -08:00
netkernelconf all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
netknob all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
netmon all: use Go 1.26 things, run most gofix modernizers 2026-03-06 13:32:03 -08:00
netns netns: add Android callback to bind socket to network (#18915) 2026-03-11 12:28:28 -07:00
netstat all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
netutil all: use Go 1.26 things, run most gofix modernizers 2026-03-06 13:32:03 -08:00
netx all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
packet types/ptr: deprecate ptr.To, use Go 1.26 new 2026-03-05 20:13:18 -08:00
ping all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
portmapper all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
porttrack net/porttrack: change magic listen address format for Go 1.26 2026-03-04 21:57:05 -08:00
proxymux all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
routetable netns,wgengine: add OpenBSD support to netns via an rtable 2026-02-25 12:44:32 -08:00
sockopts all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
socks5 all: use Go 1.26 things, run most gofix modernizers 2026-03-06 13:32:03 -08:00
sockstats all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
speedtest all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
stun all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
stunserver all: use Go 1.26 things, run most gofix modernizers 2026-03-06 13:32:03 -08:00
tcpinfo all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
tlsdial all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
tsaddr all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
tsdial all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
tshttpproxy all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
tstun wgengine/magicsock,control/controlclient: do not overwrite discokey with old key (#18606) 2026-03-20 08:56:27 -04:00
udprelay net/{batching,udprelay},wgengine/magicsock: add SO_RXQ_OVFL clientmetrics 2026-03-13 14:27:03 -07:00
wsconn all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00