From: Gabriel Goller <g.goller@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH proxmox-ve-rs v3 04/32] sdn: generate fabric routing configuration in zone VRFs
Date: Mon, 16 Nov 2026 17:11:24 +0100 [thread overview]
Message-ID: <20261116161154.343743-5-g.goller@proxmox.com> (raw)
In-Reply-To: <20261116161154.343743-1-g.goller@proxmox.com>
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 | 89 ++++++++++++++++++-------
proxmox-ve-config/src/sdn/fabric/mod.rs | 10 +++
2 files changed, 74 insertions(+), 25 deletions(-)
diff --git a/proxmox-ve-config/src/sdn/fabric/frr.rs b/proxmox-ve-config/src/sdn/fabric/frr.rs
index d13cfbdf2e03..170ae38d38e5 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;
@@ -24,10 +25,13 @@ use crate::sdn::fabric::section_config::protocol::{
openfabric::{OpenfabricInterfaceProperties, OpenfabricProperties},
ospf::OspfInterfaceProperties,
};
-use crate::sdn::fabric::section_config::{fabric::FabricId, node::NodeId};
+use crate::sdn::fabric::section_config::{
+ fabric::{FabricId, ZoneId},
+ 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 +41,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,31 +205,50 @@ 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.router.is_none() {
- 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 = if vrf_name == VrfName::Default {
+ if frr_config.ospf.router.is_none() {
+ frr_config.ospf.router = Some(build_ospf_router(*router_id)?);
+ }
+ frr_config
+ .ospf
+ .router
+ .as_mut()
+ .expect("router was inserted")
+ } else {
+ 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.router = Some(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
@@ -238,7 +263,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
@@ -305,6 +330,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();
@@ -319,7 +345,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,
@@ -554,10 +580,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);
}
}
}
@@ -587,6 +613,13 @@ pub fn build_fabric(
Ok(())
}
+fn fabric_vrf_name(zone: Option<&ZoneId>) -> 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))
@@ -607,6 +640,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,13 +659,16 @@ fn build_ospf_interface(
};
let interface_name = interface.name.as_ref().try_into()?;
- Ok((frr_interface.into(), interface_name))
+ let mut interface: Interface<OspfInterface> = frr_interface.into();
+ interface.vrf = vrf;
+ Ok((interface, interface_name))
}
/// Helper that builds the OSPF dummy interface using the [`FabricId`] and the [`ospf::Area`].
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,
@@ -639,7 +676,9 @@ fn build_ospf_dummy_interface(
network_type: None,
};
let interface_name = format!("dummy_{}", fabric_id).try_into()?;
- Ok((frr_interface.into(), interface_name))
+ let mut interface: Interface<OspfInterface> = frr_interface.into();
+ interface.vrf = vrf;
+ Ok((interface, interface_name))
}
/// Helper that builds the OpenFabric interface.
diff --git a/proxmox-ve-config/src/sdn/fabric/mod.rs b/proxmox-ve-config/src/sdn/fabric/mod.rs
index 7c00a7b27a65..dec9661ee4aa 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
next prev parent reply other threads:[~2026-11-16 16:12 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 16:11 [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/32] SDN VRF support Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-common v3 01/32] interfaces: preserve VRF membership across address family changes Gabriel Goller
2026-11-18 14:13 ` Stefan Hanreich
2026-11-18 15:41 ` Gabriel Goller
2026-11-16 16:11 ` [PATCH proxmox-ve-rs v3 02/32] frr: add VRF-aware OSPF rendering Gabriel Goller
2026-11-18 14:41 ` Stefan Hanreich
2026-11-18 16:21 ` Gabriel Goller
2026-11-16 16:11 ` [PATCH proxmox-ve-rs v3 03/32] sdn: add zone references to OSPF and BGP fabrics Gabriel Goller
2026-11-18 14:10 ` Stefan Hanreich
2026-11-18 16:55 ` Gabriel Goller
2026-11-16 16:11 ` Gabriel Goller [this message]
2026-11-18 14:53 ` [PATCH proxmox-ve-rs v3 04/32] sdn: generate fabric routing configuration in zone VRFs Stefan Hanreich
2026-11-18 17:26 ` Gabriel Goller
2026-11-16 16:11 ` [PATCH proxmox-ve-rs v3 05/32] sdn: fix VRF route-map scoping and zone ID validation Gabriel Goller
2026-11-16 16:11 ` [PATCH proxmox-ve-rs v3 06/32] tests: fabrics: add test for fabrics in VRFs Gabriel Goller
2026-11-18 15:01 ` Stefan Hanreich
2026-11-18 17:33 ` Gabriel Goller
2026-11-16 16:11 ` [PATCH proxmox-ve-rs v3 07/32] sdn: allow static routes in simple zone VRFs Gabriel Goller
2026-11-18 15:29 ` Stefan Hanreich
2026-11-18 18:10 ` Gabriel Goller
2026-11-16 16:11 ` [PATCH proxmox-ve-rs v3 08/32] sdn: support static routes in EVPN " Gabriel Goller
2026-11-18 15:32 ` Stefan Hanreich
2026-11-19 13:12 ` Gabriel Goller
2026-11-16 16:11 ` [PATCH proxmox-perl-rs v3 09/32] pve-rs: fabrics: assign network interfaces to configured VRFs Gabriel Goller
2026-11-16 16:11 ` [PATCH proxmox-perl-rs v3 10/32] pve-rs: fabrics: make per-fabric status queries VRF-aware Gabriel Goller
2026-11-18 15:42 ` Stefan Hanreich
2026-11-19 13:30 ` Gabriel Goller
2026-11-16 16:11 ` [PATCH proxmox-perl-rs v3 11/32] pve-rs: fabrics: include VRF routes in aggregate status Gabriel Goller
2026-11-16 16:11 ` [PATCH proxmox-perl-rs v3 12/32] pve-rs: fabrics: expose host interface membership Gabriel Goller
2026-11-16 16:11 ` [PATCH proxmox-perl-rs v3 13/32] sdn: expose static routes for simple zone uplinks Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-network v3 14/32] sdn: evpn: add unreachable IPv6 default route to zone VRFs Gabriel Goller
2026-11-18 16:08 ` Stefan Hanreich
2026-11-18 16:39 ` Stefan Hanreich
2026-11-19 13:38 ` Gabriel Goller
2026-11-19 15:51 ` Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-network v3 15/32] sdn: add optional VRFs for simple zones Gabriel Goller
2026-11-18 16:18 ` Stefan Hanreich
2026-11-19 13:44 ` Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-network v3 16/32] sdn: allow fabrics to use simple zone VRFs Gabriel Goller
2026-11-18 16:27 ` Stefan Hanreich
2026-11-19 14:14 ` Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-network v3 17/32] sdn: require underlay fabrics to use the default VRF Gabriel Goller
2026-11-18 16:30 ` Stefan Hanreich
2026-11-19 14:33 ` Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-network v3 18/32] sdn: always generate EVPN zone VRFs Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-network v3 19/32] api: sdn: allow EVPN zones as fabric VRFs Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-network v3 20/32] api: sdn: disallow BGP fabrics in EVPN zone VRFs Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-network v3 21/32] sdn: simple: support static routes in zone routing tables Gabriel Goller
2026-11-18 16:49 ` Stefan Hanreich
2026-11-19 14:53 ` Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-network v3 22/32] sdn: evpn: allow static routes Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-network v3 23/32] sdn: zones: SNAT via dedicated uplinks in zone VRFs Gabriel Goller
2026-11-18 18:07 ` Stefan Hanreich
2026-11-16 16:11 ` [PATCH pve-network v3 24/32] sdn: dhcp: only configure DHCP for zones on the local node Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-network v3 25/32] sdn: dhcp: run dnsmasq in the zone VRF Gabriel Goller
2026-11-16 16:11 ` [PATCH proxmox-widget-toolkit v3 26/32] ui: network: allow selecting a VRF for host interfaces Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-manager v3 27/32] ui: sdn: add VRF zone selection for fabrics Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-manager v3 28/32] ui: sdn: expose EVPN zones as fabric VRFs Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-manager v3 29/32] network: allow setting the VRF of host interfaces Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-manager v3 30/32] ui: sdn: allow static routes for Simple zone VRFs Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-manager v3 31/32] ui: sdn: allow static routes in EVPN zones Gabriel Goller
2026-11-16 16:11 ` [PATCH pve-manager v3 32/32] network: generate SDN DHCP config after ifreload Gabriel Goller
2026-11-18 18:27 ` [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/32] SDN VRF support Stefan Hanreich
2026-11-19 15:33 ` Gabriel Goller
2026-11-19 20:10 ` Gabriel Goller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261116161154.343743-5-g.goller@proxmox.com \
--to=g.goller@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox