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 200CF1FF0DA for ; Thu, 19 Nov 2026 20:41:34 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 9E03821722; Thu, 19 Nov 2026 20:41:26 +0100 (CET) From: Gabriel Goller To: pve-devel@lists.proxmox.com Subject: [PATCH proxmox-ve-rs v3 02/28] frr: add VRF-aware OSPF rendering Date: Thu, 19 Nov 2026 20:40:48 +0100 Message-ID: <20261119194116.575520-3-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: 1795117281330 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.241 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: I4ALBVRASRGGSVXRPPBNPDATW4F3BZMJ X-Message-ID-Hash: I4ALBVRASRGGSVXRPPBNPDATW4F3BZMJ 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: 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 --- 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, + pub vrf_router: BTreeMap, #[serde(default)] pub interfaces: BTreeMap>, } 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, #[serde(default)] pub network_type: Option, + /// VRF of the interface, `None` for the default VRF. + #[serde(default)] + pub vrf: Option, } 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