mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-25 19:15:34 +00:00
wgengine/magicsock: add an explicit else branch to peerMap update.
Clarifies that the replace+delete of peerinfo data is only when peerInfo already exists. Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
parent
1c56643136
commit
e7eb46bced
@ -112,7 +112,6 @@ type Ping struct {
|
|||||||
|
|
||||||
// NodeKey is allegedly the ping sender's wireguard public key.
|
// NodeKey is allegedly the ping sender's wireguard public key.
|
||||||
// Old clients (~1.16.0 and earlier) don't send this field.
|
// Old clients (~1.16.0 and earlier) don't send this field.
|
||||||
|
|
||||||
// It shouldn't be trusted by itself, but can be combined with
|
// It shouldn't be trusted by itself, but can be combined with
|
||||||
// netmap data to reduce the discokey:nodekey relation from 1:N to
|
// netmap data to reduce the discokey:nodekey relation from 1:N to
|
||||||
// 1:1.
|
// 1:1.
|
||||||
|
@ -172,12 +172,13 @@ func (m *peerMap) upsertEndpoint(ep *endpoint) {
|
|||||||
if pi == nil {
|
if pi == nil {
|
||||||
pi = newPeerInfo(ep)
|
pi = newPeerInfo(ep)
|
||||||
m.byNodeKey[ep.publicKey] = pi
|
m.byNodeKey[ep.publicKey] = pi
|
||||||
}
|
} else {
|
||||||
old := pi.ep
|
old := pi.ep
|
||||||
pi.ep = ep
|
pi.ep = ep
|
||||||
if old != nil && old.discoKey != ep.discoKey {
|
if old != nil && old.discoKey != ep.discoKey {
|
||||||
delete(m.byDiscoKey, old.discoKey)
|
delete(m.byDiscoKey, old.discoKey)
|
||||||
delete(m.nodesOfDisco[old.discoKey], ep.publicKey)
|
delete(m.nodesOfDisco[old.discoKey], ep.publicKey)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if !ep.discoKey.IsZero() {
|
if !ep.discoKey.IsZero() {
|
||||||
m.byDiscoKey[ep.discoKey] = pi
|
m.byDiscoKey[ep.discoKey] = pi
|
||||||
|
Loading…
Reference in New Issue
Block a user