wgengine/magicsock: suppress TSMP disco advert when bestAddr is peer relay

Updates #20156

Signed-off-by: Jordan Whited <jordan@tailscale.com>
This commit is contained in:
Jordan Whited
2026-06-18 11:43:00 -07:00
committed by Jordan Whited
parent 00b9e8d8ce
commit 54005752a5
3 changed files with 65 additions and 4 deletions
+4 -4
View File
@@ -4527,9 +4527,9 @@ type NewDiscoKeyAvailable struct {
// maybeSendTSMPDiscoAdvert conditionally emits an event indicating that we
// should send our DiscoKey to the first node address of the magicksock endpoint.
//
// The event is suppressed if we are already communicating directly or
// less than 60 seconds has passed since the last DiscoKey was sent, or netmap
// caching is disabled on this node.
// The event is suppressed if we are communicating over a non-DERP path, or
// less than [discoKeyAdvertisementInterval] has passed since the last DiscoKey
// was sent, or netmap caching is disabled on this node.
//
// We do not need the Conn to be locked, but the endpoint should be.
func (c *Conn) maybeSendTSMPDiscoAdvert(de *endpoint) {
@@ -4557,7 +4557,7 @@ func (c *Conn) maybeSendTSMPDiscoAdvert(de *endpoint) {
now := mono.Now()
if now.Sub(de.lastDiscoKeyAdvertisement) <= discoKeyAdvertisementInterval ||
(!de.lastDiscoKeyAdvertisement.IsZero() && de.bestAddr.isDirect()) {
(!de.lastDiscoKeyAdvertisement.IsZero() && !de.bestAddr.isZero()) {
return
}