From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id CAA561FF0DA for ; Thu, 19 Nov 2026 20:42:01 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id D5B92217F9; Thu, 19 Nov 2026 20:41:33 +0100 (CET) From: Gabriel Goller To: pve-devel@lists.proxmox.com Subject: [PATCH proxmox-ve-rs v3 03/28] sdn: add zone references to OSPF and BGP fabrics Date: Thu, 19 Nov 2026 20:40:49 +0100 Message-ID: <20261119194116.575520-4-g.goller@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261119194116.575520-1-g.goller@proxmox.com> References: <20261119194116.575520-1-g.goller@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1795117281434 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.236 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: TNBWE5ZJ5I3IIZEBOPPZB5NFUT4JY5AF X-Message-ID-Hash: TNBWE5ZJ5I3IIZEBOPPZB5NFUT4JY5AF X-MailFrom: g.goller@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- 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, + /// 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, + /// 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