Skip to content

Commit 22af56f

Browse files
nbrownusJackDoan
andauthored
Fix recv_error receipt limit allowance for v1.9.x (#1459)
* Fix recv_error receipt limit allowance * backport #1463 recv_error behavior changes --------- Co-authored-by: JackDoan <me@jackdoan.com>
1 parent 1d73e46 commit 22af56f

File tree

2 files changed

+8
-19
lines changed

2 files changed

+8
-19
lines changed

hostmap.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ const defaultPromoteEvery = 1000 // Count of packets sent before we try mo
2222
const defaultReQueryEvery = 5000 // Count of packets sent before re-querying a hostinfo to the lighthouse
2323
const defaultReQueryWait = time.Minute // Minimum amount of seconds to wait before re-querying a hostinfo the lighthouse. Evaluated every ReQueryEvery
2424
const MaxRemotes = 10
25-
const maxRecvError = 4
2625

2726
// MaxHostInfosPerVpnIp is the max number of hostinfos we will track for a given vpn ip
2827
// 5 allows for an initial handshake and each host pair re-handshaking twice
@@ -220,7 +219,6 @@ type HostInfo struct {
220219
remoteIndexId uint32
221220
localIndexId uint32
222221
vpnIp netip.Addr
223-
recvError atomic.Uint32
224222
remoteCidr *bart.Table[struct{}]
225223
relayState RelayState
226224

@@ -705,13 +703,6 @@ func (i *HostInfo) SetRemoteIfPreferred(hm *HostMap, newRemote netip.AddrPort) b
705703
return false
706704
}
707705

708-
func (i *HostInfo) RecvErrorExceeded() bool {
709-
if i.recvError.Add(1) >= maxRecvError {
710-
return true
711-
}
712-
return true
713-
}
714-
715706
func (i *HostInfo) CreateRemoteCIDR(c *cert.NebulaCertificate) {
716707
if len(c.Details.Ips) == 1 && len(c.Details.Subnets) == 0 {
717708
// Simple case, no CIDRTree needed

outside.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -286,16 +286,18 @@ func (f *Interface) handleHostRoaming(hostinfo *HostInfo, ip netip.AddrPort) {
286286

287287
}
288288

289+
// handleEncrypted returns true if a packet should be processed, false otherwise
289290
func (f *Interface) handleEncrypted(ci *ConnectionState, addr netip.AddrPort, h *header.H) bool {
290-
// If connectionstate exists and the replay protector allows, process packet
291-
// Else, send recv errors for 300 seconds after a restart to allow fast reconnection.
292-
if ci == nil || !ci.window.Check(f.l, h.MessageCounter) {
291+
// If connectionstate does not exist, send a recv error, if possible, to encourage a fast reconnect
292+
if ci == nil {
293293
if addr.IsValid() {
294294
f.maybeSendRecvError(addr, h.RemoteIndex)
295-
return false
296-
} else {
297-
return false
298295
}
296+
return false
297+
}
298+
// If the window check fails, refuse to process the packet, but don't send a recv error
299+
if !ci.window.Check(f.l, h.MessageCounter) {
300+
return false
299301
}
300302

301303
return true
@@ -458,10 +460,6 @@ func (f *Interface) handleRecvError(addr netip.AddrPort, h *header.H) {
458460
return
459461
}
460462

461-
if !hostinfo.RecvErrorExceeded() {
462-
return
463-
}
464-
465463
if hostinfo.remote.IsValid() && hostinfo.remote != addr {
466464
f.l.Infoln("Someone spoofing recv_errors? ", addr, hostinfo.remote)
467465
return

0 commit comments

Comments
 (0)