From: Gabriel Goller <g.goller@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH pve-network v3 14/28] sdn: add optional VRFs for simple zones
Date: Thu, 19 Nov 2026 20:41:00 +0100 [thread overview]
Message-ID: <20261119194116.575520-15-g.goller@proxmox.com> (raw)
In-Reply-To: <20261119194116.575520-1-g.goller@proxmox.com>
Allow simple zones to isolate routing with dedicated-vrf. It is
disabled by default to preserve existing behavior.
Create the VRF even when the zone has no VNets, so fabrics can use it
without requiring a VNet.
Add unreachable IPv4 and IPv6 default routes with the highest metric
to the VRF, as EVPN does on non-exit nodes. Otherwise lookups that find
no route in the VRF table fall through to the main table, e.g. if no
default route is configured or before FRR has installed it.
Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
src/PVE/API2/Network/SDN/Zones.pm | 6 ++++
src/PVE/Network/SDN/Zones.pm | 17 ++++++++--
src/PVE/Network/SDN/Zones/EvpnPlugin.pm | 5 +--
src/PVE/Network/SDN/Zones/Plugin.pm | 19 +++++++++++
src/PVE/Network/SDN/Zones/SimplePlugin.pm | 32 +++++++++++++++--
.../hetzner-vrf/expected_sdn_interfaces | 27 +++++++++++++++
src/test/zones/simple/hetzner-vrf/interfaces | 6 ++++
src/test/zones/simple/hetzner-vrf/sdn_config | 34 +++++++++++++++++++
.../simple/vrf-empty/expected_sdn_interfaces | 7 ++++
src/test/zones/simple/vrf-empty/interfaces | 2 ++
src/test/zones/simple/vrf-empty/sdn_config | 12 +++++++
.../zones/simple/vrf/expected_sdn_interfaces | 14 ++++++++
src/test/zones/simple/vrf/interfaces | 2 ++
src/test/zones/simple/vrf/sdn_config | 17 ++++++++++
14 files changed, 193 insertions(+), 7 deletions(-)
create mode 100644 src/test/zones/simple/hetzner-vrf/expected_sdn_interfaces
create mode 100644 src/test/zones/simple/hetzner-vrf/interfaces
create mode 100644 src/test/zones/simple/hetzner-vrf/sdn_config
create mode 100644 src/test/zones/simple/vrf-empty/expected_sdn_interfaces
create mode 100644 src/test/zones/simple/vrf-empty/interfaces
create mode 100644 src/test/zones/simple/vrf-empty/sdn_config
create mode 100644 src/test/zones/simple/vrf/expected_sdn_interfaces
create mode 100644 src/test/zones/simple/vrf/interfaces
create mode 100644 src/test/zones/simple/vrf/sdn_config
diff --git a/src/PVE/API2/Network/SDN/Zones.pm b/src/PVE/API2/Network/SDN/Zones.pm
index 74b10f032bf4..38d950fda076 100644
--- a/src/PVE/API2/Network/SDN/Zones.pm
+++ b/src/PVE/API2/Network/SDN/Zones.pm
@@ -61,6 +61,12 @@ my $ZONE_PROPERTIES = {
optional => 1,
description => 'Name of DHCP server backend for this zone.',
},
+ 'dedicated-vrf' => {
+ type => 'boolean',
+ default => 0,
+ optional => 1,
+ description => 'Create a dedicated VRF for a simple zone.',
+ },
'rt-import' => {
type => 'string',
optional => 1,
diff --git a/src/PVE/Network/SDN/Zones.pm b/src/PVE/Network/SDN/Zones.pm
index c189652a79eb..1d3ad22c1cd5 100644
--- a/src/PVE/Network/SDN/Zones.pm
+++ b/src/PVE/Network/SDN/Zones.pm
@@ -124,6 +124,9 @@ sub generate_etc_network_config {
my $controller_cfg = $cfg->{controllers};
return if !$vnet_cfg && !$zone_cfg;
+ my $vnet_ids = $vnet_cfg ? ($vnet_cfg->{ids} // {}) : {};
+ my $zone_ids = $zone_cfg ? ($zone_cfg->{ids} // {}) : {};
+
my $interfaces_config = PVE::INotify::read_file('interfaces');
my $bridge_ports = PVE::IPRoute2::get_bridge_port_mapping();
@@ -131,8 +134,16 @@ sub generate_etc_network_config {
my $config = {};
my $nodename = PVE::INotify::nodename();
- for my $id (sort keys %{ $vnet_cfg->{ids} }) {
- my $vnet = $vnet_cfg->{ids}->{$id};
+ for my $zone_id (sort keys %$zone_ids) {
+ my $plugin_config = $zone_ids->{$zone_id};
+ next if defined($plugin_config->{nodes}) && !$plugin_config->{nodes}->{$nodename};
+
+ my $plugin = PVE::Network::SDN::Zones::Plugin->lookup($plugin_config->{type});
+ $plugin->generate_zone_config($plugin_config, $zone_id, $config);
+ }
+
+ for my $id (sort keys %$vnet_ids) {
+ my $vnet = $vnet_ids->{$id};
my $zone = $vnet->{zone};
if (!$zone) {
@@ -140,7 +151,7 @@ sub generate_etc_network_config {
next;
}
- my $plugin_config = $zone_cfg->{ids}->{$zone};
+ my $plugin_config = $zone_ids->{$zone};
if (!defined($plugin_config)) {
warn "can't generate vnet '$id': zone $zone don't exist\n";
diff --git a/src/PVE/Network/SDN/Zones/EvpnPlugin.pm b/src/PVE/Network/SDN/Zones/EvpnPlugin.pm
index 0fe07eae0766..534ac9ffa5b1 100644
--- a/src/PVE/Network/SDN/Zones/EvpnPlugin.pm
+++ b/src/PVE/Network/SDN/Zones/EvpnPlugin.pm
@@ -319,8 +319,9 @@ sub generate_sdn_config {
push @iface_config, "vrf-table auto";
my $route_action = $is_evpn_gateway ? 'del' : 'add';
push @iface_config,
- "post-up ip route $route_action vrf $vrf_iface unreachable default metric 4278198272",
- "post-up ip -6 route $route_action vrf $vrf_iface unreachable default metric 4278198272 || true";
+ PVE::Network::SDN::Zones::Plugin::vrf_unreachable_default_cmds(
+ $vrf_iface, $route_action,
+ );
push(@{ $config->{$vrf_iface} }, @iface_config) if !$config->{$vrf_iface};
diff --git a/src/PVE/Network/SDN/Zones/Plugin.pm b/src/PVE/Network/SDN/Zones/Plugin.pm
index f3844ffda3b5..2de538607710 100644
--- a/src/PVE/Network/SDN/Zones/Plugin.pm
+++ b/src/PVE/Network/SDN/Zones/Plugin.pm
@@ -99,6 +99,25 @@ sub encode_value {
return $value;
}
+# Unreachable IPv4 and IPv6 default routes with the highest metric, so that
+# lookups without a matching route in the VRF table do not fall through to the
+# main table. $action is 'add' or 'del'.
+sub vrf_unreachable_default_cmds {
+ my ($vrf_iface, $action) = @_;
+
+ # IPv6 can be disabled on the kernel command line.
+ return (
+ "post-up ip route $action vrf $vrf_iface unreachable default metric 4278198272",
+ "post-up ip -6 route $action vrf $vrf_iface unreachable default metric 4278198272 || true",
+ );
+}
+
+sub generate_zone_config {
+ my ($class, $plugin_config, $zone_id, $config) = @_;
+
+ return $config;
+}
+
sub generate_sdn_config {
my (
$class,
diff --git a/src/PVE/Network/SDN/Zones/SimplePlugin.pm b/src/PVE/Network/SDN/Zones/SimplePlugin.pm
index 347eee9a46ba..bc591839819d 100644
--- a/src/PVE/Network/SDN/Zones/SimplePlugin.pm
+++ b/src/PVE/Network/SDN/Zones/SimplePlugin.pm
@@ -35,6 +35,11 @@ sub properties {
type => 'string',
enum => PVE::Network::SDN::Dhcp->plugin_types(),
},
+ 'dedicated-vrf' => {
+ description => 'Create a dedicated VRF for the zone.',
+ type => 'boolean',
+ default => 0,
+ },
};
}
@@ -47,15 +52,34 @@ sub options {
dnszone => { optional => 1 },
ipam => { optional => 1 },
dhcp => { optional => 1 },
+ 'dedicated-vrf' => { optional => 1 },
};
}
+sub generate_zone_config {
+ my ($class, $plugin_config, $zone_id, $config) = @_;
+
+ if ($plugin_config->{'dedicated-vrf'}) {
+ my $vrf_iface = "vrf_$zone_id";
+ if (!defined($config->{$vrf_iface})) {
+ $config->{$vrf_iface} = [
+ 'vrf-table auto',
+ PVE::Network::SDN::Zones::Plugin::vrf_unreachable_default_cmds(
+ $vrf_iface, 'add',
+ ),
+ ];
+ }
+ }
+
+ return $config;
+}
+
# Plugin implementation
sub generate_sdn_config {
my (
$class,
$plugin_config,
- $zoneid,
+ $zone_id,
$vnetid,
$vnet,
$controller,
@@ -110,7 +134,10 @@ sub generate_sdn_config {
}
#add route for /32 pointtopoint
- push @iface_config, "up ip route add $cidr dev $vnetid" if $mask == 32 && $ipversion == 4;
+ if ($mask == 32 && $ipversion == 4) {
+ my $vrf = $plugin_config->{'dedicated-vrf'} ? " vrf vrf_$zone_id" : '';
+ push @iface_config, "up ip route add $cidr dev $vnetid$vrf";
+ }
if ($subnet->{snat}) {
#find outgoing interface
my ($outip, $outiface);
@@ -150,6 +177,7 @@ sub generate_sdn_config {
push @iface_config, "alias $alias" if $alias;
push @iface_config, "ip-forward on" if $enable_forward_v4;
push @iface_config, "ip6-forward on" if $enable_forward_v6;
+ push @iface_config, "vrf vrf_$zone_id" if $plugin_config->{'dedicated-vrf'};
push @{ $config->{$vnetid} }, @iface_config;
diff --git a/src/test/zones/simple/hetzner-vrf/expected_sdn_interfaces b/src/test/zones/simple/hetzner-vrf/expected_sdn_interfaces
new file mode 100644
index 000000000000..f0a306fa3694
--- /dev/null
+++ b/src/test/zones/simple/hetzner-vrf/expected_sdn_interfaces
@@ -0,0 +1,27 @@
+#version:1
+
+auto myvnet
+iface myvnet
+ address 144.76.100.65/29
+ bridge_ports none
+ bridge_stp off
+ bridge_fd 0
+ ip-forward on
+ vrf vrf_myzone
+
+auto myvnet2
+iface myvnet2
+ address 144.76.0.1/32
+ up ip route add 144.76.200.65/32 dev myvnet2 vrf vrf_myzone
+ up ip route add 144.76.200.66/32 dev myvnet2 vrf vrf_myzone
+ bridge_ports none
+ bridge_stp off
+ bridge_fd 0
+ ip-forward on
+ vrf vrf_myzone
+
+auto vrf_myzone
+iface vrf_myzone
+ vrf-table auto
+ post-up ip route add vrf vrf_myzone unreachable default metric 4278198272
+ post-up ip -6 route add vrf vrf_myzone unreachable default metric 4278198272 || true
diff --git a/src/test/zones/simple/hetzner-vrf/interfaces b/src/test/zones/simple/hetzner-vrf/interfaces
new file mode 100644
index 000000000000..53e894aaa4ef
--- /dev/null
+++ b/src/test/zones/simple/hetzner-vrf/interfaces
@@ -0,0 +1,6 @@
+auto eth0
+iface eth0 inet static
+ address 144.76.0.1
+ netmask 255.255.255.255
+ pointopoint 172.31.1.1
+ gateway 172.31.1.1
diff --git a/src/test/zones/simple/hetzner-vrf/sdn_config b/src/test/zones/simple/hetzner-vrf/sdn_config
new file mode 100644
index 000000000000..847c42da81a4
--- /dev/null
+++ b/src/test/zones/simple/hetzner-vrf/sdn_config
@@ -0,0 +1,34 @@
+{
+ version => 1,
+ vnets => {
+ ids => {
+ myvnet => { type => "vnet", zone => "myzone" },
+ myvnet2 => { type => "vnet", zone => "myzone" },
+ },
+ },
+ zones => {
+ ids => { myzone => { ipam => "pve", type => "simple", "dedicated-vrf" => 1 } },
+ },
+
+ subnets => {
+ ids => {
+ 'myzone-144.76.100.64-29' => {
+ 'type' => 'subnet',
+ 'vnet' => 'myvnet',
+ 'gateway' => '144.76.100.65',
+ },
+ 'myzone-144.76.200.65-32' => {
+ 'type' => 'subnet',
+ 'vnet' => 'myvnet2',
+ 'gateway' => '144.76.0.1',
+ },
+ 'myzone-144.76.200.66-32' => {
+ 'type' => 'subnet',
+ 'vnet' => 'myvnet2',
+ 'gateway' => '144.76.0.1',
+ },
+ }
+ }
+}
+
+
diff --git a/src/test/zones/simple/vrf-empty/expected_sdn_interfaces b/src/test/zones/simple/vrf-empty/expected_sdn_interfaces
new file mode 100644
index 000000000000..5daf4e9cb62a
--- /dev/null
+++ b/src/test/zones/simple/vrf-empty/expected_sdn_interfaces
@@ -0,0 +1,7 @@
+#version:1
+
+auto vrf_myzone
+iface vrf_myzone
+ vrf-table auto
+ post-up ip route add vrf vrf_myzone unreachable default metric 4278198272
+ post-up ip -6 route add vrf vrf_myzone unreachable default metric 4278198272 || true
diff --git a/src/test/zones/simple/vrf-empty/interfaces b/src/test/zones/simple/vrf-empty/interfaces
new file mode 100644
index 000000000000..f1bd92ed2b43
--- /dev/null
+++ b/src/test/zones/simple/vrf-empty/interfaces
@@ -0,0 +1,2 @@
+auto lo
+iface lo inet loopback
diff --git a/src/test/zones/simple/vrf-empty/sdn_config b/src/test/zones/simple/vrf-empty/sdn_config
new file mode 100644
index 000000000000..32fd5ea50432
--- /dev/null
+++ b/src/test/zones/simple/vrf-empty/sdn_config
@@ -0,0 +1,12 @@
+{
+ version => 1,
+ vnets => { ids => {} },
+ zones => {
+ ids => {
+ myzone => {
+ type => "simple",
+ "dedicated-vrf" => 1,
+ },
+ },
+ },
+}
diff --git a/src/test/zones/simple/vrf/expected_sdn_interfaces b/src/test/zones/simple/vrf/expected_sdn_interfaces
new file mode 100644
index 000000000000..776a12052e17
--- /dev/null
+++ b/src/test/zones/simple/vrf/expected_sdn_interfaces
@@ -0,0 +1,14 @@
+#version:1
+
+auto myvnet
+iface myvnet
+ bridge_ports none
+ bridge_stp off
+ bridge_fd 0
+ vrf vrf_myzone
+
+auto vrf_myzone
+iface vrf_myzone
+ vrf-table auto
+ post-up ip route add vrf vrf_myzone unreachable default metric 4278198272
+ post-up ip -6 route add vrf vrf_myzone unreachable default metric 4278198272 || true
diff --git a/src/test/zones/simple/vrf/interfaces b/src/test/zones/simple/vrf/interfaces
new file mode 100644
index 000000000000..f1bd92ed2b43
--- /dev/null
+++ b/src/test/zones/simple/vrf/interfaces
@@ -0,0 +1,2 @@
+auto lo
+iface lo inet loopback
diff --git a/src/test/zones/simple/vrf/sdn_config b/src/test/zones/simple/vrf/sdn_config
new file mode 100644
index 000000000000..c57074e1bf4a
--- /dev/null
+++ b/src/test/zones/simple/vrf/sdn_config
@@ -0,0 +1,17 @@
+{
+ version => 1,
+ vnets => {
+ ids => {
+ myvnet => { type => "vnet", zone => "myzone" },
+ },
+ },
+ zones => {
+ ids => {
+ myzone => {
+ ipam => "pve",
+ type => "simple",
+ "dedicated-vrf" => 1,
+ },
+ },
+ },
+}
--
2.47.3
next prev parent reply other threads:[~2026-11-19 19:44 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 19:40 [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/28] SDN VRF support Gabriel Goller
2026-11-19 19:40 ` [PATCH pve-common v3 01/28] interfaces: preserve VRF membership across address family changes Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-ve-rs v3 02/28] frr: add VRF-aware OSPF rendering Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-ve-rs v3 03/28] sdn: add zone references to OSPF and BGP fabrics Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-ve-rs v3 04/28] sdn: generate fabric routing configuration in zone VRFs Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-ve-rs v3 05/28] sdn: fix VRF route-map scoping and zone ID validation Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-ve-rs v3 06/28] tests: fabrics: add tests for fabrics in VRFs Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-ve-rs v3 07/28] sdn: allow static routes in simple zone VRFs Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-perl-rs v3 08/28] pve-rs: fabrics: assign network interfaces to configured VRFs Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-perl-rs v3 09/28] pve-rs: fabrics: make per-fabric status queries VRF-aware Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-perl-rs v3 10/28] pve-rs: fabrics: include VRF routes in aggregate status Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-perl-rs v3 11/28] pve-rs: fabrics: expose host interface membership Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-perl-rs v3 12/28] sdn: expose static routes for simple zone uplinks Gabriel Goller
2026-11-19 19:40 ` [PATCH pve-network v3 13/28] sdn: evpn: add unreachable IPv6 default route to zone VRFs Gabriel Goller
2026-11-19 19:41 ` Gabriel Goller [this message]
2026-11-19 19:41 ` [PATCH pve-network v3 15/28] sdn: allow fabrics to use simple " Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-network v3 16/28] sdn: require underlay fabrics to use the default VRF Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-network v3 17/28] sdn: move full range CIDR formats into a separate module Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-network v3 18/28] sdn: simple: support static routes in zone routing tables Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-network v3 19/28] sdn: dhcp: only configure DHCP for zones on the local node Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-network v3 20/28] sdn: dhcp: run dnsmasq in the zone VRF Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-network v3 21/28] sdn: dhcp: fix DNS server option for IPv4 subnets without gateway Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-network v3 22/28] sdn: evpn: no exit node null routes for simple zone VRFs Gabriel Goller
2026-11-19 19:41 ` [PATCH proxmox-widget-toolkit v3 23/28] ui: network: allow selecting a VRF for host interfaces Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-manager v3 24/28] ui: sdn: add VRF zone selection for fabrics Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-manager v3 25/28] network: allow setting the VRF of host interfaces Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-manager v3 26/28] ui: sdn: allow static routes for Simple zone VRFs Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-manager v3 27/28] network: generate SDN DHCP config after ifreload Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-manager v3 28/28] ui: sdn: subnet: allow setting the DHCP DNS server 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=20261119194116.575520-15-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.