public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Stefan Hanreich <s.hanreich@proxmox.com>
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	[thread overview]
Message-ID: <20261112171102.674232-1-s.hanreich@proxmox.com> (raw)

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




             reply	other threads:[~2026-11-12 17:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 17:10 Stefan Hanreich [this message]
2026-11-12 17:10 ` [PATCH proxmox 1/4] network-types: add a type for network interface names Stefan Hanreich
2026-11-12 17:10 ` [PATCH proxmox 2/4] network-types: add a type for network interface altnames Stefan Hanreich
2026-11-12 17:10 ` [PATCH proxmox 3/4] network-types: add types for names reported by the kernel Stefan Hanreich
2026-11-12 17:11 ` [PATCH proxmox 4/4] network-types: add a type for names of existing configurations Stefan Hanreich
2026-11-12 17:36   ` Stefan Hanreich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261112171102.674232-1-s.hanreich@proxmox.com \
    --to=s.hanreich@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal