public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Gabriel Goller <g.goller@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH pve-manager v3 29/32] network: allow setting the VRF of host interfaces
Date: Mon, 16 Nov 2026 17:11:49 +0100	[thread overview]
Message-ID: <20261116161154.343743-30-g.goller@proxmox.com> (raw)
In-Reply-To: <20261116161154.343743-1-g.goller@proxmox.com>

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
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 <g.goller@proxmox.com>
---
 PVE/API2/Network.pm                  | 41 ++++++++++++------
 www/manager6/form/SDNZoneSelector.js | 63 +++++++++++++++++++++++-----
 www/manager6/node/Config.js          | 12 ++++++
 3 files changed, 93 insertions(+), 23 deletions(-)

diff --git a/PVE/API2/Network.pm b/PVE/API2/Network.pm
index 6f8854822f00..df89d26243d0 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,11 +662,6 @@ __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};
-
             $check_duplicate_ports->($ifaces, $iface, $param);
 
             $map_cidr_to_address_netmask->($param);
@@ -704,6 +709,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);
         };
@@ -769,11 +776,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 +797,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 +846,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 +865,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 05fd4be8b270..acfc61013616 100644
--- a/www/manager6/form/SDNZoneSelector.js
+++ b/www/manager6/form/SDNZoneSelector.js
@@ -5,6 +5,7 @@ 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',
 
