all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Gabriel Goller <g.goller@proxmox.com>
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	[thread overview]
Message-ID: <20261119194116.575520-4-g.goller@proxmox.com> (raw)
In-Reply-To: <20261119194116.575520-1-g.goller@proxmox.com>

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





  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 ` Gabriel Goller [this message]
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

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-4-g.goller@proxmox.com \
    --to=g.goller@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal