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 965FE1FF066 for ; Tue, 24 Nov 2026 12:43:06 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 1BE7621545; Tue, 24 Nov 2026 12:43:04 +0100 (CET) From: Stoiko Ivanov To: pve-devel@lists.proxmox.com Subject: [PATCH installer v2] network: align VLAN interface names with the documentation Date: Tue, 24 Nov 2026 12:42:32 +0100 Message-ID: <20261124114245.2656326-1-s.ivanov@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1795520578140 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.353 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: G3EWJAHKS3NVEDHUFJDKAEDXUHXWZ6NZ X-Message-ID-Hash: G3EWJAHKS3NVEDHUFJDKAEDXUHXWZ6NZ X-MailFrom: s.ivanov@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: Our documentation has relied on ifupdown(2)'s way of handling $iface.$vid as identifier for VLAN interfaces for a long while (looking through pve-docs commit history shows `vlan-raw-device` only occurring in the api-viewer) One case where the $iface.$vlan_id naming breaks is for long interface names (e.g. enp129s0f1np1, or mac-based enxdadadadadada) Use the dot-notation where this is possible, and fallback to `vlan$vlan_id` with `vlan-raw-device $iface` where this is needed For the dot-notation case also drop `vlan-raw-device` to avoid misconfigurations due to mismatches/incomplete substitutions. I considered also adding `vlan-id $vlan_id` to the config in the `vlan-raw-device` case, based on ifupdown-addons-interfaces(5) saying it requires it, but my tests show it's not needed. I considered encoding the interface name as "utf-8" for the length comparison, but we luckily restrict the pinned names to ascii only. Sticking to our documentation should help reducing the different ways that people are configuring their interfaces and thus hopefully the potential for errors. Signed-off-by: Stoiko Ivanov --- v1->v2: * merge both patches into a single one * handle the quite real case of long predictable ifnames (enp129s0f1np1) pointed out by Stefan (and a review tool) * add a test-case. v1: https://lore.proxmox.com/pve-devel/dbbc7520-5e8a-4e10-9371-d1c7745cfd5c@proxmox.com/T/#t Proxmox/Install.pm | 12 +++- test/generate-ifupdown2-config.pl | 106 +++++++++++++++++++++--------- 2 files changed, 85 insertions(+), 33 deletions(-) diff --git a/Proxmox/Install.pm b/Proxmox/Install.pm index 76bfd04..c1660fb 100644 --- a/Proxmox/Install.pm +++ b/Proxmox/Install.pm @@ -16,6 +16,7 @@ use Proxmox::Install::StorageConfig; use Proxmox::Sys::Block qw(get_cached_disks wipe_disk partition_bootable_disk); use Proxmox::Sys::Command qw(run_command syscmd); use Proxmox::Sys::File qw(file_read_firstline file_read_all file_write_all); +use Proxmox::Sys::Net; use Proxmox::Sys::ZFS; use Proxmox::UI; @@ -887,9 +888,16 @@ sub generate_ifupdown2_config { my $get_vlan_stanza = sub { my ($raw_device) = @_; - my $config = "auto vlan$vlan_id\niface vlan$vlan_id $ntype static\n\taddress $cidr\n"; + my $devname = "$raw_device.$vlan_id"; + my $long_if = length($devname) > Proxmox::Sys::Net::MAX_IFNAME_LEN; + $devname = "vlan$vlan_id" if $long_if; + + my $config = "auto $devname\niface $devname $ntype static\n\taddress $cidr\n"; $config .= "\tgateway $gateway\n" if !$is_gateway6_from_ra; - return [4, "vlan$vlan_id", $config . "\tvlan-raw-device $raw_device\n"]; + + $config .= "\tvlan-raw-device $raw_device\n" if $long_if; + + return [4, $devname, $config]; }; if ($iso_env->{cfg}->{bridged_network} && defined($vlan_id)) { diff --git a/test/generate-ifupdown2-config.pl b/test/generate-ifupdown2-config.pl index a3b7bdb..9bf6a40 100755 --- a/test/generate-ifupdown2-config.pl +++ b/test/generate-ifupdown2-config.pl @@ -152,11 +152,10 @@ is_generated( auto eno1 iface eno1 inet manual -auto vlan5 -iface vlan5 inet static +auto eno1.5 +iface eno1.5 inet static address 192.168.0.10/24 gateway 192.168.0.1 - vlan-raw-device eno1 iface eno2 inet manual EOT @@ -194,11 +193,10 @@ iface bond0 inet manual bond-miimon 100 bond-mode active-backup -auto vlan5 -iface vlan5 inet static +auto bond0.5 +iface bond0.5 inet static address 192.168.0.10/24 gateway 192.168.0.1 - vlan-raw-device bond0 auto eno1 iface eno1 inet manual @@ -244,11 +242,10 @@ iface vmbr0 inet manual bridge-vlan-aware yes bridge-vids 2-4094 -auto vlan5 -iface vlan5 inet static +auto vmbr0.5 +iface vmbr0.5 inet static address 192.168.0.10/24 gateway 192.168.0.1 - vlan-raw-device vmbr0 EOT , 'host network setup', ); @@ -304,11 +301,10 @@ iface vmbr0 inet manual bridge-vlan-aware yes bridge-vids 2-4094 -auto vlan5 -iface vlan5 inet static +auto vmbr0.5 +iface vmbr0.5 inet static address 192.168.0.10/24 gateway 192.168.0.1 - vlan-raw-device vmbr0 EOT , 'host network setup', ); @@ -323,11 +319,10 @@ iface eno1 inet manual iface eno2 inet manual -auto vlan5 -iface vlan5 inet static +auto eno1.5 +iface eno1.5 inet static address 192.168.0.10/24 gateway 192.168.0.1 - vlan-raw-device eno1 EOT , 'interfaces ordered like the network API', ); @@ -347,11 +342,10 @@ iface bond0 inet manual bond-miimon 100 bond-mode active-backup -auto vlan5 -iface vlan5 inet static +auto bond0.5 +iface bond0.5 inet static address 192.168.0.10/24 gateway 192.168.0.1 - vlan-raw-device bond0 EOT , 'interfaces ordered like the network API', ); @@ -363,11 +357,10 @@ is_generated( auto eno1 iface eno1 inet manual -auto vlan5 -iface vlan5 inet static +auto eno1.5 +iface eno1.5 inet static address 192.168.0.10/24 gateway 192.168.0.1 - vlan-raw-device eno1 iface eno2 inet manual EOT @@ -749,11 +742,10 @@ iface bond0 inet6 manual bond-miimon 100 bond-mode active-backup -auto vlan5 -iface vlan5 inet6 static +auto bond0.5 +iface bond0.5 inet6 static address 2001:db8::1/64 gateway fe80::1 - vlan-raw-device bond0 auto eno1 iface eno1 inet6 manual @@ -797,10 +789,9 @@ is_generated( auto eno1 iface eno1 inet6 manual -auto vlan5 -iface vlan5 inet6 static +auto eno1.5 +iface eno1.5 inet6 static address 2001:db8::1/64 - vlan-raw-device eno1 iface eno2 inet6 manual EOT @@ -822,10 +813,9 @@ iface vmbr0 inet6 manual bridge-vlan-aware yes bridge-vids 2-4094 -auto vlan5 -iface vlan5 inet6 static +auto vmbr0.5 +iface vmbr0.5 inet6 static address 2001:db8::1/64 - vlan-raw-device vmbr0 EOT , 'gateway learned from router advertisements on the management VLAN on a bridge is not configured', ); @@ -834,7 +824,7 @@ set_config(bridge => 0, bond => 0, vlan => 1); Proxmox::Install::Config::merge({ mngmt_vlan => { enabled => 1, vid => 200 } }); like( Proxmox::Install::generate_ifupdown2_config(), - qr/^iface vlan200 inet6 static\n\taddress 2001:db8::1\/64\n\tgateway fe80::1\n/m, + qr/^iface eno1.200 inet6 static\n\taddress 2001:db8::1\/64\n\tgateway fe80::1\n/m, 'management VLAN other than the installation environment one gets the configured gateway', ); @@ -845,6 +835,60 @@ like( 'untagged management network with a tagged installation environment gets the configured gateway', ); +# handling of long predictable nic name +$proxmox_install_runenv->redefine( + get => sub { + return { + network => { + interfaces => { + enp129s0f1np1 => { + mac => '12:34:56:ab:cd:ef', + index => 1, + name => 'enp129s0f1np1', + pinned_id => '0', + }, + }, + }, + }; + }, +); +set_config(bridge => 0, bond => 0, vlan => 0); +Proxmox::Install::Config::merge({ + mngmt_nic => 'enp129s0f1np1', + cidr => '192.168.0.10/24', + gateway => '192.168.0.1', +}); +is_generated( + < 0, bond => 0, vlan => 1); +Proxmox::Install::Config::merge({ + mngmt_nic => 'enp129s0f1np1', + cidr => '192.168.0.10/24', + gateway => '192.168.0.1', + mngmt_vlan => { enabled => 1, vid => 4094 }, +}); +is_generated( + <