diff --git a/ipn/ipnlocal/local.go b/ipn/ipnlocal/local.go index 085cdc60c..6daad96d6 100644 --- a/ipn/ipnlocal/local.go +++ b/ipn/ipnlocal/local.go @@ -5830,6 +5830,9 @@ func (b *LocalBackend) handlePeerWireGuardState(peerKey key.NodePublic, st ipn.P delete(b.peerWGStableIDByKey, peerKey) addPeerWGStateMetric(old.PeerWireGuardState, -1) } else { + if st == ipn.PeerWireGuardStateEstablished { + b.MagicConn().MaybeSendTSMPDiscoAdvert(peerKey) + } old := b.peerWGState[id].PeerWireGuardState if old == st { return diff --git a/wgengine/magicsock/magicsock.go b/wgengine/magicsock/magicsock.go index 8e4c6bba7..6da8824bf 100644 --- a/wgengine/magicsock/magicsock.go +++ b/wgengine/magicsock/magicsock.go @@ -2678,7 +2678,7 @@ func (c *Conn) enqueueCallMeMaybe(derpAddr netip.AddrPort, de *endpoint) { return } - c.maybeSendTSMPDiscoAdvert(de) + //c.maybeSendTSMPDiscoAdvert(de) eps := make([]netip.AddrPort, 0, len(c.lastEndpoints)) for _, ep := range c.lastEndpoints { @@ -4552,6 +4552,12 @@ type NewDiscoKeyAvailable struct { NodeID tailcfg.NodeID } +func (c *Conn) MaybeSendTSMPDiscoAdvert(nk key.NodePublic) { + if ep, ok := c.peerMap.endpointForNodeKey(nk); ok { + c.maybeSendTSMPDiscoAdvert(ep) + } +} + // maybeSendTSMPDiscoAdvert conditionally emits an event indicating that we // should send our DiscoKey to the first node address of the magicksock endpoint. // @@ -4572,9 +4578,9 @@ func (c *Conn) maybeSendTSMPDiscoAdvert(de *endpoint) { // here has pathological behaviors. Therefore, it should be disabled for // almost all tailnets, and we lean on the network map caching control knob // for this purpose. See #20081. - if c.controlKnobs == nil || !c.controlKnobs.CacheNetworkMaps.Load() { - return - } + //if c.controlKnobs == nil || !c.controlKnobs.CacheNetworkMaps.Load() { + // return + //} de.mu.Lock() defer de.mu.Unlock()