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 7DAE31FF183 for ; Wed, 2 Jul 2025 16:50:50 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id EAEEF1E1CE; Wed, 2 Jul 2025 16:51:19 +0200 (CEST) From: Gabriel Goller To: pve-devel@lists.proxmox.com Date: Wed, 2 Jul 2025 16:50:03 +0200 Message-Id: <20250702145101.894299-19-g.goller@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250702145101.894299-1-g.goller@proxmox.com> References: <20250702145101.894299-1-g.goller@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.019 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: [pve-devel] [PATCH proxmox-ve-rs v4 12/22] config: sdn: fabrics: add interface name struct 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" From: Stefan Hanreich A simple String wrapper that represents the name of a network interface. We are restricting the interface name to ASCII-only characters via the regex, since otherwise the length check would fail, due to String being Unicode. While network interface names can be arbitrary bytes and don't correspond to a specific encoding, restricting it to ASCII seemed sensible here. We can always lift the restriction later if this is required. Co-authored-by: Gabriel Goller Signed-off-by: Stefan Hanreich --- .../sdn/fabric/section_config/interface.rs | 22 +++++++++++++++++++ .../src/sdn/fabric/section_config/mod.rs | 1 + 2 files changed, 23 insertions(+) create mode 100644 proxmox-ve-config/src/sdn/fabric/section_config/interface.rs diff --git a/proxmox-ve-config/src/sdn/fabric/section_config/interface.rs b/proxmox-ve-config/src/sdn/fabric/section_config/interface.rs new file mode 100644 index 000000000000..4374f382b161 --- /dev/null +++ b/proxmox-ve-config/src/sdn/fabric/section_config/interface.rs @@ -0,0 +1,22 @@ +use serde::{Deserialize, Serialize}; + +use proxmox_schema::{api, api_string_type, const_regex, ApiStringFormat, UpdaterType}; + +const_regex! { + pub INTERFACE_NAME_REGEX = r"^[[:ascii:]]+$"; +} + +pub const INTERFACE_NAME_FORMAT: ApiStringFormat = ApiStringFormat::Pattern(&INTERFACE_NAME_REGEX); + +api_string_type! { + /// Name of a network interface. + /// + /// The interface name can have a maximum of 15 characters. This is a kernel limit. + #[api( + min_length: 1, + max_length: 15, + format: &INTERFACE_NAME_FORMAT, + )] + #[derive(Debug, Deserialize, Serialize, Clone, Hash, PartialEq, Eq, PartialOrd, Ord, UpdaterType)] + pub struct InterfaceName(String); +} diff --git a/proxmox-ve-config/src/sdn/fabric/section_config/mod.rs b/proxmox-ve-config/src/sdn/fabric/section_config/mod.rs index 0ca56958b3a8..b61bc43d871e 100644 --- a/proxmox-ve-config/src/sdn/fabric/section_config/mod.rs +++ b/proxmox-ve-config/src/sdn/fabric/section_config/mod.rs @@ -1,2 +1,3 @@ pub mod fabric; +pub mod interface; pub mod node; -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel