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 7F1201FF0DA for ; Thu, 19 Nov 2026 20:44:55 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 6792E21801; Thu, 19 Nov 2026 20:42:14 +0100 (CET) From: Gabriel Goller To: pve-devel@lists.proxmox.com Subject: [PATCH pve-manager v3 25/28] network: allow setting the VRF of host interfaces Date: Thu, 19 Nov 2026 20:41:11 +0100 Message-ID: <20261119194116.575520-26-g.goller@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261119194116.575520-1-g.goller@proxmox.com> References: <20261119194116.575520-1-g.goller@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1795117283245 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.212 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: 6VFXGYQNBMGYLA2OYHKIWYZBU3RKV5P5 X-Message-ID-Hash: 6VFXGYQNBMGYLA2OYHKIWYZBU3RKV5P5 X-MailFrom: g.goller@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: Host interfaces can now be put into a VRF from the network panel. The VRF field suggests the VRFs of applied SDN zones on this node, but also accepts other VRF names, for example a VRF configured by hand. Interfaces that are part of a fabric get their VRF from the fabric, so setting one is rejected and the field is read-only for them. Their other settings stay editable. The duplicate gateway check now only compares interfaces in the same VRF, because every VRF has its own default route. Signed-off-by: Gabriel Goller --- PVE/API2/Network.pm | 55 ++++++++++++++++++++++------ www/manager6/form/SDNZoneSelector.js | 44 ++++++++++++++++++---- www/manager6/node/Config.js | 12 ++++++ 3 files changed, 93 insertions(+), 18 deletions(-) diff --git a/PVE/API2/Network.pm b/PVE/API2/Network.pm index 6f8854822f00..74d63cfe9f0b 100644 --- a/PVE/API2/Network.pm +++ b/PVE/API2/Network.pm @@ -165,6 +165,14 @@ my $confdesc = { minimum => 1, maximum => 4094, }, + vrf => { + description => 'VRF master interface.', + type => 'string', + minLength => 1, + maxLength => 15, + pattern => '[a-zA-Z0-9_][a-zA-Z0-9_.-]*', + optional => 1, + }, gateway => { description => 'Default gateway address.', type => 'string', @@ -520,7 +528,9 @@ __PACKAGE__->register_method({ my $check_duplicate = sub { my ($config, $newiface, $key, $name) = @_; + my $vrf = $config->{$newiface}->{vrf} // ''; foreach my $iface (keys %$config) { + next if ($config->{$iface}->{vrf} // '') ne $vrf; raise_param_exc({ $key => "$name already exists on interface '$iface'." }) if ($newiface ne $iface) && $config->{$iface}->{$key}; } @@ -652,10 +662,12 @@ __PACKAGE__->register_method({ raise_param_exc({ iface => "interface already exists" }) if $ifaces->{$iface}; - &$check_duplicate_gateway($ifaces, $iface) - if $param->{gateway}; - &$check_duplicate_gateway6($ifaces, $iface) - if $param->{gateway6}; + if ($have_sdn && $param->{vrf}) { + my $fabrics = PVE::Network::SDN::Fabrics::config(); + raise_param_exc({ + vrf => "cannot set VRF on an interface that is part of a fabric" }) + if $fabrics->is_fabric_interface(PVE::INotify::nodename(), $iface); + } $check_duplicate_ports->($ifaces, $iface, $param); @@ -704,6 +716,8 @@ __PACKAGE__->register_method({ if $param->{bridge_vids}; $ifaces->{$iface} = $param; + $check_duplicate_gateway->($ifaces, $iface) if $param->{gateway}; + $check_duplicate_gateway6->($ifaces, $iface) if $param->{gateway6}; PVE::INotify::write_file('interfaces', $config); }; @@ -753,6 +767,15 @@ __PACKAGE__->register_method({ raise_param_exc({ iface => "interface does not exist" }) if !$ifaces->{$iface}; + if ( + $have_sdn && $param->{vrf} && $param->{vrf} ne ($ifaces->{$iface}->{vrf} // '') + ) { + my $fabrics = PVE::Network::SDN::Fabrics::config(); + raise_param_exc({ + vrf => "cannot set VRF on an interface that is part of a fabric" }) + if $fabrics->is_fabric_interface(PVE::INotify::nodename(), $iface); + } + my $families = ($param->{families} ||= []); foreach my $k (PVE::Tools::split_list($delete)) { delete $ifaces->{$iface}->{$k}; @@ -769,11 +792,6 @@ __PACKAGE__->register_method({ $map_cidr_to_address_netmask->($param); - &$check_duplicate_gateway($ifaces, $iface) - if $param->{gateway}; - &$check_duplicate_gateway6($ifaces, $iface) - if $param->{gateway6}; - $check_duplicate_ports->($ifaces, $iface, $param); if ($param->{address}) { @@ -795,6 +813,8 @@ __PACKAGE__->register_method({ foreach my $k (keys %$param) { $ifaces->{$iface}->{$k} = $param->{$k}; } + $check_duplicate_gateway->($ifaces, $iface) if $ifaces->{$iface}->{gateway}; + $check_duplicate_gateway6->($ifaces, $iface) if $ifaces->{$iface}->{gateway6}; if ( $param->{bridge_vids} @@ -842,6 +862,12 @@ __PACKAGE__->register_method({ method => { type => 'string', }, + 'vrf-readonly' => { + type => 'boolean', + optional => 1, + description => + 'The VRF field is managed by an SDN fabric and should be disabled in the host network editor.', + }, }, }, code => sub { @@ -855,10 +881,17 @@ __PACKAGE__->register_method({ raise_param_exc({ iface => "interface does not exist" }) if !$ifaces->{$iface}; + my $data = { $ifaces->{$iface}->%* }; my $altnames = extract_altnames($iface); - $ifaces->{$iface}->{altnames} = $altnames if defined($altnames); + $data->{altnames} = $altnames if defined($altnames); + + if ($have_sdn) { + my $fabrics = PVE::Network::SDN::Fabrics::config(); + $data->{'vrf-readonly'} = 1 + if $fabrics->is_fabric_interface(PVE::INotify::nodename(), $iface); + } - return $ifaces->{$iface}; + return $data; }, }); diff --git a/www/manager6/form/SDNZoneSelector.js b/www/manager6/form/SDNZoneSelector.js index dde25371f18d..dfd516add5ca 100644 --- a/www/manager6/form/SDNZoneSelector.js +++ b/www/manager6/form/SDNZoneSelector.js @@ -5,12 +5,19 @@ Ext.define( alias: ['widget.pveSDNZoneSelector'], allowBlank: false, + // Use 'vrf' to submit the native VRF interface name instead of the zone ID. valueField: 'zone', displayField: 'zone', // Only show simple zones which create a dedicated VRF. vrfOnly: false, + // Only show zones available on this node, if specified. + nodename: undefined, + + // Only show zones from the applied SDN configuration, not pending changes. + running: false, + initComponent: function () { var me = this; @@ -20,15 +27,29 @@ Ext.define( property: 'zone', direction: 'ASC', }, - filters: me.vrfOnly - ? [ - function (record) { - return record.get('type') === 'simple' && record.get('dedicated-vrf'); - }, - ] - : [], + filters: [ + function (record) { + return ( + !me.vrfOnly || + (record.get('type') === 'simple' && record.get('dedicated-vrf')) + ); + }, + function (record) { + let nodes = record.get('nodes'); + return !me.nodename || !nodes || nodes.split(',').includes(me.nodename); + }, + ], }); + if (me.running) { + // Don't touch the shared model proxy, other selectors need the pending config. + store.setProxy({ + type: 'proxmox', + url: '/api2/json/cluster/sdn/zones', + extraParams: { running: 1 }, + }); + } + Ext.apply(me, { store: store, autoSelect: false, @@ -55,6 +76,15 @@ Ext.define( fields: [ 'zone', 'type', + 'nodes', + { + name: 'vrf', + // Preserve custom values in the synthetic records created by ComboBox. + convert: (value, record) => { + let zone = record.get('zone'); + return value ?? (zone ? `vrf_${zone}` : value); + }, + }, { name: 'dedicated-vrf', type: 'boolean', defaultValue: false }, ], proxy: { diff --git a/www/manager6/node/Config.js b/www/manager6/node/Config.js index 747119379e75..4cfb1dc69a8f 100644 --- a/www/manager6/node/Config.js +++ b/www/manager6/node/Config.js @@ -196,6 +196,18 @@ Ext.define('PVE.node.Config', { nodename: nodename, editOptions: { enableBridgeVlanIds: true, + vrfSelector: { + xtype: 'pveSDNZoneSelector', + running: true, + vrfOnly: true, + valueField: 'vrf', + displayField: 'vrf', + editable: true, + forceSelection: false, + anyMatch: true, + maxLength: 15, + notFoundIsValid: true, + }, }, onlineHelp: 'sysadmin_network_configuration', }, -- 2.47.3