public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/28] SDN VRF support
@ 2026-11-19 19:40 Gabriel Goller
  2026-11-19 19:40 ` [PATCH pve-common v3 01/28] interfaces: preserve VRF membership across address family changes Gabriel Goller
                   ` (27 more replies)
  0 siblings, 28 replies; 29+ messages in thread
From: Gabriel Goller @ 2026-11-19 19:40 UTC (permalink / raw)
  To: pve-devel

This series adds VRF support to SDN zones and fabrics.

A simple zone can now use either the default VRF or a dedicated VRF. The
simple zone dialog has a checkbox for this and uses the default VRF by
default. If the checkbox is disabled, the zone creates a dedicated VRF named
`vrf_<zone-name>`. EVPN zones always create a dedicated VRF. BGP and OSPF
fabrics can select a zone and run inside its VRF.

This is the second iteration. The first iteration added VRFs as a separate
SDN object with a distinct GUI subdirectory. This was scrapped because VRFs
are an implementation detail and should not be exposed on their own in the
GUI. Zones already provide a logical L3 building block and should map to VRFs
instead.

Route leaking between VRFs partly depends on the following FRR change, so it
will come a bit later: https://github.com/FRRouting/frr/pull/22426

Static routes on simple zones always require Sys.Modify on '/nodes/<node>'
for all nodes of the zone, in addition to SDN.Allocate on the zone. This
applies when creating or deleting a zone with routes, changing its routes,
and changing the nodes or the dedicated-vrf setting of a zone with routes.
Zones without nodes require Sys.Modify on all cluster nodes. Routes can
change the routing of the host, e.g. via a host interface or the default
routing table, so SDN.Allocate alone is not enough.

Host interfaces can be added to a zone VRF in the host network config, which
is local to each node. Disabling dedicated-vrf, removing a node from the zone,
or deleting the zone removes the VRF on that node, but host interfaces may
still reference it. ifreload then fails to enslave the interface and to add
its gateway, and reports this in the apply log. This is not checked on
purpose: the zone API cannot see the network config of other nodes, and the
failure leaves the main routing table untouched. Users have to remove the
VRF from host interfaces before removing the VRF itself.

As always, thanks to Stefan Hanreich for his help.

Changelog:
v3: (thanks @Stefan)
 * removed SNAT (coming in a subsequent series)
 * removed static routes for EVPN zones (coming in a subsequent series)
 * removed the nexthop-vrf property on the routes (coming in a subsequent series)
 * added dhcp-dns-server option in ui
 * made ipv6 unreachable route add fallible
 * some api permission check updates
 * disable vrfs for ovs interfaces and fabric interfaces
 

v2: (thanks @Stefan)
 * allow interfaces to be added to vrfs
 * allow static routes to be configured on vrfs
 * fix ospf vrf statistics
 * fix dhcp
 * fix snat

RFC (v1):
 * rebase


pve-common:

Gabriel Goller (1):
  interfaces: preserve VRF membership across address family changes

 src/PVE/Network/Interfaces.pm | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)


proxmox-ve-rs:

Gabriel Goller (6):
  frr: add VRF-aware OSPF rendering
  sdn: add zone references to OSPF and BGP fabrics
  sdn: generate fabric routing configuration in zone VRFs
  sdn: fix VRF route-map scoping and zone ID validation
  tests: fabrics: add tests for fabrics in VRFs
  sdn: allow static routes in simple zone VRFs

 proxmox-frr-templates/templates/bgpd.jinja    |   7 +-
 .../templates/frr.conf.jinja                  |   3 +-
 .../templates/interface.jinja                 |   6 +-
 .../templates/ip_routes.jinja                 |  13 +-
 proxmox-frr-templates/templates/ospfd.jinja   |  14 +-
 .../templates/protocol_routemaps.jinja        |  13 +
 proxmox-frr/src/ser/mod.rs                    |  27 +-
 proxmox-frr/src/ser/ospf.rs                   |   5 +-
 proxmox-ve-config/src/sdn/fabric/frr.rs       | 123 +++++---
 proxmox-ve-config/src/sdn/fabric/mod.rs       |  24 +-
 .../src/sdn/fabric/section_config/fabric.rs   |  12 +-
 .../sdn/fabric/section_config/protocol/bgp.rs |  10 +
 .../fabric/section_config/protocol/ospf.rs    |  10 +
 proxmox-ve-config/src/sdn/mod.rs              |  12 +
 proxmox-ve-config/src/sdn/static_route.rs     | 181 ++++++++++++
 .../tests/fabric/cfg/vrf/fabrics.cfg          |  43 +++
 .../tests/fabric/cfg/vrf/route-maps.cfg       |  15 +
 .../tests/fabric/cfg/vrf_default/fabrics.cfg  |  37 +++
 .../tests/fabric/cfg/vrf_ipv6/fabrics.cfg     |  25 ++
 .../tests/fabric/cfg/vrf_ipv6/route-maps.cfg  |   7 +
 .../fabric/cfg/vrf_redistribute/fabrics.cfg   |  23 ++
 .../cfg/vrf_redistribute/route-maps.cfg       |   7 +
 .../fabric/cfg/vrf_route_filter/fabrics.cfg   |  23 ++
 .../cfg/vrf_route_filter/prefix-lists.cfg     |   8 +
 proxmox-ve-config/tests/fabric/helper.rs      |  40 +++
 proxmox-ve-config/tests/fabric/main.rs        | 275 +++++++++++++++++-
 .../snapshots/fabric__vrf_default_pve.snap    | 113 +++++++
 .../snapshots/fabric__vrf_ipv6_pve.snap       | 102 +++++++
 .../fabric/snapshots/fabric__vrf_pve.snap     | 134 +++++++++
 .../fabric__vrf_redistribute_pve.snap         |  74 +++++
 .../fabric__vrf_route_filter_pve.snap         |  85 ++++++
 .../tests/static_routes/cfg/fabrics.cfg       |  19 ++
 .../tests/static_routes/cfg/zones.json        |  20 ++
 proxmox-ve-config/tests/static_routes/main.rs | 188 ++++++++++++
 ...c_routes__preserve_legacy_evpn_routes.snap |  12 +
 ...tatic_routes__simple_zone_routes_pve1.snap |  20 ++
 ...tatic_routes__simple_zone_routes_pve2.snap |  10 +
 ...outes__vrf_fabrics_with_static_routes.snap |  70 +++++
 38 files changed, 1739 insertions(+), 71 deletions(-)
 create mode 100644 proxmox-ve-config/src/sdn/static_route.rs
 create mode 100644 proxmox-ve-config/tests/fabric/cfg/vrf/fabrics.cfg
 create mode 100644 proxmox-ve-config/tests/fabric/cfg/vrf/route-maps.cfg
 create mode 100644 proxmox-ve-config/tests/fabric/cfg/vrf_default/fabrics.cfg
 create mode 100644 proxmox-ve-config/tests/fabric/cfg/vrf_ipv6/fabrics.cfg
 create mode 100644 proxmox-ve-config/tests/fabric/cfg/vrf_ipv6/route-maps.cfg
 create mode 100644 proxmox-ve-config/tests/fabric/cfg/vrf_redistribute/fabrics.cfg
 create mode 100644 proxmox-ve-config/tests/fabric/cfg/vrf_redistribute/route-maps.cfg
 create mode 100644 proxmox-ve-config/tests/fabric/cfg/vrf_route_filter/fabrics.cfg
 create mode 100644 proxmox-ve-config/tests/fabric/cfg/vrf_route_filter/prefix-lists.cfg
 create mode 100644 proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_default_pve.snap
 create mode 100644 proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_ipv6_pve.snap
 create mode 100644 proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_pve.snap
 create mode 100644 proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_redistribute_pve.snap
 create mode 100644 proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_route_filter_pve.snap
 create mode 100644 proxmox-ve-config/tests/static_routes/cfg/fabrics.cfg
 create mode 100644 proxmox-ve-config/tests/static_routes/cfg/zones.json
 create mode 100644 proxmox-ve-config/tests/static_routes/main.rs
 create mode 100644 proxmox-ve-config/tests/static_routes/snapshots/static_routes__preserve_legacy_evpn_routes.snap
 create mode 100644 proxmox-ve-config/tests/static_routes/snapshots/static_routes__simple_zone_routes_pve1.snap
 create mode 100644 proxmox-ve-config/tests/static_routes/snapshots/static_routes__simple_zone_routes_pve2.snap
 create mode 100644 proxmox-ve-config/tests/static_routes/snapshots/static_routes__vrf_fabrics_with_static_routes.snap


proxmox-perl-rs:

Gabriel Goller (5):
  pve-rs: fabrics: assign network interfaces to configured VRFs
  pve-rs: fabrics: make per-fabric status queries VRF-aware
  pve-rs: fabrics: include VRF routes in aggregate status
  pve-rs: fabrics: expose host interface membership
  sdn: expose static routes for simple zone uplinks

 pve-rs/src/bindings/sdn/fabrics.rs | 407 +++++++++++++++++++----------
 pve-rs/src/bindings/sdn/mod.rs     |  18 +-
 pve-rs/src/sdn/status.rs           | 149 +++++++++--
 3 files changed, 402 insertions(+), 172 deletions(-)


pve-network:

Gabriel Goller (10):
  sdn: evpn: add unreachable IPv6 default route to zone VRFs
  sdn: add optional VRFs for simple zones
  sdn: allow fabrics to use simple zone VRFs
  sdn: require underlay fabrics to use the default VRF
  sdn: move full range CIDR formats into a separate module
  sdn: simple: support static routes in zone routing tables
  sdn: dhcp: only configure DHCP for zones on the local node
  sdn: dhcp: run dnsmasq in the zone VRF
  sdn: dhcp: fix DNS server option for IPv4 subnets without gateway
  sdn: evpn: no exit node null routes for simple zone VRFs

 src/PVE/API2/Network/SDN/Fabrics/Fabric.pm    |  56 +++-
 .../API2/Network/SDN/Fabrics/FabricNode.pm    |  20 ++
 src/PVE/API2/Network/SDN/Zones.pm             |  58 ++++
 src/PVE/Network/SDN.pm                        |  22 +-
 src/PVE/Network/SDN/Controllers/BgpPlugin.pm  |   2 +-
 src/PVE/Network/SDN/Controllers/EvpnPlugin.pm |  12 +-
 src/PVE/Network/SDN/Dhcp.pm                   |  14 +-
 src/PVE/Network/SDN/Dhcp/Dnsmasq.pm           |  70 +++-
 src/PVE/Network/SDN/Fabrics.pm                |  49 +++
 src/PVE/Network/SDN/Formats.pm                |  51 +++
 src/PVE/Network/SDN/Makefile                  |   1 +
 src/PVE/Network/SDN/PrefixLists.pm            |  40 +--
 src/PVE/Network/SDN/SubnetPlugin.pm           |   8 +-
 src/PVE/Network/SDN/Zones.pm                  |  59 +++-
 src/PVE/Network/SDN/Zones/EvpnPlugin.pm       |  12 +-
 src/PVE/Network/SDN/Zones/Plugin.pm           |  72 ++++
 src/PVE/Network/SDN/Zones/SimplePlugin.pm     |  33 +-
 src/PVE/Network/SDN/Zones/VxlanPlugin.pm      |   5 +
 src/test/Makefile                             |   8 +-
 src/test/run_test_fabric_host_vrf.pl          |  93 ++++++
 src/test/run_test_static_routes.pl            | 313 ++++++++++++++++++
 src/test/run_test_vnets_blackbox.pl           |  42 +++
 .../advertise_subnets/expected_sdn_interfaces |   1 +
 .../evpn/auto_mode/expected_sdn_interfaces    |   1 +
 .../evpn/bgp_ebgp/expected_sdn_interfaces     |   1 +
 .../bgp_ebgp_multihop/expected_sdn_interfaces |   1 +
 .../expected_sdn_interfaces                   |   1 +
 .../expected_sdn_interfaces                   |   1 +
 .../evpn/bgp_fabric/expected_sdn_interfaces   |   1 +
 .../evpn/bgp_loopback/expected_sdn_interfaces |   1 +
 .../expected_sdn_interfaces                   |   1 +
 .../combined_bgp_isis/expected_sdn_interfaces |   1 +
 .../expected_sdn_interfaces                   |   1 +
 .../zones/evpn/ebgp/expected_sdn_interfaces   |   1 +
 .../expected_sdn_interfaces                   |   1 +
 .../expected_sdn_interfaces                   |   1 +
 .../expected_sdn_interfaces                   |   2 +
 .../ebgp_loopback/expected_sdn_interfaces     |   1 +
 .../expected_sdn_interfaces                   |   1 +
 .../expected_sdn_interfaces                   |   2 +
 .../evpn/exitnode/expected_sdn_interfaces     |   1 +
 .../expected_sdn_interfaces                   |   1 +
 .../expected_sdn_interfaces                   |   1 +
 .../exitnode_primary/expected_sdn_interfaces  |   1 +
 .../exitnode_snat/expected_sdn_interfaces     |   1 +
 .../exitnodenullroute/expected_sdn_interfaces |   2 +
 .../expected_controller_config                |  78 +++++
 .../expected_sdn_interfaces                   |  67 ++++
 .../exitnodenullroute_simple_vrf/interfaces   |   7 +
 .../exitnodenullroute_simple_vrf/sdn_config   |  47 +++
 .../frr_local_merge/expected_sdn_interfaces   |   1 +
 .../expected_sdn_interfaces                   |   1 +
 .../zones/evpn/ipv4/expected_sdn_interfaces   |   1 +
 .../evpn/ipv4ipv6/expected_sdn_interfaces     |   1 +
 .../ipv4ipv6nogateway/expected_sdn_interfaces |   1 +
 .../zones/evpn/ipv6/expected_sdn_interfaces   |   1 +
 .../evpn/ipv6underlay/expected_sdn_interfaces |   1 +
 .../zones/evpn/isis/expected_sdn_interfaces   |   1 +
 .../isis_loopback/expected_sdn_interfaces     |   1 +
 .../multipath_relax/expected_sdn_interfaces   |   1 +
 .../multiplezones/expected_sdn_interfaces     |   2 +
 .../openfabric_fabric/expected_sdn_interfaces |   1 +
 .../expected_sdn_interfaces                   |   1 +
 .../expected_sdn_interfaces                   |   1 +
 .../evpn/ospf_fabric/expected_sdn_interfaces  |   1 +
 .../evpn/routemap/expected_sdn_interfaces     |   1 +
 .../expected_sdn_interfaces                   |   1 +
 .../expected_sdn_interfaces                   |   1 +
 .../evpn/rt_import/expected_sdn_interfaces    |   1 +
 .../evpn/vxlanport/expected_sdn_interfaces    |   1 +
 .../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 +
 79 files changed, 1330 insertions(+), 78 deletions(-)
 create mode 100644 src/PVE/Network/SDN/Formats.pm
 create mode 100755 src/test/run_test_fabric_host_vrf.pl
 create mode 100644 src/test/run_test_static_routes.pl
 create mode 100644 src/test/zones/evpn/exitnodenullroute_simple_vrf/expected_controller_config
 create mode 100644 src/test/zones/evpn/exitnodenullroute_simple_vrf/expected_sdn_interfaces
 create mode 100644 src/test/zones/evpn/exitnodenullroute_simple_vrf/interfaces
 create mode 100644 src/test/zones/evpn/exitnodenullroute_simple_vrf/sdn_config
 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


proxmox-widget-toolkit:

Gabriel Goller (1):
  ui: network: allow selecting a VRF for host interfaces

 src/node/NetworkEdit.js | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)


pve-manager:

Gabriel Goller (5):
  ui: sdn: add VRF zone selection for fabrics
  network: allow setting the VRF of host interfaces
  ui: sdn: allow static routes for Simple zone VRFs
  network: generate SDN DHCP config after ifreload
  ui: sdn: subnet: allow setting the DHCP DNS server

 PVE/API2/Network.pm                    |  60 +++++--
 bin/pve-sdn-commit                     |   5 +-
 www/manager6/Makefile                  |   1 +
 www/manager6/Toolkit.js                |   2 +-
 www/manager6/form/SDNZoneSelector.js   |  46 ++++-
 www/manager6/node/Config.js            |  12 ++
 www/manager6/sdn/StaticRoutes.js       | 222 +++++++++++++++++++++++++
 www/manager6/sdn/SubnetEdit.js         |  15 ++
 www/manager6/sdn/fabrics/FabricEdit.js |  15 ++
 www/manager6/sdn/zones/Base.js         |  22 ++-
 www/manager6/sdn/zones/SimpleEdit.js   |  21 +++
 11 files changed, 404 insertions(+), 17 deletions(-)
 create mode 100644 www/manager6/sdn/StaticRoutes.js


Summary over all repositories:
  133 files changed, 3907 insertions(+), 339 deletions(-)

-- 
Generated by murpp 0.11.0




