mirror of
https://github.com/markqvist/Reticulum.git
synced 2026-11-19 22:46:32 -05:00
Fixed PR egress limiter not preemptively considering potential outbound, and added late egress check to avoid state race under high incoming PR load
This commit is contained in:
parent
2aed542e61
commit
6f6751d6b6
2 changed files with 9 additions and 5 deletions
|
|
@ -82,7 +82,7 @@ class Interface:
|
|||
IC_BURST_PENALTY = 15
|
||||
IC_HELD_RELEASE_INTERVAL = 5
|
||||
IC_DEQUE_MIN_SAMPLE = 2
|
||||
IC_BURST_MIN_SAMPLES = 6
|
||||
EC_BURST_MIN_SAMPLES = 2
|
||||
EC_PR_FREQ = 5
|
||||
EGRESS_CONTROL = False
|
||||
|
||||
|
|
@ -220,10 +220,10 @@ class Interface:
|
|||
def should_egress_limit_pr(self):
|
||||
if self.egress_control:
|
||||
freq_threshold = self.ec_pr_freq
|
||||
op_freq = self.outgoing_pr_frequency()
|
||||
op_freq = self.outgoing_pr_frequency(preemptive=True)
|
||||
|
||||
if op_freq > freq_threshold:
|
||||
if len(self.op_freq_deque) >= self.IC_BURST_MIN_SAMPLES: return True
|
||||
if len(self.op_freq_deque) >= self.EC_BURST_MIN_SAMPLES: return True
|
||||
|
||||
return False
|
||||
|
||||
|
|
@ -356,8 +356,8 @@ class Interface:
|
|||
hz = n / span
|
||||
return hz
|
||||
|
||||
def outgoing_pr_frequency(self):
|
||||
n = len(self.op_freq_deque)
|
||||
def outgoing_pr_frequency(self, preemptive=False):
|
||||
n = len(self.op_freq_deque)+(1 if preemptive else 0)
|
||||
if not len(self.op_freq_deque) > 1: return 0
|
||||
else:
|
||||
oldest = self.op_freq_deque[0]
|
||||
|
|
|
|||
|
|
@ -3213,6 +3213,10 @@ class Transport:
|
|||
:param destination_hash: A destination hash as *bytes*.
|
||||
:param on_interface: If specified, the path request will only be sent on this interface. In normal use, Reticulum handles this automatically, and this parameter should not be used.
|
||||
"""
|
||||
if on_interface and recursive and on_interface.should_egress_limit_pr():
|
||||
RNS.log(f"Blocking recursive path request on {on_interface} due to active egress limiting", RNS.LOG_EXTREME) if RNS.sl(RNS.LOG_EXTREME) else None
|
||||
return
|
||||
|
||||
if tag == None: request_tag = RNS.Identity.get_random_hash()
|
||||
else: request_tag = tag
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue