wgengine/magicsock: fix de-dup disco ping handling for netmap endpoints (#7118)

Fixes #7116

Signed-off-by: Jordan Whited <jordan@tailscale.com>
pull/7131/head
Jordan Whited 1 year ago committed by GitHub
parent 01e736e1d5
commit 39e52c4b0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -3747,10 +3747,10 @@ type endpointState struct {
// updated and use it to discard old candidates.
lastGotPing time.Time
// lastGotPingTxID, if lastGotPing is non-zero, contains the TxID for the
// last incoming ping. This is used to de-dup incoming pings that we may
// see on both the raw disco socket on Linux, and UDP socket. We cannot rely
// solely on the raw socket disco handling due to https://github.com/tailscale/tailscale/issues/7078.
// lastGotPingTxID contains the TxID for the last incoming ping. This is
// used to de-dup incoming pings that we may see on both the raw disco
// socket on Linux, and UDP socket. We cannot rely solely on the raw socket
// disco handling due to https://github.com/tailscale/tailscale/issues/7078.
lastGotPingTxID stun.TxID
// callMeMaybeTime, if non-zero, is the time this endpoint
@ -4219,16 +4219,16 @@ func (de *endpoint) addCandidateEndpoint(ep netip.AddrPort, forRxPingTxID stun.T
defer de.mu.Unlock()
if st, ok := de.endpointState[ep]; ok {
duplicatePing = forRxPingTxID == st.lastGotPingTxID
if !duplicatePing {
st.lastGotPingTxID = forRxPingTxID
}
if st.lastGotPing.IsZero() {
// Already-known endpoint from the network map.
return false
}
if forRxPingTxID == st.lastGotPingTxID {
return true
return duplicatePing
}
st.lastGotPing = time.Now()
st.lastGotPingTxID = forRxPingTxID
return false
return duplicatePing
}
// Newly discovered endpoint. Exciting!

Loading…
Cancel
Save