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 C4D3A1FF17A for ; Fri, 4 Jul 2025 16:40:39 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 7E55D3A855; Fri, 4 Jul 2025 16:41:21 +0200 (CEST) Date: Fri, 4 Jul 2025 16:40:47 +0200 From: Gabriel Goller To: Wolfgang Bumiller Message-ID: Mail-Followup-To: Wolfgang Bumiller , pve-devel@lists.proxmox.com References: <20250702145101.894299-1-g.goller@proxmox.com> <20250702145101.894299-10-g.goller@proxmox.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20241002-35-39f9a6 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.014 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [net.rs] Subject: Re: [pve-devel] [PATCH proxmox-ve-rs v4 03/22] sdn-types: initial commit X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Cc: pve-devel@lists.proxmox.com Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" >> [snip] >> diff --git a/proxmox-sdn-types/src/net.rs b/proxmox-sdn-types/src/net.rs >> new file mode 100644 >> index 000000000000..78a47983f0c7 >> --- /dev/null >> +++ b/proxmox-sdn-types/src/net.rs >> @@ -0,0 +1,329 @@ >> +use std::{ >> + fmt::Display, >> + net::{IpAddr, Ipv4Addr, Ipv6Addr}, >> +}; >> + >> +use anyhow::{bail, Error}; >> +use const_format::concatcp; >> +use serde::{Deserialize, Serialize}; >> + >> +use proxmox_schema::{api, api_string_type, const_regex, ApiStringFormat, UpdaterType}; >> + >> +const NET_AFI_REGEX_STR: &str = r"(?:[a-fA-F0-9]{2})"; > >Would it make sense to represent the `NetAFI` type as an `u8`? >Could then be `Copy` and wouldn't need to allocate a string. Stefan initially suggested that we could display the whole NET as [u8, n], but we then discarded it as there would be some components which are not in a power of 2 size which would make the handling tricky. I am kinda wary of representing some parts of the NET as u8 and some as String, I think that only makes it more complex and isn't really worth the hassle. If you think this is important though, I'll give it a shot... >> +const NET_AREA_REGEX_STR: &str = r"(?:[a-fA-F0-9]{4})"; >> +const NET_SYSTEM_ID_REGEX_STR: &str = r"(?:[a-fA-F0-9]{4})\.(?:[a-fA-F0-9]{4})\.(?:[a-fA-F0-9]{4})"; >> +const NET_SELECTOR_REGEX_STR: &str = r"(?:[a-fA-F0-9]{2})"; > >^ Same for the selector. > >> + >> +const_regex! { >> + NET_AFI_REGEX = concatcp!(r"^", NET_AFI_REGEX_STR, r"$"); >> + NET_AREA_REGEX = concatcp!(r"^", NET_AREA_REGEX_STR, r"$"); >> + NET_SYSTEM_ID_REGEX = concatcp!(r"^", NET_SYSTEM_ID_REGEX_STR, r"$"); >> + NET_SELECTOR_REGEX = concatcp!(r"^", NET_SELECTOR_REGEX_STR, r"$"); > >^ Why don't we anchor the consts already instead of concating that here? >Or - if they are only used this once we could just inline them here? Yeah, we could probably inline them here, I think we just copied this from PBS (where we always do this). >> +} >> + >> +const NET_AFI_FORMAT: ApiStringFormat = ApiStringFormat::Pattern(&NET_AFI_REGEX); >> +const NET_AREA_FORMAT: ApiStringFormat = ApiStringFormat::Pattern(&NET_AREA_REGEX); >> +const NET_SYSTEM_ID_FORMAT: ApiStringFormat = ApiStringFormat::Pattern(&NET_SYSTEM_ID_REGEX); >> +const NET_SELECTOR_FORMAT: ApiStringFormat = ApiStringFormat::Pattern(&NET_SELECTOR_REGEX); >> + >> [snip] _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel