From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 8956B80277 for ; Wed, 17 Nov 2021 10:21:28 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 7987F2072C for ; Wed, 17 Nov 2021 10:20:58 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id C159A2071A for ; Wed, 17 Nov 2021 10:20:57 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 923F343D33; Wed, 17 Nov 2021 10:20:57 +0100 (CET) From: Dietmar Maurer To: pbs-devel@lists.proxmox.com Date: Wed, 17 Nov 2021 10:20:53 +0100 Message-Id: <20211117092053.1643823-2-dietmar@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211117092053.1643823-1-dietmar@proxmox.com> References: <20211117092053.1643823-1-dietmar@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.497 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% 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] [RFC proxmox-backup 2/2] use HumanByte for traffic-control config 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: , X-List-Received-Date: Wed, 17 Nov 2021 09:21:28 -0000 --- pbs-api-types/src/traffic_control.rs | 18 +++++++++--------- src/cached_traffic_control.rs | 18 ++++++++++++------ 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/pbs-api-types/src/traffic_control.rs b/pbs-api-types/src/traffic_control.rs index 0dd7ed58..210f53ac 100644 --- a/pbs-api-types/src/traffic_control.rs +++ b/pbs-api-types/src/traffic_control.rs @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize}; use proxmox_schema::{api, Schema, IntegerSchema, StringSchema, Updater}; use crate::{ - CIDR_SCHEMA, DAILY_DURATION_FORMAT, + HumanByte, CIDR_SCHEMA, DAILY_DURATION_FORMAT, PROXMOX_SAFE_ID_FORMAT, SINGLE_LINE_COMMENT_SCHEMA, }; @@ -38,19 +38,19 @@ pub const TRAFFIC_CONTROL_BURST_SCHEMA: Schema = IntegerSchema::new( schema: SINGLE_LINE_COMMENT_SCHEMA, }, "rate-in": { - schema: TRAFFIC_CONTROL_RATE_SCHEMA, + type: HumanByte, optional: true, }, "burst-in": { - schema: TRAFFIC_CONTROL_BURST_SCHEMA, + type: HumanByte, optional: true, }, "rate-out": { - schema: TRAFFIC_CONTROL_RATE_SCHEMA, + type: HumanByte, optional: true, }, "burst-out": { - schema: TRAFFIC_CONTROL_BURST_SCHEMA, + type: HumanByte, optional: true, }, network: { @@ -79,13 +79,13 @@ pub struct TrafficControlRule { /// Rule applies to Source IPs within this networks pub network: Vec, #[serde(skip_serializing_if="Option::is_none")] - pub rate_in: Option, + pub rate_in: Option, #[serde(skip_serializing_if="Option::is_none")] - pub burst_in: Option, + pub burst_in: Option, #[serde(skip_serializing_if="Option::is_none")] - pub rate_out: Option, + pub rate_out: Option, #[serde(skip_serializing_if="Option::is_none")] - pub burst_out: Option, + pub burst_out: Option, // fixme: expose this? // /// Bandwidth is shared accross all connections // #[serde(skip_serializing_if="Option::is_none")] diff --git a/src/cached_traffic_control.rs b/src/cached_traffic_control.rs index 426ebba7..5c6ce042 100644 --- a/src/cached_traffic_control.rs +++ b/src/cached_traffic_control.rs @@ -225,7 +225,10 @@ impl TrafficControlCache { Some(ref read_limiter) => { match rule.rate_in { Some(rate_in) => { - read_limiter.update_rate(rate_in, rule.burst_in.unwrap_or(rate_in)); + read_limiter.update_rate( + rate_in.as_u64(), + rule.burst_in.unwrap_or(rate_in).as_u64(), + ); } None => entry.0 = None, } @@ -236,8 +239,8 @@ impl TrafficControlCache { let limiter = create_limiter( self.use_shared_memory, &name, - rate_in, - rule.burst_in.unwrap_or(rate_in), + rate_in.as_u64(), + rule.burst_in.unwrap_or(rate_in).as_u64(), )?; entry.0 = Some(limiter); } @@ -248,7 +251,10 @@ impl TrafficControlCache { Some(ref write_limiter) => { match rule.rate_out { Some(rate_out) => { - write_limiter.update_rate(rate_out, rule.burst_out.unwrap_or(rate_out)); + write_limiter.update_rate( + rate_out.as_u64(), + rule.burst_out.unwrap_or(rate_out).as_u64(), + ); } None => entry.1 = None, } @@ -259,8 +265,8 @@ impl TrafficControlCache { let limiter = create_limiter( self.use_shared_memory, &name, - rate_out, - rule.burst_out.unwrap_or(rate_out), + rate_out.as_u64(), + rule.burst_out.unwrap_or(rate_out).as_u64(), )?; entry.1 = Some(limiter); } -- 2.30.2