@@ -14,6 +15,24 @@ Ext.define(
         // Hide EVPN zones, e.g. for BGP fabrics, which cannot run in an EVPN zone VRF.
         excludeEvpn: false,
 
+        // Only show zones available on this node, if specified.
+        nodename: undefined,
+
+        // Exclude a zone, including its native VRF name when custom input is allowed.
+        excludeZone: undefined,
+
+        // Only show zones from the applied SDN configuration, not pending changes.
+        running: false,
+
+        validator: function (value) {
+            let me = this;
+            let excluded = me.valueField === 'vrf' ? `vrf_${me.excludeZone}` : me.excludeZone;
+            if (me.excludeZone && value === excluded) {
+                return gettext('This zone is not allowed.');
+            }
+            return me.callParent([value]);
+        },
+
         initComponent: function () {
             var me = this;
 
@@ -23,19 +42,32 @@ Ext.define(
                     property: 'zone',
                     direction: 'ASC',
                 },
-                filters: me.vrfOnly
-                    ? [
-                          function (record) {
-                              let type = record.get('type');
-                              return (
-                                  (type === 'evpn' && !me.excludeEvpn) ||
-                                  (type === 'simple' && record.get('dedicated-vrf'))
-                              );
-                          },
-                      ]
-                    : [],
+                filters: [
+                    (record) => !me.excludeZone || record.get('zone') !== me.excludeZone,
+                    function (record) {
+                        let type = record.get('type');
+                        return (
+                            !me.vrfOnly ||
+                            (type === 'evpn' && !me.excludeEvpn) ||
+                            (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,
@@ -62,6 +94,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 217ee284c078..9f75f9096d5f 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





  parent reply	other threads:[~2026-11-16 16:15 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 16:11 [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/32] SDN VRF support Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-common v3 01/32] interfaces: preserve VRF membership across address family changes Gabriel Goller
2026-11-18 14:13   ` Stefan Hanreich
2026-11-18 15:41     ` Gabriel Goller
2026-11-16 16:11 ` [PATCH proxmox-ve-rs v3 02/32] frr: add VRF-aware OSPF rendering Gabriel Goller
2026-11-18 14:41   ` Stefan Hanreich
2026-11-18 16:21     ` Gabriel Goller
2026-11-16 16:11 ` [PATCH proxmox-ve-rs v3 03/32] sdn: add zone references to OSPF and BGP fabrics Gabriel Goller
2026-11-18 14:10   ` Stefan Hanreich
2026-11-18 16:55     ` Gabriel Goller
2026-11-16 16:11 ` [PATCH proxmox-ve-rs v3 04/32] sdn: generate fabric routing configuration in zone VRFs Gabriel Goller
2026-11-18 14:53   ` Stefan Hanreich
2026-11-18 17:26     ` Gabriel Goller
2026-11-16 16:11 ` [PATCH proxmox-ve-rs v3 05/32] sdn: fix VRF route-map scoping and zone ID validation Gabriel Goller
2026-11-16 16:11 ` [PATCH proxmox-ve-rs v3 06/32] tests: fabrics: add test for fabrics in VRFs Gabriel Goller
2026-11-18 15:01   ` Stefan Hanreich
2026-11-18 17:33     ` Gabriel Goller
2026-11-16 16:11 ` [PATCH proxmox-ve-rs v3 07/32] sdn: allow static routes in simple zone VRFs Gabriel Goller
2026-11-18 15:29   ` Stefan Hanreich
2026-11-18 18:10     ` Gabriel Goller
2026-11-16 16:11 ` [PATCH proxmox-ve-rs v3 08/32] sdn: support static routes in EVPN " Gabriel Goller
2026-11-18 15:32   ` Stefan Hanreich
2026-11-19 13:12     ` Gabriel Goller
2026-11-16 16:11 ` [PATCH proxmox-perl-rs v3 09/32] pve-rs: fabrics: assign network interfaces to configured VRFs Gabriel Goller
2026-11-16 16:11 ` [PATCH proxmox-perl-rs v3 10/32] pve-rs: fabrics: make per-fabric status queries VRF-aware Gabriel Goller
2026-11-18 15:42   ` Stefan Hanreich
2026-11-19 13:30     ` Gabriel Goller
2026-11-16 16:11 ` [PATCH proxmox-perl-rs v3 11/32] pve-rs: fabrics: include VRF routes in aggregate status Gabriel Goller
2026-11-16 16:11 ` [PATCH proxmox-perl-rs v3 12/32] pve-rs: fabrics: expose host interface membership Gabriel Goller
2026-11-16 16:11 ` [PATCH proxmox-perl-rs v3 13/32] sdn: expose static routes for simple zone uplinks Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-network v3 14/32] sdn: evpn: add unreachable IPv6 default route to zone VRFs Gabriel Goller
2026-11-18 16:08   ` Stefan Hanreich
2026-11-18 16:39     ` Stefan Hanreich
2026-11-19 13:38       ` Gabriel Goller
2026-11-19 15:51         ` Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-network v3 15/32] sdn: add optional VRFs for simple zones Gabriel Goller
2026-11-18 16:18   ` Stefan Hanreich
2026-11-19 13:44     ` Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-network v3 16/32] sdn: allow fabrics to use simple zone VRFs Gabriel Goller
2026-11-18 16:27   ` Stefan Hanreich
2026-11-19 14:14     ` Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-network v3 17/32] sdn: require underlay fabrics to use the default VRF Gabriel Goller
2026-11-18 16:30   ` Stefan Hanreich
2026-11-19 14:33     ` Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-network v3 18/32] sdn: always generate EVPN zone VRFs Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-network v3 19/32] api: sdn: allow EVPN zones as fabric VRFs Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-network v3 20/32] api: sdn: disallow BGP fabrics in EVPN zone VRFs Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-network v3 21/32] sdn: simple: support static routes in zone routing tables Gabriel Goller
2026-11-18 16:49   ` Stefan Hanreich
2026-11-19 14:53     ` Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-network v3 22/32] sdn: evpn: allow static routes Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-network v3 23/32] sdn: zones: SNAT via dedicated uplinks in zone VRFs Gabriel Goller
2026-11-18 18:07   ` Stefan Hanreich
2026-11-16 16:11 ` [PATCH pve-network v3 24/32] sdn: dhcp: only configure DHCP for zones on the local node Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-network v3 25/32] sdn: dhcp: run dnsmasq in the zone VRF Gabriel Goller
2026-11-16 16:11 ` [PATCH proxmox-widget-toolkit v3 26/32] ui: network: allow selecting a VRF for host interfaces Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-manager v3 27/32] ui: sdn: add VRF zone selection for fabrics Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-manager v3 28/32] ui: sdn: expose EVPN zones as fabric VRFs Gabriel Goller
2026-11-16 16:11 ` Gabriel Goller [this message]
2026-11-16 16:11 ` [PATCH pve-manager v3 30/32] ui: sdn: allow static routes for Simple zone VRFs Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-manager v3 31/32] ui: sdn: allow static routes in EVPN zones Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-manager v3 32/32] network: generate SDN DHCP config after ifreload Gabriel Goller
2026-11-18 18:27 ` [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/32] SDN VRF support Stefan Hanreich
2026-11-19 15:33   ` Gabriel Goller
2026-11-19 20:10 ` Gabriel Goller

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=20261116161154.343743-30-g.goller@proxmox.com \
    --to=g.goller@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