tailscale/cmd
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
..
addlicense all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
build-webclient all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
checkmetrics all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
cigocacher cmd/cigocacher: make --stats flag best-effort (#18761) 2026-02-19 16:06:12 +00:00
cloner types/ptr: deprecate ptr.To, use Go 1.26 new 2026-03-05 20:13:18 -08:00
connector-gen all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
containerboot cmd/{containerboot,k8s-operator}: reissue auth keys for broken proxies (#16450) 2026-03-11 10:25:57 +00:00
derper all: use Go 1.26 things, run most gofix modernizers 2026-03-06 13:32:03 -08:00
derpprobe all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
dist all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
distsign all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
featuretags all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
get-authkey all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
gitops-pusher cmd/gitops-pusher: fix precedence when id token env var is empty 2026-01-30 17:37:11 -07:00
hello all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
jsonimports all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
k8s-nameserver all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
k8s-operator wgengine/magicsock,control/controlclient: do not overwrite discokey with old key (#18606) 2026-03-20 08:56:27 -04:00
k8s-proxy types/ptr: deprecate ptr.To, use Go 1.26 new 2026-03-05 20:13:18 -08:00
mkmanifest all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
mkpkg all: use Go 1.26 things, run most gofix modernizers 2026-03-06 13:32:03 -08:00
mkversion all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
nardump all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
natc all: use Go 1.26 things, run most gofix modernizers 2026-03-06 13:32:03 -08:00
netlogfmt all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
nginx-auth all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
omitsize all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
pgproxy all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
printdep cmd/printdep: add --next flag to use rc Go build hash instead 2026-01-27 14:49:56 -08:00
proxy-test-server all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
proxy-to-grafana all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
sniproxy all: use Go 1.26 things, run most gofix modernizers 2026-03-06 13:32:03 -08:00
speedtest all: use Go 1.26 things, run most gofix modernizers 2026-03-06 13:32:03 -08:00
ssh-auth-none-demo all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
stunc all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
stund types/ptr: deprecate ptr.To, use Go 1.26 new 2026-03-05 20:13:18 -08:00
stunstamp all: use Go 1.26 things, run most gofix modernizers 2026-03-06 13:32:03 -08:00
sync-containers all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
systray all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
tailscale all: use Go 1.26 things, run most gofix modernizers 2026-03-06 13:32:03 -08:00
tailscaled wgengine/magicsock,control/controlclient: do not overwrite discokey with old key (#18606) 2026-03-20 08:56:27 -04:00
testcontrol all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
testwrapper cmd/testwrapper: make test tolerant of a GOEXPERIMENT being set 2026-03-06 14:05:35 -08:00
tl-longchain all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
tsconnect go.toolchain.branch: switch to Go 1.26 2026-03-04 21:57:05 -08:00
tsidp wgengine/magicsock,control/controlclient: do not overwrite discokey with old key (#18606) 2026-03-20 08:56:27 -04:00
tsshd all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
tta all: use Go 1.26 things, run most gofix modernizers 2026-03-06 13:32:03 -08:00
vet all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
viewer all: use Go 1.26 things, run most gofix modernizers 2026-03-06 13:32:03 -08:00
vnet all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
xdpderper all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00