^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH pve-common v3 01/28] interfaces: preserve VRF membership across address family changes
  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 ` Gabriel Goller
  2026-11-19 19:40 ` [PATCH proxmox-ve-rs v3 02/28] frr: add VRF-aware OSPF rendering Gabriel Goller
                   ` (26 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Gabriel Goller @ 2026-11-19 19:40 UTC (permalink / raw)
  To: pve-devel

Store VRF membership as an interface option, not an address family
option. Otherwise, switching from IPv4 to IPv6-only can drop the VRF
assignment when the IPv4 stanza is removed.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 src/PVE/Network/Interfaces.pm | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/PVE/Network/Interfaces.pm b/src/PVE/Network/Interfaces.pm
index 8aed1ab3c473..1737ec5c014b 100644
--- a/src/PVE/Network/Interfaces.pm
+++ b/src/PVE/Network/Interfaces.pm
@@ -134,7 +134,7 @@ my $check_mtu = sub($ifaces, $parent, $child) {
 #       gateway6 => IP,
 #       comments6 => [ "..." ],
 #
-#       <known options>, # like bridge_ports, ovs_*
+#       <known options>, # interface-wide (shared by inet/inet6): bridge_ports, ovs_*, vrf
 #
 #       # extra/unknown options stored by-family:
 #       options => { <inet options>... }
@@ -226,6 +226,7 @@ sub __read_etc_network_interfaces($fh, $ip_links = undef, $active_ifaces = undef
 
                     my $simple_options = {
                         'mtu' => 1,
+                        'vrf' => 1,
                         'ovs_type' => 1,
                         'ovs_options' => 1,
                         'ovs_bridge' => 1,
@@ -885,6 +886,7 @@ sub __write_etc_network_interfaces($config, $ifupdown2 = undef) {
                 my $n = $ifaces->{$p};
                 $n->{autostart} = 1;
                 die "OVS bond '$iface' - unable to find slave '$p'\n" if !$n;
+                die "OVS bond '$iface' - slave '$p' cannot have a VRF master\n" if $n->{vrf};
                 die
                     "OVS bond '$iface' - wrong interface type on slave '$p' ('$n->{type}' != 'eth')\n"
                     if $n->{type} ne 'eth';
@@ -893,6 +895,13 @@ sub __write_etc_network_interfaces($config, $ifupdown2 = undef) {
         }
     }
 
+    # OVS interfaces are not supported in VRFs
+    foreach my $iface (keys %$ifaces) {
+        my $d = $ifaces->{$iface};
+        die "iface '$iface' - VRF is not supported on OVS interfaces\n"
+            if $d->{vrf} && $d->{type} =~ m/^OVS/;
+    }
+
     # check bond
     foreach my $iface (keys %$ifaces) {
         my $d = $ifaces->{$iface};
@@ -904,6 +913,7 @@ sub __write_etc_network_interfaces($config, $ifupdown2 = undef) {
             $n->{autostart} = 1;
 
             die "bond '$iface' - unable to find slave '$p'\n" if !$n;
+            die "bond '$iface' - slave '$p' cannot have a VRF master\n" if $n->{vrf};
             die
                 "bond '$iface' - wrong interface type on slave '$p' ('$n->{type}' != 'eth or bond')\n"
                 if ($n->{type} ne 'eth' && $n->{type} ne 'bond');
@@ -1027,6 +1037,7 @@ sub __write_etc_network_interfaces($config, $ifupdown2 = undef) {
                 }
                 my $n = $ifaces_copy->{$p};
                 die "bridge '$iface' - unable to find bridge port '$p'\n" if !$n;
+                die "bridge '$iface' - port '$p' cannot have a VRF master\n" if $n->{vrf};
                 die "iface $p - ip address can't be set on interface if bridged in $iface\n"
                     if ($n->{method} && $n->{method} eq 'static' && $n->{address} ne '0.0.0.0')
                     || ($n->{method6} && $n->{method6} eq 'static' && $n->{address6} ne '::');
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH proxmox-ve-rs v3 02/28] frr: add VRF-aware OSPF rendering
  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 ` 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
                   ` (25 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Gabriel Goller @ 2026-11-19 19:40 UTC (permalink / raw)
  To: pve-devel

Add an optional VRF name and render it in the FRR interface declaration.
Keep OSPF router configuration for custom VRFs separately from the
router in the default routing table (like we do with BGP).

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 proxmox-frr-templates/templates/interface.jinja |  6 +++++-
 proxmox-frr-templates/templates/ospfd.jinja     | 14 +++++++++-----
 proxmox-frr/src/ser/mod.rs                      |  2 +-
 proxmox-frr/src/ser/ospf.rs                     |  5 ++++-
 proxmox-ve-config/src/sdn/fabric/frr.rs         |  9 +++++++--
 5 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/proxmox-frr-templates/templates/interface.jinja b/proxmox-frr-templates/templates/interface.jinja
index 4c5014844fc8..512aaa2f6f86 100644
--- a/proxmox-frr-templates/templates/interface.jinja
+++ b/proxmox-frr-templates/templates/interface.jinja
@@ -1,6 +1,10 @@
-{% macro interface(name, addresses_v4, addresses_v6) %}
+{% macro interface(name, addresses_v4, addresses_v6, vrf=none) %}
 !
+{% if vrf %}
+interface {{ name }} vrf {{ vrf }}
+{% else %}
 interface {{ name }}
+{% endif %}
 {% for address in addresses_v6 %}
  ipv6 address {{address}}
 {% endfor %}
diff --git a/proxmox-frr-templates/templates/ospfd.jinja b/proxmox-frr-templates/templates/ospfd.jinja
index 427ed7f9ddb4..30dea96592c0 100644
--- a/proxmox-frr-templates/templates/ospfd.jinja
+++ b/proxmox-frr-templates/templates/ospfd.jinja
@@ -1,16 +1,20 @@
 {% from "interface.jinja" import interface %}
-{% if ospf.router %}
+{% for vrf_name, router in ospf.vrf_router|items %}
 !
+{% if vrf_name == "default" %}
 router ospf
- ospf router-id {{ ospf.router.router_id }}
-{% for redistribution in ospf.router.redistribute %}
+{% else %}
+router ospf vrf {{ vrf_name }}
+{% endif %}
+ ospf router-id {{ router.router_id }}
+{% for redistribution in router.redistribute %}
  redistribute {{ redistribution.source }}{% if redistribution.metric is defined %} metric {{ redistribution.metric }}{% endif %}{% if redistribution.route_map is defined %} route-map {{ redistribution.route_map }}{% endif %}
 
 {% endfor %}
 exit
-{% endif %}
+{% endfor %}
 {% for interface_name, interface_config in ospf.interfaces|items %}
-{% call interface(interface_name, interface_config.addresses_v4, interface_config.addresses_v6) %}
+{% call interface(interface_name, interface_config.addresses_v4, interface_config.addresses_v6, interface_config.vrf) %}
  ip ospf area {{ interface_config.area }}
 {% if interface_config.passive %}
  ip ospf passive
diff --git a/proxmox-frr/src/ser/mod.rs b/proxmox-frr/src/ser/mod.rs
index 0f2b52138cf3..0a484b38e8fd 100644
--- a/proxmox-frr/src/ser/mod.rs
+++ b/proxmox-frr/src/ser/mod.rs
@@ -246,7 +246,7 @@ pub struct IsisFrrConfig {
 #[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
 pub struct OspfFrrConfig {
     #[serde(default)]
-    pub router: Option<ospf::OspfRouter>,
+    pub vrf_router: BTreeMap<VrfName, ospf::OspfRouter>,
     #[serde(default)]
     pub interfaces: BTreeMap<InterfaceName, Interface<ospf::OspfInterface>>,
 }
diff --git a/proxmox-frr/src/ser/ospf.rs b/proxmox-frr/src/ser/ospf.rs
index e27b3660c2ed..c4b0f17b80e8 100644
--- a/proxmox-frr/src/ser/ospf.rs
+++ b/proxmox-frr/src/ser/ospf.rs
@@ -5,7 +5,7 @@ use proxmox_sdn_types::ospf::NetworkType;
 use serde::{Deserialize, Serialize};
 use thiserror::Error;
 
-use crate::ser::{FrrWord, FrrWordError, route_map::RouteMapName};
+use crate::ser::{FrrWord, FrrWordError, VrfName, route_map::RouteMapName};
 
 #[derive(Error, Debug)]
 pub enum AreaParsingError {
@@ -120,4 +120,7 @@ pub struct OspfInterface {
     pub passive: Option<bool>,
     #[serde(default)]
     pub network_type: Option<NetworkType>,
+    /// VRF of the interface, `None` for the default VRF.
+    #[serde(default)]
+    pub vrf: Option<VrfName>,
 }
diff --git a/proxmox-ve-config/src/sdn/fabric/frr.rs b/proxmox-ve-config/src/sdn/fabric/frr.rs
index d13cfbdf2e03..462ee72ad38e 100644
--- a/proxmox-ve-config/src/sdn/fabric/frr.rs
+++ b/proxmox-ve-config/src/sdn/fabric/frr.rs
@@ -207,7 +207,7 @@ pub fn build_fabric(
                 let frr_word_area = ser::FrrWord::new(fabric.properties().area.to_string())?;
                 let frr_area = ser::ospf::Area::new(frr_word_area)?;
 
-                if frr_config.ospf.router.is_none() {
+                if !frr_config.ospf.vrf_router.contains_key(&VrfName::Default) {
                     let mut ospf_router = build_ospf_router(*router_id)?;
 
                     ospf_router.redistribute = fabric
@@ -218,7 +218,10 @@ pub fn build_fabric(
                         .map(OspfRedistribution::from)
                         .collect();
 
-                    frr_config.ospf.router = Some(ospf_router);
+                    frr_config
+                        .ospf
+                        .vrf_router
+                        .insert(VrfName::Default, ospf_router);
                 }
 
                 // Add dummy interface
@@ -622,6 +625,7 @@ fn build_ospf_interface(
             }
             Some(network_type) => Some(network_type),
         },
+        vrf: None,
     };
 
     let interface_name = interface.name.as_ref().try_into()?;
@@ -637,6 +641,7 @@ fn build_ospf_dummy_interface(
         area,
         passive: Some(true),
         network_type: None,
+        vrf: None,
     };
     let interface_name = format!("dummy_{}", fabric_id).try_into()?;
     Ok((frr_interface.into(), interface_name))
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH proxmox-ve-rs v3 03/28] sdn: add zone references to OSPF and BGP fabrics
  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 ` Gabriel Goller
  2026-11-19 19:40 ` [PATCH proxmox-ve-rs v3 04/28] sdn: generate fabric routing configuration in zone VRFs Gabriel Goller
                   ` (24 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Gabriel Goller @ 2026-11-19 19:40 UTC (permalink / raw)
  To: pve-devel

Allow OSPF and BGP fabrics to refer to an SDN zone. The zone provides
the VRF in which the fabric routing protocol will run. The zone can only
be set when creating a fabric, so it is skipped in the updater.

Scope prefix overlap checks and OSPF area uniqueness by zone. Different
VRFs have independent routing tables, so they can reuse addresses and
OSPF areas.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 proxmox-ve-config/src/sdn/fabric/mod.rs       | 14 +++++++---
 .../src/sdn/fabric/section_config/fabric.rs   | 12 +++++++-
 .../sdn/fabric/section_config/protocol/bgp.rs | 10 +++++++
 .../fabric/section_config/protocol/ospf.rs    | 10 +++++++
 proxmox-ve-config/src/sdn/mod.rs              | 11 ++++++++
 proxmox-ve-config/tests/fabric/main.rs        | 28 +++++++++++++++++++
 6 files changed, 80 insertions(+), 5 deletions(-)

diff --git a/proxmox-ve-config/src/sdn/fabric/mod.rs b/proxmox-ve-config/src/sdn/fabric/mod.rs
index 79bb1fd91651..ae74b981f285 100644
--- a/proxmox-ve-config/src/sdn/fabric/mod.rs
+++ b/proxmox-ve-config/src/sdn/fabric/mod.rs
@@ -773,8 +773,8 @@ impl Validatable for FabricConfig {
     /// Ensures that:
     /// - (node, interface) combinations exist only once across all fabrics
     /// - every entry (fabric) validates
-    /// - all the ospf fabrics have different areas
-    /// - IP prefixes of fabrics do not overlap
+    /// - OSPF areas are unique within each VRF
+    /// - IP prefixes do not overlap within the same VRF
     fn validate(&self) -> Result<(), FabricConfigError> {
         let mut wireguard_interfaces = HashSet::new();
         let mut wireguard_listen_ports = HashSet::new();
@@ -789,6 +789,11 @@ impl Validatable for FabricConfig {
             .flat_map(|(i, f1)| fabrics.iter().skip(i + 1).map(move |f2| (f1, f2)));
 
         for (fabric1, fabric2) in cartesian_product {
+            // Separate VRFs have independent routing tables and may use overlapping address space.
+            if fabric1.zone() != fabric2.zone() {
+                continue;
+            }
+
             if let (Some(prefix1), Some(prefix2)) = (fabric1.ip_prefix(), fabric2.ip_prefix()) {
                 if prefix1.overlaps(&prefix2) {
                     return Err(FabricConfigError::OverlappingIp4Prefix(
@@ -815,13 +820,14 @@ impl Validatable for FabricConfig {
         // additionally, for wireguard check the listen ports of the interfaces as well
         for entry in self.fabrics.values() {
             if let FabricEntry::Ospf(entry) = entry {
-                if !ospf_area.insert(
+                if !ospf_area.insert((
+                    entry.fabric_section().properties().zone().cloned(),
                     entry
                         .fabric_section()
                         .properties()
                         .area()
                         .get_ipv4_representation(),
-                ) {
+                )) {
                     return Err(FabricConfigError::DuplicateOspfArea);
                 }
             }
diff --git a/proxmox-ve-config/src/sdn/fabric/section_config/fabric.rs b/proxmox-ve-config/src/sdn/fabric/section_config/fabric.rs
index 7e39e46a9341..307cd37d0c4c 100644
--- a/proxmox-ve-config/src/sdn/fabric/section_config/fabric.rs
+++ b/proxmox-ve-config/src/sdn/fabric/section_config/fabric.rs
@@ -8,6 +8,7 @@ use proxmox_schema::{
 };
 
 use crate::common::valid::Validatable;
+use crate::sdn::ZoneName;
 use crate::sdn::fabric::FabricConfigError;
 use crate::sdn::fabric::section_config::protocol::bgp::{
     BgpDeletableProperties, BgpProperties, BgpPropertiesUpdater,
@@ -203,6 +204,15 @@ impl Fabric {
         }
     }
 
+    /// Get the SDN zone whose VRF contains this fabric.
+    pub fn zone(&self) -> Option<&ZoneName> {
+        match self {
+            Fabric::Ospf(fabric_section) => fabric_section.properties().zone(),
+            Fabric::Bgp(fabric_section) => fabric_section.properties().zone(),
+            Fabric::Openfabric(_) | Fabric::WireGuard(_) => None,
+        }
+    }
+
     /// Get the ip-prefix (IPv4 CIDR) of the [`Fabric`].
     ///
     /// This is a common property for all protocols.
@@ -260,7 +270,7 @@ impl Validatable for Fabric {
         match self {
             Fabric::Openfabric(fabric_section) => fabric_section.validate(),
             Fabric::Ospf(fabric_section) => fabric_section.validate(),
-            Fabric::WireGuard(_fabric_section) => Ok(()),
+            Fabric::WireGuard(_) => Ok(()),
             Fabric::Bgp(fabric_section) => fabric_section.validate(),
         }
     }
diff --git a/proxmox-ve-config/src/sdn/fabric/section_config/protocol/bgp.rs b/proxmox-ve-config/src/sdn/fabric/section_config/protocol/bgp.rs
index 9623730ab97d..b9a59645f2a0 100644
--- a/proxmox-ve-config/src/sdn/fabric/section_config/protocol/bgp.rs
+++ b/proxmox-ve-config/src/sdn/fabric/section_config/protocol/bgp.rs
@@ -10,6 +10,7 @@ use serde::{Deserialize, Serialize};
 use proxmox_schema::{ApiStringFormat, Updater, api, property_string::PropertyString};
 
 use crate::common::valid::Validatable;
+use crate::sdn::ZoneName;
 use crate::sdn::fabric::FabricConfigError;
 use crate::sdn::fabric::section_config::fabric::FabricSection;
 use crate::sdn::fabric::section_config::interface::InterfaceName;
@@ -94,6 +95,11 @@ impl ASN {
 #[derive(Debug, Clone, Serialize, Deserialize, Updater, Hash)]
 /// Properties for a BGP fabric.
 pub struct BgpProperties {
+    /// SDN zone whose VRF contains this fabric.
+    #[updater(skip)]
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub(crate) zone: Option<ZoneName>,
+
     /// enable BFD for this fabric
     #[serde(default, deserialize_with = "proxmox_serde::perl::deserialize_bool")]
     pub(crate) bfd: bool,
@@ -119,6 +125,10 @@ pub struct BgpProperties {
 }
 
 impl BgpProperties {
+    pub fn zone(&self) -> Option<&ZoneName> {
+        self.zone.as_ref()
+    }
+
     pub fn bfd(&self) -> bool {
         self.bfd
     }
diff --git a/proxmox-ve-config/src/sdn/fabric/section_config/protocol/ospf.rs b/proxmox-ve-config/src/sdn/fabric/section_config/protocol/ospf.rs
index 26be07546964..908a313d9bf5 100644
--- a/proxmox-ve-config/src/sdn/fabric/section_config/protocol/ospf.rs
+++ b/proxmox-ve-config/src/sdn/fabric/section_config/protocol/ospf.rs
@@ -9,6 +9,7 @@ use serde::{Deserialize, Serialize};
 use proxmox_schema::{ApiStringFormat, Updater, api, property_string::PropertyString};
 
 use crate::common::valid::Validatable;
+use crate::sdn::ZoneName;
 use crate::sdn::fabric::FabricConfigError;
 use crate::sdn::fabric::section_config::fabric::FabricSection;
 use crate::sdn::fabric::section_config::interface::InterfaceName;
@@ -99,6 +100,11 @@ mod frr {
 #[derive(Debug, Clone, Serialize, Deserialize, Updater, Hash)]
 /// Properties for an Ospf fabric.
 pub struct OspfProperties {
+    /// SDN zone whose VRF contains this fabric.
+    #[updater(skip)]
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub(crate) zone: Option<ZoneName>,
+
     /// OSPF area
     pub(crate) area: Area,
 
@@ -115,6 +121,10 @@ pub struct OspfProperties {
 }
 
 impl OspfProperties {
+    pub fn zone(&self) -> Option<&ZoneName> {
+        self.zone.as_ref()
+    }
+
     pub fn set_area(&mut self, value: Area) {
         self.area = value;
     }
diff --git a/proxmox-ve-config/src/sdn/mod.rs b/proxmox-ve-config/src/sdn/mod.rs
index 2133396145bd..f4d40f590455 100644
--- a/proxmox-ve-config/src/sdn/mod.rs
+++ b/proxmox-ve-config/src/sdn/mod.rs
@@ -8,6 +8,7 @@ pub mod wireguard;
 use std::{error::Error, fmt::Display, str::FromStr};
 
 use proxmox_network_types::ip_address::Cidr;
+use proxmox_schema::{ApiStringFormat, ApiType, Schema, StringSchema};
 
 #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
 pub enum SdnNameError {
@@ -57,8 +58,18 @@ fn validate_sdn_name(name: &str) -> Result<(), SdnNameError> {
 #[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
 pub struct ZoneName(String);
 
+proxmox_serde::forward_serialize_to_display!(ZoneName);
 proxmox_serde::forward_deserialize_to_from_str!(ZoneName);
 
+const ZONE_NAME_FORMAT: ApiStringFormat =
+    ApiStringFormat::VerifyFn(|name| Ok(validate_sdn_name(name)?));
+
+impl ApiType for ZoneName {
+    const API_SCHEMA: Schema = StringSchema::new("Name of an SDN zone.")
+        .format(&ZONE_NAME_FORMAT)
+        .schema();
+}
+
 impl ZoneName {
     /// construct a new zone name
     ///
diff --git a/proxmox-ve-config/tests/fabric/main.rs b/proxmox-ve-config/tests/fabric/main.rs
index ee59e9a2ea44..09cf1be2f99c 100644
--- a/proxmox-ve-config/tests/fabric/main.rs
+++ b/proxmox-ve-config/tests/fabric/main.rs
@@ -165,6 +165,34 @@ fn openfabric_ipv6_only() {
     insta::assert_snapshot!(helper::reference_name!("pve"), output);
 }
 
+#[test]
+fn vrf_prefix_overlap_is_scoped_by_zone() {
+    let raw = r#"
+ospf_fabric: first
+        area 0
+        ip_prefix 10.0.0.0/24
+        zone zoneone
+
+ospf_fabric: second
+        area 1
+        ip_prefix 10.0.0.0/24
+        zone zonetwo
+
+ospf_node: first_pve
+        interfaces name=eth0
+        ip 10.0.0.1
+
+ospf_node: second_pve
+        interfaces name=eth1
+        ip 10.0.0.1
+"#;
+
+    assert!(FabricConfig::parse_section_config(raw).is_ok());
+    assert!(
+        FabricConfig::parse_section_config(&raw.replace("zone zonetwo", "zone zoneone")).is_err()
+    );
+}
+
 #[test]
 fn bgp_default() {
     let config = FabricConfig::parse_section_config(helper::get_fabrics_config!()).unwrap();
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH proxmox-ve-rs v3 04/28] sdn: generate fabric routing configuration in zone VRFs
  2026-11-19 19:40 [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/28] SDN VRF support Gabriel Goller
                   ` (2 preceding siblings ...)
  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 ` 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
                   ` (23 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Gabriel Goller @ 2026-11-19 19:40 UTC (permalink / raw)
  To: pve-devel

Map a fabric zone to the corresponding vrf_<zone> FRR instance. Generate
OSPF routers and interfaces in that VRF, and store BGP routers under the
same VRF name. Keep fabrics without a zone in the default routing table.

Collect OSPF redistribution rules on the router for the selected VRF so
that several fabrics in one VRF contribute to the same OSPF instance.
This keeps protocol configuration and interface configuration in the
routing table selected by the zone.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 proxmox-ve-config/src/sdn/fabric/frr.rs | 71 +++++++++++++++----------
 proxmox-ve-config/src/sdn/fabric/mod.rs | 10 ++++
 2 files changed, 54 insertions(+), 27 deletions(-)

diff --git a/proxmox-ve-config/src/sdn/fabric/frr.rs b/proxmox-ve-config/src/sdn/fabric/frr.rs
index 462ee72ad38e..ea042b2fea01 100644
--- a/proxmox-ve-config/src/sdn/fabric/frr.rs
+++ b/proxmox-ve-config/src/sdn/fabric/frr.rs
@@ -1,3 +1,4 @@
+use std::collections::{BTreeMap, btree_map};
 use std::net::{IpAddr, Ipv4Addr};
 
 use tracing;
@@ -18,6 +19,7 @@ use proxmox_sdn_types::net::Net;
 
 use crate::common::valid::Valid;
 
+use crate::sdn::ZoneName;
 use crate::sdn::fabric::section_config::protocol::bgp::{BgpNode, bgp_router_id};
 use crate::sdn::fabric::section_config::protocol::{
     bgp::BgpRedistributionSource,
@@ -27,7 +29,7 @@ use crate::sdn::fabric::section_config::protocol::{
 use crate::sdn::fabric::section_config::{fabric::FabricId, node::NodeId};
 use crate::sdn::fabric::{FabricConfig, FabricEntry};
 
-/// Constructs the FRR config from the the passed [`Valid<FabricConfig>`].
+/// Constructs the FRR config from the passed [`Valid<FabricConfig>`].
 ///
 /// Iterates over the [`FabricConfig`] and constructs all the FRR routers, interfaces, route-maps,
 /// etc.
@@ -37,7 +39,9 @@ pub fn build_fabric(
     frr_config: &mut FrrConfig,
 ) -> Result<(), anyhow::Error> {
     let mut routemap_seq = 100;
-    let mut current_router_id: Option<Ipv4Addr> = None;
+    // OSPF router IDs only need to be unique within a VRF, and node addresses are only unique
+    // within a VRF, so pick the router ID per VRF.
+    let mut ospf_router_ids: BTreeMap<VrfName, Ipv4Addr> = BTreeMap::new();
     let mut current_net: Option<Net> = None;
 
     for (fabric_id, entry) in config.into_inner().iter() {
@@ -199,34 +203,37 @@ pub fn build_fabric(
                     continue;
                 };
 
-                let router_id = current_router_id
-                    .get_or_insert(node.ip().expect("node must have an ipv4 address"));
-
                 let fabric = ospf_entry.fabric_section();
+                let vrf_name = fabric_vrf_name(fabric.properties().zone())?;
+
+                let router_id = ospf_router_ids
+                    .entry(vrf_name.clone())
+                    .or_insert(node.ip().expect("node must have an ipv4 address"));
 
                 let frr_word_area = ser::FrrWord::new(fabric.properties().area.to_string())?;
                 let frr_area = ser::ospf::Area::new(frr_word_area)?;
 
-                if !frr_config.ospf.vrf_router.contains_key(&VrfName::Default) {
-                    let mut ospf_router = build_ospf_router(*router_id)?;
-
-                    ospf_router.redistribute = fabric
-                        .properties()
-                        .redistributions()
-                        .into_iter()
-                        .cloned()
-                        .map(OspfRedistribution::from)
-                        .collect();
+                let redistributions = fabric
+                    .properties()
+                    .redistributions()
+                    .into_iter()
+                    .cloned()
+                    .map(OspfRedistribution::from);
+
+                let ospf_router = match frr_config.ospf.vrf_router.entry(vrf_name.clone()) {
+                    btree_map::Entry::Occupied(entry) => entry.into_mut(),
+                    btree_map::Entry::Vacant(entry) => entry.insert(build_ospf_router(*router_id)?),
+                };
+                ospf_router.redistribute.extend(redistributions);
 
-                    frr_config
-                        .ospf
-                        .vrf_router
-                        .insert(VrfName::Default, ospf_router);
-                }
+                let interface_vrf = match &vrf_name {
+                    VrfName::Default => None,
+                    custom => Some(custom.clone()),
+                };
 
                 // Add dummy interface
                 let (interface, interface_name) =
-                    build_ospf_dummy_interface(fabric_id, frr_area.clone())?;
+                    build_ospf_dummy_interface(fabric_id, frr_area.clone(), interface_vrf.clone())?;
 
                 if frr_config
                     .ospf
@@ -241,7 +248,7 @@ pub fn build_fabric(
 
                 for interface in node.properties().interfaces.iter() {
                     let (interface, interface_name) =
-                        build_ospf_interface(frr_area.clone(), interface)?;
+                        build_ospf_interface(frr_area.clone(), interface, interface_vrf.clone())?;
 
                     if frr_config
                         .ospf
@@ -308,6 +315,7 @@ pub fn build_fabric(
                 };
 
                 let fabric = bgp_entry.fabric_section();
+                let vrf_name = fabric_vrf_name(fabric.properties().zone())?;
 
                 let local_asn = properties.asn().as_u32();
 
@@ -322,7 +330,7 @@ pub fn build_fabric(
                 let local_as = frr_config
                     .bgp
                     .vrf_router
-                    .get(&VrfName::Default)
+                    .get(&vrf_name)
                     .filter(|existing| existing.asn != local_asn)
                     .map(|_| LocalAsSettings {
                         asn: local_asn,
@@ -557,10 +565,10 @@ pub fn build_fabric(
                     custom_frr_config: Default::default(),
                 };
 
-                if let Some(existing) = frr_config.bgp.vrf_router.get_mut(&VrfName::Default) {
+                if let Some(existing) = frr_config.bgp.vrf_router.get_mut(&vrf_name) {
                     existing.merge_fabric(router);
                 } else {
-                    frr_config.bgp.vrf_router.insert(VrfName::Default, router);
+                    frr_config.bgp.vrf_router.insert(vrf_name, router);
                 }
             }
         }
@@ -590,6 +598,13 @@ pub fn build_fabric(
     Ok(())
 }
 
+fn fabric_vrf_name(zone: Option<&ZoneName>) -> Result<VrfName, ser::FrrWordError> {
+    Ok(match zone {
+        Some(zone) => VrfName::Custom(FrrWord::new(format!("vrf_{zone}"))?),
+        None => VrfName::Default,
+    })
+}
+
 /// Helper that builds a OSPF router with a the router_id.
 fn build_ospf_router(router_id: Ipv4Addr) -> Result<OspfRouter, anyhow::Error> {
     Ok(OspfRouter::new(router_id))
@@ -610,6 +625,7 @@ fn build_openfabric_router(
 fn build_ospf_interface(
     area: ser::ospf::Area,
     interface: &OspfInterfaceProperties,
+    vrf: Option<VrfName>,
 ) -> Result<(Interface<OspfInterface>, InterfaceName), anyhow::Error> {
     let frr_interface = ser::ospf::OspfInterface {
         area,
@@ -625,7 +641,7 @@ fn build_ospf_interface(
             }
             Some(network_type) => Some(network_type),
         },
-        vrf: None,
+        vrf,
     };
 
     let interface_name = interface.name.as_ref().try_into()?;
@@ -636,12 +652,13 @@ fn build_ospf_interface(
 fn build_ospf_dummy_interface(
     fabric_id: &FabricId,
     area: ospf::Area,
+    vrf: Option<VrfName>,
 ) -> Result<(Interface<OspfInterface>, InterfaceName), anyhow::Error> {
     let frr_interface = ser::ospf::OspfInterface {
         area,
         passive: Some(true),
         network_type: None,
-        vrf: None,
+        vrf,
     };
     let interface_name = format!("dummy_{}", fabric_id).try_into()?;
     Ok((frr_interface.into(), interface_name))
diff --git a/proxmox-ve-config/src/sdn/fabric/mod.rs b/proxmox-ve-config/src/sdn/fabric/mod.rs
index ae74b981f285..9915ebdf7a3f 100644
--- a/proxmox-ve-config/src/sdn/fabric/mod.rs
+++ b/proxmox-ve-config/src/sdn/fabric/mod.rs
@@ -541,6 +541,16 @@ impl FabricEntry {
             FabricEntry::Bgp(entry) => &mut entry.fabric,
         }
     }
+
+    pub fn fabric_vrf_name(&self) -> Option<String> {
+        let zone = match self {
+            FabricEntry::Ospf(entry) => entry.fabric_section().properties().zone(),
+            FabricEntry::Bgp(entry) => entry.fabric_section().properties().zone(),
+            FabricEntry::Openfabric(_) | FabricEntry::WireGuard(_) => None,
+        };
+
+        zone.map(|zone| format!("vrf_{zone}"))
+    }
 }
 
 impl From<Fabric> for FabricEntry {
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH proxmox-ve-rs v3 05/28] sdn: fix VRF route-map scoping and zone ID validation
  2026-11-19 19:40 [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/28] SDN VRF support Gabriel Goller
                   ` (3 preceding siblings ...)
  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 ` Gabriel Goller
  2026-11-19 19:40 ` [PATCH proxmox-ve-rs v3 06/28] tests: fabrics: add tests for fabrics in VRFs Gabriel Goller
                   ` (22 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Gabriel Goller @ 2026-11-19 19:40 UTC (permalink / raw)
  To: pve-devel

Attach protocol route-maps inside the VRF where the protocol runs. Give
VRF route-maps distinct names so fabrics in separate routing tables do
not overwrite or refer to each other. Keep the existing global route-map
handling for protocols in the default routing table.

Add the final BGP permit entry to both global and VRF-specific route-maps
so unrelated routes are not dropped by the implicit deny.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 .../templates/protocol_routemaps.jinja        | 13 ++++
 proxmox-frr/src/ser/mod.rs                    |  2 +
 proxmox-ve-config/src/sdn/fabric/frr.rs       | 59 ++++++++++++-------
 proxmox-ve-config/tests/fabric/main.rs        | 57 +++++++++++++++++-
 4 files changed, 110 insertions(+), 21 deletions(-)

diff --git a/proxmox-frr-templates/templates/protocol_routemaps.jinja b/proxmox-frr-templates/templates/protocol_routemaps.jinja
index 38c00b6407ee..0f4ca5fdbe0c 100644
--- a/proxmox-frr-templates/templates/protocol_routemaps.jinja
+++ b/proxmox-frr-templates/templates/protocol_routemaps.jinja
@@ -8,3 +8,16 @@ ip protocol {{ protocol_name }} route-map {{ protocol_routemap.v4 }}
 ipv6 protocol {{ protocol_name }} route-map {{ protocol_routemap.v6 }}
 {% endif %}
 {% endfor %}
+{% for vrf_name, protocol_routemaps in vrf_protocol_routemaps | items %}
+!
+vrf {{ vrf_name }}
+{% for protocol_name, protocol_routemap in protocol_routemaps | items %}
+{% if protocol_routemap.v4 %}
+ ip protocol {{ protocol_name }} route-map {{ protocol_routemap.v4 }}
+{% endif %}
+{% if protocol_routemap.v6 %}
+ ipv6 protocol {{ protocol_name }} route-map {{ protocol_routemap.v6 }}
+{% endif %}
+{% endfor %}
+exit-vrf
+{% endfor %}
diff --git a/proxmox-frr/src/ser/mod.rs b/proxmox-frr/src/ser/mod.rs
index 0a484b38e8fd..8d3588e93c36 100644
--- a/proxmox-frr/src/ser/mod.rs
+++ b/proxmox-frr/src/ser/mod.rs
@@ -217,6 +217,8 @@ pub struct FrrConfig {
     #[serde(default)]
     pub protocol_routemaps: BTreeMap<FrrProtocol, IpProtocolRouteMap>,
     #[serde(default)]
+    pub vrf_protocol_routemaps: BTreeMap<VrfName, BTreeMap<FrrProtocol, IpProtocolRouteMap>>,
+    #[serde(default)]
     pub routemaps: BTreeMap<RouteMapName, Vec<RouteMapEntry>>,
     #[serde(default)]
     pub access_lists: BTreeMap<AccessListName, Vec<AccessListRule>>,
diff --git a/proxmox-ve-config/src/sdn/fabric/frr.rs b/proxmox-ve-config/src/sdn/fabric/frr.rs
index ea042b2fea01..e5d88a7fa9ba 100644
--- a/proxmox-ve-config/src/sdn/fabric/frr.rs
+++ b/proxmox-ve-config/src/sdn/fabric/frr.rs
@@ -1,4 +1,4 @@
-use std::collections::{BTreeMap, btree_map};
+use std::collections::{BTreeMap, BTreeSet, btree_map};
 use std::net::{IpAddr, Ipv4Addr};
 
 use tracing;
@@ -39,6 +39,7 @@ pub fn build_fabric(
     frr_config: &mut FrrConfig,
 ) -> Result<(), anyhow::Error> {
     let mut routemap_seq = 100;
+    let mut fabric_bgp_routemaps = BTreeSet::new();
     // OSPF router IDs only need to be unique within a VRF, and node addresses are only unique
     // within a VRF, so pick the router ID per VRF.
     let mut ospf_router_ids: BTreeMap<VrfName, Ipv4Addr> = BTreeMap::new();
@@ -260,7 +261,7 @@ pub fn build_fabric(
                     }
                 }
 
-                let routemap_name = ser::route_map::RouteMapName::new("pve_ospf")?;
+                let routemap_name = protocol_routemap_name("pve_ospf", &vrf_name)?;
                 let routemap = frr_config
                     .routemaps
                     .entry(routemap_name.clone())
@@ -297,10 +298,7 @@ pub fn build_fabric(
 
                 routemap.push(routemap_entry);
 
-                let protocol_routemap = frr_config
-                    .protocol_routemaps
-                    .entry(FrrProtocol::Ospf)
-                    .or_default();
+                let protocol_routemap = protocol_routemap(frr_config, &vrf_name, FrrProtocol::Ospf);
 
                 protocol_routemap.v4 = Some(routemap_name);
             }
@@ -443,7 +441,7 @@ pub fn build_fabric(
                         networks: vec![Ipv4Cidr::from(ip)],
                     });
 
-                    let routemap_name = ser::route_map::RouteMapName::new("pve_bgp")?;
+                    let routemap_name = protocol_routemap_name("pve_bgp", &vrf_name)?;
                     let routemap = frr_config
                         .routemaps
                         .entry(routemap_name.clone())
@@ -455,11 +453,10 @@ pub fn build_fabric(
 
                     routemap.push(routemap_entry);
 
-                    let protocol_routemap = frr_config
-                        .protocol_routemaps
-                        .entry(FrrProtocol::Bgp)
-                        .or_default();
+                    let protocol_routemap =
+                        protocol_routemap(frr_config, &vrf_name, FrrProtocol::Bgp);
 
+                    fabric_bgp_routemaps.insert(routemap_name.clone());
                     protocol_routemap.v4 = Some(routemap_name);
                 }
 
@@ -528,7 +525,7 @@ pub fn build_fabric(
                         redistribute,
                     });
 
-                    let routemap_name = ser::route_map::RouteMapName::new("pve_bgp6")?;
+                    let routemap_name = protocol_routemap_name("pve_bgp6", &vrf_name)?;
                     let routemap = frr_config
                         .routemaps
                         .entry(routemap_name.clone())
@@ -540,11 +537,10 @@ pub fn build_fabric(
 
                     routemap.push(routemap_entry);
 
-                    let protocol_routemap = frr_config
-                        .protocol_routemaps
-                        .entry(FrrProtocol::Bgp)
-                        .or_default();
+                    let protocol_routemap =
+                        protocol_routemap(frr_config, &vrf_name, FrrProtocol::Bgp);
 
+                    fabric_bgp_routemaps.insert(routemap_name.clone());
                     protocol_routemap.v6 = Some(routemap_name);
                 };
 
@@ -578,10 +574,7 @@ pub fn build_fabric(
     // routes (e.g. EVPN-imported VRF routes) reach the kernel unchanged.
     // Without this, the implicit deny at the end of the route-map would drop
     // them.
-    for routemap_name in [
-        ser::route_map::RouteMapName::new("pve_bgp")?,
-        ser::route_map::RouteMapName::new("pve_bgp6")?,
-    ] {
+    for routemap_name in fabric_bgp_routemaps {
         if let Some(routemap) = frr_config.routemaps.get_mut(&routemap_name) {
             routemap.push(RouteMapEntry {
                 seq: 65535,
@@ -605,6 +598,32 @@ fn fabric_vrf_name(zone: Option<&ZoneName>) -> Result<VrfName, ser::FrrWordError
     })
 }
 
+fn protocol_routemap_name(
+    prefix: &str,
+    vrf_name: &VrfName,
+) -> Result<RouteMapName, ser::FrrWordError> {
+    match vrf_name {
+        VrfName::Default => RouteMapName::new(prefix),
+        VrfName::Custom(vrf_name) => RouteMapName::new(format!("{prefix}_{vrf_name}")),
+    }
+}
+
+fn protocol_routemap<'a>(
+    frr_config: &'a mut FrrConfig,
+    vrf_name: &VrfName,
+    protocol: FrrProtocol,
+) -> &'a mut ser::IpProtocolRouteMap {
+    match vrf_name {
+        VrfName::Default => frr_config.protocol_routemaps.entry(protocol).or_default(),
+        custom => frr_config
+            .vrf_protocol_routemaps
+            .entry(custom.clone())
+            .or_default()
+            .entry(protocol)
+            .or_default(),
+    }
+}
+
 /// Helper that builds a OSPF router with a the router_id.
 fn build_ospf_router(router_id: Ipv4Addr) -> Result<OspfRouter, anyhow::Error> {
     Ok(OspfRouter::new(router_id))
diff --git a/proxmox-ve-config/tests/fabric/main.rs b/proxmox-ve-config/tests/fabric/main.rs
index 09cf1be2f99c..88a24fa4afec 100644
--- a/proxmox-ve-config/tests/fabric/main.rs
+++ b/proxmox-ve-config/tests/fabric/main.rs
@@ -3,7 +3,8 @@ use std::net::Ipv4Addr;
 use std::str::FromStr;
 
 use proxmox_frr::ser::bgp::{AddressFamilies, BgpRouter, CommonAddressFamilyOptions, L2vpnEvpnAF};
-use proxmox_frr::ser::{FrrConfig, VrfName, serializer::dump};
+use proxmox_frr::ser::route_map::RouteMapName;
+use proxmox_frr::ser::{FrrConfig, FrrProtocol, FrrWord, VrfName, serializer::dump};
 use proxmox_ve_config::sdn::fabric::{
     FabricConfig, frr::build_fabric, section_config::node::NodeId,
 };
@@ -193,6 +194,60 @@ ospf_node: second_pve
     );
 }
 
+#[test]
+fn protocol_routemaps_are_scoped_by_vrf() {
+    let raw = r#"
+ospf_fabric: ospf
+        area 0
+        ip_prefix 10.0.0.0/24
+        zone zoneone
+
+ospf_node: ospf_pve
+        interfaces name=eth0
+        ip 10.0.0.1
+
+bgp_fabric: bgp
+        bfd 0
+        ip_prefix 10.0.1.0/24
+        zone zonetwo
+
+bgp_node: bgp_pve
+        asn 65001
+        interfaces name=eth1
+        ip 10.0.1.1
+        role internal
+"#;
+    let config = FabricConfig::parse_section_config(raw).unwrap();
+    let mut frr_config = FrrConfig::default();
+
+    build_fabric(NodeId::from_str("pve").unwrap(), config, &mut frr_config).unwrap();
+
+    let ospf_routemap = &frr_config.vrf_protocol_routemaps
+        [&VrfName::Custom(FrrWord::new("vrf_zoneone").unwrap())][&FrrProtocol::Ospf];
+    assert_eq!(
+        ospf_routemap.v4.as_ref().unwrap(),
+        &RouteMapName::new("pve_ospf_vrf_zoneone").unwrap()
+    );
+    let bgp_routemap = &frr_config.vrf_protocol_routemaps
+        [&VrfName::Custom(FrrWord::new("vrf_zonetwo").unwrap())][&FrrProtocol::Bgp];
+    assert_eq!(
+        bgp_routemap.v4.as_ref().unwrap(),
+        &RouteMapName::new("pve_bgp_vrf_zonetwo").unwrap()
+    );
+    assert!(
+        frr_config
+            .protocol_routemaps
+            .get(&FrrProtocol::Ospf)
+            .is_none()
+    );
+    assert!(
+        frr_config
+            .protocol_routemaps
+            .get(&FrrProtocol::Bgp)
+            .is_none()
+    );
+}
+
 #[test]
 fn bgp_default() {
     let config = FabricConfig::parse_section_config(helper::get_fabrics_config!()).unwrap();
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH proxmox-ve-rs v3 06/28] tests: fabrics: add tests for fabrics in VRFs
  2026-11-19 19:40 [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/28] SDN VRF support Gabriel Goller
                   ` (4 preceding siblings ...)
  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 ` Gabriel Goller
  2026-11-19 19:40 ` [PATCH proxmox-ve-rs v3 07/28] sdn: allow static routes in simple zone VRFs Gabriel Goller
                   ` (21 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Gabriel Goller @ 2026-11-19 19:40 UTC (permalink / raw)
  To: pve-devel

Add integration tests covering OSPF and BGP fabrics in SDN zone VRFs,
alongside fabrics in the default VRF, with redistributions, route
filters and IPv6.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 .../tests/fabric/cfg/vrf/fabrics.cfg          |  43 ++++
 .../tests/fabric/cfg/vrf/route-maps.cfg       |  15 ++
 .../tests/fabric/cfg/vrf_default/fabrics.cfg  |  37 ++++
 .../tests/fabric/cfg/vrf_ipv6/fabrics.cfg     |  25 +++
 .../tests/fabric/cfg/vrf_ipv6/route-maps.cfg  |   7 +
 .../fabric/cfg/vrf_redistribute/fabrics.cfg   |  23 ++
 .../cfg/vrf_redistribute/route-maps.cfg       |   7 +
 .../fabric/cfg/vrf_route_filter/fabrics.cfg   |  23 ++
 .../cfg/vrf_route_filter/prefix-lists.cfg     |   8 +
 proxmox-ve-config/tests/fabric/helper.rs      |  40 ++++
 proxmox-ve-config/tests/fabric/main.rs        | 204 +++++++++++++++++-
 .../snapshots/fabric__vrf_default_pve.snap    | 113 ++++++++++
 .../snapshots/fabric__vrf_ipv6_pve.snap       | 102 +++++++++
 .../fabric/snapshots/fabric__vrf_pve.snap     | 134 ++++++++++++
 .../fabric__vrf_redistribute_pve.snap         |  74 +++++++
 .../fabric__vrf_route_filter_pve.snap         |  85 ++++++++
 16 files changed, 931 insertions(+), 9 deletions(-)
 create mode 100644 proxmox-ve-config/tests/fabric/cfg/vrf/fabrics.cfg
 create mode 100644 proxmox-ve-config/tests/fabric/cfg/vrf/route-maps.cfg
 create mode 100644 proxmox-ve-config/tests/fabric/cfg/vrf_default/fabrics.cfg
 create mode 100644 proxmox-ve-config/tests/fabric/cfg/vrf_ipv6/fabrics.cfg
 create mode 100644 proxmox-ve-config/tests/fabric/cfg/vrf_ipv6/route-maps.cfg
 create mode 100644 proxmox-ve-config/tests/fabric/cfg/vrf_redistribute/fabrics.cfg
 create mode 100644 proxmox-ve-config/tests/fabric/cfg/vrf_redistribute/route-maps.cfg
 create mode 100644 proxmox-ve-config/tests/fabric/cfg/vrf_route_filter/fabrics.cfg
 create mode 100644 proxmox-ve-config/tests/fabric/cfg/vrf_route_filter/prefix-lists.cfg
 create mode 100644 proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_default_pve.snap
 create mode 100644 proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_ipv6_pve.snap
 create mode 100644 proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_pve.snap
 create mode 100644 proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_redistribute_pve.snap
 create mode 100644 proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_route_filter_pve.snap

diff --git a/proxmox-ve-config/tests/fabric/cfg/vrf/fabrics.cfg b/proxmox-ve-config/tests/fabric/cfg/vrf/fabrics.cfg
new file mode 100644
index 000000000000..05a1cb57642a
--- /dev/null
+++ b/proxmox-ve-config/tests/fabric/cfg/vrf/fabrics.cfg
@@ -0,0 +1,43 @@
+ospf_fabric: ospfred
+        area 0
+        ip_prefix 10.0.0.0/24
+        zone red
+
+ospf_fabric: ospfblue
+        area 0
+        ip_prefix 10.0.0.0/24
+        zone blue
+
+ospf_node: ospfred_pve
+        interfaces name=ens18
+        ip 10.0.0.1
+
+ospf_node: ospfblue_pve
+        interfaces name=ens19
+        ip 10.0.0.1
+
+bgp_fabric: bgpred
+        bfd 0
+        ip_prefix 10.1.0.0/24
+        route_map_in red-in
+        route_map_out red-out
+        zone red
+
+bgp_fabric: bgpblue
+        bfd 0
+        ip_prefix 10.1.0.0/24
+        route_map_in blue-in
+        route_map_out blue-out
+        zone blue
+
+bgp_node: bgpred_pve
+        asn 65001
+        interfaces name=ens20
+        ip 10.1.0.1
+        role internal
+
+bgp_node: bgpblue_pve
+        asn 65002
+        interfaces name=ens21
+        ip 10.1.0.1
+        role internal
diff --git a/proxmox-ve-config/tests/fabric/cfg/vrf/route-maps.cfg b/proxmox-ve-config/tests/fabric/cfg/vrf/route-maps.cfg
new file mode 100644
index 000000000000..b382fc369b51
--- /dev/null
+++ b/proxmox-ve-config/tests/fabric/cfg/vrf/route-maps.cfg
@@ -0,0 +1,15 @@
+route-map-entry: blue-in_10
+        action permit
+        set key=local-preference,value=200
+
+route-map-entry: blue-out_10
+        action permit
+        set key=metric,value=20
+
+route-map-entry: red-in_10
+        action permit
+        set key=local-preference,value=100
+
+route-map-entry: red-out_10
+        action permit
+        set key=metric,value=10
diff --git a/proxmox-ve-config/tests/fabric/cfg/vrf_default/fabrics.cfg b/proxmox-ve-config/tests/fabric/cfg/vrf_default/fabrics.cfg
new file mode 100644
index 000000000000..e93b590b18a3
--- /dev/null
+++ b/proxmox-ve-config/tests/fabric/cfg/vrf_default/fabrics.cfg
@@ -0,0 +1,37 @@
+ospf_fabric: underlay
+        area 0
+        ip_prefix 10.0.0.0/24
+
+ospf_fabric: ospfred
+        area 0
+        ip_prefix 10.0.0.0/24
+        zone red
+
+ospf_node: underlay_pve
+        interfaces name=ens18
+        ip 10.0.0.1
+
+ospf_node: ospfred_pve
+        interfaces name=ens19
+        ip 10.0.0.2
+
+bgp_fabric: bgpdef
+        bfd 0
+        ip_prefix 10.1.0.0/24
+
+bgp_fabric: bgpred
+        bfd 0
+        ip_prefix 10.1.0.0/24
+        zone red
+
+bgp_node: bgpdef_pve
+        asn 65001
+        interfaces name=ens20
+        ip 10.1.0.1
+        role internal
+
+bgp_node: bgpred_pve
+        asn 65002
+        interfaces name=ens21
+        ip 10.1.0.2
+        role internal
diff --git a/proxmox-ve-config/tests/fabric/cfg/vrf_ipv6/fabrics.cfg b/proxmox-ve-config/tests/fabric/cfg/vrf_ipv6/fabrics.cfg
new file mode 100644
index 000000000000..ad2e3451333f
--- /dev/null
+++ b/proxmox-ve-config/tests/fabric/cfg/vrf_ipv6/fabrics.cfg
@@ -0,0 +1,25 @@
+bgp_fabric: bgpred
+        bfd 0
+        ip6_prefix fd00:10::/64
+        route_map_in red-in
+        route_map_out red-out
+        zone red
+
+bgp_fabric: bgpblue
+        bfd 0
+        ip_prefix 10.1.0.0/24
+        ip6_prefix fd00:20::/64
+        zone blue
+
+bgp_node: bgpred_pve
+        asn 65001
+        interfaces name=ens18
+        ip6 fd00:10::1
+        role internal
+
+bgp_node: bgpblue_pve
+        asn 65002
+        interfaces name=ens19
+        ip 10.1.0.1
+        ip6 fd00:20::1
+        role internal
diff --git a/proxmox-ve-config/tests/fabric/cfg/vrf_ipv6/route-maps.cfg b/proxmox-ve-config/tests/fabric/cfg/vrf_ipv6/route-maps.cfg
new file mode 100644
index 000000000000..c65af38666ca
--- /dev/null
+++ b/proxmox-ve-config/tests/fabric/cfg/vrf_ipv6/route-maps.cfg
@@ -0,0 +1,7 @@
+route-map-entry: red-in_10
+        action permit
+        set key=local-preference,value=100
+
+route-map-entry: red-out_10
+        action permit
+        set key=metric,value=10
diff --git a/proxmox-ve-config/tests/fabric/cfg/vrf_redistribute/fabrics.cfg b/proxmox-ve-config/tests/fabric/cfg/vrf_redistribute/fabrics.cfg
new file mode 100644
index 000000000000..5ea790ca6798
--- /dev/null
+++ b/proxmox-ve-config/tests/fabric/cfg/vrf_redistribute/fabrics.cfg
@@ -0,0 +1,23 @@
+ospf_fabric: ospfred
+        area 0
+        ip_prefix 10.0.0.0/24
+        redistribute source=connected
+        redistribute source=static,metric=50,route-map=redistribute-static
+        zone red
+
+ospf_node: ospfred_pve
+        interfaces name=ens18
+        ip 10.0.0.1
+
+bgp_fabric: bgpblue
+        bfd 0
+        ip_prefix 10.1.0.0/24
+        redistribute source=connected
+        redistribute source=ospf,metric=100,route-map=redistribute-ospf
+        zone blue
+
+bgp_node: bgpblue_pve
+        asn 65001
+        interfaces name=ens19
+        ip 10.1.0.1
+        role internal
diff --git a/proxmox-ve-config/tests/fabric/cfg/vrf_redistribute/route-maps.cfg b/proxmox-ve-config/tests/fabric/cfg/vrf_redistribute/route-maps.cfg
new file mode 100644
index 000000000000..d85b7ce58040
--- /dev/null
+++ b/proxmox-ve-config/tests/fabric/cfg/vrf_redistribute/route-maps.cfg
@@ -0,0 +1,7 @@
+route-map-entry: redistribute-ospf_10
+        action permit
+        set key=local-preference,value=150
+
+route-map-entry: redistribute-static_10
+        action permit
+        set key=metric,value=30
diff --git a/proxmox-ve-config/tests/fabric/cfg/vrf_route_filter/fabrics.cfg b/proxmox-ve-config/tests/fabric/cfg/vrf_route_filter/fabrics.cfg
new file mode 100644
index 000000000000..4cc0f893d876
--- /dev/null
+++ b/proxmox-ve-config/tests/fabric/cfg/vrf_route_filter/fabrics.cfg
@@ -0,0 +1,23 @@
+ospf_fabric: ospfred
+        area 0
+        ip_prefix 10.0.0.0/24
+        route_filter red-allowed
+        zone red
+
+ospf_node: ospfred_pve
+        interfaces name=ens18
+        ip 10.0.0.1
+
+bgp_fabric: bgpblue
+        bfd 0
+        ip_prefix 10.1.0.0/24
+        ip6_prefix fd00:10::/64
+        route_filter blue-allowed
+        zone blue
+
+bgp_node: bgpblue_pve
+        asn 65001
+        interfaces name=ens19
+        ip 10.1.0.1
+        ip6 fd00:10::1
+        role internal
diff --git a/proxmox-ve-config/tests/fabric/cfg/vrf_route_filter/prefix-lists.cfg b/proxmox-ve-config/tests/fabric/cfg/vrf_route_filter/prefix-lists.cfg
new file mode 100644
index 000000000000..624b03ae1b3f
--- /dev/null
+++ b/proxmox-ve-config/tests/fabric/cfg/vrf_route_filter/prefix-lists.cfg
@@ -0,0 +1,8 @@
+prefix-list: blue-allowed
+        entries action=permit,prefix=10.1.0.0/24,le=32,seq=10
+        entries action=permit,prefix=192.0.2.0/24,seq=20
+        entries action=permit,prefix=fd00:10::/64,le=128,seq=30
+
+prefix-list: red-allowed
+        entries action=permit,prefix=10.0.0.0/24,le=32,seq=10
+        entries action=permit,prefix=198.51.100.0/24,seq=20
diff --git a/proxmox-ve-config/tests/fabric/helper.rs b/proxmox-ve-config/tests/fabric/helper.rs
index 93404b8eb7af..31d15a6428e3 100644
--- a/proxmox-ve-config/tests/fabric/helper.rs
+++ b/proxmox-ve-config/tests/fabric/helper.rs
@@ -18,6 +18,42 @@ macro_rules! get_fabrics_config {
     }};
 }
 
+#[allow(unused_macros)]
+macro_rules! get_route_maps_config {
+    () => {{
+        fn f() {}
+        fn type_name_of<T>(_: T) -> &'static str {
+            std::any::type_name::<T>()
+        }
+        let mut name = type_name_of(f);
+
+        name = match &name[..name.len() - 3].rfind(':') {
+            Some(pos) => &name[pos + 1..name.len() - 3],
+            None => &name[..name.len() - 3],
+        };
+        let real_filename = format!("tests/fabric/cfg/{name}/route-maps.cfg");
+        &std::fs::read_to_string(real_filename).expect("cannot find route-map config file")
+    }};
+}
+
+#[allow(unused_macros)]
+macro_rules! get_prefix_lists_config {
+    () => {{
+        fn f() {}
+        fn type_name_of<T>(_: T) -> &'static str {
+            std::any::type_name::<T>()
+        }
+        let mut name = type_name_of(f);
+
+        name = match &name[..name.len() - 3].rfind(':') {
+            Some(pos) => &name[pos + 1..name.len() - 3],
+            None => &name[..name.len() - 3],
+        };
+        let real_filename = format!("tests/fabric/cfg/{name}/prefix-lists.cfg");
+        &std::fs::read_to_string(real_filename).expect("cannot find prefix-list config file")
+    }};
+}
+
 #[allow(unused_macros)]
 macro_rules! reference_name {
     ($suffix:expr) => {{
@@ -40,4 +76,8 @@ macro_rules! reference_name {
 #[allow(unused_imports)]
 pub(crate) use get_fabrics_config;
 #[allow(unused_imports)]
+pub(crate) use get_prefix_lists_config;
+#[allow(unused_imports)]
+pub(crate) use get_route_maps_config;
+#[allow(unused_imports)]
 pub(crate) use reference_name;
diff --git a/proxmox-ve-config/tests/fabric/main.rs b/proxmox-ve-config/tests/fabric/main.rs
index 88a24fa4afec..213d8cc0e262 100644
--- a/proxmox-ve-config/tests/fabric/main.rs
+++ b/proxmox-ve-config/tests/fabric/main.rs
@@ -3,10 +3,15 @@ use std::net::Ipv4Addr;
 use std::str::FromStr;
 
 use proxmox_frr::ser::bgp::{AddressFamilies, BgpRouter, CommonAddressFamilyOptions, L2vpnEvpnAF};
-use proxmox_frr::ser::route_map::RouteMapName;
-use proxmox_frr::ser::{FrrConfig, FrrProtocol, FrrWord, VrfName, serializer::dump};
-use proxmox_ve_config::sdn::fabric::{
-    FabricConfig, frr::build_fabric, section_config::node::NodeId,
+use proxmox_frr::ser::route_map::{AccessAction, RouteMapEntry, RouteMapName};
+use proxmox_frr::ser::{
+    FrrConfig, FrrProtocol, FrrWord, IpProtocolRouteMap, VrfName, serializer::dump,
+};
+use proxmox_section_config::typed::ApiSectionDataEntry;
+use proxmox_ve_config::sdn::{
+    fabric::{FabricConfig, frr::build_fabric, section_config::node::NodeId},
+    prefix_list::{PrefixList, frr::build_frr_prefix_lists},
+    route_map::{RouteMap, frr::build_frr_route_maps},
 };
 
 mod helper;
@@ -219,9 +224,31 @@ bgp_node: bgp_pve
 "#;
     let config = FabricConfig::parse_section_config(raw).unwrap();
     let mut frr_config = FrrConfig::default();
+    let correct_src = RouteMapName::new("correct_src").unwrap();
+    let correct_src_entry = RouteMapEntry {
+        seq: 1,
+        action: AccessAction::Permit,
+        matches: Vec::new(),
+        sets: Vec::new(),
+        custom_frr_config: Vec::new(),
+        call: None,
+        exit_action: None,
+    };
+    frr_config
+        .routemaps
+        .insert(correct_src.clone(), vec![correct_src_entry.clone()]);
+    frr_config.protocol_routemaps.insert(
+        FrrProtocol::Bgp,
+        IpProtocolRouteMap {
+            v4: Some(correct_src.clone()),
+            v6: None,
+        },
+    );
 
     build_fabric(NodeId::from_str("pve").unwrap(), config, &mut frr_config).unwrap();
 
+    assert_eq!(frr_config.routemaps[&correct_src], vec![correct_src_entry]);
+
     let ospf_routemap = &frr_config.vrf_protocol_routemaps
         [&VrfName::Custom(FrrWord::new("vrf_zoneone").unwrap())][&FrrProtocol::Ospf];
     assert_eq!(
@@ -240,14 +267,173 @@ bgp_node: bgp_pve
             .get(&FrrProtocol::Ospf)
             .is_none()
     );
-    assert!(
-        frr_config
-            .protocol_routemaps
-            .get(&FrrProtocol::Bgp)
-            .is_none()
+    assert_eq!(
+        frr_config.protocol_routemaps[&FrrProtocol::Bgp].v4,
+        Some(correct_src)
     );
 }
 
+#[test]
+fn ospf_router_id_is_selected_per_vrf() {
+    let raw = r#"
+ospf_fabric: red
+        area 0
+        ip_prefix 10.0.0.0/24
+        zone red
+
+ospf_node: red_pve
+        interfaces name=eth0
+        ip 10.0.0.1
+
+ospf_fabric: blue
+        area 0
+        ip_prefix 10.0.0.0/24
+        zone blue
+
+ospf_node: blue_pve
+        interfaces name=eth1
+        ip 10.0.0.2
+
+ospf_node: blue_pve2
+        interfaces name=eth1
+        ip 10.0.0.1
+"#;
+    let config = FabricConfig::parse_section_config(raw).unwrap();
+    let mut frr_config = FrrConfig::default();
+
+    build_fabric(NodeId::from_str("pve").unwrap(), config, &mut frr_config).unwrap();
+
+    let router_id = |vrf: &str| {
+        frr_config.ospf.vrf_router[&VrfName::Custom(FrrWord::new(vrf).unwrap())].router_id
+    };
+    assert_eq!(router_id("vrf_red"), Ipv4Addr::new(10, 0, 0, 1));
+    assert_eq!(router_id("vrf_blue"), Ipv4Addr::new(10, 0, 0, 2));
+}
+
+#[test]
+fn vrf() {
+    let config = FabricConfig::parse_section_config(helper::get_fabrics_config!()).unwrap();
+    let route_maps =
+        RouteMap::parse_section_config("route-maps.cfg", helper::get_route_maps_config!()).unwrap();
+    let mut frr_config = FrrConfig::default();
+
+    build_frr_route_maps(
+        route_maps
+            .into_iter()
+            .map(|(_, route_map_entry)| route_map_entry),
+        &mut frr_config,
+    )
+    .unwrap();
+    build_fabric(
+        NodeId::from_str("pve").expect("invalid nodeid"),
+        config,
+        &mut frr_config,
+    )
+    .unwrap();
+
+    let output = dump(&frr_config).expect("error dumping stuff");
+
+    insta::assert_snapshot!(helper::reference_name!("pve"), output);
+}
+
+/// Fabrics in the default VRF and in a zone VRF on the same node.
+#[test]
+fn vrf_default() {
+    let config = FabricConfig::parse_section_config(helper::get_fabrics_config!()).unwrap();
+    let mut frr_config = FrrConfig::default();
+
+    build_fabric(
+        NodeId::from_str("pve").expect("invalid nodeid"),
+        config,
+        &mut frr_config,
+    )
+    .unwrap();
+
+    let output = dump(&frr_config).expect("error dumping stuff");
+
+    insta::assert_snapshot!(helper::reference_name!("pve"), output);
+}
+
+/// Redistributions of OSPF and BGP fabrics in zone VRFs.
+#[test]
+fn vrf_redistribute() {
+    let config = FabricConfig::parse_section_config(helper::get_fabrics_config!()).unwrap();
+    let route_maps =
+        RouteMap::parse_section_config("route-maps.cfg", helper::get_route_maps_config!()).unwrap();
+    let mut frr_config = FrrConfig::default();
+
+    build_frr_route_maps(
+        route_maps
+            .into_iter()
+            .map(|(_, route_map_entry)| route_map_entry),
+        &mut frr_config,
+    )
+    .unwrap();
+    build_fabric(
+        NodeId::from_str("pve").expect("invalid nodeid"),
+        config,
+        &mut frr_config,
+    )
+    .unwrap();
+
+    let output = dump(&frr_config).expect("error dumping stuff");
+
+    insta::assert_snapshot!(helper::reference_name!("pve"), output);
+}
+
+/// Route filters of OSPF and BGP fabrics in zone VRFs.
+#[test]
+fn vrf_route_filter() {
+    let config = FabricConfig::parse_section_config(helper::get_fabrics_config!()).unwrap();
+    let prefix_lists =
+        PrefixList::parse_section_config("prefix-lists.cfg", helper::get_prefix_lists_config!())
+            .unwrap();
+    let mut frr_config = FrrConfig::default();
+
+    build_frr_prefix_lists(
+        prefix_lists.into_iter().map(|(_, prefix_list)| prefix_list),
+        &mut frr_config,
+    )
+    .unwrap();
+    build_fabric(
+        NodeId::from_str("pve").expect("invalid nodeid"),
+        config,
+        &mut frr_config,
+    )
+    .unwrap();
+
+    let output = dump(&frr_config).expect("error dumping stuff");
+
+    insta::assert_snapshot!(helper::reference_name!("pve"), output);
+}
+
+/// IPv6-only and dual-stack BGP fabrics in zone VRFs.
+#[test]
+fn vrf_ipv6() {
+    let config = FabricConfig::parse_section_config(helper::get_fabrics_config!()).unwrap();
+    let route_maps =
+        RouteMap::parse_section_config("route-maps.cfg", helper::get_route_maps_config!()).unwrap();
+    let mut frr_config = FrrConfig::default();
+
+    build_frr_route_maps(
+        route_maps
+            .into_iter()
+            .map(|(_, route_map_entry)| route_map_entry),
+        &mut frr_config,
+    )
+    .unwrap();
+    build_fabric(
+        NodeId::from_str("pve").expect("invalid nodeid"),
+        config,
+        &mut frr_config,
+    )
+    .unwrap();
+
+    let output = dump(&frr_config).expect("error dumping stuff");
+
+    insta::assert_snapshot!(helper::reference_name!("pve"), output);
+}
+
 #[test]
 fn bgp_default() {
     let config = FabricConfig::parse_section_config(helper::get_fabrics_config!()).unwrap();
diff --git a/proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_default_pve.snap b/proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_default_pve.snap
new file mode 100644
index 000000000000..1a612b5ffb7a
--- /dev/null
+++ b/proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_default_pve.snap
@@ -0,0 +1,113 @@
+---
+source: proxmox-ve-config/tests/fabric/main.rs
+expression: output
+---
+!
+router bgp 65001
+ bgp router-id 10.1.0.1
+ no bgp default ipv4-unicast
+ neighbor bgpdef peer-group
+ neighbor bgpdef remote-as external
+ neighbor ens20 interface peer-group bgpdef
+ !
+ address-family ipv4 unicast
+  network 10.1.0.1/32
+  neighbor bgpdef activate
+  neighbor bgpdef soft-reconfiguration inbound
+  neighbor bgpdef route-map pve_bgp_bgpdef_in in
+ exit-address-family
+exit
+!
+router bgp 65002 vrf vrf_red
+ bgp router-id 10.1.0.2
+ no bgp default ipv4-unicast
+ neighbor bgpred peer-group
+ neighbor bgpred remote-as external
+ neighbor ens21 interface peer-group bgpred
+ !
+ address-family ipv4 unicast
+  network 10.1.0.2/32
+  neighbor bgpred activate
+  neighbor bgpred soft-reconfiguration inbound
+  neighbor bgpred route-map pve_bgp_bgpred_in in
+ exit-address-family
+exit
+!
+router ospf
+ ospf router-id 10.0.0.1
+exit
+!
+router ospf vrf vrf_red
+ ospf router-id 10.0.0.2
+exit
+!
+interface dummy_ospfred vrf vrf_red
+ ip ospf area 0
+ ip ospf passive
+exit
+!
+interface dummy_underlay
+ ip ospf area 0
+ ip ospf passive
+exit
+!
+interface ens18
+ ip ospf area 0
+ ip ospf network point-to-point
+exit
+!
+interface ens19 vrf vrf_red
+ ip ospf area 0
+ ip ospf network point-to-point
+exit
+!
+access-list pve_bgp_bgpdef_ips permit 10.1.0.0/24
+!
+access-list pve_bgp_bgpred_ips permit 10.1.0.0/24
+!
+access-list pve_ospf_ospfred_ips permit 10.0.0.0/24
+!
+access-list pve_ospf_underlay_ips permit 10.0.0.0/24
+!
+route-map pve_bgp permit 100
+ match ip address pve_bgp_bgpdef_ips
+ set src 10.1.0.1
+exit
+!
+route-map pve_bgp permit 65535
+exit
+!
+route-map pve_bgp_bgpdef_in permit 10
+ match ip address pve_bgp_bgpdef_ips
+exit
+!
+route-map pve_bgp_bgpred_in permit 10
+ match ip address pve_bgp_bgpred_ips
+exit
+!
+route-map pve_bgp_vrf_red permit 110
+ match ip address pve_bgp_bgpred_ips
+ set src 10.1.0.2
+exit
+!
+route-map pve_bgp_vrf_red permit 65535
+exit
+!
+route-map pve_ospf permit 130
+ match ip address pve_ospf_underlay_ips
+ set src 10.0.0.1
+exit
+!
+route-map pve_ospf_vrf_red permit 120
+ match ip address pve_ospf_ospfred_ips
+ set src 10.0.0.2
+exit
+!
+ip protocol bgp route-map pve_bgp
+!
+ip protocol ospf route-map pve_ospf
+!
+vrf vrf_red
+ ip protocol bgp route-map pve_bgp_vrf_red
+ ip protocol ospf route-map pve_ospf_vrf_red
+exit-vrf
diff --git a/proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_ipv6_pve.snap b/proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_ipv6_pve.snap
new file mode 100644
index 000000000000..9ce4701a0d0d
--- /dev/null
+++ b/proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_ipv6_pve.snap
@@ -0,0 +1,102 @@
+---
+source: proxmox-ve-config/tests/fabric/main.rs
+expression: output
+---
+!
+router bgp 65002 vrf vrf_blue
+ bgp router-id 10.1.0.1
+ no bgp default ipv4-unicast
+ neighbor bgpblue peer-group
+ neighbor bgpblue remote-as external
+ neighbor ens19 interface peer-group bgpblue
+ !
+ address-family ipv4 unicast
+  network 10.1.0.1/32
+  neighbor bgpblue activate
+  neighbor bgpblue soft-reconfiguration inbound
+  neighbor bgpblue route-map pve_bgp_bgpblue_in in
+ exit-address-family
+ !
+ address-family ipv6 unicast
+  network fd00:20::1/128
+  neighbor bgpblue activate
+  neighbor bgpblue soft-reconfiguration inbound
+  neighbor bgpblue route-map pve_bgp6_bgpblue_in in
+ exit-address-family
+exit
+!
+router bgp 65001 vrf vrf_red
+ bgp router-id 5.76.46.251
+ no bgp default ipv4-unicast
+ neighbor bgpred peer-group
+ neighbor bgpred remote-as external
+ neighbor ens18 interface peer-group bgpred
+ !
+ address-family ipv6 unicast
+  network fd00:10::1/128
+  neighbor bgpred activate
+  neighbor bgpred soft-reconfiguration inbound
+  neighbor bgpred route-map pve_bgp6_bgpred_in in
+  neighbor bgpred route-map red-out out
+ exit-address-family
+exit
+!
+ipv6 access-list pve_bgp_bgpblue_ip6s permit fd00:20::/64
+!
+access-list pve_bgp_bgpblue_ips permit 10.1.0.0/24
+!
+ipv6 access-list pve_bgp_bgpred_ip6s permit fd00:10::/64
+!
+route-map pve_bgp6_bgpblue_in permit 10
+ match ipv6 address pve_bgp_bgpblue_ip6s
+exit
+!
+route-map pve_bgp6_bgpred_in permit 10
+ match ipv6 address pve_bgp_bgpred_ip6s
+ call red-in
+exit
+!
+route-map pve_bgp6_vrf_blue permit 110
+ match ipv6 address pve_bgp_bgpblue_ip6s
+ set src fd00:20::1
+exit
+!
+route-map pve_bgp6_vrf_blue permit 65535
+exit
+!
+route-map pve_bgp6_vrf_red permit 120
+ match ipv6 address pve_bgp_bgpred_ip6s
+ set src fd00:10::1
+exit
+!
+route-map pve_bgp6_vrf_red permit 65535
+exit
+!
+route-map pve_bgp_bgpblue_in permit 10
+ match ip address pve_bgp_bgpblue_ips
+exit
+!
+route-map pve_bgp_vrf_blue permit 100
+ match ip address pve_bgp_bgpblue_ips
+ set src 10.1.0.1
+exit
+!
+route-map pve_bgp_vrf_blue permit 65535
+exit
+!
+route-map red-in permit 10
+ set local-preference 100
+exit
+!
+route-map red-out permit 10
+ set metric 10
+exit
+!
+vrf vrf_blue
+ ip protocol bgp route-map pve_bgp_vrf_blue
+ ipv6 protocol bgp route-map pve_bgp6_vrf_blue
+exit-vrf
+!
+vrf vrf_red
+ ipv6 protocol bgp route-map pve_bgp6_vrf_red
+exit-vrf
diff --git a/proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_pve.snap b/proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_pve.snap
new file mode 100644
index 000000000000..84973240deb4
--- /dev/null
+++ b/proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_pve.snap
@@ -0,0 +1,134 @@
+---
+source: proxmox-ve-config/tests/fabric/main.rs
+expression: output
+---
+!
+router bgp 65002 vrf vrf_blue
+ bgp router-id 10.1.0.1
+ no bgp default ipv4-unicast
+ neighbor bgpblue peer-group
+ neighbor bgpblue remote-as external
+ neighbor ens21 interface peer-group bgpblue
+ !
+ address-family ipv4 unicast
+  network 10.1.0.1/32
+  neighbor bgpblue activate
+  neighbor bgpblue soft-reconfiguration inbound
+  neighbor bgpblue route-map pve_bgp_bgpblue_in in
+  neighbor bgpblue route-map blue-out out
+ exit-address-family
+exit
+!
+router bgp 65001 vrf vrf_red
+ bgp router-id 10.1.0.1
+ no bgp default ipv4-unicast
+ neighbor bgpred peer-group
+ neighbor bgpred remote-as external
+ neighbor ens20 interface peer-group bgpred
+ !
+ address-family ipv4 unicast
+  network 10.1.0.1/32
+  neighbor bgpred activate
+  neighbor bgpred soft-reconfiguration inbound
+  neighbor bgpred route-map pve_bgp_bgpred_in in
+  neighbor bgpred route-map red-out out
+ exit-address-family
+exit
+!
+router ospf vrf vrf_blue
+ ospf router-id 10.0.0.1
+exit
+!
+router ospf vrf vrf_red
+ ospf router-id 10.0.0.1
+exit
+!
+interface dummy_ospfblue vrf vrf_blue
+ ip ospf area 0
+ ip ospf passive
+exit
+!
+interface dummy_ospfred vrf vrf_red
+ ip ospf area 0
+ ip ospf passive
+exit
+!
+interface ens18 vrf vrf_red
+ ip ospf area 0
+ ip ospf network point-to-point
+exit
+!
+interface ens19 vrf vrf_blue
+ ip ospf area 0
+ ip ospf network point-to-point
+exit
+!
+access-list pve_bgp_bgpblue_ips permit 10.1.0.0/24
+!
+access-list pve_bgp_bgpred_ips permit 10.1.0.0/24
+!
+access-list pve_ospf_ospfblue_ips permit 10.0.0.0/24
+!
+access-list pve_ospf_ospfred_ips permit 10.0.0.0/24
+!
+route-map blue-in permit 10
+ set local-preference 200
+exit
+!
+route-map blue-out permit 10
+ set metric 20
+exit
+!
+route-map pve_bgp_bgpblue_in permit 10
+ match ip address pve_bgp_bgpblue_ips
+ call blue-in
+exit
+!
+route-map pve_bgp_bgpred_in permit 10
+ match ip address pve_bgp_bgpred_ips
+ call red-in
+exit
+!
+route-map pve_bgp_vrf_blue permit 100
+ match ip address pve_bgp_bgpblue_ips
+ set src 10.1.0.1
+exit
+!
+route-map pve_bgp_vrf_blue permit 65535
+exit
+!
+route-map pve_bgp_vrf_red permit 110
+ match ip address pve_bgp_bgpred_ips
+ set src 10.1.0.1
+exit
+!
+route-map pve_bgp_vrf_red permit 65535
+exit
+!
+route-map pve_ospf_vrf_blue permit 120
+ match ip address pve_ospf_ospfblue_ips
+ set src 10.0.0.1
+exit
+!
+route-map pve_ospf_vrf_red permit 130
+ match ip address pve_ospf_ospfred_ips
+ set src 10.0.0.1
+exit
+!
+route-map red-in permit 10
+ set local-preference 100
+exit
+!
+route-map red-out permit 10
+ set metric 10
+exit
+!
+vrf vrf_blue
+ ip protocol bgp route-map pve_bgp_vrf_blue
+ ip protocol ospf route-map pve_ospf_vrf_blue
+exit-vrf
+!
+vrf vrf_red
+ ip protocol bgp route-map pve_bgp_vrf_red
+ ip protocol ospf route-map pve_ospf_vrf_red
+exit-vrf
diff --git a/proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_redistribute_pve.snap b/proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_redistribute_pve.snap
new file mode 100644
index 000000000000..af7afd7b9fea
--- /dev/null
+++ b/proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_redistribute_pve.snap
@@ -0,0 +1,74 @@
+---
+source: proxmox-ve-config/tests/fabric/main.rs
+expression: output
+---
+!
+router bgp 65001 vrf vrf_blue
+ bgp router-id 10.1.0.1
+ no bgp default ipv4-unicast
+ neighbor bgpblue peer-group
+ neighbor bgpblue remote-as external
+ neighbor ens19 interface peer-group bgpblue
+ !
+ address-family ipv4 unicast
+  network 10.1.0.1/32
+  neighbor bgpblue activate
+  neighbor bgpblue soft-reconfiguration inbound
+  neighbor bgpblue route-map pve_bgp_bgpblue_in in
+  redistribute connected
+  redistribute ospf metric 100 route-map redistribute-ospf
+ exit-address-family
+exit
+!
+router ospf vrf vrf_red
+ ospf router-id 10.0.0.1
+ redistribute connected
+ redistribute static metric 50 route-map redistribute-static
+exit
+!
+interface dummy_ospfred vrf vrf_red
+ ip ospf area 0
+ ip ospf passive
+exit
+!
+interface ens18 vrf vrf_red
+ ip ospf area 0
+ ip ospf network point-to-point
+exit
+!
+access-list pve_bgp_bgpblue_ips permit 10.1.0.0/24
+!
+access-list pve_ospf_ospfred_ips permit 10.0.0.0/24
+!
+route-map pve_bgp_bgpblue_in permit 10
+ match ip address pve_bgp_bgpblue_ips
+exit
+!
+route-map pve_bgp_vrf_blue permit 100
+ match ip address pve_bgp_bgpblue_ips
+ set src 10.1.0.1
+exit
+!
+route-map pve_bgp_vrf_blue permit 65535
+exit
+!
+route-map pve_ospf_vrf_red permit 110
+ match ip address pve_ospf_ospfred_ips
+ set src 10.0.0.1
+exit
+!
+route-map redistribute-ospf permit 10
+ set local-preference 150
+exit
+!
+route-map redistribute-static permit 10
+ set metric 30
+exit
+!
+vrf vrf_blue
+ ip protocol bgp route-map pve_bgp_vrf_blue
+exit-vrf
+!
+vrf vrf_red
+ ip protocol ospf route-map pve_ospf_vrf_red
+exit-vrf
diff --git a/proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_route_filter_pve.snap b/proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_route_filter_pve.snap
new file mode 100644
index 000000000000..fa4a3f71e55b
--- /dev/null
+++ b/proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_route_filter_pve.snap
@@ -0,0 +1,85 @@
+---
+source: proxmox-ve-config/tests/fabric/main.rs
+expression: output
+---
+!
+router bgp 65001 vrf vrf_blue
+ bgp router-id 10.1.0.1
+ no bgp default ipv4-unicast
+ neighbor bgpblue peer-group
+ neighbor bgpblue remote-as external
+ neighbor ens19 interface peer-group bgpblue
+ !
+ address-family ipv4 unicast
+  network 10.1.0.1/32
+  neighbor bgpblue activate
+  neighbor bgpblue soft-reconfiguration inbound
+  neighbor bgpblue route-map pve_bgp_bgpblue_in in
+ exit-address-family
+ !
+ address-family ipv6 unicast
+  network fd00:10::1/128
+  neighbor bgpblue activate
+  neighbor bgpblue soft-reconfiguration inbound
+  neighbor bgpblue route-map pve_bgp6_bgpblue_in in
+ exit-address-family
+exit
+!
+ip prefix-list blue-allowed seq 10 permit 10.1.0.0/24 le 32
+ip prefix-list blue-allowed seq 20 permit 192.0.2.0/24
+ipv6 prefix-list blue-allowed seq 30 permit fd00:10::/64 le 128
+!
+ip prefix-list red-allowed seq 10 permit 10.0.0.0/24 le 32
+ip prefix-list red-allowed seq 20 permit 198.51.100.0/24
+!
+router ospf vrf vrf_red
+ ospf router-id 10.0.0.1
+exit
+!
+interface dummy_ospfred vrf vrf_red
+ ip ospf area 0
+ ip ospf passive
+exit
+!
+interface ens18 vrf vrf_red
+ ip ospf area 0
+ ip ospf network point-to-point
+exit
+!
+route-map pve_bgp6_bgpblue_in permit 10
+ match ipv6 address prefix-list blue-allowed
+exit
+!
+route-map pve_bgp6_vrf_blue permit 110
+ match ipv6 address prefix-list blue-allowed
+ set src fd00:10::1
+exit
+!
+route-map pve_bgp6_vrf_blue permit 65535
+exit
+!
+route-map pve_bgp_bgpblue_in permit 10
+ match ip address prefix-list blue-allowed
+exit
+!
+route-map pve_bgp_vrf_blue permit 100
+ match ip address prefix-list blue-allowed
+ set src 10.1.0.1
+exit
+!
+route-map pve_bgp_vrf_blue permit 65535
+exit
+!
+route-map pve_ospf_vrf_red permit 120
+ match ip address prefix-list red-allowed
+ set src 10.0.0.1
+exit
+!
+vrf vrf_blue
+ ip protocol bgp route-map pve_bgp_vrf_blue
+ ipv6 protocol bgp route-map pve_bgp6_vrf_blue
+exit-vrf
+!
+vrf vrf_red
+ ip protocol ospf route-map pve_ospf_vrf_red
+exit-vrf
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH proxmox-ve-rs v3 07/28] sdn: allow static routes in simple zone VRFs
  2026-11-19 19:40 [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/28] SDN VRF support Gabriel Goller
                   ` (5 preceding siblings ...)
  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 ` 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
                   ` (20 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Gabriel Goller @ 2026-11-19 19:40 UTC (permalink / raw)
  To: pve-devel

Allow simple zones to reach upstream networks through zone-wide static
routes, without requiring node-local FRR overrides. Install routes in
vrf_<zone> when dedicated-vrf is enabled, or in the default routing table
otherwise. Only generate routes on nodes that belong to the zone.

Support IPv4 and IPv6 routes, with an optional outgoing interface and
administrative distance.

Reject prefixes with host bits set, since staticd normalizes them and
frr-reload would otherwise replace them on every reload. Keep the perl
vrf field as the outgoing interface for existing EVPN routes, separate
from the VRF in which the route is installed.

Skip invalid routes with a warning instead of failing, so a single bad
route in zones.cfg does not abort generating the whole FRR config.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 proxmox-frr-templates/templates/bgpd.jinja    |   7 +-
 .../templates/frr.conf.jinja                  |   3 +-
 .../templates/ip_routes.jinja                 |  13 +-
 proxmox-frr/src/ser/mod.rs                    |  23 ++-
 proxmox-ve-config/src/sdn/mod.rs              |   1 +
 proxmox-ve-config/src/sdn/static_route.rs     | 181 +++++++++++++++++
 .../tests/static_routes/cfg/fabrics.cfg       |  19 ++
 .../tests/static_routes/cfg/zones.json        |  20 ++
 proxmox-ve-config/tests/static_routes/main.rs | 188 ++++++++++++++++++
 ...c_routes__preserve_legacy_evpn_routes.snap |  12 ++
 ...tatic_routes__simple_zone_routes_pve1.snap |  20 ++
 ...tatic_routes__simple_zone_routes_pve2.snap |  10 +
 ...outes__vrf_fabrics_with_static_routes.snap |  70 +++++++
 13 files changed, 553 insertions(+), 14 deletions(-)
 create mode 100644 proxmox-ve-config/src/sdn/static_route.rs
 create mode 100644 proxmox-ve-config/tests/static_routes/cfg/fabrics.cfg
 create mode 100644 proxmox-ve-config/tests/static_routes/cfg/zones.json
 create mode 100644 proxmox-ve-config/tests/static_routes/main.rs
 create mode 100644 proxmox-ve-config/tests/static_routes/snapshots/static_routes__preserve_legacy_evpn_routes.snap
 create mode 100644 proxmox-ve-config/tests/static_routes/snapshots/static_routes__simple_zone_routes_pve1.snap
 create mode 100644 proxmox-ve-config/tests/static_routes/snapshots/static_routes__simple_zone_routes_pve2.snap
 create mode 100644 proxmox-ve-config/tests/static_routes/snapshots/static_routes__vrf_fabrics_with_static_routes.snap

diff --git a/proxmox-frr-templates/templates/bgpd.jinja b/proxmox-frr-templates/templates/bgpd.jinja
index 61956bb0ef49..1fc950083ce5 100644
--- a/proxmox-frr-templates/templates/bgpd.jinja
+++ b/proxmox-frr-templates/templates/bgpd.jinja
@@ -1,4 +1,5 @@
 {% from "bgp_router.jinja" import bgp_router %}
+{% from "ip_routes.jinja" import static_route %}
 {% for vrf_name, vrf in bgp.vrfs|items %}
 !
 vrf {{ vrf_name }}
@@ -6,11 +7,7 @@ vrf {{ vrf_name }}
  vni {{ vrf.vni }}
 {% endif %}
 {% for ip_route in vrf.ip_routes %}
-{% if ip_route.vrf %}
- {{ "ipv6" if ip_route.is_ipv6 else "ip" }} route {{ ip_route.prefix }} {{ ip_route.via }} {{ ip_route.vrf }}
-{% else %}
- {{ "ipv6" if ip_route.is_ipv6 else "ip" }} route {{ ip_route.prefix }} {{ ip_route.via }}
-{% endif %}
+ {{ static_route(ip_route) }}
 {% endfor %}
 {% for line in vrf.custom_frr_config %}
 {{ line }}
diff --git a/proxmox-frr-templates/templates/frr.conf.jinja b/proxmox-frr-templates/templates/frr.conf.jinja
index 1f98489e09fb..a6cd2afd10cc 100644
--- a/proxmox-frr-templates/templates/frr.conf.jinja
+++ b/proxmox-frr-templates/templates/frr.conf.jinja
@@ -1,3 +1,4 @@
+{% from "ip_routes.jinja" import ip_routes as render_ip_routes %}
 {% include "bgpd.jinja" %}
 {% include "isisd.jinja" %}
 {% include "prefix_lists.jinja" %}
@@ -8,5 +9,5 @@
 {% include "ospfd.jinja" %}
 {% include "access_lists.jinja" %}
 {% include "route_maps.jinja" %}
-{% include "ip_routes.jinja" %}
+{{ render_ip_routes(ip_routes) -}}
 {% include "protocol_routemaps.jinja" %}
diff --git a/proxmox-frr-templates/templates/ip_routes.jinja b/proxmox-frr-templates/templates/ip_routes.jinja
index 3e33a709e821..d0930ed4ba95 100644
--- a/proxmox-frr-templates/templates/ip_routes.jinja
+++ b/proxmox-frr-templates/templates/ip_routes.jinja
@@ -1,8 +1,9 @@
-{% for ip_route in ip_routes %}
+{% macro static_route(route) -%}
+{{ "ipv6" if route.is_ipv6 else "ip" }} route {{ route.prefix }}{% if route.via %} {{ route.via }}{% endif %}{% if route.vrf %} {{ route.vrf }}{% endif %}{% if route.distance and route.distance != 1 %} {{ route.distance }}{% endif %}{% if route.destination_vrf %} vrf {{ route.destination_vrf }}{% endif %}
+{%- endmacro %}
+{% macro ip_routes(routes) -%}
+{% for ip_route in routes %}
 !
-{% if ip_route.vrf %}
-{{ "ipv6" if ip_route.is_ipv6 else "ip" }} route {{ ip_route.prefix }} {{ ip_route.via }} {{ ip_route.vrf }}
-{% else %}
-{{ "ipv6" if ip_route.is_ipv6 else "ip" }} route {{ ip_route.prefix }} {{ ip_route.via }}
-{% endif %}
+{{ static_route(ip_route) }}
 {% endfor %}
+{%- endmacro %}
diff --git a/proxmox-frr/src/ser/mod.rs b/proxmox-frr/src/ser/mod.rs
index 8d3588e93c36..468a5d914135 100644
--- a/proxmox-frr/src/ser/mod.rs
+++ b/proxmox-frr/src/ser/mod.rs
@@ -171,8 +171,27 @@ pub struct IpRoute {
     #[serde(default, deserialize_with = "proxmox_serde::perl::deserialize_bool")]
     is_ipv6: bool,
     prefix: Cidr,
-    via: IpOrInterface,
-    vrf: Option<InterfaceName>,
+    pub via: Option<IpOrInterface>,
+    /// Outgoing interface (e.g. EVPN's xvrf_<zone> veth). Keep the "vrf" perl
+    /// key for backwards compat.
+    #[serde(rename = "vrf")]
+    pub iface: Option<InterfaceName>,
+    pub distance: Option<u8>,
+    /// VRF in which to install the route -- None selects the default VRF.
+    pub destination_vrf: Option<InterfaceName>,
+}
+
+impl IpRoute {
+    pub fn new(prefix: Cidr, via: Option<IpOrInterface>) -> Self {
+        Self {
+            is_ipv6: prefix.is_ipv6(),
+            prefix,
+            via,
+            iface: None,
+            distance: None,
+            destination_vrf: None,
+        }
+    }
 }
 
 #[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
diff --git a/proxmox-ve-config/src/sdn/mod.rs b/proxmox-ve-config/src/sdn/mod.rs
index f4d40f590455..88987cd52283 100644
--- a/proxmox-ve-config/src/sdn/mod.rs
+++ b/proxmox-ve-config/src/sdn/mod.rs
@@ -3,6 +3,7 @@ pub mod fabric;
 pub mod ipam;
 pub mod prefix_list;
 pub mod route_map;
+pub mod static_route;
 pub mod wireguard;
 
 use std::{error::Error, fmt::Display, str::FromStr};
diff --git a/proxmox-ve-config/src/sdn/static_route.rs b/proxmox-ve-config/src/sdn/static_route.rs
new file mode 100644
index 000000000000..38ac85b281a4
--- /dev/null
+++ b/proxmox-ve-config/src/sdn/static_route.rs
@@ -0,0 +1,181 @@
+//! Static routes stored as repeatable property strings in simple SDN zones.
+
+use std::collections::BTreeMap;
+use std::net::IpAddr;
+
+use anyhow::{Error, bail};
+use proxmox_network_types::Cidr;
+use proxmox_schema::{api, property_string::PropertyString};
+use serde::{Deserialize, Serialize};
+
+use crate::common::valid::Validatable;
+use crate::sdn::ZoneName;
+use crate::sdn::fabric::section_config::interface::InterfaceName;
+
+#[api(
+    properties: {
+        via: { type: String, optional: true, format: &proxmox_schema::api_types::IP_FORMAT },
+        iface: { type: InterfaceName, optional: true },
+        distance: { type: Integer, optional: true, minimum: 1, maximum: 255 },
+    },
+)]
+#[derive(Clone, Debug, Serialize, Deserialize)]
+#[serde(rename_all = "kebab-case", deny_unknown_fields)]
+/// A static route in a simple zone. The destination VRF is determined by the zone.
+pub struct StaticRoute {
+    /// Destination prefix, including 0.0.0.0/0 or ::/0 for a default route.
+    pub prefix: Cidr,
+    /// Next-hop gateway address.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub via: Option<IpAddr>,
+    /// Outgoing interface, required for IPv6 link-local gateways.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub iface: Option<InterfaceName>,
+    /// Administrative distance. FRR's default is 1; 255 prevents installation.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub distance: Option<u8>,
+}
+
+impl Validatable for StaticRoute {
+    type Error = Error;
+
+    fn validate(&self) -> Result<(), Error> {
+        // staticd stores the network address, so a prefix with host bits set would never match
+        // the running config and frr-reload would replace the route on every reload
+        let canonical = match self.prefix {
+            Cidr::Ipv4(cidr) => Cidr::Ipv4(cidr.canonical()),
+            Cidr::Ipv6(cidr) => Cidr::Ipv6(cidr.canonical()),
+        };
+        if self.prefix != canonical {
+            bail!(
+                "prefix '{}' has host bits set, use '{canonical}' instead",
+                self.prefix
+            );
+        }
+        if self.via.is_none() && self.iface.is_none() {
+            bail!("a static route requires a gateway (via) or an outgoing interface (iface)");
+        }
+        if let Some(via) = self.via {
+            if via.is_ipv6() != self.prefix.is_ipv6() {
+                bail!("gateway and destination prefix must use the same address family");
+            }
+            if let IpAddr::V6(via) = via {
+                if via.is_unicast_link_local() && self.iface.is_none() {
+                    bail!("an IPv6 link-local gateway requires an outgoing interface (iface)");
+                }
+            }
+        }
+        if let Some(iface) = &self.iface {
+            let iface = iface.as_str();
+            if ["null0", "blackhole", "reject"].contains(&iface.to_ascii_lowercase().as_str())
+                || iface.parse::<IpAddr>().is_ok()
+            {
+                bail!("'{iface}' is not an outgoing interface");
+            }
+        }
+        if self.distance == Some(0) {
+            bail!("administrative distance must be between 1 and 255");
+        }
+        Ok(())
+    }
+}
+
+/// The subset of zones.cfg needed to generate static routes, as represented by the perl parser.
+#[derive(Clone, Debug, Default, Deserialize)]
+pub struct ZoneRoutesConfig {
+    pub ids: BTreeMap<ZoneName, ZoneRoutes>,
+}
+
+/// Routing-related properties of a single SDN zone.
+#[derive(Clone, Debug, Deserialize)]
+pub struct ZoneRoutes {
+    #[serde(rename = "type")]
+    pub ty: String,
+    #[serde(
+        default,
+        rename = "dedicated-vrf",
+        deserialize_with = "proxmox_serde::perl::deserialize_bool"
+    )]
+    pub dedicated_vrf: bool,
+    pub nodes: Option<BTreeMap<String, serde_json::Value>>,
+    #[serde(default, deserialize_with = "deserialize_routes_lossy")]
+    pub route: Vec<PropertyString<StaticRoute>>,
+}
+
+/// Skip routes that do not parse, so that a single invalid route does not fail the whole config.
+fn deserialize_routes_lossy<'de, D>(
+    deserializer: D,
+) -> Result<Vec<PropertyString<StaticRoute>>, D::Error>
+where
+    D: serde::Deserializer<'de>,
+{
+    let routes = Vec::<String>::deserialize(deserializer)?;
+    Ok(routes
+        .into_iter()
+        .filter_map(|route| match route.parse() {
+            Ok(parsed) => Some(parsed),
+            Err(err) => {
+                log::warn!("skipping static route '{route}': {err}");
+                None
+            }
+        })
+        .collect())
+}
+
+#[cfg(feature = "frr")]
+impl ZoneRoutesConfig {
+    /// Generate routes only on nodes participating in the zone.
+    ///
+    /// Invalid routes are skipped with a warning, so that they do not prevent generating the rest
+    /// of the FRR configuration.
+    pub fn routes_for_node(&self, node: &str) -> Vec<proxmox_frr::ser::IpRoute> {
+        let mut routes = Vec::new();
+        for (zone, config) in &self.ids {
+            if config.route.is_empty() {
+                continue;
+            }
+            if config.ty != "simple" {
+                log::warn!("zone '{zone}': static routes are only supported in simple zones");
+                continue;
+            }
+            if config
+                .nodes
+                .as_ref()
+                .is_some_and(|nodes| !nodes.contains_key(node))
+            {
+                continue;
+            }
+            for route in &config.route {
+                match zone_route_to_frr(zone, config, route) {
+                    Ok(route) => routes.push(route),
+                    Err(err) => {
+                        log::warn!("zone '{zone}': skipping route '{}': {err}", route.prefix)
+                    }
+                }
+            }
+        }
+        routes
+    }
+}
+
+#[cfg(feature = "frr")]
+fn zone_route_to_frr(
+    zone: &ZoneName,
+    config: &ZoneRoutes,
+    route: &StaticRoute,
+) -> Result<proxmox_frr::ser::IpRoute, Error> {
+    use proxmox_frr::ser::{InterfaceName as FrrInterfaceName, IpOrInterface, IpRoute};
+
+    let to_frr = |name: &InterfaceName| FrrInterfaceName::try_from(name.as_str());
+
+    route.validate()?;
+
+    let mut frr_route = IpRoute::new(route.prefix, route.via.map(IpOrInterface::Ip));
+    frr_route.iface = route.iface.as_ref().map(to_frr).transpose()?;
+    frr_route.distance = route.distance;
+    frr_route.destination_vrf = config
+        .dedicated_vrf
+        .then(|| FrrInterfaceName::try_from(format!("vrf_{zone}")))
+        .transpose()?;
+    Ok(frr_route)
+}
diff --git a/proxmox-ve-config/tests/static_routes/cfg/fabrics.cfg b/proxmox-ve-config/tests/static_routes/cfg/fabrics.cfg
new file mode 100644
index 000000000000..7c34f1f8e9bd
--- /dev/null
+++ b/proxmox-ve-config/tests/static_routes/cfg/fabrics.cfg
@@ -0,0 +1,19 @@
+ospf_fabric: blue
+        area 0
+        ip_prefix 10.0.0.0/24
+        zone blue
+
+ospf_node: blue_pve1
+        interfaces name=ens18
+        ip 10.0.0.1
+
+bgp_fabric: red
+        bfd 0
+        ip_prefix 10.0.0.0/24
+        zone red
+
+bgp_node: red_pve1
+        asn 65001
+        interfaces name=ens19
+        ip 10.0.0.1
+        role internal
diff --git a/proxmox-ve-config/tests/static_routes/cfg/zones.json b/proxmox-ve-config/tests/static_routes/cfg/zones.json
new file mode 100644
index 000000000000..9b19898b8b7b
--- /dev/null
+++ b/proxmox-ve-config/tests/static_routes/cfg/zones.json
@@ -0,0 +1,20 @@
+{
+    "ids": {
+        "blue": {
+            "type": "simple",
+            "dedicated-vrf": 1,
+            "route": [
+                "prefix=203.0.113.0/24,via=10.0.0.2",
+                "prefix=2001:db8:42::/64,via=fe80::2,iface=ens19"
+            ]
+        },
+        "red": {
+            "type": "simple",
+            "dedicated-vrf": 1,
+            "route": [
+                "prefix=203.0.113.0/24,via=10.0.0.3,iface=ens19,distance=20",
+                "prefix=2001:db8:42::/64,iface=ens19,distance=30"
+            ]
+        }
+    }
+}
diff --git a/proxmox-ve-config/tests/static_routes/main.rs b/proxmox-ve-config/tests/static_routes/main.rs
new file mode 100644
index 000000000000..a3a5c03ad560
--- /dev/null
+++ b/proxmox-ve-config/tests/static_routes/main.rs
@@ -0,0 +1,188 @@
+#![cfg(feature = "frr")]
+
+use anyhow::Error;
+use proxmox_frr::ser::{FrrConfig, IpRoute, serializer::dump};
+use proxmox_schema::property_string::PropertyString;
+use proxmox_ve_config::common::valid::Validatable;
+use proxmox_ve_config::sdn::fabric::{
+    FabricConfig, frr::build_fabric, section_config::node::NodeId,
+};
+use proxmox_ve_config::sdn::static_route::{StaticRoute, ZoneRoutesConfig};
+use serde_json::json;
+
+#[test]
+fn simple_zone_routes_to_frr() -> Result<(), Error> {
+    // This is the zones.cfg representation in the SDN running configuration. Repeated route
+    // properties remain an array, including routes with the same prefix for ECMP and failover.
+    let zones: ZoneRoutesConfig = serde_json::from_value(json!({"ids": {
+        "isolated": {
+            "type": "simple",
+            "dedicated-vrf": 1,
+            "nodes": {"pve1": 1},
+            "route": [
+                "prefix=0.0.0.0/0,via=192.0.2.1",
+                "prefix=0.0.0.0/0,via=192.0.2.2,distance=1",
+                "prefix=0.0.0.0/0,via=192.0.2.3,distance=200",
+                "prefix=::/0,via=fe80::1,iface=uplink0",
+                "prefix=2001:db8:20::/64,iface=uplink1,distance=10"
+            ]
+        },
+        "shared": {
+            "type": "simple",
+            "dedicated-vrf": 0,
+            "route": [
+                "prefix=0.0.0.0/0,via=198.51.100.1,iface=eth0,distance=5",
+                "prefix=::/0,via=2001:db8::1",
+                "prefix=203.0.113.0/24,iface=ppp0"
+            ]
+        },
+        "disabled": {
+            "type": "simple",
+            "nodes": {},
+            "route": ["prefix=192.0.2.0/24,iface=unused0"]
+        },
+        "unused": {"type": "vlan"}
+    }}))?;
+    let config = FrrConfig {
+        ip_routes: zones.routes_for_node("pve1"),
+        ..Default::default()
+    };
+    let output = dump(&config)?;
+    insta::assert_snapshot!("simple_zone_routes_pve1", output);
+
+    let config = FrrConfig {
+        ip_routes: zones.routes_for_node("pve2"),
+        ..Default::default()
+    };
+    let output = dump(&config)?;
+    insta::assert_snapshot!("simple_zone_routes_pve2", output);
+    Ok(())
+}
+
+#[test]
+fn validate_route_properties() {
+    for value in [
+        "prefix=0.0.0.0/0,via=192.0.2.1",
+        "prefix=::/0,via=fe80::1,iface=eth0",
+        "prefix=10.0.0.0/8,iface=eth0.100,distance=255",
+        "prefix=::/0,via=2001:db8::1",
+    ] {
+        let route = value.parse::<PropertyString<StaticRoute>>().unwrap();
+        route.validate().unwrap();
+        let encoded = route.to_property_string().unwrap();
+        encoded
+            .parse::<PropertyString<StaticRoute>>()
+            .unwrap()
+            .validate()
+            .unwrap();
+    }
+
+    for value in [
+        "prefix=0.0.0.0/0",
+        "via=192.0.2.1",
+        "prefix=0.0.0.0/33,via=192.0.2.1",
+        "prefix=10.0.0.1/24,via=192.0.2.1",
+        "prefix=2001:db8::1/64,via=2001:db8::ffff",
+        "prefix=0.0.0.0/0,via=2001:db8::1",
+        "prefix=::/0,via=192.0.2.1",
+        "prefix=::/0,via=fe80::1",
+        "prefix=0.0.0.0/0,iface=",
+        "prefix=0.0.0.0/0,iface=interface-too-long",
+        "prefix=0.0.0.0/0,iface=eth0 vrf default",
+        "prefix=0.0.0.0/0,iface=eth0\nexit",
+        "prefix=0.0.0.0/0,iface=blackhole",
+        "prefix=0.0.0.0/0,iface=Null0",
+        "prefix=0.0.0.0/0,iface=192.0.2.1",
+        "prefix=0.0.0.0/0,via=192.0.2.1,distance=0",
+        "prefix=0.0.0.0/0,via=192.0.2.1,distance=256",
+        "prefix=0.0.0.0/0,via=192.0.2.1,vrf=vrf_other",
+        "prefix=0.0.0.0/0,via=192.0.2.1,nexthop-vrf=default",
+        "prefix=0.0.0.0/0,via=192.0.2.1,via=192.0.2.2",
+    ] {
+        let result = value
+            .parse::<PropertyString<StaticRoute>>()
+            .map_err(Error::from)
+            .and_then(|route| route.validate());
+        assert!(result.is_err(), "accepted invalid route: {value}");
+    }
+}
+
+#[test]
+fn skip_routes_in_other_zone_types() -> Result<(), Error> {
+    for ty in ["vlan", "qinq", "vxlan", "evpn", "faucet"] {
+        let zones: ZoneRoutesConfig = serde_json::from_value(json!({"ids": {
+            "zone1": {"type": ty, "route": ["prefix=0.0.0.0/0,via=192.0.2.1"]}
+        }}))?;
+        assert!(zones.routes_for_node("pve1").is_empty());
+    }
+    Ok(())
+}
+
+#[test]
+fn skip_invalid_routes() -> Result<(), Error> {
+    // Invalid routes must not prevent generating the valid ones, or the rest of the FRR config.
+    let zones: ZoneRoutesConfig = serde_json::from_value(json!({"ids": {
+        "zone1": {
+            "type": "simple",
+            "route": [
+                "prefix=10.0.0.1/24,via=192.0.2.1",
+                "prefix=0.0.0.0/0,via=192.0.2.1",
+                "prefix=0.0.0.0/0,via=192.0.2.1,unknown=1",
+                "prefix=::/0,via=fe80::1"
+            ]
+        }
+    }}))?;
+    let config = FrrConfig {
+        ip_routes: zones.routes_for_node("pve1"),
+        ..Default::default()
+    };
+    assert_eq!(config.ip_routes.len(), 1);
+    assert!(dump(&config)?.contains("ip route 0.0.0.0/0 192.0.2.1"));
+    Ok(())
+}
+
+#[test]
+fn preserve_legacy_evpn_routes() -> Result<(), Error> {
+    // The historical 'vrf' field is actually the outgoing interface, not a destination VRF.
+    let route: IpRoute = serde_json::from_value(json!({
+        "prefix": "203.0.113.0/24", "via": "10.255.255.2", "vrf": "xvrf_zone1"
+    }))?;
+    let mut config = FrrConfig::default();
+    config.ip_routes.push(route);
+    config.ip_routes.push(serde_json::from_value(json!({
+        "is_ipv6": 1, "prefix": "2001:db8::/64", "via": "fe80::2", "vrf": "xvrf_zone1"
+    }))?);
+    assert_eq!(
+        serde_json::to_value(&config.ip_routes[0])?["vrf"],
+        "xvrf_zone1"
+    );
+    config.bgp.vrfs.insert(
+        "vrf_zone1".try_into()?,
+        serde_json::from_value(json!({
+            "ip_routes": [{"prefix": "203.0.113.0/24", "via": "null0"}]
+        }))?,
+    );
+    let output = dump(&config)?;
+    insta::assert_snapshot!(output);
+    Ok(())
+}
+
+#[test]
+fn vrf_fabrics_with_static_routes() -> Result<(), Error> {
+    let fabrics = FabricConfig::parse_section_config(include_str!("cfg/fabrics.cfg"))?;
+    let zones: ZoneRoutesConfig = serde_json::from_str(include_str!("cfg/zones.json"))?;
+    let mut config = FrrConfig::default();
+
+    // Both fabrics use the same subnet, and both zones route the same IPv4 and IPv6 prefixes.
+    // Static routes must retain their installation VRF, even with a different next-hop VRF.
+    build_fabric(
+        NodeId::from_string("pve1".to_owned())?,
+        fabrics,
+        &mut config,
+    )?;
+    config.ip_routes.extend(zones.routes_for_node("pve1"));
+
+    let output = dump(&config)?;
+    insta::assert_snapshot!(output);
+    Ok(())
+}
diff --git a/proxmox-ve-config/tests/static_routes/snapshots/static_routes__preserve_legacy_evpn_routes.snap b/proxmox-ve-config/tests/static_routes/snapshots/static_routes__preserve_legacy_evpn_routes.snap
new file mode 100644
index 000000000000..999c04522074
--- /dev/null
+++ b/proxmox-ve-config/tests/static_routes/snapshots/static_routes__preserve_legacy_evpn_routes.snap
@@ -0,0 +1,12 @@
+---
+source: proxmox-ve-config/tests/static_routes/main.rs
+expression: output
+---
+!
+vrf vrf_zone1
+ ip route 203.0.113.0/24 null0
+exit-vrf
+!
+ip route 203.0.113.0/24 10.255.255.2 xvrf_zone1
+!
+ipv6 route 2001:db8::/64 fe80::2 xvrf_zone1
diff --git a/proxmox-ve-config/tests/static_routes/snapshots/static_routes__simple_zone_routes_pve1.snap b/proxmox-ve-config/tests/static_routes/snapshots/static_routes__simple_zone_routes_pve1.snap
new file mode 100644
index 000000000000..c08421619c74
--- /dev/null
+++ b/proxmox-ve-config/tests/static_routes/snapshots/static_routes__simple_zone_routes_pve1.snap
@@ -0,0 +1,20 @@
+---
+source: proxmox-ve-config/tests/static_routes/main.rs
+expression: output
+---
+!
+ip route 0.0.0.0/0 192.0.2.1 vrf vrf_isolated
+!
+ip route 0.0.0.0/0 192.0.2.2 vrf vrf_isolated
+!
+ip route 0.0.0.0/0 192.0.2.3 200 vrf vrf_isolated
+!
+ipv6 route ::/0 fe80::1 uplink0 vrf vrf_isolated
+!
+ipv6 route 2001:db8:20::/64 uplink1 10 vrf vrf_isolated
+!
+ip route 0.0.0.0/0 198.51.100.1 eth0 5
+!
+ipv6 route ::/0 2001:db8::1
+!
+ip route 203.0.113.0/24 ppp0
diff --git a/proxmox-ve-config/tests/static_routes/snapshots/static_routes__simple_zone_routes_pve2.snap b/proxmox-ve-config/tests/static_routes/snapshots/static_routes__simple_zone_routes_pve2.snap
new file mode 100644
index 000000000000..ff327491d71a
--- /dev/null
+++ b/proxmox-ve-config/tests/static_routes/snapshots/static_routes__simple_zone_routes_pve2.snap
@@ -0,0 +1,10 @@
+---
+source: proxmox-ve-config/tests/static_routes/main.rs
+expression: output
+---
+!
+ip route 0.0.0.0/0 198.51.100.1 eth0 5
+!
+ipv6 route ::/0 2001:db8::1
+!
+ip route 203.0.113.0/24 ppp0
diff --git a/proxmox-ve-config/tests/static_routes/snapshots/static_routes__vrf_fabrics_with_static_routes.snap b/proxmox-ve-config/tests/static_routes/snapshots/static_routes__vrf_fabrics_with_static_routes.snap
new file mode 100644
index 000000000000..da021eebe049
--- /dev/null
+++ b/proxmox-ve-config/tests/static_routes/snapshots/static_routes__vrf_fabrics_with_static_routes.snap
@@ -0,0 +1,70 @@
+---
+source: proxmox-ve-config/tests/static_routes/main.rs
+expression: output
+---
+!
+router bgp 65001 vrf vrf_red
+ bgp router-id 10.0.0.1
+ no bgp default ipv4-unicast
+ neighbor red peer-group
+ neighbor red remote-as external
+ neighbor ens19 interface peer-group red
+ !
+ address-family ipv4 unicast
+  network 10.0.0.1/32
+  neighbor red activate
+  neighbor red soft-reconfiguration inbound
+  neighbor red route-map pve_bgp_red_in in
+ exit-address-family
+exit
+!
+router ospf vrf vrf_blue
+ ospf router-id 10.0.0.1
+exit
+!
+interface dummy_blue vrf vrf_blue
+ ip ospf area 0
+ ip ospf passive
+exit
+!
+interface ens18 vrf vrf_blue
+ ip ospf area 0
+ ip ospf network point-to-point
+exit
+!
+access-list pve_bgp_red_ips permit 10.0.0.0/24
+!
+access-list pve_ospf_blue_ips permit 10.0.0.0/24
+!
+route-map pve_bgp_red_in permit 10
+ match ip address pve_bgp_red_ips
+exit
+!
+route-map pve_bgp_vrf_red permit 110
+ match ip address pve_bgp_red_ips
+ set src 10.0.0.1
+exit
+!
+route-map pve_bgp_vrf_red permit 65535
+exit
+!
+route-map pve_ospf_vrf_blue permit 100
+ match ip address pve_ospf_blue_ips
+ set src 10.0.0.1
+exit
+!
+ip route 203.0.113.0/24 10.0.0.2 vrf vrf_blue
+!
+ipv6 route 2001:db8:42::/64 fe80::2 ens19 vrf vrf_blue
+!
+ip route 203.0.113.0/24 10.0.0.3 ens19 20 vrf vrf_red
+!
+ipv6 route 2001:db8:42::/64 ens19 30 vrf vrf_red
+!
+vrf vrf_blue
+ ip protocol ospf route-map pve_ospf_vrf_blue
+exit-vrf
+!
+vrf vrf_red
+ ip protocol bgp route-map pve_bgp_vrf_red
+exit-vrf
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH proxmox-perl-rs v3 08/28] pve-rs: fabrics: assign network interfaces to configured VRFs
  2026-11-19 19:40 [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/28] SDN VRF support Gabriel Goller
                   ` (6 preceding siblings ...)
  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 ` 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
                   ` (19 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Gabriel Goller @ 2026-11-19 19:40 UTC (permalink / raw)
  To: pve-devel

Add the VRF stanza to generated interface configuration when a fabric
has a VRF. Apply it to dummy addresses, protocol interfaces, and BGP
unnumbered interfaces so traffic enters the correct routing table.

Fabrics without a VRF keep their existing configuration.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 pve-rs/src/bindings/sdn/fabrics.rs | 59 ++++++++++++++++++++++--------
 1 file changed, 43 insertions(+), 16 deletions(-)

diff --git a/pve-rs/src/bindings/sdn/fabrics.rs b/pve-rs/src/bindings/sdn/fabrics.rs
index 1d3e8b5bbf34..b7c2d91e5471 100644
--- a/pve-rs/src/bindings/sdn/fabrics.rs
+++ b/pve-rs/src/bindings/sdn/fabrics.rs
@@ -586,7 +586,12 @@ pub mod pve_rs_sdn_fabrics {
     }
 
     /// Helper function to generate the default `/etc/network/interfaces` config for a given CIDR.
-    fn render_interface(name: &str, cidr: Cidr, link_type: Option<&str>) -> Result<String, Error> {
+    fn render_interface(
+        name: &str,
+        cidr: Cidr,
+        link_type: Option<&str>,
+        vrf: Option<&str>,
+    ) -> Result<String, Error> {
         let mut interface = String::new();
 
         writeln!(interface, "auto {name}")?;
@@ -598,6 +603,9 @@ pub mod pve_rs_sdn_fabrics {
         if let Some(link_type) = link_type {
             writeln!(interface, "\tlink-type {link_type}")?;
         }
+        if let Some(vrf) = vrf {
+            writeln!(interface, "\tvrf {vrf}")?;
+        }
         writeln!(interface, "\tip-forward 1")?;
 
         Ok(interface)
@@ -607,12 +615,14 @@ pub mod pve_rs_sdn_fabrics {
         interfaces: &mut String,
         fabric: &Fabric,
         node: &ConfigNode,
+        vrf: Option<&str>,
     ) -> Result<(), Error> {
         if let Some(ip) = node.ip() {
             let interface = render_interface(
                 &format!("dummy_{}", fabric.id()),
                 Cidr::new_v4(ip, 32)?,
                 Some("dummy"),
+                vrf,
             )?;
             writeln!(interfaces)?;
             write!(interfaces, "{interface}")?;
@@ -623,6 +633,7 @@ pub mod pve_rs_sdn_fabrics {
                 &format!("dummy_{}", fabric.id()),
                 Cidr::new_v6(ip6, 128)?,
                 Some("dummy"),
+                vrf,
             )?;
             writeln!(interfaces)?;
             write!(interfaces, "{interface}")?;
@@ -640,28 +651,35 @@ pub mod pve_rs_sdn_fabrics {
         let config = this.fabric_config.lock().unwrap();
         let mut interfaces = String::new();
 
-        let node_fabrics = config.values().filter_map(|entry| {
-            entry
-                .get_node(&node_id)
-                .map(|node| (entry.fabric(), node))
-                .ok()
-        });
+        let node_fabrics = config
+            .values()
+            .filter_map(|entry| entry.get_node(&node_id).map(|node| (entry, node)).ok());
 
-        for (fabric, node) in node_fabrics {
-            render_dummy_interfaces(&mut interfaces, fabric, node)?;
+        for (entry, node) in node_fabrics {
+            let fabric = entry.fabric();
+            let vrf = entry.fabric_vrf_name();
+            render_dummy_interfaces(&mut interfaces, fabric, node, vrf.as_deref())?;
 
             match node {
                 ConfigNode::Openfabric(node_section) => {
                     for interface in node_section.properties().interfaces() {
                         if let Some(ip) = interface.ip() {
-                            let interface =
-                                render_interface(interface.name(), Cidr::from(ip), None)?;
+                            let interface = render_interface(
+                                interface.name(),
+                                Cidr::from(ip),
+                                None,
+                                vrf.as_deref(),
+                            )?;
                             writeln!(interfaces)?;
                             write!(interfaces, "{interface}")?;
                         }
                         if let Some(ip) = interface.ip6() {
-                            let interface =
-                                render_interface(interface.name(), Cidr::from(ip), None)?;
+                            let interface = render_interface(
+                                interface.name(),
+                                Cidr::from(ip),
+                                None,
+                                vrf.as_deref(),
+                            )?;
                             writeln!(interfaces)?;
                             write!(interfaces, "{interface}")?;
                         }
@@ -678,7 +696,8 @@ pub mod pve_rs_sdn_fabrics {
                             } else {
                                 anyhow::bail!("there has to be a ipv4 or ipv6 node address");
                             });
-                            let interface = render_interface(interface.name(), cidr, None)?;
+                            let interface =
+                                render_interface(interface.name(), cidr, None, vrf.as_deref())?;
                             writeln!(interfaces)?;
                             write!(interfaces, "{interface}")?;
                         }
@@ -688,8 +707,12 @@ pub mod pve_rs_sdn_fabrics {
                     for interface in node_section.properties().interfaces() {
                         writeln!(interfaces)?;
                         if let Some(ip) = interface.ip() {
-                            let interface =
-                                render_interface(interface.name(), Cidr::from(ip), None)?;
+                            let interface = render_interface(
+                                interface.name(),
+                                Cidr::from(ip),
+                                None,
+                                vrf.as_deref(),
+                            )?;
                             write!(interfaces, "{interface}")?;
                         } else {
                             let interface = render_interface(
@@ -698,6 +721,7 @@ pub mod pve_rs_sdn_fabrics {
                                     anyhow::anyhow!("there has to be a ipv4 address")
                                 })?)),
                                 None,
+                                vrf.as_deref(),
                             )?;
                             write!(interfaces, "{interface}")?;
                         }
@@ -765,6 +789,9 @@ pub mod pve_rs_sdn_fabrics {
                             writeln!(interfaces)?;
                             writeln!(interfaces, "auto {name}")?;
                             writeln!(interfaces, "iface {name} inet manual")?;
+                            if let Some(vrf) = &vrf {
+                                writeln!(interfaces, "\tvrf {vrf}")?;
+                            }
                             writeln!(interfaces, "\tip-forward 1")?;
                             writeln!(interfaces, "\tip6-forward 1")?;
                             // BGP unnumbered uses RAs to discover peer link-local
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH proxmox-perl-rs v3 09/28] pve-rs: fabrics: make per-fabric status queries VRF-aware
  2026-11-19 19:40 [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/28] SDN VRF support Gabriel Goller
                   ` (7 preceding siblings ...)
  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 ` 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
                   ` (18 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Gabriel Goller @ 2026-11-19 19:40 UTC (permalink / raw)
  To: pve-devel

Use the fabric VRF in FRR route, neighbor, and interface queries for
OSPF and BGP.

Keep the existing commands for fabrics in the default routing table.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 pve-rs/src/bindings/sdn/fabrics.rs | 101 ++++++++++++++++-------------
 1 file changed, 55 insertions(+), 46 deletions(-)

diff --git a/pve-rs/src/bindings/sdn/fabrics.rs b/pve-rs/src/bindings/sdn/fabrics.rs
index b7c2d91e5471..06ecd0d07eaf 100644
--- a/pve-rs/src/bindings/sdn/fabrics.rs
+++ b/pve-rs/src/bindings/sdn/fabrics.rs
@@ -827,6 +827,23 @@ pub mod pve_rs_sdn_fabrics {
         .transpose()
     }
 
+    /// Run a single `vtysh` command and return its stdout.
+    ///
+    /// The command is passed as a single argument, so it is not interpreted by a shell. Like
+    /// before, when it was run through `sh`, a missing `vtysh` binary yields empty output.
+    fn vtysh(command: &str) -> Result<String, Error> {
+        let output = match Command::new("vtysh")
+            .env("VTYSH_HISTFILE", "/dev/null")
+            .args(["-c", command])
+            .output()
+        {
+            Ok(output) => output,
+            Err(err) if err.kind() == std::io::ErrorKind::NotFound => return Ok(String::new()),
+            Err(err) => return Err(err.into()),
+        };
+        Ok(String::from_utf8(output.stdout)?)
+    }
+
     /// Get the routes that have been learned and distributed by this specific fabric on this node.
     ///
     /// Read and parse the fabric config to get the protocol and the interfaces. Parse the vtysh
@@ -841,6 +858,7 @@ pub mod pve_rs_sdn_fabrics {
         };
 
         let fabric = config.get_fabric(&fabric_id)?;
+        let vrf = fabric.fabric_vrf_name();
         match fabric {
             FabricEntry::Openfabric(_) => {
                 let openfabric_ipv4_routes_string = String::from_utf8(
@@ -878,12 +896,11 @@ pub mod pve_rs_sdn_fabrics {
                 )
             }
             FabricEntry::Ospf(_) => {
-                let ospf_routes_string = String::from_utf8(
-                    Command::new("sh")
-                        .args(["-c", "vtysh -c 'show ip route ospf json'"])
-                        .output()?
-                        .stdout,
-                )?;
+                let command = match &vrf {
+                    Some(vrf) => format!("show ip route vrf {vrf} ospf json"),
+                    None => "show ip route ospf json".to_string(),
+                };
+                let ospf_routes_string = vtysh(&command)?;
                 let ospf_routes: proxmox_frr::de::Routes = if ospf_routes_string.is_empty() {
                     proxmox_frr::de::Routes::default()
                 } else {
@@ -895,21 +912,17 @@ pub mod pve_rs_sdn_fabrics {
             }
             FabricEntry::WireGuard(_) => Ok(Vec::new()),
             FabricEntry::Bgp(_) => {
-                let bgp_ipv4_routes_string = String::from_utf8(
-                    Command::new("sh")
-                        .env("VTYSH_HISTFILE", "/dev/null")
-                        .args(["-c", "vtysh -c 'show ip route bgp json'"])
-                        .output()?
-                        .stdout,
-                )?;
+                let ipv4_command = match &vrf {
+                    Some(vrf) => format!("show ip route vrf {vrf} bgp json"),
+                    None => "show ip route bgp json".to_string(),
+                };
+                let ipv6_command = match &vrf {
+                    Some(vrf) => format!("show ipv6 route vrf {vrf} bgp json"),
+                    None => "show ipv6 route bgp json".to_string(),
+                };
+                let bgp_ipv4_routes_string = vtysh(&ipv4_command)?;
 
-                let bgp_ipv6_routes_string = String::from_utf8(
-                    Command::new("sh")
-                        .env("VTYSH_HISTFILE", "/dev/null")
-                        .args(["-c", "vtysh -c 'show ipv6 route bgp json'"])
-                        .output()?
-                        .stdout,
-                )?;
+                let bgp_ipv6_routes_string = vtysh(&ipv6_command)?;
 
                 let mut bgp_routes: proxmox_frr::de::Routes = if bgp_ipv4_routes_string.is_empty() {
                     proxmox_frr::de::Routes::default()
@@ -941,6 +954,7 @@ pub mod pve_rs_sdn_fabrics {
         };
 
         let fabric = config.get_fabric(&fabric_id)?;
+        let vrf = fabric.fabric_vrf_name();
 
         match fabric {
             FabricEntry::Openfabric(_) => {
@@ -961,12 +975,11 @@ pub mod pve_rs_sdn_fabrics {
                 status::get_neighbors_openfabric(fabric_id, openfabric_neighbors).map(|v| v.into())
             }
             FabricEntry::Ospf(fabric) => {
-                let ospf_neighbors_string = String::from_utf8(
-                    Command::new("sh")
-                        .args(["-c", "vtysh -c 'show ip ospf neighbor json'"])
-                        .output()?
-                        .stdout,
-                )?;
+                let command = match &vrf {
+                    Some(vrf) => format!("show ip ospf vrf {vrf} neighbor json"),
+                    None => "show ip ospf neighbor json".to_string(),
+                };
+                let ospf_neighbors_string = vtysh(&command)?;
                 let ospf_neighbors: proxmox_frr::de::ospf::Neighbors =
                     if ospf_neighbors_string.is_empty() {
                         proxmox_frr::de::ospf::Neighbors::default()
@@ -985,13 +998,11 @@ pub mod pve_rs_sdn_fabrics {
             }
             FabricEntry::WireGuard(_) => Ok(status::NeighborStatus::WireGuard(Vec::new())),
             FabricEntry::Bgp(_) => {
-                let bgp_neighbors_string = String::from_utf8(
-                    Command::new("sh")
-                        .env("VTYSH_HISTFILE", "/dev/null")
-                        .args(["-c", "vtysh -c 'show bgp neighbors json'"])
-                        .output()?
-                        .stdout,
-                )?;
+                let command = match &vrf {
+                    Some(vrf) => format!("show bgp vrf {vrf} neighbors json"),
+                    None => "show bgp neighbors json".to_string(),
+                };
+                let bgp_neighbors_string = vtysh(&command)?;
                 let bgp_neighbors: std::collections::BTreeMap<String, status::BgpNeighborInfo> =
                     if bgp_neighbors_string.is_empty() {
                         std::collections::BTreeMap::new()
@@ -1018,6 +1029,7 @@ pub mod pve_rs_sdn_fabrics {
         };
 
         let fabric = config.get_fabric(&fabric_id)?;
+        let vrf = fabric.fabric_vrf_name();
 
         match fabric {
             FabricEntry::Openfabric(_) => {
@@ -1039,12 +1051,11 @@ pub mod pve_rs_sdn_fabrics {
                     .map(|v| v.into())
             }
             FabricEntry::Ospf(fabric) => {
-                let ospf_interfaces_string = String::from_utf8(
-                    Command::new("sh")
-                        .args(["-c", "vtysh -c 'show ip ospf interface json'"])
-                        .output()?
-                        .stdout,
-                )?;
+                let command = match &vrf {
+                    Some(vrf) => format!("show ip ospf vrf {vrf} interface json"),
+                    None => "show ip ospf interface json".to_string(),
+                };
+                let ospf_interfaces_string = vtysh(&command)?;
                 let ospf_interfaces: proxmox_frr::de::ospf::Interfaces =
                     if ospf_interfaces_string.is_empty() {
                         proxmox_frr::de::ospf::Interfaces::default()
@@ -1063,13 +1074,11 @@ pub mod pve_rs_sdn_fabrics {
             }
             FabricEntry::WireGuard(_) => Ok(status::InterfaceStatus::WireGuard(Vec::new())),
             FabricEntry::Bgp(_) => {
-                let bgp_neighbors_string = String::from_utf8(
-                    Command::new("sh")
-                        .env("VTYSH_HISTFILE", "/dev/null")
-                        .args(["-c", "vtysh -c 'show bgp neighbors json'"])
-                        .output()?
-                        .stdout,
-                )?;
+                let command = match &vrf {
+                    Some(vrf) => format!("show bgp vrf {vrf} neighbors json"),
+                    None => "show bgp neighbors json".to_string(),
+                };
+                let bgp_neighbors_string = vtysh(&command)?;
                 let bgp_neighbors: std::collections::BTreeMap<String, status::BgpNeighborInfo> =
                     if bgp_neighbors_string.is_empty() {
                         std::collections::BTreeMap::new()
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH proxmox-perl-rs v3 10/28] pve-rs: fabrics: include VRF routes in aggregate status
  2026-11-19 19:40 [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/28] SDN VRF support Gabriel Goller
                   ` (8 preceding siblings ...)
  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 ` Gabriel Goller
  2026-11-19 19:40 ` [PATCH proxmox-perl-rs v3 11/28] pve-rs: fabrics: expose host interface membership Gabriel Goller
                   ` (17 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Gabriel Goller @ 2026-11-19 19:40 UTC (permalink / raw)
  To: pve-devel

Collect OSPF and BGP routes from every VRF used by a fabric on the
local node, in addition to routes from the default routing table. Run
the related commands in one vtysh process and merge their JSON output,
including entries which share the same prefix.

Match routes by VRF when deciding whether a fabric has active routes.
This prevents routes from another routing table from affecting its
status. Add a parser test for duplicate prefixes across VRFs.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 pve-rs/src/bindings/sdn/fabrics.rs | 211 ++++++++++++++++++-----------
 pve-rs/src/sdn/status.rs           | 149 ++++++++++++++++----
 2 files changed, 251 insertions(+), 109 deletions(-)

diff --git a/pve-rs/src/bindings/sdn/fabrics.rs b/pve-rs/src/bindings/sdn/fabrics.rs
index 06ecd0d07eaf..c319e1201094 100644
--- a/pve-rs/src/bindings/sdn/fabrics.rs
+++ b/pve-rs/src/bindings/sdn/fabrics.rs
@@ -5,7 +5,7 @@ pub mod pve_rs_sdn_fabrics {
     //! This provides the configuration for the SDN fabrics, as well as helper methods for reading
     //! / writing the configuration, as well as for generating ifupdown2 and FRR configuration.
 
-    use std::collections::{BTreeMap, HashMap, HashSet};
+    use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
     use std::fmt::Write;
     use std::net::IpAddr;
     use std::ops::Deref;
@@ -980,13 +980,15 @@ pub mod pve_rs_sdn_fabrics {
                     None => "show ip ospf neighbor json".to_string(),
                 };
                 let ospf_neighbors_string = vtysh(&command)?;
-                let ospf_neighbors: proxmox_frr::de::ospf::Neighbors =
-                    if ospf_neighbors_string.is_empty() {
-                        proxmox_frr::de::ospf::Neighbors::default()
-                    } else {
-                        serde_json::from_str(&ospf_neighbors_string)
-                            .with_context(|| "error parsing ospf neighbors")?
-                    };
+                let ospf_neighbors = if ospf_neighbors_string.is_empty() {
+                    proxmox_frr::de::ospf::Neighbors::default()
+                } else {
+                    let output = serde_json::from_str(&ospf_neighbors_string)
+                        .with_context(|| "error parsing ospf neighbors")?;
+                    let output = status::extract_vrf_status(output, vrf.as_deref())?;
+                    serde_json::from_value(output)
+                        .with_context(|| "error parsing ospf neighbors")?
+                };
 
                 status::get_neighbors_ospf(
                     fabric_id,
@@ -1056,13 +1058,15 @@ pub mod pve_rs_sdn_fabrics {
                     None => "show ip ospf interface json".to_string(),
                 };
                 let ospf_interfaces_string = vtysh(&command)?;
-                let ospf_interfaces: proxmox_frr::de::ospf::Interfaces =
-                    if ospf_interfaces_string.is_empty() {
-                        proxmox_frr::de::ospf::Interfaces::default()
-                    } else {
-                        serde_json::from_str(&ospf_interfaces_string)
-                            .with_context(|| "error parsing ospf interfaces")?
-                    };
+                let ospf_interfaces = if ospf_interfaces_string.is_empty() {
+                    proxmox_frr::de::ospf::Interfaces::default()
+                } else {
+                    let output = serde_json::from_str(&ospf_interfaces_string)
+                        .with_context(|| "error parsing ospf interfaces")?;
+                    let output = status::extract_vrf_status(output, vrf.as_deref())?;
+                    serde_json::from_value(output)
+                        .with_context(|| "error parsing ospf interfaces")?
+                };
 
                 status::get_interfaces_ospf(
                     fabric_id,
@@ -1092,6 +1096,78 @@ pub mod pve_rs_sdn_fabrics {
         }
     }
 
+    fn extend_routes(destination: &mut proxmox_frr::de::Routes, source: proxmox_frr::de::Routes) {
+        for (prefix, routes) in source.0 {
+            destination.0.entry(prefix).or_default().extend(routes);
+        }
+    }
+
+    /// Query and merge routes from multiple FRR commands in a single `vtysh` process.
+    ///
+    /// The exit status is ignored, like in the single-command queries: if FRR is not running,
+    /// `vtysh` fails without printing anything to stdout, which yields no routes. This is polled
+    /// by pvestatd, so an error here would be logged on every cycle.
+    fn query_routes(
+        commands: impl IntoIterator<Item = String>,
+        protocol: &str,
+    ) -> Result<proxmox_frr::de::Routes, Error> {
+        let mut command = Command::new("vtysh");
+        command.env("VTYSH_HISTFILE", "/dev/null");
+        for query in commands {
+            command.args(["-c", &query]);
+        }
+
+        let output = match command.output() {
+            Ok(output) => output,
+            Err(err) if err.kind() == std::io::ErrorKind::NotFound => {
+                return Ok(proxmox_frr::de::Routes::default());
+            }
+            Err(err) => return Err(err.into()),
+        };
+
+        parse_routes(&output.stdout, protocol)
+    }
+
+    fn parse_routes(raw: &[u8], protocol: &str) -> Result<proxmox_frr::de::Routes, Error> {
+        let mut routes = proxmox_frr::de::Routes::default();
+        let route_stream =
+            serde_json::Deserializer::from_slice(raw).into_iter::<proxmox_frr::de::Routes>();
+        for queried_routes in route_stream {
+            extend_routes(
+                &mut routes,
+                queried_routes.with_context(|| format!("error parsing {protocol} routes"))?,
+            );
+        }
+
+        Ok(routes)
+    }
+
+    #[cfg(test)]
+    mod tests {
+        use super::parse_routes;
+
+        #[test]
+        fn parses_batched_routes_with_duplicate_prefixes() {
+            let raw = br#"
+                {"10.0.0.0/24":[{"nexthops":[],"metric":10,"protocol":"bgp","vrfName":"vrf_a"}]}
+                {"10.0.0.0/24":[{"nexthops":[],"metric":10,"protocol":"bgp","vrfName":"vrf_b"}]}
+            "#;
+
+            let routes = parse_routes(raw, "BGP").expect("batched routes should parse");
+            let routes = routes.0.values().next().expect("route should exist");
+
+            assert_eq!(routes.len(), 2);
+            assert_eq!(routes[0].vrf_name, "vrf_a");
+            assert_eq!(routes[1].vrf_name, "vrf_b");
+        }
+
+        #[test]
+        fn parses_empty_output() {
+            let routes = parse_routes(b"", "BGP").expect("empty output should parse");
+            assert!(routes.0.is_empty());
+        }
+    }
+
     /// Return the status of all fabrics on this node.
     ///
     /// Go through all fabrics in the config, then filter out the ones that exist on this node.
@@ -1107,76 +1183,47 @@ pub mod pve_rs_sdn_fabrics {
             return Ok(HashMap::new());
         };
 
-        let openfabric_ipv4_routes_string = String::from_utf8(
-            Command::new("sh")
-                .args(["-c", "vtysh -c 'show ip route openfabric json'"])
-                .output()?
-                .stdout,
-        )?;
-
-        let openfabric_ipv6_routes_string = String::from_utf8(
-            Command::new("sh")
-                .args(["-c", "vtysh -c 'show ipv6 route openfabric json'"])
-                .output()?
-                .stdout,
-        )?;
-
-        let ospf_routes_string = String::from_utf8(
-            Command::new("sh")
-                .args(["-c", "vtysh -c 'show ip route ospf json'"])
-                .output()?
-                .stdout,
-        )?;
-
-        let mut openfabric_routes: proxmox_frr::de::Routes =
-            if openfabric_ipv4_routes_string.is_empty() {
-                proxmox_frr::de::Routes::default()
-            } else {
-                serde_json::from_str(&openfabric_ipv4_routes_string)
-                    .with_context(|| "error parsing openfabric ipv4 routes")?
-            };
-        if !openfabric_ipv6_routes_string.is_empty() {
-            let openfabric_ipv6_routes: proxmox_frr::de::Routes =
-                serde_json::from_str(&openfabric_ipv6_routes_string)
-                    .with_context(|| "error parsing openfabric ipv6 routes")?;
-            openfabric_routes.0.extend(openfabric_ipv6_routes.0);
-        }
-
-        let ospf_routes: proxmox_frr::de::Routes = if ospf_routes_string.is_empty() {
-            proxmox_frr::de::Routes::default()
-        } else {
-            serde_json::from_str(&ospf_routes_string)
-                .with_context(|| "error parsing ospf routes")?
-        };
-
-        let bgp_ipv4_routes_string = String::from_utf8(
-            Command::new("sh")
-                .env("VTYSH_HISTFILE", "/dev/null")
-                .args(["-c", "vtysh -c 'show ip route bgp json'"])
-                .output()?
-                .stdout,
+        let openfabric_routes = query_routes(
+            [
+                "show ip route openfabric json".to_string(),
+                "show ipv6 route openfabric json".to_string(),
+            ],
+            "OpenFabric",
         )?;
 
-        let bgp_ipv6_routes_string = String::from_utf8(
-            Command::new("sh")
-                .env("VTYSH_HISTFILE", "/dev/null")
-                .args(["-c", "vtysh -c 'show ipv6 route bgp json'"])
-                .output()?
-                .stdout,
-        )?;
-
-        let mut bgp_routes: proxmox_frr::de::Routes = if bgp_ipv4_routes_string.is_empty() {
-            proxmox_frr::de::Routes::default()
-        } else {
-            serde_json::from_str(&bgp_ipv4_routes_string)
-                .with_context(|| "error parsing bgp ipv4 routes")?
-        };
-        if !bgp_ipv6_routes_string.is_empty() {
-            let bgp_ipv6_routes: proxmox_frr::de::Routes =
-                serde_json::from_str(&bgp_ipv6_routes_string)
-                    .with_context(|| "error parsing bgp ipv6 routes")?;
-            bgp_routes.0.extend(bgp_ipv6_routes.0);
+        let node_id = NodeId::from_string(proxmox_sys::nodename().to_string())?;
+        let ospf_vrfs: BTreeSet<_> = config
+            .values()
+            .filter(|entry| {
+                matches!(entry, FabricEntry::Ospf(_)) && entry.get_node(&node_id).is_ok()
+            })
+            .filter_map(FabricEntry::fabric_vrf_name)
+            .collect();
+        let mut ospf_commands = vec!["show ip route ospf json".to_string()];
+        ospf_commands.extend(
+            ospf_vrfs
+                .iter()
+                .map(|vrf| format!("show ip route vrf {vrf} ospf json")),
+        );
+        let ospf_routes = query_routes(ospf_commands, "OSPF")?;
+
+        let bgp_vrfs: BTreeSet<_> = config
+            .values()
+            .filter(|entry| {
+                matches!(entry, FabricEntry::Bgp(_)) && entry.get_node(&node_id).is_ok()
+            })
+            .filter_map(FabricEntry::fabric_vrf_name)
+            .collect();
+        let mut bgp_commands = vec![
+            "show ip route bgp json".to_string(),
+            "show ipv6 route bgp json".to_string(),
+        ];
+        for vrf in bgp_vrfs {
+            bgp_commands.extend(
+                ["ip", "ipv6"].map(|family| format!("show {family} route vrf {vrf} bgp json")),
+            );
         }
+        let bgp_routes = query_routes(bgp_commands, "BGP")?;
 
         let route_status = status::RoutesParsed {
             openfabric: openfabric_routes,
diff --git a/pve-rs/src/sdn/status.rs b/pve-rs/src/sdn/status.rs
index 7a1334d20804..369fe3a982b2 100644
--- a/pve-rs/src/sdn/status.rs
+++ b/pve-rs/src/sdn/status.rs
@@ -355,6 +355,20 @@ pub fn get_neighbors_openfabric(
     Ok(stats)
 }
 
+/// Extract status output nested under a VRF name, or return non-VRF output unchanged.
+pub fn extract_vrf_status(
+    mut output: serde_json::Value,
+    vrf: Option<&str>,
+) -> Result<serde_json::Value, anyhow::Error> {
+    match vrf {
+        Some(vrf) => output
+            .get_mut(vrf)
+            .map(serde_json::Value::take)
+            .ok_or_else(|| anyhow::anyhow!("missing status for VRF '{vrf}'")),
+        None => Ok(output),
+    }
+}
+
 /// Convert the parsed ospf neighbor neighbor information into a list of [`ospf::NeighborStatus`].
 ///
 /// Ospf does not use the name of the fabric at all, so we again need to retrieve the interfaces of
@@ -535,6 +549,10 @@ pub fn get_status(
             continue;
         }
         let fabric_id = node.id().fabric_id();
+        let vrf_name = config
+            .get_fabric(fabric_id)?
+            .fabric_vrf_name()
+            .unwrap_or_else(|| "default".to_string());
 
         let (current_protocol, all_routes) = match &node {
             ConfigNode::Openfabric(_) => (Protocol::Openfabric, &routes.openfabric.0),
@@ -565,13 +583,14 @@ pub fn get_status(
         // determine status by checking if any routes exist for our interfaces
         let has_routes = all_routes.values().any(|v| {
             v.iter().any(|route| {
-                route.nexthops.iter().any(|nexthop| {
-                    if let Some(iface_name) = &nexthop.interface_name {
-                        interface_names.contains(iface_name.as_str())
-                    } else {
-                        false
-                    }
-                })
+                route.vrf_name == vrf_name
+                    && route.nexthops.iter().any(|nexthop| {
+                        if let Some(iface_name) = &nexthop.interface_name {
+                            interface_names.contains(iface_name.as_str())
+                        } else {
+                            false
+                        }
+                    })
             })
         });
 
@@ -1400,11 +1419,8 @@ mod tests {
             }
             "#;
 
-            let neighbors: de::ospf::Neighbors = if json_output.is_empty() {
-                de::ospf::Neighbors::default()
-            } else {
-                serde_json::from_str(json_output).expect("error parsing json output")
-            };
+            let neighbors: de::ospf::Neighbors =
+                serde_json::from_str(json_output).expect("error parsing json output");
 
             let fabric_config = sample_one_fabric_config();
 
@@ -1436,6 +1452,94 @@ mod tests {
             assert_eq!(reference, output);
         }
 
+        #[test]
+        fn neighbors_vrf() {
+            let json_output = r#"
+            {
+              "vrf_vrf": {
+                "vrfName": "vrf_vrf",
+                "vrfId": 6,
+                "neighbors": {
+                  "4.4.4.3": [{
+                    "nbrState": "Full\/-",
+                    "upTime": "13m35s",
+                    "ifaceAddress": "4.4.4.3",
+                    "ifaceName": "nic1:4.4.4.1"
+                  }],
+                  "4.4.4.2": [{
+                    "nbrState": "Full\/-",
+                    "upTime": "13m35s",
+                    "ifaceAddress": "4.4.4.2",
+                    "ifaceName": "nic2:4.4.4.1"
+                  }]
+                }
+              },
+              "other_vrf": { "neighbors": {} }
+            }
+            "#;
+
+            let output = serde_json::from_str(json_output).unwrap();
+            let output = extract_vrf_status(output, Some("vrf_vrf")).unwrap();
+            let neighbors: de::ospf::Neighbors = serde_json::from_value(output).unwrap();
+            assert_eq!(neighbors.neighbors.len(), 2);
+            for (address, interface) in [("4.4.4.3", "nic1"), ("4.4.4.2", "nic2")] {
+                let neighbor = &neighbors.neighbors[address];
+                assert_eq!(neighbor.len(), 1);
+                assert_eq!(neighbor[0].interface_address, address);
+                assert_eq!(neighbor[0].interface_name, format!("{interface}:4.4.4.1"));
+                assert_eq!(neighbor[0].neighbor_state, "Full/-");
+                assert_eq!(neighbor[0].up_time, "13m35s");
+            }
+        }
+
+        #[test]
+        fn interfaces_vrf() {
+            let json_output = r#"
+            {
+              "vrf_vrf": {
+                "vrfName": "vrf_vrf",
+                "vrfId": 6,
+                "interfaces": {
+                  "dummy_fabric": { "ifUp": true, "networkType": "BROADCAST" },
+                  "nic1": { "ifUp": true, "networkType": "POINTOPOINT" },
+                  "nic2": { "ifUp": true, "networkType": "POINTOPOINT" }
+                }
+              },
+              "other_vrf": { "interfaces": {} }
+            }
+            "#;
+
+            let output = serde_json::from_str(json_output).unwrap();
+            let output = extract_vrf_status(output, Some("vrf_vrf")).unwrap();
+            let interfaces: de::ospf::Interfaces = serde_json::from_value(output).unwrap();
+            assert_eq!(interfaces.interfaces.len(), 3);
+            for (name, ty) in [
+                ("dummy_fabric", de::ospf::NetworkType::Broadcast),
+                ("nic1", de::ospf::NetworkType::PointToPoint),
+                ("nic2", de::ospf::NetworkType::PointToPoint),
+            ] {
+                let interface = &interfaces.interfaces[name];
+                assert!(interface.if_up);
+                assert_eq!(interface.network_type, ty);
+            }
+        }
+
+        #[test]
+        fn extract_non_vrf_status() {
+            for output in [
+                serde_json::json!({ "neighbors": {} }),
+                serde_json::json!({ "interfaces": {} }),
+            ] {
+                assert_eq!(extract_vrf_status(output.clone(), None).unwrap(), output);
+            }
+        }
+
+        #[test]
+        fn extract_missing_vrf_status() {
+            let output = serde_json::json!({ "other_vrf": { "neighbors": {} } });
+            assert!(extract_vrf_status(output, Some("vrf_vrf")).is_err());
+        }
+
         #[test]
         fn neighbors_multiple_areas() {
             let json_output = r#"
@@ -1509,11 +1613,8 @@ mod tests {
             }
             "#;
 
-            let neighbors: de::ospf::Neighbors = if json_output.is_empty() {
-                de::ospf::Neighbors::default()
-            } else {
-                serde_json::from_str(json_output).expect("error parsing json output")
-            };
+            let neighbors: de::ospf::Neighbors =
+                serde_json::from_str(json_output).expect("error parsing json output");
 
             let fabric_config = sample_two_fabric_config();
 
@@ -1672,11 +1773,8 @@ mod tests {
             }
             "#;
 
-            let interfaces: de::ospf::Interfaces = if json_output.is_empty() {
-                de::ospf::Interfaces::default()
-            } else {
-                serde_json::from_str(json_output).expect("error parsing json output")
-            };
+            let interfaces: de::ospf::Interfaces =
+                serde_json::from_str(json_output).expect("error parsing json output");
 
             let fabric_config = sample_one_fabric_config();
 
@@ -1904,11 +2002,8 @@ mod tests {
             }
             "#;
 
-            let interfaces: de::ospf::Interfaces = if json_output.is_empty() {
-                de::ospf::Interfaces::default()
-            } else {
-                serde_json::from_str(json_output).expect("error parsing json output")
-            };
+            let interfaces: de::ospf::Interfaces =
+                serde_json::from_str(json_output).expect("error parsing json output");
 
             let fabric_config = sample_two_fabric_config();
 
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH proxmox-perl-rs v3 11/28] pve-rs: fabrics: expose host interface membership
  2026-11-19 19:40 [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/28] SDN VRF support Gabriel Goller
                   ` (9 preceding siblings ...)
  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 ` Gabriel Goller
  2026-11-19 19:40 ` [PATCH proxmox-perl-rs v3 12/28] sdn: expose static routes for simple zone uplinks Gabriel Goller
                   ` (16 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Gabriel Goller @ 2026-11-19 19:40 UTC (permalink / raw)
  To: pve-devel

Allow the host network editor to identify fabric-managed interfaces from
the parsed configuration rather than reparsing API property strings.
This keeps the VRF field under fabric control without locking unrelated
interface settings.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 pve-rs/src/bindings/sdn/fabrics.rs | 36 ++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/pve-rs/src/bindings/sdn/fabrics.rs b/pve-rs/src/bindings/sdn/fabrics.rs
index c319e1201094..40bdaff086b3 100644
--- a/pve-rs/src/bindings/sdn/fabrics.rs
+++ b/pve-rs/src/bindings/sdn/fabrics.rs
@@ -484,6 +484,42 @@ pub mod pve_rs_sdn_fabrics {
         ifaces
     }
 
+    /// Method: Check whether an interface is configured in a fabric on the given node.
+    #[export]
+    pub fn is_fabric_interface(
+        #[try_from_ref] this: &PerlFabricConfig,
+        node_id: NodeId,
+        interface_name: &str,
+    ) -> bool {
+        let config = this.fabric_config.lock().unwrap();
+
+        config
+            .values()
+            .filter_map(|entry| entry.get_node(&node_id).ok())
+            .any(|node| match node {
+                ConfigNode::Openfabric(node) => node
+                    .properties()
+                    .interfaces()
+                    .any(|interface| interface.name().as_str() == interface_name),
+                ConfigNode::Ospf(node) => node
+                    .properties()
+                    .interfaces()
+                    .any(|interface| interface.name().as_str() == interface_name),
+                ConfigNode::WireGuard(node) => match node.properties() {
+                    WireGuardNode::Internal(properties) => properties
+                        .interfaces()
+                        .any(|interface| interface.name().as_str() == interface_name),
+                    WireGuardNode::External(_) => false,
+                },
+                ConfigNode::Bgp(node) => match node.properties() {
+                    BgpNode::Internal(properties) => properties
+                        .interfaces()
+                        .any(|interface| interface.name().as_str() == interface_name),
+                    BgpNode::External(_) => false,
+                },
+            })
+    }
+
     /// Method: Return all FRR daemons that need to be enabled for this fabric configuration
     /// instance.
     ///
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH proxmox-perl-rs v3 12/28] sdn: expose static routes for simple zone uplinks
  2026-11-19 19:40 [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/28] SDN VRF support Gabriel Goller
                   ` (10 preceding siblings ...)
  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 ` 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
                   ` (15 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Gabriel Goller @ 2026-11-19 19:40 UTC (permalink / raw)
  To: pve-devel

Allow zone configuration to provide static routes for simple zone VRFs,
so upstream connectivity does not require node-local FRR overrides.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 pve-rs/src/bindings/sdn/mod.rs | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/pve-rs/src/bindings/sdn/mod.rs b/pve-rs/src/bindings/sdn/mod.rs
index dcae046a7e46..742e02329eef 100644
--- a/pve-rs/src/bindings/sdn/mod.rs
+++ b/pve-rs/src/bindings/sdn/mod.rs
@@ -10,15 +10,31 @@ pub mod pve_rs_sdn {
     //! This provides general methods for generating the frr config.
 
     use anyhow::Error;
-    use proxmox_frr::ser::{FrrConfig, serializer::to_raw_config};
+    use proxmox_frr::ser::{FrrConfig, IpRoute, serializer::to_raw_config};
+    use proxmox_schema::property_string::PropertyString;
 
     use proxmox_ve_config::common::valid::Validatable;
     use proxmox_ve_config::sdn::fabric::section_config::node::NodeId;
+    use proxmox_ve_config::sdn::static_route::{StaticRoute, ZoneRoutesConfig};
 
     use crate::bindings::pve_rs_sdn_fabrics::PerlFabricConfig;
     use crate::bindings::sdn::prefix_lists::pve_rs_sdn_prefix_lists::PerlPrefixListConfig;
     use crate::bindings::sdn::route_maps::pve_rs_sdn_route_maps::PerlRouteMapConfig;
 
+    /// Validate a route property string before storing it in zones.cfg.
+    #[export]
+    pub fn validate_static_route(route: &str) -> Result<(), Error> {
+        route.parse::<PropertyString<StaticRoute>>()?.validate()
+    }
+
+    /// Return static routes for simple zones participating on this node.
+    ///
+    /// Invalid routes are skipped with a warning.
+    #[export]
+    pub fn get_zone_routes(zones: ZoneRoutesConfig, node_id: NodeId) -> Vec<IpRoute> {
+        zones.routes_for_node(node_id.as_ref())
+    }
+
     /// Return the FRR configuration for the passed FrrConfig and the FabricsConfig as an array of
     /// strings, where each line represents a line in the FRR configuration.
     #[export]
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH pve-network v3 13/28] sdn: evpn: add unreachable IPv6 default route to zone VRFs
  2026-11-19 19:40 [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/28] SDN VRF support Gabriel Goller
                   ` (11 preceding siblings ...)
  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 ` Gabriel Goller
  2026-11-19 19:41 ` [PATCH pve-network v3 14/28] sdn: add optional VRFs for simple zones Gabriel Goller
                   ` (14 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Gabriel Goller @ 2026-11-19 19:40 UTC (permalink / raw)
  To: pve-devel

Without a family flag, ip route only adds the IPv4 unreachable default
route. IPv6 lookups that find no route in the VRF table therefore fall
through to the main table on non-exit nodes, e.g. before FRR has
installed the default route from the exit nodes.

The IPv6 route add command can fail because the kernel can disable IPv6
through the cmdline. Disabling with sysctl like we recommend still
allows IPv6 routes.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 src/PVE/Network/SDN/Zones/EvpnPlugin.pm               | 11 ++++-------
 .../evpn/advertise_subnets/expected_sdn_interfaces    |  1 +
 src/test/zones/evpn/auto_mode/expected_sdn_interfaces |  1 +
 src/test/zones/evpn/bgp_ebgp/expected_sdn_interfaces  |  1 +
 .../evpn/bgp_ebgp_multihop/expected_sdn_interfaces    |  1 +
 .../bgp_ebgp_reverse_order/expected_sdn_interfaces    |  1 +
 .../expected_sdn_interfaces                           |  1 +
 .../zones/evpn/bgp_fabric/expected_sdn_interfaces     |  1 +
 .../zones/evpn/bgp_loopback/expected_sdn_interfaces   |  1 +
 .../evpn/bgp_multipath_relax/expected_sdn_interfaces  |  1 +
 .../evpn/combined_bgp_isis/expected_sdn_interfaces    |  1 +
 .../expected_sdn_interfaces                           |  1 +
 src/test/zones/evpn/ebgp/expected_sdn_interfaces      |  1 +
 .../expected_sdn_interfaces                           |  1 +
 .../expected_sdn_interfaces                           |  1 +
 .../expected_sdn_interfaces                           |  2 ++
 .../zones/evpn/ebgp_loopback/expected_sdn_interfaces  |  1 +
 .../expected_sdn_interfaces                           |  1 +
 .../expected_sdn_interfaces                           |  2 ++
 src/test/zones/evpn/exitnode/expected_sdn_interfaces  |  1 +
 .../exitnode_local_routing/expected_sdn_interfaces    |  1 +
 .../expected_sdn_interfaces                           |  1 +
 .../evpn/exitnode_primary/expected_sdn_interfaces     |  1 +
 .../zones/evpn/exitnode_snat/expected_sdn_interfaces  |  1 +
 .../evpn/exitnodenullroute/expected_sdn_interfaces    |  2 ++
 .../evpn/frr_local_merge/expected_sdn_interfaces      |  1 +
 .../expected_sdn_interfaces                           |  1 +
 src/test/zones/evpn/ipv4/expected_sdn_interfaces      |  1 +
 src/test/zones/evpn/ipv4ipv6/expected_sdn_interfaces  |  1 +
 .../evpn/ipv4ipv6nogateway/expected_sdn_interfaces    |  1 +
 src/test/zones/evpn/ipv6/expected_sdn_interfaces      |  1 +
 .../zones/evpn/ipv6underlay/expected_sdn_interfaces   |  1 +
 src/test/zones/evpn/isis/expected_sdn_interfaces      |  1 +
 .../zones/evpn/isis_loopback/expected_sdn_interfaces  |  1 +
 .../evpn/multipath_relax/expected_sdn_interfaces      |  1 +
 .../zones/evpn/multiplezones/expected_sdn_interfaces  |  2 ++
 .../evpn/openfabric_fabric/expected_sdn_interfaces    |  1 +
 .../openfabric_fabric_ipv6/expected_sdn_interfaces    |  1 +
 .../expected_sdn_interfaces                           |  1 +
 .../zones/evpn/ospf_fabric/expected_sdn_interfaces    |  1 +
 src/test/zones/evpn/routemap/expected_sdn_interfaces  |  1 +
 .../evpn/routemap_exit_node/expected_sdn_interfaces   |  1 +
 .../evpn/routemap_prefix_list/expected_sdn_interfaces |  1 +
 src/test/zones/evpn/rt_import/expected_sdn_interfaces |  1 +
 src/test/zones/evpn/vxlanport/expected_sdn_interfaces |  1 +
 45 files changed, 52 insertions(+), 7 deletions(-)

diff --git a/src/PVE/Network/SDN/Zones/EvpnPlugin.pm b/src/PVE/Network/SDN/Zones/EvpnPlugin.pm
index c31b6c6a2bfd..0fe07eae0766 100644
--- a/src/PVE/Network/SDN/Zones/EvpnPlugin.pm
+++ b/src/PVE/Network/SDN/Zones/EvpnPlugin.pm
@@ -317,13 +317,10 @@ sub generate_sdn_config {
         #vrf interface
         @iface_config = ();
         push @iface_config, "vrf-table auto";
-        if (!$is_evpn_gateway) {
-            push @iface_config,
-                "post-up ip route add vrf $vrf_iface unreachable default metric 4278198272";
-        } else {
-            push @iface_config,
-                "post-up ip route del vrf $vrf_iface unreachable default metric 4278198272";
-        }
+        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";
 
         push(@{ $config->{$vrf_iface} }, @iface_config) if !$config->{$vrf_iface};
 
diff --git a/src/test/zones/evpn/advertise_subnets/expected_sdn_interfaces b/src/test/zones/evpn/advertise_subnets/expected_sdn_interfaces
index 9d1c64c0f3fa..a15ecfd0f5d0 100644
--- a/src/test/zones/evpn/advertise_subnets/expected_sdn_interfaces
+++ b/src/test/zones/evpn/advertise_subnets/expected_sdn_interfaces
@@ -16,6 +16,7 @@ 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
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/auto_mode/expected_sdn_interfaces b/src/test/zones/evpn/auto_mode/expected_sdn_interfaces
index 4cf13e05e688..eee7618ff3ef 100644
--- a/src/test/zones/evpn/auto_mode/expected_sdn_interfaces
+++ b/src/test/zones/evpn/auto_mode/expected_sdn_interfaces
@@ -15,6 +15,7 @@ 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
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/bgp_ebgp/expected_sdn_interfaces b/src/test/zones/evpn/bgp_ebgp/expected_sdn_interfaces
index 4cf13e05e688..eee7618ff3ef 100644
--- a/src/test/zones/evpn/bgp_ebgp/expected_sdn_interfaces
+++ b/src/test/zones/evpn/bgp_ebgp/expected_sdn_interfaces
@@ -15,6 +15,7 @@ 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
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/bgp_ebgp_multihop/expected_sdn_interfaces b/src/test/zones/evpn/bgp_ebgp_multihop/expected_sdn_interfaces
index 4cf13e05e688..eee7618ff3ef 100644
--- a/src/test/zones/evpn/bgp_ebgp_multihop/expected_sdn_interfaces
+++ b/src/test/zones/evpn/bgp_ebgp_multihop/expected_sdn_interfaces
@@ -15,6 +15,7 @@ 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
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/bgp_ebgp_reverse_order/expected_sdn_interfaces b/src/test/zones/evpn/bgp_ebgp_reverse_order/expected_sdn_interfaces
index 4cf13e05e688..eee7618ff3ef 100644
--- a/src/test/zones/evpn/bgp_ebgp_reverse_order/expected_sdn_interfaces
+++ b/src/test/zones/evpn/bgp_ebgp_reverse_order/expected_sdn_interfaces
@@ -15,6 +15,7 @@ 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
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/bgp_evpn_routemap_prefix_list/expected_sdn_interfaces b/src/test/zones/evpn/bgp_evpn_routemap_prefix_list/expected_sdn_interfaces
index 4cf13e05e688..eee7618ff3ef 100644
--- a/src/test/zones/evpn/bgp_evpn_routemap_prefix_list/expected_sdn_interfaces
+++ b/src/test/zones/evpn/bgp_evpn_routemap_prefix_list/expected_sdn_interfaces
@@ -15,6 +15,7 @@ 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
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/bgp_fabric/expected_sdn_interfaces b/src/test/zones/evpn/bgp_fabric/expected_sdn_interfaces
index fd16853cd00e..9dc094d489aa 100644
--- a/src/test/zones/evpn/bgp_fabric/expected_sdn_interfaces
+++ b/src/test/zones/evpn/bgp_fabric/expected_sdn_interfaces
@@ -16,6 +16,7 @@ auto vrf_evpn
 iface vrf_evpn
 	vrf-table auto
 	post-up ip route add vrf vrf_evpn unreachable default metric 4278198272
+	post-up ip -6 route add vrf vrf_evpn unreachable default metric 4278198272 || true
 
 auto vrfbr_evpn
 iface vrfbr_evpn
diff --git a/src/test/zones/evpn/bgp_loopback/expected_sdn_interfaces b/src/test/zones/evpn/bgp_loopback/expected_sdn_interfaces
index 4cf13e05e688..eee7618ff3ef 100644
--- a/src/test/zones/evpn/bgp_loopback/expected_sdn_interfaces
+++ b/src/test/zones/evpn/bgp_loopback/expected_sdn_interfaces
@@ -15,6 +15,7 @@ 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
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/bgp_multipath_relax/expected_sdn_interfaces b/src/test/zones/evpn/bgp_multipath_relax/expected_sdn_interfaces
index 4cf13e05e688..eee7618ff3ef 100644
--- a/src/test/zones/evpn/bgp_multipath_relax/expected_sdn_interfaces
+++ b/src/test/zones/evpn/bgp_multipath_relax/expected_sdn_interfaces
@@ -15,6 +15,7 @@ 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
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/combined_bgp_isis/expected_sdn_interfaces b/src/test/zones/evpn/combined_bgp_isis/expected_sdn_interfaces
index 4cf13e05e688..eee7618ff3ef 100644
--- a/src/test/zones/evpn/combined_bgp_isis/expected_sdn_interfaces
+++ b/src/test/zones/evpn/combined_bgp_isis/expected_sdn_interfaces
@@ -15,6 +15,7 @@ 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
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/disable_arp_nd_suppression/expected_sdn_interfaces b/src/test/zones/evpn/disable_arp_nd_suppression/expected_sdn_interfaces
index bbde90648dbb..05e4a1204351 100644
--- a/src/test/zones/evpn/disable_arp_nd_suppression/expected_sdn_interfaces
+++ b/src/test/zones/evpn/disable_arp_nd_suppression/expected_sdn_interfaces
@@ -16,6 +16,7 @@ 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
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/ebgp/expected_sdn_interfaces b/src/test/zones/evpn/ebgp/expected_sdn_interfaces
index 4cf13e05e688..eee7618ff3ef 100644
--- a/src/test/zones/evpn/ebgp/expected_sdn_interfaces
+++ b/src/test/zones/evpn/ebgp/expected_sdn_interfaces
@@ -15,6 +15,7 @@ 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
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/ebgp_evpn_ibgp_wan_evpn_ebgp/expected_sdn_interfaces b/src/test/zones/evpn/ebgp_evpn_ibgp_wan_evpn_ebgp/expected_sdn_interfaces
index 7481d3655ca9..976ab963e829 100644
--- a/src/test/zones/evpn/ebgp_evpn_ibgp_wan_evpn_ebgp/expected_sdn_interfaces
+++ b/src/test/zones/evpn/ebgp_evpn_ibgp_wan_evpn_ebgp/expected_sdn_interfaces
@@ -15,6 +15,7 @@ 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
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/ebgp_evpn_ibgp_wan_evpn_ebgp_rt_import/expected_sdn_interfaces b/src/test/zones/evpn/ebgp_evpn_ibgp_wan_evpn_ebgp_rt_import/expected_sdn_interfaces
index 7481d3655ca9..976ab963e829 100644
--- a/src/test/zones/evpn/ebgp_evpn_ibgp_wan_evpn_ebgp_rt_import/expected_sdn_interfaces
+++ b/src/test/zones/evpn/ebgp_evpn_ibgp_wan_evpn_ebgp_rt_import/expected_sdn_interfaces
@@ -15,6 +15,7 @@ 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
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/ebgp_evpn_ibgp_wan_evpn_ebgp_rt_import_mixed/expected_sdn_interfaces b/src/test/zones/evpn/ebgp_evpn_ibgp_wan_evpn_ebgp_rt_import_mixed/expected_sdn_interfaces
index 39f3beb14c58..8c8eb1861dc1 100644
--- a/src/test/zones/evpn/ebgp_evpn_ibgp_wan_evpn_ebgp_rt_import_mixed/expected_sdn_interfaces
+++ b/src/test/zones/evpn/ebgp_evpn_ibgp_wan_evpn_ebgp_rt_import_mixed/expected_sdn_interfaces
@@ -26,11 +26,13 @@ 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
 
 auto vrf_myzone2
 iface vrf_myzone2
 	vrf-table auto
 	post-up ip route add vrf vrf_myzone2 unreachable default metric 4278198272
+	post-up ip -6 route add vrf vrf_myzone2 unreachable default metric 4278198272 || true
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/ebgp_loopback/expected_sdn_interfaces b/src/test/zones/evpn/ebgp_loopback/expected_sdn_interfaces
index 4cf13e05e688..eee7618ff3ef 100644
--- a/src/test/zones/evpn/ebgp_loopback/expected_sdn_interfaces
+++ b/src/test/zones/evpn/ebgp_loopback/expected_sdn_interfaces
@@ -15,6 +15,7 @@ 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
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/evpn_cluster_ibgp_uplink_ebgp/expected_sdn_interfaces b/src/test/zones/evpn/evpn_cluster_ibgp_uplink_ebgp/expected_sdn_interfaces
index 4cf13e05e688..eee7618ff3ef 100644
--- a/src/test/zones/evpn/evpn_cluster_ibgp_uplink_ebgp/expected_sdn_interfaces
+++ b/src/test/zones/evpn/evpn_cluster_ibgp_uplink_ebgp/expected_sdn_interfaces
@@ -15,6 +15,7 @@ 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
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/evpn_multiple_zones_cluster_ibgp_uplink_ebgp/expected_sdn_interfaces b/src/test/zones/evpn/evpn_multiple_zones_cluster_ibgp_uplink_ebgp/expected_sdn_interfaces
index 88706b7c1a5d..3cc60e1bbd1a 100644
--- a/src/test/zones/evpn/evpn_multiple_zones_cluster_ibgp_uplink_ebgp/expected_sdn_interfaces
+++ b/src/test/zones/evpn/evpn_multiple_zones_cluster_ibgp_uplink_ebgp/expected_sdn_interfaces
@@ -26,11 +26,13 @@ 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
 
 auto vrf_myzone2
 iface vrf_myzone2
 	vrf-table auto
 	post-up ip route add vrf vrf_myzone2 unreachable default metric 4278198272
+	post-up ip -6 route add vrf vrf_myzone2 unreachable default metric 4278198272 || true
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/exitnode/expected_sdn_interfaces b/src/test/zones/evpn/exitnode/expected_sdn_interfaces
index 5ab308477596..572b65c47f6d 100644
--- a/src/test/zones/evpn/exitnode/expected_sdn_interfaces
+++ b/src/test/zones/evpn/exitnode/expected_sdn_interfaces
@@ -15,6 +15,7 @@ auto vrf_myzone
 iface vrf_myzone
 	vrf-table auto
 	post-up ip route del vrf vrf_myzone unreachable default metric 4278198272
+	post-up ip -6 route del vrf vrf_myzone unreachable default metric 4278198272 || true
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/exitnode_local_routing/expected_sdn_interfaces b/src/test/zones/evpn/exitnode_local_routing/expected_sdn_interfaces
index 301f5b30202a..c6e1f16c09bd 100644
--- a/src/test/zones/evpn/exitnode_local_routing/expected_sdn_interfaces
+++ b/src/test/zones/evpn/exitnode_local_routing/expected_sdn_interfaces
@@ -15,6 +15,7 @@ auto vrf_myzone
 iface vrf_myzone
 	vrf-table auto
 	post-up ip route del vrf vrf_myzone unreachable default metric 4278198272
+	post-up ip -6 route del vrf vrf_myzone unreachable default metric 4278198272 || true
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/exitnode_local_routing_ipv6/expected_sdn_interfaces b/src/test/zones/evpn/exitnode_local_routing_ipv6/expected_sdn_interfaces
index b46d4e7b6ea0..aa34a274cea2 100644
--- a/src/test/zones/evpn/exitnode_local_routing_ipv6/expected_sdn_interfaces
+++ b/src/test/zones/evpn/exitnode_local_routing_ipv6/expected_sdn_interfaces
@@ -15,6 +15,7 @@ auto vrf_myzone
 iface vrf_myzone
 	vrf-table auto
 	post-up ip route del vrf vrf_myzone unreachable default metric 4278198272
+	post-up ip -6 route del vrf vrf_myzone unreachable default metric 4278198272 || true
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/exitnode_primary/expected_sdn_interfaces b/src/test/zones/evpn/exitnode_primary/expected_sdn_interfaces
index 5ab308477596..572b65c47f6d 100644
--- a/src/test/zones/evpn/exitnode_primary/expected_sdn_interfaces
+++ b/src/test/zones/evpn/exitnode_primary/expected_sdn_interfaces
@@ -15,6 +15,7 @@ auto vrf_myzone
 iface vrf_myzone
 	vrf-table auto
 	post-up ip route del vrf vrf_myzone unreachable default metric 4278198272
+	post-up ip -6 route del vrf vrf_myzone unreachable default metric 4278198272 || true
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/exitnode_snat/expected_sdn_interfaces b/src/test/zones/evpn/exitnode_snat/expected_sdn_interfaces
index 0d7d17412f0b..b607231bbbfc 100644
--- a/src/test/zones/evpn/exitnode_snat/expected_sdn_interfaces
+++ b/src/test/zones/evpn/exitnode_snat/expected_sdn_interfaces
@@ -34,6 +34,7 @@ auto vrf_myzone
 iface vrf_myzone
 	vrf-table auto
 	post-up ip route del vrf vrf_myzone unreachable default metric 4278198272
+	post-up ip -6 route del vrf vrf_myzone unreachable default metric 4278198272 || true
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/exitnodenullroute/expected_sdn_interfaces b/src/test/zones/evpn/exitnodenullroute/expected_sdn_interfaces
index 4bf5ccf96f91..ef8df562d351 100644
--- a/src/test/zones/evpn/exitnodenullroute/expected_sdn_interfaces
+++ b/src/test/zones/evpn/exitnodenullroute/expected_sdn_interfaces
@@ -34,11 +34,13 @@ auto vrf_myzone
 iface vrf_myzone
 	vrf-table auto
 	post-up ip route del vrf vrf_myzone unreachable default metric 4278198272
+	post-up ip -6 route del vrf vrf_myzone unreachable default metric 4278198272 || true
 
 auto vrf_myzone2
 iface vrf_myzone2
 	vrf-table auto
 	post-up ip route del vrf vrf_myzone2 unreachable default metric 4278198272
+	post-up ip -6 route del vrf vrf_myzone2 unreachable default metric 4278198272 || true
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/frr_local_merge/expected_sdn_interfaces b/src/test/zones/evpn/frr_local_merge/expected_sdn_interfaces
index c7ddf44ef6d3..7a7f94b60edf 100644
--- a/src/test/zones/evpn/frr_local_merge/expected_sdn_interfaces
+++ b/src/test/zones/evpn/frr_local_merge/expected_sdn_interfaces
@@ -16,6 +16,7 @@ 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
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/frr_local_merge_router_without_exit/expected_sdn_interfaces b/src/test/zones/evpn/frr_local_merge_router_without_exit/expected_sdn_interfaces
index 169f32d38951..18e10f714a64 100644
--- a/src/test/zones/evpn/frr_local_merge_router_without_exit/expected_sdn_interfaces
+++ b/src/test/zones/evpn/frr_local_merge_router_without_exit/expected_sdn_interfaces
@@ -16,6 +16,7 @@ auto vrf_evpnz
 iface vrf_evpnz
 	vrf-table auto
 	post-up ip route add vrf vrf_evpnz unreachable default metric 4278198272
+	post-up ip -6 route add vrf vrf_evpnz unreachable default metric 4278198272 || true
 
 auto vrfbr_evpnz
 iface vrfbr_evpnz
diff --git a/src/test/zones/evpn/ipv4/expected_sdn_interfaces b/src/test/zones/evpn/ipv4/expected_sdn_interfaces
index 9d1c64c0f3fa..a15ecfd0f5d0 100644
--- a/src/test/zones/evpn/ipv4/expected_sdn_interfaces
+++ b/src/test/zones/evpn/ipv4/expected_sdn_interfaces
@@ -16,6 +16,7 @@ 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
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/ipv4ipv6/expected_sdn_interfaces b/src/test/zones/evpn/ipv4ipv6/expected_sdn_interfaces
index 7a5d741b067c..7c8e41db2d64 100644
--- a/src/test/zones/evpn/ipv4ipv6/expected_sdn_interfaces
+++ b/src/test/zones/evpn/ipv4ipv6/expected_sdn_interfaces
@@ -18,6 +18,7 @@ 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
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/ipv4ipv6nogateway/expected_sdn_interfaces b/src/test/zones/evpn/ipv4ipv6nogateway/expected_sdn_interfaces
index 378fa77fa368..56a38b79db89 100644
--- a/src/test/zones/evpn/ipv4ipv6nogateway/expected_sdn_interfaces
+++ b/src/test/zones/evpn/ipv4ipv6nogateway/expected_sdn_interfaces
@@ -14,6 +14,7 @@ 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
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/ipv6/expected_sdn_interfaces b/src/test/zones/evpn/ipv6/expected_sdn_interfaces
index b2bdbfefd810..e19500849ab2 100644
--- a/src/test/zones/evpn/ipv6/expected_sdn_interfaces
+++ b/src/test/zones/evpn/ipv6/expected_sdn_interfaces
@@ -16,6 +16,7 @@ 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
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/ipv6underlay/expected_sdn_interfaces b/src/test/zones/evpn/ipv6underlay/expected_sdn_interfaces
index 3b91f75eb3dd..a0efc06f6ea6 100644
--- a/src/test/zones/evpn/ipv6underlay/expected_sdn_interfaces
+++ b/src/test/zones/evpn/ipv6underlay/expected_sdn_interfaces
@@ -16,6 +16,7 @@ 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
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/isis/expected_sdn_interfaces b/src/test/zones/evpn/isis/expected_sdn_interfaces
index 4cf13e05e688..eee7618ff3ef 100644
--- a/src/test/zones/evpn/isis/expected_sdn_interfaces
+++ b/src/test/zones/evpn/isis/expected_sdn_interfaces
@@ -15,6 +15,7 @@ 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
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/isis_loopback/expected_sdn_interfaces b/src/test/zones/evpn/isis_loopback/expected_sdn_interfaces
index e595dc93f60a..add32eb4a63e 100644
--- a/src/test/zones/evpn/isis_loopback/expected_sdn_interfaces
+++ b/src/test/zones/evpn/isis_loopback/expected_sdn_interfaces
@@ -15,6 +15,7 @@ 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
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/multipath_relax/expected_sdn_interfaces b/src/test/zones/evpn/multipath_relax/expected_sdn_interfaces
index 4cf13e05e688..eee7618ff3ef 100644
--- a/src/test/zones/evpn/multipath_relax/expected_sdn_interfaces
+++ b/src/test/zones/evpn/multipath_relax/expected_sdn_interfaces
@@ -15,6 +15,7 @@ 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
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/multiplezones/expected_sdn_interfaces b/src/test/zones/evpn/multiplezones/expected_sdn_interfaces
index e279b0a5770f..ab0a4ac2b63c 100644
--- a/src/test/zones/evpn/multiplezones/expected_sdn_interfaces
+++ b/src/test/zones/evpn/multiplezones/expected_sdn_interfaces
@@ -26,11 +26,13 @@ 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
 
 auto vrf_myzone2
 iface vrf_myzone2
 	vrf-table auto
 	post-up ip route add vrf vrf_myzone2 unreachable default metric 4278198272
+	post-up ip -6 route add vrf vrf_myzone2 unreachable default metric 4278198272 || true
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/openfabric_fabric/expected_sdn_interfaces b/src/test/zones/evpn/openfabric_fabric/expected_sdn_interfaces
index 7460b12ce686..fbb594e19cd1 100644
--- a/src/test/zones/evpn/openfabric_fabric/expected_sdn_interfaces
+++ b/src/test/zones/evpn/openfabric_fabric/expected_sdn_interfaces
@@ -16,6 +16,7 @@ auto vrf_evpn
 iface vrf_evpn
 	vrf-table auto
 	post-up ip route add vrf vrf_evpn unreachable default metric 4278198272
+	post-up ip -6 route add vrf vrf_evpn unreachable default metric 4278198272 || true
 
 auto vrfbr_evpn
 iface vrfbr_evpn
diff --git a/src/test/zones/evpn/openfabric_fabric_ipv6/expected_sdn_interfaces b/src/test/zones/evpn/openfabric_fabric_ipv6/expected_sdn_interfaces
index d01771386658..ec7079ce0371 100644
--- a/src/test/zones/evpn/openfabric_fabric_ipv6/expected_sdn_interfaces
+++ b/src/test/zones/evpn/openfabric_fabric_ipv6/expected_sdn_interfaces
@@ -16,6 +16,7 @@ auto vrf_evpn
 iface vrf_evpn
 	vrf-table auto
 	post-up ip route add vrf vrf_evpn unreachable default metric 4278198272
+	post-up ip -6 route add vrf vrf_evpn unreachable default metric 4278198272 || true
 
 auto vrfbr_evpn
 iface vrfbr_evpn
diff --git a/src/test/zones/evpn/openfabric_fabric_ipv6_only/expected_sdn_interfaces b/src/test/zones/evpn/openfabric_fabric_ipv6_only/expected_sdn_interfaces
index 51507d7d3fbe..67694b09d7c4 100644
--- a/src/test/zones/evpn/openfabric_fabric_ipv6_only/expected_sdn_interfaces
+++ b/src/test/zones/evpn/openfabric_fabric_ipv6_only/expected_sdn_interfaces
@@ -16,6 +16,7 @@ auto vrf_evpn
 iface vrf_evpn
 	vrf-table auto
 	post-up ip route add vrf vrf_evpn unreachable default metric 4278198272
+	post-up ip -6 route add vrf vrf_evpn unreachable default metric 4278198272 || true
 
 auto vrfbr_evpn
 iface vrfbr_evpn
diff --git a/src/test/zones/evpn/ospf_fabric/expected_sdn_interfaces b/src/test/zones/evpn/ospf_fabric/expected_sdn_interfaces
index 2543304a47ba..c737b8ebe1af 100644
--- a/src/test/zones/evpn/ospf_fabric/expected_sdn_interfaces
+++ b/src/test/zones/evpn/ospf_fabric/expected_sdn_interfaces
@@ -16,6 +16,7 @@ auto vrf_evpn
 iface vrf_evpn
 	vrf-table auto
 	post-up ip route add vrf vrf_evpn unreachable default metric 4278198272
+	post-up ip -6 route add vrf vrf_evpn unreachable default metric 4278198272 || true
 
 auto vrfbr_evpn
 iface vrfbr_evpn
diff --git a/src/test/zones/evpn/routemap/expected_sdn_interfaces b/src/test/zones/evpn/routemap/expected_sdn_interfaces
index 4cf13e05e688..eee7618ff3ef 100644
--- a/src/test/zones/evpn/routemap/expected_sdn_interfaces
+++ b/src/test/zones/evpn/routemap/expected_sdn_interfaces
@@ -15,6 +15,7 @@ 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
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/routemap_exit_node/expected_sdn_interfaces b/src/test/zones/evpn/routemap_exit_node/expected_sdn_interfaces
index 5ab308477596..572b65c47f6d 100644
--- a/src/test/zones/evpn/routemap_exit_node/expected_sdn_interfaces
+++ b/src/test/zones/evpn/routemap_exit_node/expected_sdn_interfaces
@@ -15,6 +15,7 @@ auto vrf_myzone
 iface vrf_myzone
 	vrf-table auto
 	post-up ip route del vrf vrf_myzone unreachable default metric 4278198272
+	post-up ip -6 route del vrf vrf_myzone unreachable default metric 4278198272 || true
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/routemap_prefix_list/expected_sdn_interfaces b/src/test/zones/evpn/routemap_prefix_list/expected_sdn_interfaces
index 4cf13e05e688..eee7618ff3ef 100644
--- a/src/test/zones/evpn/routemap_prefix_list/expected_sdn_interfaces
+++ b/src/test/zones/evpn/routemap_prefix_list/expected_sdn_interfaces
@@ -15,6 +15,7 @@ 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
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/rt_import/expected_sdn_interfaces b/src/test/zones/evpn/rt_import/expected_sdn_interfaces
index 9d1c64c0f3fa..a15ecfd0f5d0 100644
--- a/src/test/zones/evpn/rt_import/expected_sdn_interfaces
+++ b/src/test/zones/evpn/rt_import/expected_sdn_interfaces
@@ -16,6 +16,7 @@ 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
 
 auto vrfbr_myzone
 iface vrfbr_myzone
diff --git a/src/test/zones/evpn/vxlanport/expected_sdn_interfaces b/src/test/zones/evpn/vxlanport/expected_sdn_interfaces
index d511bf99eca1..385b70b5c0fc 100644
--- a/src/test/zones/evpn/vxlanport/expected_sdn_interfaces
+++ b/src/test/zones/evpn/vxlanport/expected_sdn_interfaces
@@ -16,6 +16,7 @@ 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
 
 auto vrfbr_myzone
 iface vrfbr_myzone
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH pve-network v3 14/28] sdn: add optional VRFs for simple zones
  2026-11-19 19:40 [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/28] SDN VRF support Gabriel Goller
                   ` (12 preceding siblings ...)
  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
  2026-11-19 19:41 ` [PATCH pve-network v3 15/28] sdn: allow fabrics to use simple zone VRFs Gabriel Goller
                   ` (13 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Gabriel Goller @ 2026-11-19 19:41 UTC (permalink / raw)
  To: pve-devel

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





^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH pve-network v3 15/28] sdn: allow fabrics to use simple zone VRFs
  2026-11-19 19:40 [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/28] SDN VRF support Gabriel Goller
                   ` (13 preceding siblings ...)
  2026-11-19 19:41 ` [PATCH pve-network v3 14/28] sdn: add optional VRFs for simple zones Gabriel Goller
@ 2026-11-19 19:41 ` Gabriel Goller
  2026-11-19 19:41 ` [PATCH pve-network v3 16/28] sdn: require underlay fabrics to use the default VRF Gabriel Goller
                   ` (12 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Gabriel Goller @ 2026-11-19 19:41 UTC (permalink / raw)
  To: pve-devel

Let BGP and OSPF fabrics use a simple zone with dedicated-vrf enabled
to keep their routes separate from the default VRF.

The zone must be enabled on every fabric node. Prevent zone changes
or deletion that would leave a fabric without its VRF. A fabric's zone
cannot be changed after creation, since that resets all its sessions
anyway and other objects rely on the fabric staying in its VRF.

Fail to generate the network config when a fabric interface also has a
VRF set in /etc/network/interfaces. ifupdown2 would apply only one of
the two VRFs, usually the host one, so the fabric would silently lose
the link. The fabric API cannot check this, because it does not see the
interfaces file of each node.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 src/PVE/API2/Network/SDN/Fabrics/Fabric.pm    | 56 +++++++++--
 .../API2/Network/SDN/Fabrics/FabricNode.pm    | 20 ++++
 src/PVE/API2/Network/SDN/Zones.pm             | 28 ++++++
 src/PVE/Network/SDN/Controllers/BgpPlugin.pm  |  2 +-
 src/PVE/Network/SDN/Fabrics.pm                | 39 ++++++++
 src/test/Makefile                             |  5 +-
 src/test/run_test_fabric_host_vrf.pl          | 93 +++++++++++++++++++
 7 files changed, 232 insertions(+), 11 deletions(-)
 create mode 100755 src/test/run_test_fabric_host_vrf.pl

diff --git a/src/PVE/API2/Network/SDN/Fabrics/Fabric.pm b/src/PVE/API2/Network/SDN/Fabrics/Fabric.pm
index bbc33e047154..453fc0e20a69 100644
--- a/src/PVE/API2/Network/SDN/Fabrics/Fabric.pm
+++ b/src/PVE/API2/Network/SDN/Fabrics/Fabric.pm
@@ -6,13 +6,51 @@ use warnings;
 use PVE::Network::SDN;
 use PVE::Network::SDN::Controllers;
 use PVE::Network::SDN::Fabrics;
+use PVE::Network::SDN::Zones;
 
+use PVE::Exception qw(raise_param_exc);
 use PVE::JSONSchema qw(get_standard_option);
 use PVE::Tools qw(extract_param);
 
 use PVE::RESTHandler;
 use base qw(PVE::RESTHandler);
 
+sub validate_fabric_zone {
+    my ($fabric, $config) = @_;
+
+    my $protocol = $fabric->{protocol} // '';
+    if ($protocol eq 'bgp' && !$fabric->{zone}) {
+        my $controller_cfg = PVE::Network::SDN::Controllers::config();
+        for my $controller_id (keys %{ $controller_cfg->{ids} // {} }) {
+            my $controller = $controller_cfg->{ids}->{$controller_id};
+            if ($controller->{type} eq 'bgp') {
+                die "cannot configure a BGP fabric while BGP controller '$controller_id' exists:"
+                    . " both target the default-VRF BGP router\n";
+            }
+        }
+    }
+
+    my $zone_id = $fabric->{zone};
+    return if !$zone_id;
+
+    raise_param_exc({ zone => 'VRF zones are only supported for BGP and OSPF fabrics' })
+        if $protocol !~ /^(?:bgp|ospf)$/;
+
+    my $zone = PVE::Network::SDN::Zones::get_zone($zone_id);
+
+    raise_param_exc({ zone => "zone '$zone_id' does not exist" }) if !$zone;
+    raise_param_exc({ zone => "zone '$zone_id' is not a simple zone" })
+        if $zone->{type} ne 'simple';
+    raise_param_exc({ zone => "zone '$zone_id' is configured to use the default VRF" })
+        if !$zone->{'dedicated-vrf'};
+
+    if ($config) {
+        PVE::Network::SDN::Fabrics::assert_fabric_nodes_in_zone(
+            $config, $fabric->{id}, $zone_id, $zone,
+        );
+    }
+}
+
 __PACKAGE__->register_method({
     name => 'index',
     path => '',
@@ -129,6 +167,8 @@ __PACKAGE__->register_method({
     protected => 1,
     permissions => {
         check => ['perm', '/sdn/fabrics', ['SDN.Allocate']],
+        description => "Assigning a VRF zone additionally requires 'SDN.Use' or 'SDN.Allocate'"
+            . " on '/sdn/zones/<zone>'.",
     },
     parameters => {
         properties => PVE::Network::SDN::Fabrics::fabric_properties(0),
@@ -148,18 +188,11 @@ __PACKAGE__->register_method({
                 my $digest = extract_param($param, 'digest');
                 PVE::Tools::assert_if_modified($config->digest(), $digest) if $digest;
 
-                if (($param->{protocol} // '') eq 'bgp') {
-                    my $controller_cfg = PVE::Network::SDN::Controllers::config();
-                    for my $id (keys %{ $controller_cfg->{ids} // {} }) {
-                        die "cannot add a BGP fabric while BGP controller '$id' exists:"
-                            . " both target the default-VRF BGP router\n"
-                            if $controller_cfg->{ids}->{$id}->{type} eq 'bgp';
-                    }
-                }
-
                 my $privs = ['SDN.Use', 'SDN.Allocate'];
                 PVE::Network::SDN::Fabrics::api_validate_property_references($param, $privs);
 
+                validate_fabric_zone($param);
+
                 $config->add_fabric($param);
                 PVE::Network::SDN::Fabrics::write_config($config);
             },
@@ -200,7 +233,12 @@ __PACKAGE__->register_method({
                 my $privs = ['SDN.Use', 'SDN.Allocate'];
                 PVE::Network::SDN::Fabrics::api_validate_property_references($param, $privs);
 
+                my $old_zone = $config->get_fabric($id)->{zone} // '';
+                raise_param_exc({ zone => "cannot change the VRF zone of an existing fabric" })
+                    if defined($param->{zone}) && $param->{zone} ne $old_zone;
+
                 $config->update_fabric($id, $param);
+                validate_fabric_zone($config->get_fabric($id), $config);
                 PVE::Network::SDN::Fabrics::write_config($config);
             },
             "updating fabric failed",
diff --git a/src/PVE/API2/Network/SDN/Fabrics/FabricNode.pm b/src/PVE/API2/Network/SDN/Fabrics/FabricNode.pm
index 7a148b550f7d..e5272bb82f68 100644
--- a/src/PVE/API2/Network/SDN/Fabrics/FabricNode.pm
+++ b/src/PVE/API2/Network/SDN/Fabrics/FabricNode.pm
@@ -9,6 +9,7 @@ use PVE::Tools qw(extract_param run_command);
 use PVE::Network::SDN;
 use PVE::Network::SDN::Fabrics;
 use PVE::Network::SDN::WireGuard;
+use PVE::Network::SDN::Zones;
 use PVE::RS::SDN::Fabrics;
 
 use PVE::RESTHandler;
@@ -138,6 +139,21 @@ my sub is_internal_wireguard_node {
     return $node->{protocol} eq 'wireguard' && $node->{role} eq 'internal';
 }
 
+my sub validate_node_fabric_zone {
+    my ($config, $fabric_id, $node_id) = @_;
+
+    my $fabric = $config->get_fabric($fabric_id);
+    my $zone_id = $fabric->{zone};
+    return if !$zone_id;
+
+    PVE::Network::SDN::Zones::api_get_zone_checked($zone_id, ['SDN.Use', 'SDN.Allocate']);
+    my $zone = PVE::Network::SDN::Zones::get_zone($zone_id);
+
+    PVE::Network::SDN::Fabrics::assert_fabric_node_in_zone(
+        $fabric_id, $node_id, $zone_id, $zone,
+    );
+}
+
 __PACKAGE__->register_method({
     name => 'add_node',
     path => '',
@@ -150,6 +166,8 @@ __PACKAGE__->register_method({
             ['perm', '/sdn/fabrics/{fabric_id}', ['SDN.Allocate']],
             ['perm', '/nodes/{node_id}', ['Sys.Modify']],
         ],
+        description => "If the fabric uses a VRF zone, also requires 'SDN.Use' or"
+            . " 'SDN.Allocate' on '/sdn/zones/<zone>'.",
     },
     parameters => {
         properties => PVE::Network::SDN::Fabrics::node_properties(0),
@@ -169,6 +187,8 @@ __PACKAGE__->register_method({
                 my $digest = extract_param($param, 'digest');
                 PVE::Tools::assert_if_modified($config->digest(), $digest) if $digest;
 
+                validate_node_fabric_zone($config, $param->{fabric_id}, $param->{node_id});
+
                 if (is_internal_wireguard_node($param) && $param->{interfaces}) {
                     my $private_keys = PVE::Network::SDN::WireGuard::private_keys();
 
diff --git a/src/PVE/API2/Network/SDN/Zones.pm b/src/PVE/API2/Network/SDN/Zones.pm
index 38d950fda076..e4f4b174466e 100644
--- a/src/PVE/API2/Network/SDN/Zones.pm
+++ b/src/PVE/API2/Network/SDN/Zones.pm
@@ -11,6 +11,7 @@ use PVE::SafeSyslog;
 use PVE::Tools qw(extract_param);
 
 use PVE::Network::SDN::Dns;
+use PVE::Network::SDN::Fabrics;
 use PVE::Network::SDN::Subnets;
 use PVE::Network::SDN::Vnets;
 use PVE::Network::SDN;
@@ -363,6 +364,13 @@ sub create_etc_interfaces_sdn_dir {
     mkdir("/etc/pve/sdn");
 }
 
+sub fabrics_using_zone {
+    my ($zone_id, $fabric_config) = @_;
+
+    my $fabrics = $fabric_config->list_fabrics();
+    return grep { ($fabrics->{$_}->{zone} // '') eq $zone_id } sort keys $fabrics->%*;
+}
+
 __PACKAGE__->register_method({
     name => 'create',
     protected => 1,
@@ -475,6 +483,22 @@ __PACKAGE__->register_method({
 
                 $scfg->{$_} = $opts->{$_} for keys $opts->%*;
 
+                my $fabric_config = PVE::Network::SDN::Fabrics::config();
+                my @fabric_ids = fabrics_using_zone($id, $fabric_config);
+
+                if (@fabric_ids && $scfg->{type} eq 'simple' && !$scfg->{'dedicated-vrf'}) {
+                    raise_param_exc({
+                        'dedicated-vrf' =>
+                            "zone is still used as VRF by fabric '$fabric_ids[0]'",
+                    });
+                }
+
+                for my $fabric_id (@fabric_ids) {
+                    PVE::Network::SDN::Fabrics::assert_fabric_nodes_in_zone(
+                        $fabric_config, $fabric_id, $id, $scfg,
+                    );
+                }
+
                 my $new_ipam = $scfg->{ipam};
                 if (!$new_ipam != !$old_ipam || (($new_ipam // '') ne ($old_ipam // ''))) {
                     # don't allow ipam change if subnet are defined for now, need to implement resync ipam content
@@ -547,6 +571,10 @@ __PACKAGE__->register_method({
                 my $plugin = PVE::Network::SDN::Zones::Plugin->lookup($scfg->{type});
                 my $vnet_cfg = PVE::Network::SDN::Vnets::config();
 
+                my $fabric_config = PVE::Network::SDN::Fabrics::config();
+                my @fabric_ids = fabrics_using_zone($id, $fabric_config);
+                die "zone is still used as VRF by fabric '$fabric_ids[0]'\n" if @fabric_ids;
+
                 $plugin->on_delete_hook($id, $vnet_cfg);
 
                 delete $cfg->{ids}->{$id};
diff --git a/src/PVE/Network/SDN/Controllers/BgpPlugin.pm b/src/PVE/Network/SDN/Controllers/BgpPlugin.pm
index 537b46229e58..328246ce7d77 100644
--- a/src/PVE/Network/SDN/Controllers/BgpPlugin.pm
+++ b/src/PVE/Network/SDN/Controllers/BgpPlugin.pm
@@ -209,7 +209,7 @@ sub on_update_hook {
     for my $id (keys %$fabrics) {
         die "cannot configure a BGP controller while BGP fabric '$id' exists:"
             . " both target the default-VRF BGP router\n"
-            if $fabrics->{$id}->{protocol} eq 'bgp';
+            if $fabrics->{$id}->{protocol} eq 'bgp' && !$fabrics->{$id}->{zone};
     }
 
     my $controller = $controller_cfg->{ids}->{$controllerid};
diff --git a/src/PVE/Network/SDN/Fabrics.pm b/src/PVE/Network/SDN/Fabrics.pm
index 41119b2ec782..5202ad62e520 100644
--- a/src/PVE/Network/SDN/Fabrics.pm
+++ b/src/PVE/Network/SDN/Fabrics.pm
@@ -13,6 +13,7 @@ use PVE::ParseUtils qw($IPV4RE);
 
 use PVE::Network::SDN::PrefixLists;
 use PVE::Network::SDN::RouteMaps;
+use PVE::Network::SDN::Zones;
 
 use PVE::RS::SDN;
 use PVE::RS::SDN::Fabrics;
@@ -229,6 +230,23 @@ sub write_config {
     cfs_write_file("sdn/fabrics.cfg", $config->to_raw(), 1);
 }
 
+sub assert_fabric_node_in_zone {
+    my ($fabric_id, $node_id, $zone_id, $zone) = @_;
+
+    return if !defined($zone->{nodes}) || $zone->{nodes}->{$node_id};
+
+    die "fabric '$fabric_id' contains node '$node_id', which is not enabled for zone '$zone_id'\n";
+}
+
+sub assert_fabric_nodes_in_zone {
+    my ($config, $fabric_id, $zone_id, $zone) = @_;
+
+    my $nodes = $config->list_nodes_fabric($fabric_id);
+    for my $node_id (sort keys $nodes->%*) {
+        assert_fabric_node_in_zone($fabric_id, $node_id, $zone_id, $zone);
+    }
+}
+
 sub get_frr_daemon_status {
     my ($fabric_config) = @_;
 
@@ -254,6 +272,14 @@ sub generate_etc_network_config {
     my $fabrics_config = $running_cfg->{fabrics}->{ids} // {};
     my $fabric_object = PVE::RS::SDN::Fabrics->running_config($fabrics_config);
 
+    my $ifaces = PVE::INotify::read_file('interfaces')->{ifaces};
+    for my $iface (sort keys %$ifaces) {
+        next if !$ifaces->{$iface}->{vrf};
+        die "interface '$iface' - cannot set VRF '$ifaces->{$iface}->{vrf}' on an interface that"
+            . " is part of a fabric, remove the VRF from the host interface\n"
+            if $fabric_object->is_fabric_interface($nodename, $iface);
+    }
+
     return $fabric_object->get_interfaces_etc_network_config($nodename);
 }
 
@@ -512,6 +538,15 @@ sub fabric_properties {
         protocol => get_standard_option('pve-sdn-fabric-protocol'),
         digest => get_standard_option('pve-config-digest'),
         'lock-token' => get_standard_option('pve-sdn-lock-token'),
+        zone => get_standard_option(
+            'pve-sdn-zone-id',
+            {
+                description => 'Simple zone whose VRF contains this fabric.',
+                'type-property' => 'protocol',
+                'instance-types' => ['bgp', 'ospf'],
+                optional => 1,
+            },
+        ),
         ip_prefix => {
             type => 'string',
             format => 'CIDR',
@@ -716,6 +751,10 @@ sub api_validate_property_references {
     my $prefix_list_config = PVE::Network::SDN::PrefixLists::config();
     my $route_map_config = PVE::Network::SDN::RouteMaps::config();
 
+    if (my $zone = $fabric->{zone}) {
+        PVE::Network::SDN::Zones::api_get_zone_checked($zone, $privs);
+    }
+
     if (my $route_filter = $fabric->{'route_filter'}) {
         raise_param_exc({ route_filter => "could not find prefix list $route_filter" })
             if !$prefix_list_config->get($route_filter);
diff --git a/src/test/Makefile b/src/test/Makefile
index 2e35a3d0ae2a..3df96852f27f 100644
--- a/src/test/Makefile
+++ b/src/test/Makefile
@@ -1,10 +1,13 @@
 all: test
 
-test: test_zones test_ipams test_dns test_subnets test_vnets_blackbox test_running_config test_api_index
+test: test_zones test_fabric_host_vrf test_ipams test_dns test_subnets test_vnets_blackbox test_running_config test_api_index
 
 test_zones: run_test_zones.pl
 	./run_test_zones.pl
 
+test_fabric_host_vrf: run_test_fabric_host_vrf.pl
+	./run_test_fabric_host_vrf.pl
+
 test_ipams: run_test_ipams.pl
 	./run_test_ipams.pl
 
diff --git a/src/test/run_test_fabric_host_vrf.pl b/src/test/run_test_fabric_host_vrf.pl
new file mode 100755
index 000000000000..9ed3f2579d34
--- /dev/null
+++ b/src/test/run_test_fabric_host_vrf.pl
@@ -0,0 +1,93 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use lib qw(..);
+
+use Test::More;
+use Test::MockModule;
+
+use PVE::Network::SDN::Fabrics;
+
+my $running_cfg = {
+    fabrics => {
+        ids => {
+            test => {
+                id => 'test',
+                type => 'ospf_fabric',
+                area => '0',
+                ip_prefix => '172.20.30.0/24',
+            },
+            test_localhost => {
+                id => 'test_localhost',
+                type => 'ospf_node',
+                ip => '172.20.30.1',
+                interfaces => ['name=ens19,ip=172.16.3.10/31'],
+            },
+        },
+    },
+};
+
+my $interfaces;
+my $inotify = Test::MockModule->new('PVE::INotify');
+$inotify->mock(
+    nodename => sub { return 'localhost' },
+    read_file => sub {
+        my ($file) = @_;
+        die "unexpected read of '$file'\n" if $file ne 'interfaces';
+        return { ifaces => $interfaces };
+    },
+);
+
+$interfaces = { ens19 => { vrf => 'vrf_blue' } };
+eval { PVE::Network::SDN::Fabrics::generate_etc_network_config($running_cfg) };
+like(
+    $@,
+    qr/^interface 'ens19' - cannot set VRF 'vrf_blue' on an interface that is part of a fabric/,
+    'VRF on a fabric interface fails',
+);
+
+$interfaces = { ens20 => { vrf => 'vrf_blue' }, ens19 => {} };
+my $config = eval { PVE::Network::SDN::Fabrics::generate_etc_network_config($running_cfg) };
+is($@, '', 'VRF on another interface is allowed');
+like($config, qr/^iface ens19 inet static$/m, 'fabric interface config is generated');
+
+my $zone_cfg = {
+    fabrics => {
+        ids => {
+            red => {
+                id => 'red',
+                type => 'ospf_fabric',
+                area => '0',
+                ip_prefix => '172.20.30.0/24',
+                zone => 'red',
+            },
+            red_localhost => {
+                id => 'red_localhost',
+                type => 'ospf_node',
+                ip => '172.20.30.1',
+                interfaces => ['name=ens19,ip=172.16.3.10/31'],
+            },
+        },
+    },
+};
+
+$interfaces = { ens19 => {} };
+$config = eval { PVE::Network::SDN::Fabrics::generate_etc_network_config($zone_cfg) };
+is($@, '', 'OSPF fabric in a zone VRF is allowed');
+like(
+    $config,
+    qr/^iface ens19 inet static\n(?:\t.*\n)*\tvrf vrf_red$/m,
+    'fabric interface is put into the zone VRF',
+);
+
+$interfaces = { ens19 => { vrf => 'vrf_red' } };
+eval { PVE::Network::SDN::Fabrics::generate_etc_network_config($zone_cfg) };
+like(
+    $@,
+    qr/^interface 'ens19' - cannot set VRF 'vrf_red'/,
+    'host VRF on a zone fabric interface fails',
+);
+
+done_testing();
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH pve-network v3 16/28] sdn: require underlay fabrics to use the default VRF
  2026-11-19 19:40 [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/28] SDN VRF support Gabriel Goller
                   ` (14 preceding siblings ...)
  2026-11-19 19:41 ` [PATCH pve-network v3 15/28] sdn: allow fabrics to use simple zone VRFs Gabriel Goller
@ 2026-11-19 19:41 ` 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
                   ` (11 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Gabriel Goller @ 2026-11-19 19:41 UTC (permalink / raw)
  To: pve-devel

EVPN controllers and VXLAN zones set up their VTEPs and BGP peering in
the default VRF, so an underlay fabric in a zone VRF breaks them. A
fabric's VRF cannot change after creation, so checking the fabric when
a controller or zone references it is enough.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 src/PVE/Network/SDN/Controllers/EvpnPlugin.pm | 2 ++
 src/PVE/Network/SDN/Fabrics.pm                | 9 +++++++++
 src/PVE/Network/SDN/Zones/VxlanPlugin.pm      | 5 +++++
 3 files changed, 16 insertions(+)

diff --git a/src/PVE/Network/SDN/Controllers/EvpnPlugin.pm b/src/PVE/Network/SDN/Controllers/EvpnPlugin.pm
index 4220cb6721e5..67afe936ecc9 100644
--- a/src/PVE/Network/SDN/Controllers/EvpnPlugin.pm
+++ b/src/PVE/Network/SDN/Controllers/EvpnPlugin.pm
@@ -688,6 +688,8 @@ sub on_update_hook {
         die "must have exactly one of peers / fabric defined"
             if ($controller->{peers} && $controller->{fabric})
             || !($controller->{peers} || $controller->{fabric});
+        PVE::Network::SDN::Fabrics::assert_underlay_fabric($controller->{fabric})
+            if $controller->{fabric};
         if ($controller->{peers}) {
             my @peers = PVE::Tools::split_list($controller->{peers});
             my $family;
diff --git a/src/PVE/Network/SDN/Fabrics.pm b/src/PVE/Network/SDN/Fabrics.pm
index 5202ad62e520..d881937f42fd 100644
--- a/src/PVE/Network/SDN/Fabrics.pm
+++ b/src/PVE/Network/SDN/Fabrics.pm
@@ -247,6 +247,15 @@ sub assert_fabric_nodes_in_zone {
     }
 }
 
+sub assert_underlay_fabric {
+    my ($fabric_id) = @_;
+
+    my $fabric = eval { config()->get_fabric($fabric_id) };
+    die "fabric '$fabric_id' does not exist\n" if !$fabric;
+    die "fabric '$fabric_id' is in a zone VRF, underlay fabrics must use the default VRF\n"
+        if $fabric->{zone};
+}
+
 sub get_frr_daemon_status {
     my ($fabric_config) = @_;
 
diff --git a/src/PVE/Network/SDN/Zones/VxlanPlugin.pm b/src/PVE/Network/SDN/Zones/VxlanPlugin.pm
index b8b1ef0eeb7f..059bc90f4211 100644
--- a/src/PVE/Network/SDN/Zones/VxlanPlugin.pm
+++ b/src/PVE/Network/SDN/Zones/VxlanPlugin.pm
@@ -167,6 +167,11 @@ sub on_update_hook {
             fabric => "must have exactly one of peers / fabric defined",
         });
     }
+
+    if ($zone->{fabric}) {
+        eval { PVE::Network::SDN::Fabrics::assert_underlay_fabric($zone->{fabric}) };
+        raise_param_exc({ fabric => "$@" }) if $@;
+    }
 }
 
 sub vnet_update_hook {
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH pve-network v3 17/28] sdn: move full range CIDR formats into a separate module
  2026-11-19 19:40 [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/28] SDN VRF support Gabriel Goller
                   ` (15 preceding siblings ...)
  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 ` Gabriel Goller
  2026-11-19 19:41 ` [PATCH pve-network v3 18/28] sdn: simple: support static routes in zone routing tables Gabriel Goller
                   ` (10 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Gabriel Goller @ 2026-11-19 19:41 UTC (permalink / raw)
  To: pve-devel

Zone plugins need FullRangeCIDR for static route prefixes, but using
PrefixLists from Zones::Plugin creates a circular import through
PVE::Network::SDN and Zones, so the format registration fails.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 src/PVE/Network/SDN/Fabrics.pm     |  1 +
 src/PVE/Network/SDN/Formats.pm     | 51 ++++++++++++++++++++++++++++++
 src/PVE/Network/SDN/Makefile       |  1 +
 src/PVE/Network/SDN/PrefixLists.pm | 40 +----------------------
 4 files changed, 54 insertions(+), 39 deletions(-)
 create mode 100644 src/PVE/Network/SDN/Formats.pm

diff --git a/src/PVE/Network/SDN/Fabrics.pm b/src/PVE/Network/SDN/Fabrics.pm
index d881937f42fd..8bb7fb65cfcf 100644
--- a/src/PVE/Network/SDN/Fabrics.pm
+++ b/src/PVE/Network/SDN/Fabrics.pm
@@ -11,6 +11,7 @@ use PVE::JSONSchema qw(get_standard_option);
 use PVE::INotify;
 use PVE::ParseUtils qw($IPV4RE);
 
+use PVE::Network::SDN::Formats;
 use PVE::Network::SDN::PrefixLists;
 use PVE::Network::SDN::RouteMaps;
 use PVE::Network::SDN::Zones;
diff --git a/src/PVE/Network/SDN/Formats.pm b/src/PVE/Network/SDN/Formats.pm
new file mode 100644
index 000000000000..5f826f225d29
--- /dev/null
+++ b/src/PVE/Network/SDN/Formats.pm
@@ -0,0 +1,51 @@
+package PVE::Network::SDN::Formats;
+
+# JSON schema formats shared by SDN modules. This module must not use other SDN
+# modules, so that it can be loaded by all of them without circular imports.
+
+use strict;
+use warnings;
+
+use PVE::JSONSchema;
+use PVE::Tools;
+
+PVE::JSONSchema::register_format('FullRangeCIDRv6', \&pve_verify_fullrangecidrv6);
+
+sub pve_verify_fullrangecidrv6 {
+    my ($cidr, $noerr) = @_;
+
+    if ($cidr =~ m!^(?:$PVE::Tools::IPV6RE)(?:/(\d+))\z! && ($1 >= 0) && ($1 <= 128)) {
+        return $cidr;
+    }
+
+    return undef if $noerr;
+    die "value does not look like a valid IPv6 CIDR network\n";
+}
+
+PVE::JSONSchema::register_format('FullRangeCIDRv4', \&pve_verify_fullrangecidrv4);
+
+sub pve_verify_fullrangecidrv4 {
+    my ($cidr, $noerr) = @_;
+
+    if ($cidr =~ m!^(?:$PVE::Tools::IPV4RE)(?:/(\d+))\z! && ($1 >= 0) && ($1 <= 32)) {
+        return $cidr;
+    }
+
+    return undef if $noerr;
+    die "value does not look like a valid IPv4 CIDR network\n";
+}
+
+PVE::JSONSchema::register_format('FullRangeCIDR', \&pve_verify_fullrangecidr);
+
+sub pve_verify_fullrangecidr {
+    my ($cidr, $noerr) = @_;
+
+    if (!(pve_verify_fullrangecidrv4($cidr, 1) || pve_verify_fullrangecidrv6($cidr, 1))) {
+        return undef if $noerr;
+        die "value does not look like a valid CIDR network\n";
+    }
+
+    return $cidr;
+}
+
+1;
diff --git a/src/PVE/Network/SDN/Makefile b/src/PVE/Network/SDN/Makefile
index d0b4bce2d067..67237ca4b2ca 100644
--- a/src/PVE/Network/SDN/Makefile
+++ b/src/PVE/Network/SDN/Makefile
@@ -9,6 +9,7 @@ SOURCES=Vnets.pm\
 		Dhcp.pm\
 		Fabrics.pm\
 		Frr.pm\
+		Formats.pm\
 		PrefixLists.pm\
 		RouteMaps.pm\
 		WireGuard.pm
diff --git a/src/PVE/Network/SDN/PrefixLists.pm b/src/PVE/Network/SDN/PrefixLists.pm
index d41c4ffcbc47..f825d208def5 100644
--- a/src/PVE/Network/SDN/PrefixLists.pm
+++ b/src/PVE/Network/SDN/PrefixLists.pm
@@ -7,6 +7,7 @@ use PVE::Cluster qw(cfs_register_file cfs_read_file cfs_lock_file cfs_write_file
 use PVE::JSONSchema qw(get_standard_option);
 use PVE::Tools;
 use PVE::INotify;
+use PVE::Network::SDN::Formats;
 use PVE::Network::SDN;
 use PVE::Network::SDN::RouteMaps;
 use PVE::RS::SDN::PrefixLists;
@@ -40,45 +41,6 @@ PVE::JSONSchema::register_standard_option(
     },
 );
 
-PVE::JSONSchema::register_format('FullRangeCIDRv6', \&pve_verify_fullrangecidrv6);
-
-sub pve_verify_fullrangecidrv6 {
-    my ($cidr, $noerr) = @_;
-
-    if ($cidr =~ m!^(?:$PVE::Tools::IPV6RE)(?:/(\d+))\z! && ($1 >= 0) && ($1 <= 128)) {
-        return $cidr;
-    }
-
-    return undef if $noerr;
-    die "value does not look like a valid IPv6 CIDR network\n";
-}
-
-PVE::JSONSchema::register_format('FullRangeCIDRv4', \&pve_verify_fullrangecidrv4);
-
-sub pve_verify_fullrangecidrv4 {
-    my ($cidr, $noerr) = @_;
-
-    if ($cidr =~ m!^(?:$PVE::Tools::IPV4RE)(?:/(\d+))\z! && ($1 >= 0) && ($1 <= 32)) {
-        return $cidr;
-    }
-
-    return undef if $noerr;
-    die "value does not look like a valid IPv4 CIDR network\n";
-}
-
-PVE::JSONSchema::register_format('FullRangeCIDR', \&pve_verify_fullrangecidr);
-
-sub pve_verify_fullrangecidr {
-    my ($cidr, $noerr) = @_;
-
-    if (!(pve_verify_fullrangecidrv4($cidr, 1) || pve_verify_fullrangecidrv6($cidr, 1))) {
-        return undef if $noerr;
-        die "value does not look like a valid CIDR network\n";
-    }
-
-    return $cidr;
-}
-
 cfs_register_file(
     'sdn/prefix-lists.cfg', \&parse_prefix_lists_config, \&write_prefix_lists_config,
 );
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH pve-network v3 18/28] sdn: simple: support static routes in zone routing tables
  2026-11-19 19:40 [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/28] SDN VRF support Gabriel Goller
                   ` (16 preceding siblings ...)
  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 ` 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
                   ` (9 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Gabriel Goller @ 2026-11-19 19:41 UTC (permalink / raw)
  To: pve-devel

Allow simple zones to reach outside networks through static routes,
without needing a fabric. Routes use the zone's dedicated VRF, or the
default routing table if dedicated-vrf is disabled.

Support IPv4 and IPv6 routes, including default routes, with a gateway
or an outgoing interface.

Routes can change the host's routing, e.g. through a host interface or
the default table, so changing them requires Sys.Modify on all nodes of
the zone. This includes changing the nodes or VRF of a zone with routes,
or deleting it, while changing other properties does not.

Routes are managed by FRR, so zones with static routes need FRR even
without a controller or fabric. This requires the matching pve-rs
support for route validation and FRR config generation.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 src/PVE/API2/Network/SDN/Zones.pm         |  24 ++
 src/PVE/Network/SDN.pm                    |  22 +-
 src/PVE/Network/SDN/Zones.pm              |  42 +++
 src/PVE/Network/SDN/Zones/Plugin.pm       |  53 ++++
 src/PVE/Network/SDN/Zones/SimplePlugin.pm |   1 +
 src/test/Makefile                         |   5 +-
 src/test/run_test_static_routes.pl        | 313 ++++++++++++++++++++++
 7 files changed, 456 insertions(+), 4 deletions(-)
 create mode 100644 src/test/run_test_static_routes.pl

diff --git a/src/PVE/API2/Network/SDN/Zones.pm b/src/PVE/API2/Network/SDN/Zones.pm
index e4f4b174466e..5952f407593f 100644
--- a/src/PVE/API2/Network/SDN/Zones.pm
+++ b/src/PVE/API2/Network/SDN/Zones.pm
@@ -3,6 +3,8 @@ package PVE::API2::Network::SDN::Zones;
 use strict;
 use warnings;
 
+use Storable qw(dclone);
+
 use PVE::Cluster qw(cfs_read_file cfs_write_file);
 use PVE::Exception qw(raise raise_param_exc);
 use PVE::JSONSchema qw(get_standard_option);
@@ -68,6 +70,15 @@ my $ZONE_PROPERTIES = {
         optional => 1,
         description => 'Create a dedicated VRF for a simple zone.',
     },
+    route => {
+        type => 'array',
+        optional => 1,
+        description => 'Static routes in the zone routing table. Simple zone only.',
+        items => {
+            type => 'string',
+            format => 'pve-sdn-static-route',
+        },
+    },
     'rt-import' => {
         type => 'string',
         optional => 1,
@@ -379,6 +390,8 @@ __PACKAGE__->register_method({
     description => "Create a new sdn zone object.",
     permissions => {
         check => ['perm', '/sdn/zones', ['SDN.Allocate']],
+        description => "Static routes additionally require 'Sys.Modify' on '/nodes/<node>' for"
+            . " all nodes of the zone.",
     },
     parameters => PVE::Network::SDN::Zones::Plugin->createSchema(
         undef,
@@ -413,6 +426,7 @@ __PACKAGE__->register_method({
 
                 my $privs = ['SDN.Use', 'SDN.Allocate'];
                 PVE::Network::SDN::Zones::api_validate_property_references($opts, $privs);
+                PVE::Network::SDN::Zones::api_check_route_privs($opts, undef);
 
                 my $dnsserver = $opts->{dns};
                 my $dnszone = $opts->{dnszone};
@@ -441,6 +455,9 @@ __PACKAGE__->register_method({
     description => "Update sdn zone object configuration.",
     permissions => {
         check => ['perm', '/sdn/zones/{zone}', ['SDN.Allocate']],
+        description =>
+            "Changing static routes, or the nodes or VRF of a zone with static routes,"
+            . " additionally requires 'Sys.Modify' on '/nodes/<node>' for all nodes of the zone.",
     },
     parameters => PVE::Network::SDN::Zones::Plugin->updateSchema(
         undef,
@@ -474,6 +491,7 @@ __PACKAGE__->register_method({
                 my $plugin = PVE::Network::SDN::Zones::Plugin->lookup($scfg->{type});
                 my $opts = $plugin->check_config($id, $param, 0, 1);
 
+                my $old_scfg = dclone($scfg);
                 my $old_ipam = $scfg->{ipam};
 
                 if ($delete) {
@@ -517,6 +535,7 @@ __PACKAGE__->register_method({
 
                 my $privs = ['SDN.Use', 'SDN.Allocate'];
                 PVE::Network::SDN::Zones::api_validate_property_references($opts, $privs);
+                PVE::Network::SDN::Zones::api_check_route_privs($scfg, $old_scfg);
 
                 my $dnsserver = $opts->{dns};
                 my $dnszone = $opts->{dnszone};
@@ -543,6 +562,9 @@ __PACKAGE__->register_method({
     description => "Delete sdn zone object configuration.",
     permissions => {
         check => ['perm', '/sdn/zones/{zone}', ['SDN.Allocate']],
+        description =>
+            "Deleting a zone with static routes additionally requires 'Sys.Modify' on"
+            . " '/nodes/<node>' for all nodes of the zone.",
     },
     parameters => {
         additionalProperties => 0,
@@ -571,6 +593,8 @@ __PACKAGE__->register_method({
                 my $plugin = PVE::Network::SDN::Zones::Plugin->lookup($scfg->{type});
                 my $vnet_cfg = PVE::Network::SDN::Vnets::config();
 
+                PVE::Network::SDN::Zones::api_check_route_privs(undef, $scfg);
+
                 my $fabric_config = PVE::Network::SDN::Fabrics::config();
                 my @fabric_ids = fabrics_using_zone($id, $fabric_config);
                 die "zone is still used as VRF by fabric '$fabric_ids[0]'\n" if @fabric_ids;
diff --git a/src/PVE/Network/SDN.pm b/src/PVE/Network/SDN.pm
index cdb4faddfde4..78fa906dcea8 100644
--- a/src/PVE/Network/SDN.pm
+++ b/src/PVE/Network/SDN.pm
@@ -18,6 +18,7 @@ use PVE::RESTEnvironment qw(log_warn);
 use PVE::RPCEnvironment;
 use PVE::Tools qw(file_get_contents file_set_contents extract_param dir_glob_regex run_command);
 
+use PVE::RS::SDN;
 use PVE::RS::SDN::Fabrics;
 
 use PVE::Network::SDN::Vnets;
@@ -131,10 +132,19 @@ sub running_config_has_frr {
     my $fabrics = $running_config->{fabrics}->{ids} // {};
     my $route_maps = $running_config->{'route-maps'}->{ids} // {};
     my $prefix_lists = $running_config->{'prefix-lists'}->{ids} // {};
+    my $zones = $running_config->{zones}->{ids} // {};
+    my $zone_routes =
+        grep { $_->{type} eq 'simple' && scalar(@{ $_->{route} // [] }) } values %$zones;
 
     my $local_frr_config = PVE::Network::SDN::Frr::local_frr_config_exists();
 
-    return %$controllers || %$fabrics || %$route_maps || %$prefix_lists || $local_frr_config;
+    return
+        %$controllers
+        || %$fabrics
+        || %$route_maps
+        || %$prefix_lists
+        || $zone_routes
+        || $local_frr_config;
 }
 
 sub pending_config {
@@ -564,11 +574,14 @@ sub generate_frr_raw_config {
 
     my $frr_config = {};
 
+    my $nodename = PVE::INotify::nodename();
+
     PVE::Network::SDN::Controllers::generate_frr_config($frr_config, $running_config);
+    my $routes =
+        PVE::RS::SDN::get_zone_routes($running_config->{zones} // { ids => {} }, $nodename);
+    push @{ $frr_config->{frr}->{ip_routes} }, @$routes;
     PVE::Network::SDN::Frr::append_local_config($frr_config);
 
-    my $nodename = PVE::INotify::nodename();
-
     return PVE::RS::SDN::get_frr_raw_config(
         $frr_config->{'frr'},
         $prefix_list_config,
@@ -644,6 +657,9 @@ sub canonicalize_property_strings {
 sub encode_value {
     my ($type, $key, $value) = @_;
 
+    # Route strings contain commas themselves, so preserve array element boundaries.
+    return join("\n", sort @$value) if $key eq 'route' && ref($value) eq 'ARRAY';
+
     if (
         $key eq 'nodes'
         || $key eq 'exitnodes'
diff --git a/src/PVE/Network/SDN/Zones.pm b/src/PVE/Network/SDN/Zones.pm
index 1d3ad22c1cd5..3b59f4fecef5 100644
--- a/src/PVE/Network/SDN/Zones.pm
+++ b/src/PVE/Network/SDN/Zones.pm
@@ -472,6 +472,48 @@ sub api_get_zone_checked {
     return api_get_zone($cfg, $zoneid);
 }
 
+=head3 api_check_route_privs($zone, $old_zone, $rpcenv, $authuser)
+
+Static routes are installed on the zone nodes and can change the host's routing, e.g. via a host
+interface or the default routing table, so require C<Sys.Modify> on these nodes to change them.
+
+C<$old_zone> and C<$zone> are the zone configs before and after the change, either may be undef
+on create or delete. If the routes, or the nodes or VRF they are installed on, change, the
+permission is checked for all nodes that have the routes before or after the change. Zones
+without nodes use all cluster nodes.
+
+=cut
+
+sub api_check_route_privs {
+    my ($zone, $old_zone, $rpcenv, $authuser) = @_;
+
+    my @nodes;
+    for my $z ($zone, $old_zone) {
+        next if !$z || !$z->{route} || !$z->{route}->@*;
+        push @nodes, $z->{nodes} ? keys $z->{nodes}->%* : PVE::Cluster::get_nodelist()->@*;
+    }
+    return if !@nodes;
+
+    if ($zone && $old_zone) {
+        my $changed = 0;
+        for my $key ('route', 'nodes', 'dedicated-vrf') {
+            my $new = PVE::Network::SDN::encode_value(undef, $key, $zone->{$key}) // '';
+            my $old = PVE::Network::SDN::encode_value(undef, $key, $old_zone->{$key}) // '';
+            $changed = 1 if $new ne $old;
+        }
+        return if !$changed;
+    }
+
+    $rpcenv = PVE::RPCEnvironment::get() if !defined($rpcenv);
+    $authuser = $rpcenv->get_user() if !defined($authuser);
+
+    my %seen;
+    for my $node (sort grep { !$seen{$_}++ } @nodes) {
+        next if $rpcenv->check_any($authuser, "/nodes/$node", ['Sys.Modify'], 1);
+        raise_param_exc({ route => "permission check failed: missing 'Sys.Modify' on node $node" });
+    }
+}
+
 =head3 api_validate_property_references($zone, $privs, $rpcenv, $authuser)
 
 For properties that reference another SDN entity in C<$zone> this function
diff --git a/src/PVE/Network/SDN/Zones/Plugin.pm b/src/PVE/Network/SDN/Zones/Plugin.pm
index 2de538607710..2c561eabbd40 100644
--- a/src/PVE/Network/SDN/Zones/Plugin.pm
+++ b/src/PVE/Network/SDN/Zones/Plugin.pm
@@ -8,6 +8,8 @@ use Net::IP qw(ip_get_version);
 use PVE::JSONSchema;
 use PVE::Cluster;
 use PVE::Network;
+use PVE::Network::SDN::Formats;
+use PVE::RS::SDN;
 
 use PVE::JSONSchema qw(get_standard_option);
 use base qw(PVE::SectionConfig);
@@ -29,6 +31,47 @@ PVE::JSONSchema::register_standard_option(
     },
 );
 
+my $static_route_fmt = {
+    prefix => {
+        type => 'string',
+        format => 'FullRangeCIDR',
+        description => 'Destination prefix in CIDR notation, including default routes.',
+    },
+    via => {
+        type => 'string',
+        format => 'ip',
+        optional => 1,
+        description => 'Next-hop IP address. IPv6 link-local addresses require an interface.',
+    },
+    iface => {
+        type => 'string',
+        format => 'pve-iface',
+        optional => 1,
+        description => 'Outgoing interface. At least one of via or iface is required.',
+    },
+    distance => {
+        type => 'integer',
+        minimum => 1,
+        maximum => 255,
+        optional => 1,
+        description => 'Administrative distance.',
+    },
+};
+
+PVE::JSONSchema::register_format(
+    'pve-sdn-static-route',
+    $static_route_fmt,
+    sub {
+        my ($route) = @_;
+
+        PVE::RS::SDN::validate_static_route(
+            PVE::JSONSchema::print_property_string($route, $static_route_fmt),
+        );
+
+        return $route;
+    },
+);
+
 my $defaultData = {
 
     propertyList => {
@@ -39,6 +82,16 @@ my $defaultData = {
             type => 'string',
         },
         nodes => get_standard_option('pve-node-list', { optional => 1 }),
+        route => {
+            type => 'array',
+            optional => 1,
+            description =>
+                'Static routes in the zone VRF, or the default table for Simple zones without dedicated-vrf.',
+            items => {
+                type => 'string',
+                format => 'pve-sdn-static-route',
+            },
+        },
         zone => get_standard_option(
             'pve-sdn-zone-id',
             {
diff --git a/src/PVE/Network/SDN/Zones/SimplePlugin.pm b/src/PVE/Network/SDN/Zones/SimplePlugin.pm
index bc591839819d..1d44f0b078f5 100644
--- a/src/PVE/Network/SDN/Zones/SimplePlugin.pm
+++ b/src/PVE/Network/SDN/Zones/SimplePlugin.pm
@@ -53,6 +53,7 @@ sub options {
         ipam => { optional => 1 },
         dhcp => { optional => 1 },
         'dedicated-vrf' => { optional => 1 },
+        route => { optional => 1 },
     };
 }
 
diff --git a/src/test/Makefile b/src/test/Makefile
index 3df96852f27f..0d5f3c128125 100644
--- a/src/test/Makefile
+++ b/src/test/Makefile
@@ -1,10 +1,13 @@
 all: test
 
-test: test_zones test_fabric_host_vrf test_ipams test_dns test_subnets test_vnets_blackbox test_running_config test_api_index
+test: test_zones test_static_routes test_fabric_host_vrf test_ipams test_dns test_subnets test_vnets_blackbox test_running_config test_api_index
 
 test_zones: run_test_zones.pl
 	./run_test_zones.pl
 
+test_static_routes: run_test_static_routes.pl
+	perl ./run_test_static_routes.pl
+
 test_fabric_host_vrf: run_test_fabric_host_vrf.pl
 	./run_test_fabric_host_vrf.pl
 
diff --git a/src/test/run_test_static_routes.pl b/src/test/run_test_static_routes.pl
new file mode 100644
index 000000000000..96edecc61930
--- /dev/null
+++ b/src/test/run_test_static_routes.pl
@@ -0,0 +1,313 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use lib qw(..);
+
+use Storable qw(dclone);
+use Test::More;
+use Test::MockModule;
+
+use PVE::API2::Network::SDN::Zones;
+use PVE::Network::SDN;
+
+my $routes = [
+    'prefix=0.0.0.0/0,via=192.0.2.1,iface=uplink0,distance=20',
+    'prefix=::/0,via=fe80::1,iface=uplink0',
+    'prefix=10.20.0.0/16,iface=vnet0',
+];
+my $zones = {
+    ids => {
+        isolated => {
+            type => 'simple',
+            'dedicated-vrf' => 1,
+            nodes => { localhost => 1 },
+            route => $routes,
+        },
+        plain => {
+            type => 'simple',
+            route => ['prefix=198.51.100.0/24,via=192.0.2.1'],
+        },
+        remote => {
+            type => 'simple',
+            nodes => { othernode => 1 },
+            route => ['prefix=192.0.2.0/24,iface=remote0'],
+        },
+    },
+};
+
+subtest 'route API schema and Rust validation' => sub {
+    my $create = PVE::API2::Network::SDN::Zones->map_method_by_name('create');
+    my $schema = $create->{parameters}->{properties}->{route};
+    is($schema->{type}, 'array', 'API accepts repeatable routes');
+
+    my $errors = {};
+    PVE::JSONSchema::check_prop($routes, $schema, 'route', $errors);
+    is_deeply($errors, {}, 'default routes and interface-only routes are valid');
+
+    for my $route (
+        'via=192.0.2.1',
+        'prefix=0.0.0.0/0',
+        'prefix=::/0,via=fe80::1',
+        'prefix=0.0.0.0/0,via=2001:db8::1',
+        'prefix=::/0,via=192.0.2.1',
+        'prefix=0.0.0.0/0,via=192.0.2.1,distance=256',
+        'prefix=10.0.0.0/33,via=192.0.2.1',
+        'prefix=example,via=192.0.2.1',
+        'prefix=10.0.0.0/8,iface=-uplink',
+    ) {
+        my $errors = {};
+        PVE::JSONSchema::check_prop([$route], $schema, 'route', $errors);
+        ok(scalar(keys %$errors), "reject invalid route: $route");
+    }
+
+    for my $method ('index', 'read') {
+        my $info = PVE::API2::Network::SDN::Zones->map_method_by_name($method);
+        my $properties =
+            $method eq 'index'
+            ? $info->{returns}->{items}->{properties}
+            : $info->{returns}->{properties};
+        is_deeply(
+            $properties->{route}->{items},
+            $schema->{items},
+            "$method returns route strings",
+        );
+        is(
+            $properties->{pending}->{properties}->{route}->{type},
+            'array',
+            "$method pending routes are arrays",
+        );
+    }
+
+    eval {
+        PVE::Network::SDN::Zones::VlanPlugin->check_config(
+            'vlanzone',
+            { bridge => 'vmbr0', route => $routes },
+            1,
+            1,
+        );
+    };
+    like($@, qr/unexpected property 'route'/, 'routes are only supported on simple zones');
+};
+
+subtest 'repeatable config persistence' => sub {
+    my $raw = PVE::Network::SDN::Zones::Plugin->write_config('zones.cfg', dclone($zones));
+    is(scalar(() = $raw =~ /^\s+route /gm), 5, 'one config line per route');
+    my $parsed = PVE::Network::SDN::Zones::Plugin->parse_config('zones.cfg', $raw);
+    ok(!$parsed->{errors}, 'all routes parse without errors');
+    is_deeply($parsed->{ids}, $zones->{ids}, 'routes and node restrictions survive round trip');
+};
+
+subtest 'pending arrays compare by value' => sub {
+    my $running = { zones => dclone($zones) };
+    my $configured = dclone($zones);
+    my $pending = PVE::Network::SDN::pending_config($running, $configured, 'zones');
+    ok(!$pending->{ids}->{isolated}->{state}, 'equal arrays are unchanged');
+
+    $configured->{ids}->{isolated}->{route} = [reverse @$routes];
+    $pending = PVE::Network::SDN::pending_config($running, $configured, 'zones');
+    ok(!$pending->{ids}->{isolated}->{state}, 'route ordering does not cause pending changes');
+
+    $configured->{ids}->{isolated}->{route} = ['prefix=::/0,iface=vnet1'];
+    $pending = PVE::Network::SDN::pending_config($running, $configured, 'zones');
+    is($pending->{ids}->{isolated}->{state}, 'changed', 'route modification detected');
+    is_deeply(
+        $pending->{ids}->{isolated}->{pending}->{route},
+        ['prefix=::/0,iface=vnet1'],
+        'pending retains an array',
+    );
+
+    delete $configured->{ids}->{isolated}->{route};
+    $pending = PVE::Network::SDN::pending_config($running, $configured, 'zones');
+    is($pending->{ids}->{isolated}->{pending}->{route}, 'deleted', 'route removal detected');
+};
+
+my $running = { zones => $zones, controllers => { ids => {} }, vnets => { ids => {} } };
+my $sdn = Test::MockModule->new('PVE::Network::SDN');
+$sdn->mock(running_config => sub { return $running; });
+my $inotify = Test::MockModule->new('PVE::INotify');
+$inotify->mock(nodename => sub { return 'localhost'; });
+my $controllers = Test::MockModule->new('PVE::Network::SDN::Controllers');
+$controllers->mock(read_etc_network_interfaces => sub { return { ifaces => {} }; });
+my $frr = Test::MockModule->new('PVE::Network::SDN::Frr');
+$frr->mock(local_frr_config_exists => sub { return 0; });
+$frr->mock(
+    read_local_frr_config => sub { return 'ip prefix-list LOCAL seq 5 permit 203.0.113.0/24'; },
+);
+
+subtest 'route-only FRR detection' => sub {
+    ok(PVE::Network::SDN::running_config_has_frr(), 'routes without controllers require FRR');
+    local $running->{zones} = { ids => { empty => { type => 'simple', route => [] } } };
+    ok(!PVE::Network::SDN::running_config_has_frr(), 'empty route array does not require FRR');
+};
+
+subtest 'zone routes reach FRR with local config' => sub {
+    my $fabric_config = PVE::RS::SDN::Fabrics->running_config({});
+    my $route_maps = PVE::RS::SDN::RouteMaps->running_config({});
+    my $prefix_lists = PVE::RS::SDN::PrefixLists->running_config({});
+    my $raw = PVE::Network::SDN::generate_frr_raw_config(
+        $running, $fabric_config, $route_maps, $prefix_lists,
+    );
+    my $config = join("\n", @$raw);
+    like(
+        $config,
+        qr/^ip route 0\.0\.0\.0\/0 192\.0\.2\.1 uplink0 20 vrf vrf_isolated$/m,
+        'IPv4 default route with distance',
+    );
+    like(
+        $config,
+        qr/^ipv6 route ::\/0 fe80::1 uplink0 vrf vrf_isolated$/m,
+        'IPv6 link-local default route',
+    );
+    like(
+        $config,
+        qr/^ip route 10\.20\.0\.0\/16 vnet0 vrf vrf_isolated$/m,
+        'interface-only route in zone VRF',
+    );
+    like(
+        $config,
+        qr/^ip route 198\.51\.100\.0\/24 192\.0\.2\.1(?: vrf default)?$/m,
+        'zone without dedicated VRF uses default table',
+    );
+    unlike($config, qr/remote0/, 'routes restricted to another node are omitted');
+    like(
+        $config,
+        qr/^ip prefix-list LOCAL seq 5 permit 203\.0\.113\.0\/24$/m,
+        'local FRR configuration coexists with zone routes',
+    );
+};
+
+subtest 'static routes require Sys.Modify on the zone nodes' => sub {
+    my $zone_cfg;
+    my $allowed = {};
+    my $zones_module = Test::MockModule->new('PVE::Network::SDN::Zones');
+    $zones_module->mock(
+        config => sub { return dclone($zone_cfg); },
+        write_config => sub { $zone_cfg = $_[0]; },
+        api_validate_property_references => sub { },
+    );
+    my $config_modules = [
+        map {
+            my $module = Test::MockModule->new("PVE::Network::SDN::$_");
+            $module->mock(config => sub { return { ids => {} }; });
+            $module;
+        } qw(Controllers Dns Subnets Vnets)
+    ];
+    my $fabrics_module = Test::MockModule->new('PVE::Network::SDN::Fabrics');
+    $fabrics_module->mock(config => sub { return PVE::RS::SDN::Fabrics->running_config({}); });
+    my $sdn_module = Test::MockModule->new('PVE::Network::SDN');
+    $sdn_module->mock(lock_sdn_config => sub { return $_[0]->(); });
+    my $cluster = Test::MockModule->new('PVE::Cluster');
+    $cluster->mock(
+        check_cfs_quorum => sub { },
+        get_nodelist => sub { return ['node1', 'node2']; },
+    );
+    my $api = Test::MockModule->new('PVE::API2::Network::SDN::Zones');
+    $api->mock(create_etc_interfaces_sdn_dir => sub { });
+
+    my $rpcenv = Test::MockModule->new('PVE::RPCEnvironment');
+    $rpcenv->mock(
+        get => sub { return bless {}, 'PVE::RPCEnvironment'; },
+        get_user => sub { return 'delegate@pve'; },
+        check_any => sub {
+            my ($self, $user, $path, $privs, $noerr) = @_;
+            return 1 if $allowed->{$path};
+            die "permission check failed\n" if !$noerr;
+            return 0;
+        },
+    );
+
+    my $call = sub {
+        my ($method, $param) = @_;
+        eval { PVE::API2::Network::SDN::Zones->$method(dclone($param)) };
+        return $@;
+    };
+    my $route = 'prefix=0.0.0.0/0,via=192.0.2.1';
+    my $missing = qr/missing 'Sys.Modify' on node/;
+
+    my $reset = sub {
+        $allowed = {};
+        $zone_cfg = {
+            ids => {
+                plain => { type => 'simple' },
+                routed => { type => 'simple', 'dedicated-vrf' => 1, route => [$route] },
+                pinned => { type => 'simple', nodes => { node1 => 1 }, route => [$route] },
+            },
+        };
+    };
+
+    $reset->();
+    like(
+        $call->('create', { zone => 'new', type => 'simple', route => [$route] }),
+        $missing,
+        'create with routes requires Sys.Modify',
+    );
+    ok(!$zone_cfg->{ids}->{new}, 'rejected zone is not created');
+    is(
+        $call->('create', { zone => 'new', type => 'simple' }),
+        '',
+        'create without routes does not require Sys.Modify',
+    );
+
+    like(
+        $call->('update', { zone => 'plain', route => [$route] }),
+        $missing,
+        'adding routes requires Sys.Modify',
+    );
+    ok(!$zone_cfg->{ids}->{plain}->{route}, 'rejected route is not stored');
+    like(
+        $call->('update', { zone => 'routed', delete => 'route' }),
+        $missing,
+        'removing routes requires Sys.Modify',
+    );
+    like(
+        $call->('update', { zone => 'routed', nodes => 'node1' }),
+        $missing,
+        'changing the nodes of a zone with routes requires Sys.Modify',
+    );
+    like(
+        $call->('update', { zone => 'routed', delete => 'dedicated-vrf' }),
+        $missing,
+        'moving routes into the default table requires Sys.Modify',
+    );
+    like($call->('delete', { zone => 'routed' }), $missing, 'deleting a zone with routes');
+    is(
+        $call->('update', { zone => 'routed', mtu => 1400 }),
+        '',
+        'unrelated changes are allowed',
+    );
+    is(
+        $call->('update', { zone => 'plain', mtu => 1400 }),
+        '',
+        'zones without routes unaffected',
+    );
+    is($call->('delete', { zone => 'plain' }), '', 'deleting a zone without routes');
+
+    $allowed->{'/nodes/node1'} = 1;
+    like(
+        $call->(
+            'update',
+            { zone => 'routed', route => [$route, 'prefix=::/0,via=2001:db8::1'] },
+        ),
+        qr/missing 'Sys.Modify' on node node2/,
+        'zones without nodes require Sys.Modify on all cluster nodes',
+    );
+    is(
+        $call->('update', { zone => 'pinned', route => ['prefix=::/0,via=2001:db8::1'] }),
+        '',
+        'Sys.Modify on the zone nodes is sufficient',
+    );
+    like(
+        $call->('update', { zone => 'pinned', nodes => 'node1,node2' }),
+        qr/missing 'Sys.Modify' on node node2/,
+        'adding a node to a zone with routes requires Sys.Modify on it',
+    );
+
+    $allowed->{'/nodes/node2'} = 1;
+    is($call->('update', { zone => 'new', route => [$route] }), '', 'allowed with Sys.Modify');
+    is_deeply($zone_cfg->{ids}->{new}->{route}, [$route], 'route stored');
+    is($call->('delete', { zone => 'routed' }), '', 'delete allowed with Sys.Modify');
+};
+
+done_testing();
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH pve-network v3 19/28] sdn: dhcp: only configure DHCP for zones on the local node
  2026-11-19 19:40 [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/28] SDN VRF support Gabriel Goller
                   ` (17 preceding siblings ...)
  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 ` Gabriel Goller
  2026-11-19 19:41 ` [PATCH pve-network v3 20/28] sdn: dhcp: run dnsmasq in the zone VRF Gabriel Goller
                   ` (8 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Gabriel Goller @ 2026-11-19 19:41 UTC (permalink / raw)
  To: pve-devel

regenerate_config set up a dnsmasq instance for every zone with DHCP
enabled, even on nodes that are not part of the zone. These instances
did nothing, because the vnet interfaces do not exist on those nodes.

It also meant that every node needed dnsmasq installed as soon as any
zone used DHCP. Otherwise applying the SDN config failed there, even if
none of the node's zones use DHCP.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 src/PVE/Network/SDN/Dhcp.pm | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/PVE/Network/SDN/Dhcp.pm b/src/PVE/Network/SDN/Dhcp.pm
index f6ce842c8cc2..10d7ee917da5 100644
--- a/src/PVE/Network/SDN/Dhcp.pm
+++ b/src/PVE/Network/SDN/Dhcp.pm
@@ -69,7 +69,16 @@ sub regenerate_config {
 
     my $plugins = PVE::Network::SDN::Dhcp::Plugin->lookup_types();
 
-    my $any_zone_needs_dhcp = grep { $_->{dhcp} } values $zone_cfg->{ids}->%*;
+    my @dhcp_zone_ids;
+    for my $zoneid (sort keys $zone_cfg->{ids}->%*) {
+        my $zone = $zone_cfg->{ids}->{$zoneid};
+        next if !$zone->{dhcp};
+        # the zone's VRF and bridges only exist on its nodes
+        next if defined($zone->{nodes}) && !$zone->{nodes}->{$nodename};
+        push @dhcp_zone_ids, $zoneid;
+    }
+
+    my $any_zone_needs_dhcp = scalar(@dhcp_zone_ids);
 
     foreach my $plugin_name (@$plugins) {
         my $plugin = PVE::Network::SDN::Dhcp::Plugin->lookup($plugin_name);
@@ -77,9 +86,8 @@ sub regenerate_config {
         die "Could not run before_regenerate for DHCP plugin $plugin_name $@\n" if $@;
     }
 
-    foreach my $zoneid (sort keys %{ $zone_cfg->{ids} }) {
+    foreach my $zoneid (@dhcp_zone_ids) {
         my $zone = $zone_cfg->{ids}->{$zoneid};
-        next if !$zone->{dhcp};
 
         my $dhcp_plugin_name = $zone->{dhcp};
         my $dhcp_plugin = PVE::Network::SDN::Dhcp::Plugin->lookup($dhcp_plugin_name);
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH pve-network v3 20/28] sdn: dhcp: run dnsmasq in the zone VRF
  2026-11-19 19:40 [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/28] SDN VRF support Gabriel Goller
                   ` (18 preceding siblings ...)
  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 ` 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
                   ` (7 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Gabriel Goller @ 2026-11-19 19:41 UTC (permalink / raw)
  To: pve-devel

DHCP and DNS did not work in Simple zones with a dedicated VRF. If a zone
has more than one vnet with subnets, dnsmasq serves DHCP on a single socket
that is not bound to any interface, and the kernel does not deliver packets
from VRF slaves to such sockets unless net.ipv4.udp_l3mdev_accept is set.
The DNS sockets are bound to the gateway addresses, which fails silently
because the local routes of those addresses are only in the VRF table, so
guests got a resolver that never answered.

Start the dnsmasq instance of such zones through 'ip vrf exec' using a
systemd drop-in, which binds all of its sockets to the zone VRF. This
avoids changing the host-wide sysctl, which would also expose unbound host
services to the zone. Upstream DNS servers have to be reachable from within
the VRF.

The VRF has to exist before dnsmasq starts, so the DHCP config must be
generated after ifreload. pve-manager needs a matching change.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 src/PVE/Network/SDN/Dhcp/Dnsmasq.pm | 59 ++++++++++++++++++++++++++++-
 1 file changed, 58 insertions(+), 1 deletion(-)

diff --git a/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm b/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm
index 477b700f2429..9bf37307952f 100644
--- a/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm
+++ b/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm
@@ -16,6 +16,10 @@ use PVE::RESTEnvironment qw(log_warn);
 my $DNSMASQ_CONFIG_ROOT = '/etc/dnsmasq.d';
 my $DNSMASQ_DEFAULT_ROOT = '/etc/default';
 my $DNSMASQ_LEASE_ROOT = '/var/lib/misc';
+my $SYSTEMD_UNIT_ROOT = '/etc/systemd/system';
+my $VRF_DROPIN_NAME = '00-pve-sdn-vrf.conf';
+
+my $need_daemon_reload = 0;
 
 sub type {
     return 'dnsmasq';
@@ -193,6 +197,52 @@ sub systemctl_service {
     PVE::Tools::run_command(['systemctl', $action, $service]);
 }
 
+my sub daemon_reload_if_needed {
+    return if !$need_daemon_reload;
+    PVE::Tools::run_command(['systemctl', 'daemon-reload']);
+    $need_daemon_reload = 0;
+}
+
+my sub vrf_dropin_dir {
+    my ($dhcpid) = @_;
+    return "$SYSTEMD_UNIT_ROOT/dnsmasq\@$dhcpid.service.d";
+}
+
+# dnsmasq's DHCP and DNS sockets are not bound to a device, so they don't see
+# traffic from VRF slaves. Starting it via 'ip vrf exec' binds every socket it
+# creates to the zone VRF.
+my sub write_vrf_dropin {
+    my ($dhcpid) = @_;
+
+    my $dir = vrf_dropin_dir($dhcpid);
+    mkdir($dir, 0755) if !-d $dir;
+
+    my $dropin = <<EOF;
+[Service]
+ExecStart=
+ExecStart=/usr/bin/ip vrf exec vrf_$dhcpid /usr/share/dnsmasq/systemd-helper exec "%i"
+EOF
+
+    PVE::Tools::file_set_contents("$dir/$VRF_DROPIN_NAME", $dropin);
+    $need_daemon_reload = 1;
+}
+
+my sub remove_vrf_dropins {
+    PVE::Tools::dir_glob_foreach(
+        $SYSTEMD_UNIT_ROOT,
+        'dnsmasq@.+\.service\.d',
+        sub {
+            my ($dir) = @_;
+            my $file = "$SYSTEMD_UNIT_ROOT/$dir/$VRF_DROPIN_NAME";
+            return if !-e $file;
+
+            unlink($file) or die "failed to remove $file - $!\n";
+            rmdir("$SYSTEMD_UNIT_ROOT/$dir"); # fails if other drop-ins are left
+            $need_daemon_reload = 1;
+        },
+    );
+}
+
 sub before_configure {
     my ($class, $dhcpid, $zone_cfg) = @_;
 
@@ -220,6 +270,8 @@ DBUSCFG
         "/etc/dbus-1/system.d/dnsmasq.$dhcpid.conf", $dbus_config,
     );
 
+    write_vrf_dropin($dhcpid) if $zone_cfg->{'dedicated-vrf'};
+
     my $config_directory = "$DNSMASQ_CONFIG_ROOT/$dhcpid";
 
     mkdir($config_directory, 0755) if !-d $config_directory;
@@ -286,6 +338,7 @@ sub after_configure {
 
     my $service_name = "dnsmasq\@$dhcpid";
 
+    daemon_reload_if_needed();
     systemctl_service('reload', 'dbus');
     systemctl_service('enable', $service_name);
     systemctl_service('restart', $service_name);
@@ -294,6 +347,8 @@ sub after_configure {
 sub before_regenerate {
     my ($class, $noerr) = @_;
 
+    remove_vrf_dropins();
+
     return if !assert_dnsmasq_installed($noerr);
 
     systemctl_service('stop', "dnsmasq@*");
@@ -302,7 +357,9 @@ sub before_regenerate {
 
 sub after_regenerate {
     my ($class) = @_;
-    # noop
+
+    # a drop-in may have been removed without any DHCP zone left to reload
+    daemon_reload_if_needed();
 }
 
 1;
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH pve-network v3 21/28] sdn: dhcp: fix DNS server option for IPv4 subnets without gateway
  2026-11-19 19:40 [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/28] SDN VRF support Gabriel Goller
                   ` (19 preceding siblings ...)
  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 ` 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
                   ` (6 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Gabriel Goller @ 2026-11-19 19:41 UTC (permalink / raw)
  To: pve-devel

The option prefix was only set for IPv4 subnets with a gateway, so setting
dhcp-dns-server on a subnet without one wrote an invalid line
'dhcp-option=tag:<tag>,:dns-server,<ip>' to the dnsmasq config.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 src/PVE/Network/SDN/Dhcp/Dnsmasq.pm | 11 +++-----
 src/PVE/Network/SDN/SubnetPlugin.pm |  8 +++++-
 src/test/run_test_vnets_blackbox.pl | 42 +++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+), 8 deletions(-)

diff --git a/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm b/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm
index 9bf37307952f..a34883a97cf6 100644
--- a/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm
+++ b/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm
@@ -161,13 +161,10 @@ sub configure_subnet {
 
     push @{$config}, "dhcp-range=set:$tag,$network,static,$mask,infinite";
 
-    my $option_string;
-    if (ip_is_ipv6($subnet_config->{network})) {
-        $option_string = 'option6';
-    } elsif ($subnet_config->{gateway}) {
-        $option_string = 'option';
-        push @{$config}, "dhcp-option=tag:$tag,$option_string:router,$subnet_config->{gateway}";
-    }
+    my $option_string = $is_ipv4 ? 'option' : 'option6';
+
+    push @{$config}, "dhcp-option=tag:$tag,$option_string:router,$subnet_config->{gateway}"
+        if $is_ipv4 && $subnet_config->{gateway};
 
     push @{$config},
         "dhcp-option=tag:$tag,$option_string:dns-server,$subnet_config->{'dhcp-dns-server'}"
diff --git a/src/PVE/Network/SDN/SubnetPlugin.pm b/src/PVE/Network/SDN/SubnetPlugin.pm
index 326c80ee3e90..8d4ad10b531f 100644
--- a/src/PVE/Network/SDN/SubnetPlugin.pm
+++ b/src/PVE/Network/SDN/SubnetPlugin.pm
@@ -180,7 +180,7 @@ sub properties {
         'dhcp-dns-server' => {
             type => 'string',
             format => 'ip',
-            description => 'IP address for the DNS server',
+            description => 'DNS server IP address. Must use the same address family as the subnet.',
             optional => 1,
         },
     };
@@ -229,6 +229,12 @@ sub on_update_hook {
     raise_param_exc({ gateway => "$gateway is not in subnet $cidr" })
         if $gateway && !$subnet_matcher->($gateway) && !$pointopoint;
 
+    if (my $dns_server = $subnet->{'dhcp-dns-server'}) {
+        my ($network) = split('/', $cidr, 2);
+        raise_param_exc({ 'dhcp-dns-server' => 'Must use the same address family as the subnet' })
+            if Net::IP::ip_get_version($dns_server) != Net::IP::ip_get_version($network);
+    }
+
     validate_dhcp_ranges($subnet);
 
     if ($ipam) {
diff --git a/src/test/run_test_vnets_blackbox.pl b/src/test/run_test_vnets_blackbox.pl
index 067f4c1b9962..9b8091370267 100755
--- a/src/test/run_test_vnets_blackbox.pl
+++ b/src/test/run_test_vnets_blackbox.pl
@@ -1039,4 +1039,46 @@ sub test_update_vnet_without_zone {
 }
 run_test(\&test_update_vnet_without_zone);
 
+sub test_dhcp_dns_server_family {
+    my $zoneid = 'TESTZONE';
+    my $vnetid = 'testvnet';
+
+    create_zone({ type => 'simple', zone => $zoneid });
+    create_vnet({ type => 'vnet', zone => $zoneid, vnet => $vnetid });
+
+    for my $case (
+        ['192.0.2.0/24', '198.51.100.53', '2001:db8::53', '192.0.2.128/25'],
+        ['2001:db8::/64', '2001:db8:1::53', '198.51.100.53', '2001:db8:2::/64'],
+    ) {
+        my ($subnet, $dns, $wrong_dns, $other_subnet) = @$case;
+        my $id = "$zoneid-" . ($subnet =~ s!/!-!r);
+
+        create_subnet({
+            type => 'subnet', vnet => $vnetid, subnet => $subnet, 'dhcp-dns-server' => $dns,
+        });
+        my $config = PVE::API2::Network::SDN::Subnets->read({ subnet => $id, vnet => $vnetid });
+        is($config->{'dhcp-dns-server'}, $dns, "$subnet accepts a DNS server of its own family");
+
+        my $updated = eval {
+            PVE::API2::Network::SDN::Subnets->update({
+                subnet => $id, vnet => $vnetid, 'dhcp-dns-server' => $wrong_dns,
+            });
+            1;
+        };
+        ok(!$updated, "$subnet rejects a DNS server of the other family on update");
+
+        my $created = eval {
+            create_subnet({
+                type => 'subnet',
+                vnet => $vnetid,
+                subnet => $other_subnet,
+                'dhcp-dns-server' => $wrong_dns,
+            });
+            1;
+        };
+        ok(!$created, "$other_subnet rejects a DNS server of the other family on create");
+    }
+}
+run_test(\&test_dhcp_dns_server_family);
+
 done_testing();
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH pve-network v3 22/28] sdn: evpn: no exit node null routes for simple zone VRFs
  2026-11-19 19:40 [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/28] SDN VRF support Gabriel Goller
                   ` (20 preceding siblings ...)
  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 ` 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
                   ` (5 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Gabriel Goller @ 2026-11-19 19:41 UTC (permalink / raw)
  To: pve-devel

Exit nodes add null routes for subnets of other zones, so that traffic
falling through from the EVPN zone VRF to the main table is not routed
into those zones.

Subnets of simple zones with a dedicated VRF are not in the main table,
so this is not needed. The null routes would also blackhole these
prefixes for EVPN guests even when they are reachable over the uplink,
e.g. when a dedicated VRF reuses an address range.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 src/PVE/Network/SDN/Controllers/EvpnPlugin.pm | 10 ++-
 .../expected_controller_config                | 78 +++++++++++++++++++
 .../expected_sdn_interfaces                   | 67 ++++++++++++++++
 .../exitnodenullroute_simple_vrf/interfaces   |  7 ++
 .../exitnodenullroute_simple_vrf/sdn_config   | 47 +++++++++++
 5 files changed, 208 insertions(+), 1 deletion(-)
 create mode 100644 src/test/zones/evpn/exitnodenullroute_simple_vrf/expected_controller_config
 create mode 100644 src/test/zones/evpn/exitnodenullroute_simple_vrf/expected_sdn_interfaces
 create mode 100644 src/test/zones/evpn/exitnodenullroute_simple_vrf/interfaces
 create mode 100644 src/test/zones/evpn/exitnodenullroute_simple_vrf/sdn_config

diff --git a/src/PVE/Network/SDN/Controllers/EvpnPlugin.pm b/src/PVE/Network/SDN/Controllers/EvpnPlugin.pm
index 67afe936ecc9..4a8c46258f2f 100644
--- a/src/PVE/Network/SDN/Controllers/EvpnPlugin.pm
+++ b/src/PVE/Network/SDN/Controllers/EvpnPlugin.pm
@@ -431,13 +431,21 @@ sub generate_zone_frr_config {
     # Add null routes for other zones to avoid routing between nodes through exit nodes
     if ($is_gateway) {
         my $subnets = PVE::Network::SDN::Vnets::get_subnets();
+        my $zones = PVE::Network::SDN::Zones::config(1);
         my $cidrs = {};
         foreach my $subnetid (sort keys %{$subnets}) {
             my $subnet = $subnets->{$subnetid};
             my $cidr = $subnet->{cidr};
             my $zone = $subnet->{zone};
+            next if $zone eq $id;
+
+            # Subnets of simple zones with a dedicated VRF are not routed in the default
+            # VRF, so traffic falling through from this VRF cannot reach them anyway.
+            my $zone_cfg = $zones->{ids}->{$zone};
+            next if $zone_cfg && $zone_cfg->{type} eq 'simple' && $zone_cfg->{'dedicated-vrf'};
+
             my ($ip, $mask) = split(/\//, $cidr);
-            $cidrs->{$ip} = $mask if $zone ne $id;
+            $cidrs->{$ip} = $mask;
         }
 
         my @sorted_ip =
diff --git a/src/test/zones/evpn/exitnodenullroute_simple_vrf/expected_controller_config b/src/test/zones/evpn/exitnodenullroute_simple_vrf/expected_controller_config
new file mode 100644
index 000000000000..978986ca749e
--- /dev/null
+++ b/src/test/zones/evpn/exitnodenullroute_simple_vrf/expected_controller_config
@@ -0,0 +1,78 @@
+frr version 10.6.1
+frr defaults datacenter
+hostname localhost
+log syslog informational
+service integrated-vtysh-config
+!
+vrf vrf_myzone
+ vni 1000
+ ip route 172.16.0.0/24 null0
+exit-vrf
+!
+router bgp 65000
+ bgp router-id 192.168.0.1
+ no bgp hard-administrative-reset
+ no bgp default ipv4-unicast
+ coalesce-time 1000
+ no bgp graceful-restart notification
+ neighbor VTEP peer-group
+ neighbor VTEP remote-as 65000
+ neighbor VTEP bfd
+ neighbor 192.168.0.2 peer-group VTEP
+ neighbor 192.168.0.3 peer-group VTEP
+ !
+ address-family ipv4 unicast
+  import vrf vrf_myzone
+ exit-address-family
+ !
+ address-family ipv6 unicast
+  import vrf vrf_myzone
+ exit-address-family
+ !
+ address-family l2vpn evpn
+  neighbor VTEP activate
+  neighbor VTEP route-map MAP_VTEP_IN in
+  neighbor VTEP route-map MAP_VTEP_OUT out
+  advertise-all-vni
+ exit-address-family
+exit
+!
+router bgp 65000 vrf vrf_myzone
+ bgp router-id 192.168.0.1
+ no bgp hard-administrative-reset
+ no bgp graceful-restart notification
+ !
+ address-family ipv4 unicast
+  redistribute connected
+ exit-address-family
+ !
+ address-family ipv6 unicast
+  redistribute connected
+ exit-address-family
+ !
+ address-family l2vpn evpn
+  default-originate ipv4
+  default-originate ipv6
+ exit-address-family
+exit
+!
+ip prefix-list only_default seq 1 permit 0.0.0.0/0
+!
+ipv6 prefix-list only_default_v6 seq 1 permit ::/0
+!
+route-map MAP_VTEP_IN deny 1
+ match ip address prefix-list only_default
+exit
+!
+route-map MAP_VTEP_IN deny 2
+ match ipv6 address prefix-list only_default_v6
+exit
+!
+route-map MAP_VTEP_IN permit 3
+exit
+!
+route-map MAP_VTEP_OUT permit 1
+exit
+!
+line vty
+!
diff --git a/src/test/zones/evpn/exitnodenullroute_simple_vrf/expected_sdn_interfaces b/src/test/zones/evpn/exitnodenullroute_simple_vrf/expected_sdn_interfaces
new file mode 100644
index 000000000000..0735b88a3aaa
--- /dev/null
+++ b/src/test/zones/evpn/exitnodenullroute_simple_vrf/expected_sdn_interfaces
@@ -0,0 +1,67 @@
+#version:1
+
+auto myvnet
+iface myvnet
+	address 10.0.0.1/24
+	bridge_ports vxlan_myvnet
+	bridge_stp off
+	bridge_fd 0
+	mtu 1450
+	ip-forward on
+	arp-accept on
+	vrf vrf_myzone
+
+auto simplevnet
+iface simplevnet
+	address 172.16.0.1/24
+	bridge_ports none
+	bridge_stp off
+	bridge_fd 0
+	ip-forward on
+
+auto vrf_myzone
+iface vrf_myzone
+	vrf-table auto
+	post-up ip route del vrf vrf_myzone unreachable default metric 4278198272
+	post-up ip -6 route del vrf vrf_myzone unreachable default metric 4278198272 || true
+
+auto vrf_vrfzone
+iface vrf_vrfzone
+	vrf-table auto
+	post-up ip route add vrf vrf_vrfzone unreachable default metric 4278198272
+	post-up ip -6 route add vrf vrf_vrfzone unreachable default metric 4278198272 || true
+
+auto vrfbr_myzone
+iface vrfbr_myzone
+	bridge-ports vrfvx_myzone
+	bridge_stp off
+	bridge_fd 0
+	mtu 1450
+	vrf vrf_myzone
+
+auto vrfvnet
+iface vrfvnet
+	address 172.16.1.1/24
+	address 2b0f:1480::1/64
+	bridge_ports none
+	bridge_stp off
+	bridge_fd 0
+	ip-forward on
+	ip6-forward on
+	vrf vrf_vrfzone
+
+auto vrfvx_myzone
+iface vrfvx_myzone
+	vxlan-id 1000
+	vxlan-local-tunnelip 192.168.0.1
+	bridge-learning off
+	bridge-arp-nd-suppress on
+	mtu 1450
+
+auto vxlan_myvnet
+iface vxlan_myvnet
+	vxlan-id 100
+	vxlan-local-tunnelip 192.168.0.1
+	bridge-learning off
+	bridge-arp-nd-suppress on
+	mtu 1450
diff --git a/src/test/zones/evpn/exitnodenullroute_simple_vrf/interfaces b/src/test/zones/evpn/exitnodenullroute_simple_vrf/interfaces
new file mode 100644
index 000000000000..66bb826a44b3
--- /dev/null
+++ b/src/test/zones/evpn/exitnodenullroute_simple_vrf/interfaces
@@ -0,0 +1,7 @@
+auto vmbr0
+iface vmbr0 inet static
+	address 192.168.0.1/24
+	gateway 192.168.0.254
+        bridge-ports eth0
+        bridge-stp off
+        bridge-fd 0
diff --git a/src/test/zones/evpn/exitnodenullroute_simple_vrf/sdn_config b/src/test/zones/evpn/exitnodenullroute_simple_vrf/sdn_config
new file mode 100644
index 000000000000..8a5ee50dc101
--- /dev/null
+++ b/src/test/zones/evpn/exitnodenullroute_simple_vrf/sdn_config
@@ -0,0 +1,47 @@
+{
+  version => 1,
+  vnets   => {
+               ids => {
+                        myvnet => { tag => "100", type => "vnet", zone => "myzone" },
+                        simplevnet => { type => "vnet", zone => "simple" },
+                        vrfvnet => { type => "vnet", zone => "vrfzone" },
+                      },
+             },
+
+  zones   => {
+		ids => {
+			myzone => { ipam => "pve", type => "evpn", controller => "evpnctl", 'vrf-vxlan' => 1000, exitnodes => { 'localhost' => 1 } },
+			simple => { ipam => "pve", type => "simple" },
+			vrfzone => { ipam => "pve", type => "simple", 'dedicated-vrf' => 1 },
+		}
+             },
+  controllers  => {
+               ids => { evpnctl => { type => "evpn", 'peers' => '192.168.0.1,192.168.0.2,192.168.0.3', asn => "65000" } },
+             },
+
+  subnets => {
+		ids => {
+			'myzone-10.0.0.0-24' => {
+			    'type' => 'subnet',
+			    'vnet' => 'myvnet',
+			    'gateway' => '10.0.0.1',
+			},
+			'simple-172.16.0.0-24' => {
+			    'type' => 'subnet',
+			    'vnet' => 'simplevnet',
+			    'gateway' => '172.16.0.1',
+			},
+			'vrfzone-172.16.1.0-24' => {
+			    'type' => 'subnet',
+			    'vnet' => 'vrfvnet',
+			    'gateway' => '172.16.1.1',
+			},
+			'vrfzone-2b0f:1480::-64' => {
+			    'type' => 'subnet',
+			    'vnet' => 'vrfvnet',
+			    'gateway' => '2b0f:1480::1',
+			},
+		}
+  }
+
+}
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH proxmox-widget-toolkit v3 23/28] ui: network: allow selecting a VRF for host interfaces
  2026-11-19 19:40 [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/28] SDN VRF support Gabriel Goller
                   ` (21 preceding siblings ...)
  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 ` Gabriel Goller
  2026-11-19 19:41 ` [PATCH pve-manager v3 24/28] ui: sdn: add VRF zone selection for fabrics Gabriel Goller
                   ` (4 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Gabriel Goller @ 2026-11-19 19:41 UTC (permalink / raw)
  To: pve-devel

Let applications offer VRF membership alongside the other host interface
settings without introducing SDN-specific dependencies into the toolkit.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 src/node/NetworkEdit.js | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/src/node/NetworkEdit.js b/src/node/NetworkEdit.js
index 1a3e6d3a8666..82c6eb6da3c3 100644
--- a/src/node/NetworkEdit.js
+++ b/src/node/NetworkEdit.js
@@ -8,6 +8,9 @@ Ext.define('Proxmox.node.NetworkEdit', {
     // Show alternative names below normal name
     showAltNames: false,
 
+    // Optional selector field config for assigning interfaces to a VRF.
+    vrfSelector: undefined,
+
     initComponent: function () {
         let me = this;
 
@@ -299,6 +302,20 @@ Ext.define('Proxmox.node.NetworkEdit', {
             });
         }
 
+        // OVS interfaces cannot be VRF members
+        if (me.vrfSelector && !me.iftype.startsWith('OVS')) {
+            column2.push({
+                ...me.vrfSelector,
+                fieldLabel: gettext('VRF'),
+                emptyText: gettext('No override'),
+                name: 'vrf',
+                nodename: me.nodename,
+                allowBlank: true,
+                skipEmptyText: true,
+                deleteEmpty: !me.isCreate,
+            });
+        }
+
         column2.push({
             xtype: 'textfield',
             fieldLabel: gettext('Comment'),
@@ -472,6 +489,9 @@ Ext.define('Proxmox.node.NetworkEdit', {
                         me.down('field[name=altnames]').setVisible(false);
                     }
                     me.setValues(data);
+                    if (data['vrf-readonly']) {
+                        me.down('field[name=vrf]')?.setDisabled(true);
+                    }
                     me.isValid(); // trigger validation
                 },
             });
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH pve-manager v3 24/28] ui: sdn: add VRF zone selection for fabrics
  2026-11-19 19:40 [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/28] SDN VRF support Gabriel Goller
                   ` (22 preceding siblings ...)
  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 ` Gabriel Goller
  2026-11-19 19:41 ` [PATCH pve-manager v3 25/28] network: allow setting the VRF of host interfaces Gabriel Goller
                   ` (3 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Gabriel Goller @ 2026-11-19 19:41 UTC (permalink / raw)
  To: pve-devel

Allow BGP and OSPF fabrics to select a simple zone with dedicated-vrf
enabled for routing isolation. An empty selection uses the default VRF.

Put the Dedicated VRF checkbox under Advanced in the simple zone editor.
It is unchecked by default to preserve existing behavior.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 www/manager6/form/SDNZoneSelector.js   | 16 +++++++++++++++-
 www/manager6/sdn/fabrics/FabricEdit.js | 15 +++++++++++++++
 www/manager6/sdn/zones/SimpleEdit.js   |  9 +++++++++
 3 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/www/manager6/form/SDNZoneSelector.js b/www/manager6/form/SDNZoneSelector.js
index d8a63baeb7bd..dde25371f18d 100644
--- a/www/manager6/form/SDNZoneSelector.js
+++ b/www/manager6/form/SDNZoneSelector.js
@@ -8,6 +8,9 @@ Ext.define(
         valueField: 'zone',
         displayField: 'zone',
 
+        // Only show simple zones which create a dedicated VRF.
+        vrfOnly: false,
+
         initComponent: function () {
             var me = this;
 
@@ -17,6 +20,13 @@ Ext.define(
                     property: 'zone',
                     direction: 'ASC',
                 },
+                filters: me.vrfOnly
+                    ? [
+                          function (record) {
+                              return record.get('type') === 'simple' && record.get('dedicated-vrf');
+                          },
+                      ]
+                    : [],
             });
 
             Ext.apply(me, {
@@ -42,7 +52,11 @@ Ext.define(
     function () {
         Ext.define('pve-sdn-zone', {
             extend: 'Ext.data.Model',
-            fields: ['zone', 'type'],
+            fields: [
+                'zone',
+                'type',
+                { name: 'dedicated-vrf', type: 'boolean', defaultValue: false },
+            ],
             proxy: {
                 type: 'proxmox',
                 url: '/api2/json/cluster/sdn/zones',
diff --git a/www/manager6/sdn/fabrics/FabricEdit.js b/www/manager6/sdn/fabrics/FabricEdit.js
index e9e0d1fa6286..69a865ecd7df 100644
--- a/www/manager6/sdn/fabrics/FabricEdit.js
+++ b/www/manager6/sdn/fabrics/FabricEdit.js
@@ -37,6 +37,16 @@ Ext.define('PVE.sdn.Fabric.Fabric.Edit', {
                 disabled: '{!isCreate}',
             },
         },
+        {
+            xtype: 'pveSDNZoneSelector',
+            fieldLabel: gettext('VRF Zone'),
+            labelWidth: 120,
+            name: 'zone',
+            vrfOnly: true,
+            allowBlank: true,
+            skipEmptyText: true,
+            emptyText: gettext('Default VRF'),
+        },
     ],
 
     additionalItems: [],
@@ -50,6 +60,11 @@ Ext.define('PVE.sdn.Fabric.Fabric.Edit', {
         me.autoLoad = !me.isCreate;
         me.method = me.isCreate ? 'POST' : 'PUT';
 
+        let supportsVrf = ['bgp', 'ospf'].includes(me.extraRequestParams.protocol);
+        let vrfZoneField = me.items.find((item) => item.name === 'zone');
+        vrfZoneField.hidden = !supportsVrf;
+        vrfZoneField.disabled = !supportsVrf || !me.isCreate;
+
         if (!me.isCreate) {
             me.url = `${me.baseUrl}/${me.fabricId}`;
         } else {
diff --git a/www/manager6/sdn/zones/SimpleEdit.js b/www/manager6/sdn/zones/SimpleEdit.js
index ba10bb3616ea..9c88668bb5d6 100644
--- a/www/manager6/sdn/zones/SimpleEdit.js
+++ b/www/manager6/sdn/zones/SimpleEdit.js
@@ -20,6 +20,15 @@ Ext.define('PVE.sdn.zones.SimpleInputPanel', {
 
         me.items = [];
         me.advancedItems = [
+            {
+                xtype: 'proxmoxcheckbox',
+                name: 'dedicated-vrf',
+                fieldLabel: gettext('Dedicated VRF'),
+                checked: false,
+                uncheckedValue: 0,
+                defaultValue: 0,
+                deleteDefaultValue: !me.isCreate,
+            },
             {
                 xtype: 'proxmoxcheckbox',
                 name: 'dhcp',
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH pve-manager v3 25/28] network: allow setting the VRF of host interfaces
  2026-11-19 19:40 [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/28] SDN VRF support Gabriel Goller
                   ` (23 preceding siblings ...)
  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 ` Gabriel Goller
  2026-11-19 19:41 ` [PATCH pve-manager v3 26/28] ui: sdn: allow static routes for Simple zone VRFs Gabriel Goller
                   ` (2 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: Gabriel Goller @ 2026-11-19 19:41 UTC (permalink / raw)
  To: pve-devel

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 <g.goller@proxmox.com>
---
 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





^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH pve-manager v3 26/28] ui: sdn: allow static routes for Simple zone VRFs
  2026-11-19 19:40 [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/28] SDN VRF support Gabriel Goller
                   ` (24 preceding siblings ...)
  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 ` 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
  27 siblings, 0 replies; 29+ messages in thread
From: Gabriel Goller @ 2026-11-19 19:41 UTC (permalink / raw)
  To: pve-devel

Allow Simple zones to reach networks outside their directly connected
subnets through static routes.

Routes can use a gateway, an outgoing interface, or both. IPv6 link-local
gateways require an interface. Keep the routes in a separate tab so the
general zone settings remain easy to use.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 www/manager6/Makefile                |   1 +
 www/manager6/Toolkit.js              |   2 +-
 www/manager6/sdn/StaticRoutes.js     | 222 +++++++++++++++++++++++++++
 www/manager6/sdn/zones/Base.js       |  22 ++-
 www/manager6/sdn/zones/SimpleEdit.js |  12 ++
 5 files changed, 256 insertions(+), 3 deletions(-)
 create mode 100644 www/manager6/sdn/StaticRoutes.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index e8e2bd0b49e8..349b912b61da 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -305,6 +305,7 @@ JSSRC= 							\
 	sdn/VnetPanel.js				\
 	sdn/SubnetEdit.js				\
 	sdn/SubnetView.js				\
+	sdn/StaticRoutes.js				\
 	sdn/ZoneContentView.js				\
 	sdn/ZoneContentPanel.js				\
 	sdn/ZoneBridgesPanel.js				\
diff --git a/www/manager6/Toolkit.js b/www/manager6/Toolkit.js
index 9cc89184188e..2fea13e4aed3 100644
--- a/www/manager6/Toolkit.js
+++ b/www/manager6/Toolkit.js
@@ -17,7 +17,7 @@ Ext.apply(Ext.form.field.VTypes, {
 
     IP64FullRangeCIDRAddress: function (v) {
         let result = Proxmox.Utils.IP64_cidr_match.exec(v);
-        if (result === null) {
+        if (result === null || result[0] !== v) {
             return false;
         }
         if (result[1] !== undefined) {
diff --git a/www/manager6/sdn/StaticRoutes.js b/www/manager6/sdn/StaticRoutes.js
new file mode 100644
index 000000000000..62e0be8c9182
--- /dev/null
+++ b/www/manager6/sdn/StaticRoutes.js
@@ -0,0 +1,222 @@
+Ext.define('PVE.sdn.StaticRouteEdit', {
+    extend: 'Proxmox.window.Edit',
+
+    subject: gettext('Static Route'),
+    width: 450,
+    isAdd: true,
+    url: '#',
+
+    fieldDefaults: {
+        labelWidth: 150,
+    },
+
+    items: [
+        {
+            xtype: 'textfield',
+            name: 'prefix',
+            fieldLabel: gettext('Destination Prefix'),
+            vtype: 'IP64FullRangeCIDRAddress',
+            allowBlank: false,
+        },
+        {
+            xtype: 'proxmoxtextfield',
+            name: 'via',
+            fieldLabel: gettext('Gateway'),
+            vtype: 'IP64Address',
+            skipEmptyText: true,
+            validator: function (value) {
+                let iface = this.up('window').down('[name=iface]')?.getValue();
+                return value || iface
+                    ? true
+                    : gettext('Either a gateway or an interface is required.');
+            },
+            listeners: {
+                change: function (field) {
+                    field.up('window').down('[name=iface]')?.validate();
+                },
+            },
+        },
+        {
+            xtype: 'proxmoxtextfield',
+            name: 'iface',
+            fieldLabel: gettext('Outgoing Interface'),
+            maxLength: 15,
+            regex: /^[^\s,=/]+$/,
+            skipEmptyText: true,
+            validator: function (value) {
+                let via = this.up('window').down('[name=via]')?.getValue();
+                if (!value && !via) {
+                    return gettext('Either a gateway or an interface is required.');
+                }
+                if (!value && /^fe[89ab][0-9a-f]:/i.test(via)) {
+                    return gettext('An interface is required for an IPv6 link-local gateway.');
+                }
+                return true;
+            },
+            listeners: {
+                change: function (field) {
+                    field.up('window').down('[name=via]')?.validate();
+                },
+            },
+        },
+        {
+            xtype: 'proxmoxintegerfield',
+            name: 'distance',
+            fieldLabel: gettext('Distance'),
+            minValue: 1,
+            maxValue: 255,
+            allowBlank: true,
+        },
+    ],
+
+    submit: function () {
+        let me = this;
+        if (me.isValid()) {
+            me.onSave(me.getValues());
+            me.close();
+        }
+    },
+});
+
+Ext.define('PVE.sdn.StaticRoutes', {
+    extend: 'Ext.grid.Panel',
+    alias: 'widget.pveSDNStaticRoutes',
+    mixins: ['Ext.form.field.Field'],
+
+    isCreate: false,
+    value: [],
+    height: 250,
+
+    store: {
+        fields: [
+            'route',
+            ...['prefix', 'via', 'iface', 'distance'].map((name) => ({
+                name,
+                calculate: (data) => data.route[name],
+            })),
+        ],
+        data: [],
+    },
+
+    viewConfig: {
+        emptyText: gettext('No static routes configured'),
+        deferEmptyText: false,
+    },
+
+    columns: [
+        {
+            text: gettext('Destination Prefix'),
+            dataIndex: 'prefix',
+            flex: 2,
+            renderer: Ext.htmlEncode,
+        },
+        {
+            text: gettext('Gateway'),
+            dataIndex: 'via',
+            flex: 2,
+            renderer: Ext.htmlEncode,
+        },
+        {
+            text: gettext('Interface'),
+            dataIndex: 'iface',
+            flex: 1,
+            renderer: Ext.htmlEncode,
+        },
+        {
+            text: gettext('Distance'),
+            dataIndex: 'distance',
+            width: 80,
+            renderer: Ext.htmlEncode,
+        },
+    ],
+
+    editRoute: function (record) {
+        let me = this;
+        let win = Ext.create('PVE.sdn.StaticRouteEdit', {
+            isCreate: !record,
+            onSave: function (values) {
+                if (record) {
+                    record.set('route', values);
+                } else {
+                    me.getStore().add({ route: values });
+                }
+            },
+        });
+        if (record) {
+            win.setValues(record.get('route'));
+        }
+        win.show();
+    },
+
+    isEqual: function (value1, value2) {
+        return JSON.stringify(value1) === JSON.stringify(value2);
+    },
+
+    getValue: function () {
+        return this.getStore()
+            .getRange()
+            .map((record) => PVE.Parser.printPropertyString(record.get('route')));
+    },
+
+    setValue: function (value) {
+        let me = this;
+        me.getStore().setData(
+            (value ?? []).map((route) => ({ route: PVE.Parser.parsePropertyString(route) })),
+        );
+        me.checkChange();
+        return me;
+    },
+
+    getSubmitData: function () {
+        let me = this;
+        if (me.disabled || !me.submitValue) {
+            return null;
+        }
+        let value = me.getValue();
+        if (value.length) {
+            return { [me.getName()]: value };
+        }
+        return me.isCreate ? null : { delete: me.getName() };
+    },
+
+    // The grid cannot show field errors itself. Proxmox.window.Edit marks the API errors on the
+    // form before it shows them in the error dialog, so these must exist but need not do anything.
+    markInvalid: Ext.emptyFn,
+    clearInvalid: Ext.emptyFn,
+
+    initComponent: function () {
+        let me = this;
+        let sm = Ext.create('Ext.selection.RowModel');
+
+        me.selModel = sm;
+        me.tbar = [
+            {
+                text: gettext('Add'),
+                handler: () => me.editRoute(),
+            },
+            {
+                xtype: 'proxmoxButton',
+                text: gettext('Edit'),
+                disabled: true,
+                selModel: sm,
+                handler: () => me.editRoute(sm.getSelection()[0]),
+            },
+            {
+                xtype: 'proxmoxButton',
+                text: gettext('Remove'),
+                disabled: true,
+                selModel: sm,
+                handler: () => me.getStore().remove(sm.getSelection()),
+            },
+        ];
+
+        me.callParent();
+        me.initField();
+        me.mon(me.getStore(), {
+            datachanged: me.checkChange,
+            update: me.checkChange,
+            scope: me,
+        });
+        me.on('itemdblclick', (grid, record) => me.editRoute(record));
+    },
+});
diff --git a/www/manager6/sdn/zones/Base.js b/www/manager6/sdn/zones/Base.js
index 66f93de0dff2..ebfbc953317d 100644
--- a/www/manager6/sdn/zones/Base.js
+++ b/www/manager6/sdn/zones/Base.js
@@ -45,6 +45,8 @@ Ext.define('PVE.panel.SDNZoneBase', {
                 emptyText: gettext('All') + ' (' + gettext('No restrictions') + ')',
                 multiSelect: true,
                 autoSelect: false,
+                skipEmptyText: true,
+                deleteEmpty: !me.isCreate,
             },
             {
                 xtype: 'pveSDNIpamSelector',
@@ -110,10 +112,26 @@ Ext.define('PVE.sdn.zones.BaseEdit', {
             zone: me.zone,
         });
 
+        let additionalTabs = ipanel.getAdditionalTabs?.() ?? [];
+        let items = [ipanel];
+        if (additionalTabs.length) {
+            ipanel.setTitle(gettext('General'));
+            me.width = 760;
+            me.bodyPadding = 0;
+            items = [
+                {
+                    xtype: 'tabpanel',
+                    bodyPadding: 10,
+                    deferredRender: false,
+                    items: [ipanel, ...additionalTabs],
+                },
+            ];
+        }
+
         Ext.apply(me, {
             subject: PVE.Utils.format_sdnzone_type(me.type),
             isAdd: true,
-            items: [ipanel],
+            items,
         });
 
         me.callParent();
@@ -136,7 +154,7 @@ Ext.define('PVE.sdn.zones.BaseEdit', {
 
                     values.enable = values.disable ? 0 : 1;
 
-                    ipanel.setValues(values);
+                    me.setValues(values);
                 },
             });
         }
diff --git a/www/manager6/sdn/zones/SimpleEdit.js b/www/manager6/sdn/zones/SimpleEdit.js
index 9c88668bb5d6..5b80bfcdbeec 100644
--- a/www/manager6/sdn/zones/SimpleEdit.js
+++ b/www/manager6/sdn/zones/SimpleEdit.js
@@ -3,6 +3,18 @@ Ext.define('PVE.sdn.zones.SimpleInputPanel', {
 
     onlineHelp: 'pvesdn_zone_plugin_simple',
 
+    getAdditionalTabs: function () {
+        return [
+            {
+                xtype: 'pveSDNStaticRoutes',
+                title: gettext('Static Routes'),
+                onlineHelp: this.onlineHelp,
+                name: 'route',
+                isCreate: this.isCreate,
+            },
+        ];
+    },
+
     onGetValues: function (values) {
         var me = this;
 
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH pve-manager v3 27/28] network: generate SDN DHCP config after ifreload
  2026-11-19 19:40 [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/28] SDN VRF support Gabriel Goller
                   ` (25 preceding siblings ...)
  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 ` Gabriel Goller
  2026-11-19 19:41 ` [PATCH pve-manager v3 28/28] ui: sdn: subnet: allow setting the DHCP DNS server Gabriel Goller
  27 siblings, 0 replies; 29+ messages in thread
From: Gabriel Goller @ 2026-11-19 19:41 UTC (permalink / raw)
  To: pve-devel

dnsmasq instances of SDN zones with a dedicated VRF are started inside that
VRF, so the VRF has to be created by ifreload before the DHCP config is
generated and the instances are restarted. Otherwise dnsmasq fails to start
on the first apply after enabling the VRF.

pve-sdn-commit needs the same order. At boot, networking.service brings up
the old SDN config, so the VRF of a zone changed while the node was offline
only exists after its ifreload.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 PVE/API2/Network.pm | 5 ++++-
 bin/pve-sdn-commit  | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/PVE/API2/Network.pm b/PVE/API2/Network.pm
index 74d63cfe9f0b..2115787721fa 100644
--- a/PVE/API2/Network.pm
+++ b/PVE/API2/Network.pm
@@ -958,7 +958,6 @@ __PACKAGE__->register_method({
 
             if ($have_sdn) {
                 PVE::Network::SDN::generate_etc_network_config();
-                PVE::Network::SDN::generate_dhcp_config();
                 PVE::Network::SDN::WireGuard::generate_wireguard_config();
             }
 
@@ -970,6 +969,10 @@ __PACKAGE__->register_method({
             };
             PVE::Tools::run_command(['ifreload', '-a'], errfunc => $err);
 
+            # needs the zone VRFs created by ifreload, because dnsmasq is started inside
+            # them with 'ip vrf exec'
+            PVE::Network::SDN::generate_dhcp_config() if $have_sdn;
+
             if (defined($regenerate_frr)) {
                 # SDN (or a manual invocation) is requesting a
                 # specific behavior, so we abide by the parameter set.
diff --git a/bin/pve-sdn-commit b/bin/pve-sdn-commit
index aa7e9b29056a..ab4175b87fa7 100644
--- a/bin/pve-sdn-commit
+++ b/bin/pve-sdn-commit
@@ -108,7 +108,6 @@ my $new_config_has_frr = PVE::Network::SDN::running_config_has_frr();
 my $regenerate_frr = ($previous_config_has_frr || $new_config_has_frr);
 
 PVE::Network::SDN::generate_etc_network_config();
-PVE::Network::SDN::generate_dhcp_config();
 
 my $err = sub {
     my $line = shift;
@@ -119,6 +118,10 @@ my $err = sub {
 
 PVE::Tools::run_command(['ifreload', '-a'], errfunc => $err);
 
+# needs the zone VRFs created by ifreload, because dnsmasq is started inside
+# them with 'ip vrf exec'
+PVE::Network::SDN::generate_dhcp_config();
+
 PVE::Network::SDN::generate_frr_config(1) if $regenerate_frr;
 
 exit 0;
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH pve-manager v3 28/28] ui: sdn: subnet: allow setting the DHCP DNS server
  2026-11-19 19:40 [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/28] SDN VRF support Gabriel Goller
                   ` (26 preceding siblings ...)
  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 ` Gabriel Goller
  27 siblings, 0 replies; 29+ messages in thread
From: Gabriel Goller @ 2026-11-19 19:41 UTC (permalink / raw)
  To: pve-devel

Without it, dnsmasq advertises itself as DNS server and forwards queries
to the host's resolvers. In a zone with a dedicated VRF these are often
unreachable, so guests can't resolve names. The API already supports
the option.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 www/manager6/sdn/SubnetEdit.js | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/www/manager6/sdn/SubnetEdit.js b/www/manager6/sdn/SubnetEdit.js
index a360842891a3..7d05ab227217 100644
--- a/www/manager6/sdn/SubnetEdit.js
+++ b/www/manager6/sdn/SubnetEdit.js
@@ -56,6 +56,21 @@ Ext.define('PVE.sdn.SubnetInputPanel', {
                 deleteEmpty: '{!isCreate}',
             },
         },
+        {
+            xtype: 'proxmoxtextfield',
+            name: 'dhcp-dns-server',
+            vtype: 'IP64Address',
+            skipEmptyText: true,
+            fieldLabel: gettext('DHCP DNS Resolver'),
+            allowBlank: true,
+            autoEl: {
+                tag: 'div',
+                'data-qtip': gettext('DNS server advertised to guests via DHCP.'),
+            },
+            cbind: {
+                deleteEmpty: '{!isCreate}',
+            },
+        },
     ],
 });
 
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2026-11-19 19:45 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH pve-network v3 14/28] sdn: add optional VRFs for simple zones Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-network v3 15/28] sdn: allow fabrics to use simple zone VRFs 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

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