From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 142981FF09C for ; Mon, 02 Nov 2026 13:47:58 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 6928A2186F; Mon, 02 Nov 2026 13:47:15 +0100 (CET) From: Christoph Heiss To: pve-devel@lists.proxmox.com Subject: [PATCH installer v4 14/30] install: config: add option for setting up vlan on management interface Date: Mon, 2 Nov 2026 13:45:20 +0100 Message-ID: <20261102124539.1008075-15-c.heiss@proxmox.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261102124539.1008075-1-c.heiss@proxmox.com> References: <20261102124539.1008075-1-c.heiss@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1793623615506 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.207 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: PTVNC7WYJ4SDVVW67RRNHIDI5BTWZNCC X-Message-ID-Hash: PTVNC7WYJ4SDVVW67RRNHIDI5BTWZNCC X-MailFrom: c.heiss@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: Prerequisite for the rest of the installer to support setting up a VLAN interface for management during installation. Signed-off-by: Christoph Heiss --- Changes v3 -> v4: * no changes Changes v2 -> v3: * new patch Proxmox/Install/Config.pm | 32 ++++++++++++++++++++++++++++++++ Proxmox/Sys/Net.pm | 9 +++++++++ 2 files changed, 41 insertions(+) diff --git a/Proxmox/Install/Config.pm b/Proxmox/Install/Config.pm index 967712a..3df66c2 100644 --- a/Proxmox/Install/Config.pm +++ b/Proxmox/Install/Config.pm @@ -118,6 +118,13 @@ my sub init_cfg { primary_interface => undef, }, + # Options for setting up a VLAN on the management interface. + mngmt_vlan => { + enabled => 0, + # VLAN ID to configure. + vid => 0, + }, + # maps mac address -> custom name # if set to a hash, enables interface name pinning for all interfaces network_interface_pin_map => undef, @@ -304,6 +311,31 @@ sub get_mngmt_bond_enabled { # virtual config return scalar(get_mngmt_bond_opt('members')->@*) >= 2; } +sub set_mngmt_vlan_opt { + my ($k, $v) = @_; + my $opts = get('mngmt_vlan'); + + croak "unknown management vlan option key '$k'\n" if !exists($opts->{$k}); + + if ($k eq 'vid') { + die "invalid VLAN tag '$v'\n" + if !Proxmox::Sys::Net::is_valid_vlan_id($v); + $opts->{$k} = int($v); + } else { + $opts->{$k} = $v; + } +} + +sub get_mngmt_vlan_opt { + my ($k) = @_; + my $opts = get('mngmt_vlan'); + return defined($k) ? $opts->{$k} : $opts; +} + +sub get_mngmt_vlan_enabled { + return get_mngmt_vlan_opt('enabled') != 0; +} + sub set_network_interface_pin_map { set_key('network_interface_pin_map', $_[0]); } sub get_network_interface_pin_map { return get('network_interface_pin_map'); } diff --git a/Proxmox/Sys/Net.pm b/Proxmox/Sys/Net.pm index 630d96a..485c9e9 100644 --- a/Proxmox/Sys/Net.pm +++ b/Proxmox/Sys/Net.pm @@ -17,6 +17,7 @@ our @EXPORT_OK = qw( validate_link_pin_map is_valid_bond_mode is_valid_bond_hash_policy + is_valid_vlan_id MIN_IFNAME_LEN MAX_IFNAME_LEN DEFAULT_PIN_PREFIX @@ -484,4 +485,12 @@ sub is_valid_bond_hash_policy { return exists($valid->{$policy}); } +# Returns whether the given ID is a valid VLAN ID. +# 0 and 4095 are reserved, and 1 is the default PVID of VLAN-aware bridges on Linux. +sub is_valid_vlan_id { + my ($vid) = @_; + + return defined($vid) && $vid =~ m/^[0-9]+$/ && $vid >= 2 && $vid <= 4094; +} + 1; -- 2.55.0