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

Loading…
Cancel
Save