From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 474911FF179 for ; Wed, 12 Nov 2025 12:53:56 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 9BF2CE57; Wed, 12 Nov 2025 12:54:43 +0100 (CET) From: Christian Ebner To: pbs-devel@lists.proxmox.com Date: Wed, 12 Nov 2025 12:53:46 +0100 Message-ID: <20251112115353.277514-3-c.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251112115353.277514-1-c.ebner@proxmox.com> References: <20251112115353.277514-1-c.ebner@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1762948426180 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.048 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH proxmox v3 2/5] rate-limiter: avoid division by zero in traffic updater X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" 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 --- 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 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel