[pbs-devel] [PATCH proxmox v3 2/5] rate-limiter: avoid division by zero in traffic updater
Christian Ebner
c.ebner at proxmox.com
Wed Nov 12 12:53:46 CET 2025
Do not calculate the proposed delay if the given rate is set to zero,
but rather return with no-delay similar to when the number of
consumed tokens is below the bucket size.
This effectively sets the bandwidth to be unlimited if the rate is set
to zero.
Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
Changes since version 2:
- not present in previous version
proxmox-rate-limiter/src/rate_limiter.rs | 3 +++
1 file changed, 3 insertions(+)
diff --git a/proxmox-rate-limiter/src/rate_limiter.rs b/proxmox-rate-limiter/src/rate_limiter.rs
index 945c77a6..8d879757 100644
--- a/proxmox-rate-limiter/src/rate_limiter.rs
+++ b/proxmox-rate-limiter/src/rate_limiter.rs
@@ -72,6 +72,9 @@ impl TbfState {
if self.consumed_tokens <= bucket_size {
return Self::NO_DELAY;
}
+ if rate == 0 {
+ return Self::NO_DELAY;
+ }
Duration::from_nanos(
(self.consumed_tokens - bucket_size).saturating_mul(1_000_000_000) / rate,
)
--
2.47.3
More information about the pbs-devel
mailing list