From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 928161FF0B6 for ; Thu, 12 Nov 2026 18:11:52 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 05979216E8; Thu, 12 Nov 2026 18:11:25 +0100 (CET) From: Stefan Hanreich To: pve-devel@lists.proxmox.com Subject: [PATCH proxmox 0/4] network-types: add types for network interface names Date: Thu, 12 Nov 2026 18:10:56 +0100 Message-ID: <20261112171102.674232-1-s.hanreich@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1794503476924 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.288 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: XNRL3DNZYBC6OYTTJTTC3VAJC5ZP2PTV X-Message-ID-Hash: XNRL3DNZYBC6OYTTJTTC3VAJC5ZP2PTV X-MailFrom: s.hanreich@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Network interface names are validated differently all over the stack: * pve-iface of the Perl JSON schema, e.g. for the network configuration and the interfaces of firewall rules in PVE: letters, digits and '_' with an optional VLAN or alias suffix, up to 21 characters * pve-bridge-id and the names of container interfaces: [-_.\w\d]+ * the network API of PBS and PDM: the SAFE_ID format with up to 15 characters * the installers: pve-iface, up to 15 bytes, and no names reserved for bonds, VLANs and bridges * SDN: VNet IDs of up to 8 letters and digits * iproute2 and the kernel, whose rules also differ between iproute2 versions The pve-iface format accepts names that the kernel rejects, e.g. longer than 15 bytes, but rejects names with a '-', which users have asked for (bug #6366 [1]). This series adds one type per kind of name to proxmox-network-types, with explicit conversions between them: * NetworkInterfaceName: names as accepted by the API, i.e. every name that the APIs of PVE, PBS and PDM accept and the kernel can use, plus a few that pve-iface rejects, e.g. with a '-'. It uses the format of the network API of PBS and PDM. * NetworkInterfaceAltname: names or altnames, e.g. the interface of a firewall rule * KernelNetworkInterfaceName and KernelNetworkInterfaceAltname: names as accepted by the kernel, stored as bytes * LegacyNetworkInterfaceName: names validated by pve-iface, for reading existing configurations The module documentation describes which type to use for what. The firewall hardening series uses the API types for the interfaces of firewall rules and guests. The goal is to unify the validation of interface names with types that respect all the quirks that exist, and to convert the places dealing with interface names to them in follow-up series, starting with proxmox-network-api and the new format in pve-iface. Notes ===== The kernel types store bytes, since the kernel stores names as bytes that do not have to be valid UTF-8, so String is unsuited for them. Also, not every valid UTF-8 string is a valid kernel name. 'ip -json' prints names that are not valid UTF-8 unchanged, which serde_json only accepts when deserializing into bytes. The types follow the rules of the kernel instead of iproute2, whose checks differ between versions: before 7.0, 'ip' rejected altnames with whitespace or '/', and it still rejects the empty altname. The kernel treats 0xa0 as whitespace, which is also a UTF-8 continuation byte, so it rejects some valid UTF-8 names as well, e.g. ones containing U+00E0. A test checks the resulting rule against all code points. [1] https://bugzilla.proxmox.com/show_bug.cgi?id=6366 proxmox: Stefan Hanreich (4): network-types: add a type for network interface names network-types: add a type for network interface altnames network-types: add types for names reported by the kernel network-types: add a type for names of existing configurations proxmox-network-types/Cargo.toml | 4 +- proxmox-network-types/src/lib.rs | 2 + .../src/network_interface.rs | 957 ++++++++++++++++++ 3 files changed, 962 insertions(+), 1 deletion(-) create mode 100644 proxmox-network-types/src/network_interface.rs Summary over all repositories: 3 files changed, 962 insertions(+), 1 deletions(-) -- Generated by murpp 0.12.1