From: Gabriel Goller <g.goller@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH proxmox-ve-rs v3 05/28] sdn: fix VRF route-map scoping and zone ID validation
Date: Thu, 19 Nov 2026 20:40:51 +0100 [thread overview]
Message-ID: <20261119194116.575520-6-g.goller@proxmox.com> (raw)
In-Reply-To: <20261119194116.575520-1-g.goller@proxmox.com>
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
next prev parent reply other threads:[~2026-11-19 19:42 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 19:40 [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/28] SDN VRF support Gabriel Goller
2026-11-19 19:40 ` [PATCH pve-common v3 01/28] interfaces: preserve VRF membership across address family changes Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-ve-rs v3 02/28] frr: add VRF-aware OSPF rendering Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-ve-rs v3 03/28] sdn: add zone references to OSPF and BGP fabrics Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-ve-rs v3 04/28] sdn: generate fabric routing configuration in zone VRFs Gabriel Goller
2026-11-19 19:40 ` Gabriel Goller [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261119194116.575520-6-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