From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 725E91FF0DA for ; Thu, 19 Nov 2026 20:44:47 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id C595F21A54; Thu, 19 Nov 2026 20:42:13 +0100 (CET) From: Gabriel Goller To: pve-devel@lists.proxmox.com Subject: [PATCH proxmox-ve-rs v3 07/28] sdn: allow static routes in simple zone VRFs Date: Thu, 19 Nov 2026 20:40:53 +0100 Message-ID: <20261119194116.575520-8-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: 1795117281756 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.213 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: TRKOF5A22HMA2KLAID3NX4QHWQAIPEJ3 X-Message-ID-Hash: TRKOF5A22HMA2KLAID3NX4QHWQAIPEJ3 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 simple zones to reach upstream networks through zone-wide static routes, without requiring node-local FRR overrides. Install routes in vrf_ when dedicated-vrf is enabled, or in the default routing table otherwise. Only generate routes on nodes that belong to the zone. Support IPv4 and IPv6 routes, with an optional outgoing interface and administrative distance. Reject prefixes with host bits set, since staticd normalizes them and frr-reload would otherwise replace them on every reload. Keep the perl vrf field as the outgoing interface for existing EVPN routes, separate from the VRF in which the route is installed. Skip invalid routes with a warning instead of failing, so a single bad route in zones.cfg does not abort generating the whole FRR config. Signed-off-by: Gabriel Goller --- proxmox-frr-templates/templates/bgpd.jinja | 7 +- .../templates/frr.conf.jinja | 3 +- .../templates/ip_routes.jinja | 13 +- proxmox-frr/src/ser/mod.rs | 23 ++- proxmox-ve-config/src/sdn/mod.rs | 1 + proxmox-ve-config/src/sdn/static_route.rs | 181 +++++++++++++++++ .../tests/static_routes/cfg/fabrics.cfg | 19 ++ .../tests/static_routes/cfg/zones.json | 20 ++ proxmox-ve-config/tests/static_routes/main.rs | 188 ++++++++++++++++++ ...c_routes__preserve_legacy_evpn_routes.snap | 12 ++ ...tatic_routes__simple_zone_routes_pve1.snap | 20 ++ ...tatic_routes__simple_zone_routes_pve2.snap | 10 + ...outes__vrf_fabrics_with_static_routes.snap | 70 +++++++ 13 files changed, 553 insertions(+), 14 deletions(-) create mode 100644 proxmox-ve-config/src/sdn/static_route.rs create mode 100644 proxmox-ve-config/tests/static_routes/cfg/fabrics.cfg create mode 100644 proxmox-ve-config/tests/static_routes/cfg/zones.json create mode 100644 proxmox-ve-config/tests/static_routes/main.rs create mode 100644 proxmox-ve-config/tests/static_routes/snapshots/static_routes__preserve_legacy_evpn_routes.snap create mode 100644 proxmox-ve-config/tests/static_routes/snapshots/static_routes__simple_zone_routes_pve1.snap create mode 100644 proxmox-ve-config/tests/static_routes/snapshots/static_routes__simple_zone_routes_pve2.snap create mode 100644 proxmox-ve-config/tests/static_routes/snapshots/static_routes__vrf_fabrics_with_static_routes.snap diff --git a/proxmox-frr-templates/templates/bgpd.jinja b/proxmox-frr-templates/templates/bgpd.jinja index 61956bb0ef49..1fc950083ce5 100644 --- a/proxmox-frr-templates/templates/bgpd.jinja +++ b/proxmox-frr-templates/templates/bgpd.jinja @@ -1,4 +1,5 @@ {% from "bgp_router.jinja" import bgp_router %} +{% from "ip_routes.jinja" import static_route %} {% for vrf_name, vrf in bgp.vrfs|items %} ! vrf {{ vrf_name }} @@ -6,11 +7,7 @@ vrf {{ vrf_name }} vni {{ vrf.vni }} {% endif %} {% for ip_route in vrf.ip_routes %} -{% if ip_route.vrf %} - {{ "ipv6" if ip_route.is_ipv6 else "ip" }} route {{ ip_route.prefix }} {{ ip_route.via }} {{ ip_route.vrf }} -{% else %} - {{ "ipv6" if ip_route.is_ipv6 else "ip" }} route {{ ip_route.prefix }} {{ ip_route.via }} -{% endif %} + {{ static_route(ip_route) }} {% endfor %} {% for line in vrf.custom_frr_config %} {{ line }} diff --git a/proxmox-frr-templates/templates/frr.conf.jinja b/proxmox-frr-templates/templates/frr.conf.jinja index 1f98489e09fb..a6cd2afd10cc 100644 --- a/proxmox-frr-templates/templates/frr.conf.jinja +++ b/proxmox-frr-templates/templates/frr.conf.jinja @@ -1,3 +1,4 @@ +{% from "ip_routes.jinja" import ip_routes as render_ip_routes %} {% include "bgpd.jinja" %} {% include "isisd.jinja" %} {% include "prefix_lists.jinja" %} @@ -8,5 +9,5 @@ {% include "ospfd.jinja" %} {% include "access_lists.jinja" %} {% include "route_maps.jinja" %} -{% include "ip_routes.jinja" %} +{{ render_ip_routes(ip_routes) -}} {% include "protocol_routemaps.jinja" %} diff --git a/proxmox-frr-templates/templates/ip_routes.jinja b/proxmox-frr-templates/templates/ip_routes.jinja index 3e33a709e821..d0930ed4ba95 100644 --- a/proxmox-frr-templates/templates/ip_routes.jinja +++ b/proxmox-frr-templates/templates/ip_routes.jinja @@ -1,8 +1,9 @@ -{% for ip_route in ip_routes %} +{% macro static_route(route) -%} +{{ "ipv6" if route.is_ipv6 else "ip" }} route {{ route.prefix }}{% if route.via %} {{ route.via }}{% endif %}{% if route.vrf %} {{ route.vrf }}{% endif %}{% if route.distance and route.distance != 1 %} {{ route.distance }}{% endif %}{% if route.destination_vrf %} vrf {{ route.destination_vrf }}{% endif %} +{%- endmacro %} +{% macro ip_routes(routes) -%} +{% for ip_route in routes %} ! -{% if ip_route.vrf %} -{{ "ipv6" if ip_route.is_ipv6 else "ip" }} route {{ ip_route.prefix }} {{ ip_route.via }} {{ ip_route.vrf }} -{% else %} -{{ "ipv6" if ip_route.is_ipv6 else "ip" }} route {{ ip_route.prefix }} {{ ip_route.via }} -{% endif %} +{{ static_route(ip_route) }} {% endfor %} +{%- endmacro %} diff --git a/proxmox-frr/src/ser/mod.rs b/proxmox-frr/src/ser/mod.rs index 8d3588e93c36..468a5d914135 100644 --- a/proxmox-frr/src/ser/mod.rs +++ b/proxmox-frr/src/ser/mod.rs @@ -171,8 +171,27 @@ pub struct IpRoute { #[serde(default, deserialize_with = "proxmox_serde::perl::deserialize_bool")] is_ipv6: bool, prefix: Cidr, - via: IpOrInterface, - vrf: Option, + pub via: Option, + /// Outgoing interface (e.g. EVPN's xvrf_ veth). Keep the "vrf" perl + /// key for backwards compat. + #[serde(rename = "vrf")] + pub iface: Option, + pub distance: Option, + /// VRF in which to install the route -- None selects the default VRF. + pub destination_vrf: Option, +} + +impl IpRoute { + pub fn new(prefix: Cidr, via: Option) -> Self { + Self { + is_ipv6: prefix.is_ipv6(), + prefix, + via, + iface: None, + distance: None, + destination_vrf: None, + } + } } #[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)] diff --git a/proxmox-ve-config/src/sdn/mod.rs b/proxmox-ve-config/src/sdn/mod.rs index f4d40f590455..88987cd52283 100644 --- a/proxmox-ve-config/src/sdn/mod.rs +++ b/proxmox-ve-config/src/sdn/mod.rs @@ -3,6 +3,7 @@ pub mod fabric; pub mod ipam; pub mod prefix_list; pub mod route_map; +pub mod static_route; pub mod wireguard; use std::{error::Error, fmt::Display, str::FromStr}; diff --git a/proxmox-ve-config/src/sdn/static_route.rs b/proxmox-ve-config/src/sdn/static_route.rs new file mode 100644 index 000000000000..38ac85b281a4 --- /dev/null +++ b/proxmox-ve-config/src/sdn/static_route.rs @@ -0,0 +1,181 @@ +//! Static routes stored as repeatable property strings in simple SDN zones. + +use std::collections::BTreeMap; +use std::net::IpAddr; + +use anyhow::{Error, bail}; +use proxmox_network_types::Cidr; +use proxmox_schema::{api, property_string::PropertyString}; +use serde::{Deserialize, Serialize}; + +use crate::common::valid::Validatable; +use crate::sdn::ZoneName; +use crate::sdn::fabric::section_config::interface::InterfaceName; + +#[api( + properties: { + via: { type: String, optional: true, format: &proxmox_schema::api_types::IP_FORMAT }, + iface: { type: InterfaceName, optional: true }, + distance: { type: Integer, optional: true, minimum: 1, maximum: 255 }, + }, +)] +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(rename_all = "kebab-case", deny_unknown_fields)] +/// A static route in a simple zone. The destination VRF is determined by the zone. +pub struct StaticRoute { + /// Destination prefix, including 0.0.0.0/0 or ::/0 for a default route. + pub prefix: Cidr, + /// Next-hop gateway address. + #[serde(skip_serializing_if = "Option::is_none")] + pub via: Option, + /// Outgoing interface, required for IPv6 link-local gateways. + #[serde(skip_serializing_if = "Option::is_none")] + pub iface: Option, + /// Administrative distance. FRR's default is 1; 255 prevents installation. + #[serde(skip_serializing_if = "Option::is_none")] + pub distance: Option, +} + +impl Validatable for StaticRoute { + type Error = Error; + + fn validate(&self) -> Result<(), Error> { + // staticd stores the network address, so a prefix with host bits set would never match + // the running config and frr-reload would replace the route on every reload + let canonical = match self.prefix { + Cidr::Ipv4(cidr) => Cidr::Ipv4(cidr.canonical()), + Cidr::Ipv6(cidr) => Cidr::Ipv6(cidr.canonical()), + }; + if self.prefix != canonical { + bail!( + "prefix '{}' has host bits set, use '{canonical}' instead", + self.prefix + ); + } + if self.via.is_none() && self.iface.is_none() { + bail!("a static route requires a gateway (via) or an outgoing interface (iface)"); + } + if let Some(via) = self.via { + if via.is_ipv6() != self.prefix.is_ipv6() { + bail!("gateway and destination prefix must use the same address family"); + } + if let IpAddr::V6(via) = via { + if via.is_unicast_link_local() && self.iface.is_none() { + bail!("an IPv6 link-local gateway requires an outgoing interface (iface)"); + } + } + } + if let Some(iface) = &self.iface { + let iface = iface.as_str(); + if ["null0", "blackhole", "reject"].contains(&iface.to_ascii_lowercase().as_str()) + || iface.parse::().is_ok() + { + bail!("'{iface}' is not an outgoing interface"); + } + } + if self.distance == Some(0) { + bail!("administrative distance must be between 1 and 255"); + } + Ok(()) + } +} + +/// The subset of zones.cfg needed to generate static routes, as represented by the perl parser. +#[derive(Clone, Debug, Default, Deserialize)] +pub struct ZoneRoutesConfig { + pub ids: BTreeMap, +} + +/// Routing-related properties of a single SDN zone. +#[derive(Clone, Debug, Deserialize)] +pub struct ZoneRoutes { + #[serde(rename = "type")] + pub ty: String, + #[serde( + default, + rename = "dedicated-vrf", + deserialize_with = "proxmox_serde::perl::deserialize_bool" + )] + pub dedicated_vrf: bool, + pub nodes: Option>, + #[serde(default, deserialize_with = "deserialize_routes_lossy")] + pub route: Vec>, +} + +/// Skip routes that do not parse, so that a single invalid route does not fail the whole config. +fn deserialize_routes_lossy<'de, D>( + deserializer: D, +) -> Result>, D::Error> +where + D: serde::Deserializer<'de>, +{ + let routes = Vec::::deserialize(deserializer)?; + Ok(routes + .into_iter() + .filter_map(|route| match route.parse() { + Ok(parsed) => Some(parsed), + Err(err) => { + log::warn!("skipping static route '{route}': {err}"); + None + } + }) + .collect()) +} + +#[cfg(feature = "frr")] +impl ZoneRoutesConfig { + /// Generate routes only on nodes participating in the zone. + /// + /// Invalid routes are skipped with a warning, so that they do not prevent generating the rest + /// of the FRR configuration. + pub fn routes_for_node(&self, node: &str) -> Vec { + let mut routes = Vec::new(); + for (zone, config) in &self.ids { + if config.route.is_empty() { + continue; + } + if config.ty != "simple" { + log::warn!("zone '{zone}': static routes are only supported in simple zones"); + continue; + } + if config + .nodes + .as_ref() + .is_some_and(|nodes| !nodes.contains_key(node)) + { + continue; + } + for route in &config.route { + match zone_route_to_frr(zone, config, route) { + Ok(route) => routes.push(route), + Err(err) => { + log::warn!("zone '{zone}': skipping route '{}': {err}", route.prefix) + } + } + } + } + routes + } +} + +#[cfg(feature = "frr")] +fn zone_route_to_frr( + zone: &ZoneName, + config: &ZoneRoutes, + route: &StaticRoute, +) -> Result { + use proxmox_frr::ser::{InterfaceName as FrrInterfaceName, IpOrInterface, IpRoute}; + + let to_frr = |name: &InterfaceName| FrrInterfaceName::try_from(name.as_str()); + + route.validate()?; + + let mut frr_route = IpRoute::new(route.prefix, route.via.map(IpOrInterface::Ip)); + frr_route.iface = route.iface.as_ref().map(to_frr).transpose()?; + frr_route.distance = route.distance; + frr_route.destination_vrf = config + .dedicated_vrf + .then(|| FrrInterfaceName::try_from(format!("vrf_{zone}"))) + .transpose()?; + Ok(frr_route) +} diff --git a/proxmox-ve-config/tests/static_routes/cfg/fabrics.cfg b/proxmox-ve-config/tests/static_routes/cfg/fabrics.cfg new file mode 100644 index 000000000000..7c34f1f8e9bd --- /dev/null +++ b/proxmox-ve-config/tests/static_routes/cfg/fabrics.cfg @@ -0,0 +1,19 @@ +ospf_fabric: blue + area 0 + ip_prefix 10.0.0.0/24 + zone blue + +ospf_node: blue_pve1 + interfaces name=ens18 + ip 10.0.0.1 + +bgp_fabric: red + bfd 0 + ip_prefix 10.0.0.0/24 + zone red + +bgp_node: red_pve1 + asn 65001 + interfaces name=ens19 + ip 10.0.0.1 + role internal diff --git a/proxmox-ve-config/tests/static_routes/cfg/zones.json b/proxmox-ve-config/tests/static_routes/cfg/zones.json new file mode 100644 index 000000000000..9b19898b8b7b --- /dev/null +++ b/proxmox-ve-config/tests/static_routes/cfg/zones.json @@ -0,0 +1,20 @@ +{ + "ids": { + "blue": { + "type": "simple", + "dedicated-vrf": 1, + "route": [ + "prefix=203.0.113.0/24,via=10.0.0.2", + "prefix=2001:db8:42::/64,via=fe80::2,iface=ens19" + ] + }, + "red": { + "type": "simple", + "dedicated-vrf": 1, + "route": [ + "prefix=203.0.113.0/24,via=10.0.0.3,iface=ens19,distance=20", + "prefix=2001:db8:42::/64,iface=ens19,distance=30" + ] + } + } +} diff --git a/proxmox-ve-config/tests/static_routes/main.rs b/proxmox-ve-config/tests/static_routes/main.rs new file mode 100644 index 000000000000..a3a5c03ad560 --- /dev/null +++ b/proxmox-ve-config/tests/static_routes/main.rs @@ -0,0 +1,188 @@ +#![cfg(feature = "frr")] + +use anyhow::Error; +use proxmox_frr::ser::{FrrConfig, IpRoute, serializer::dump}; +use proxmox_schema::property_string::PropertyString; +use proxmox_ve_config::common::valid::Validatable; +use proxmox_ve_config::sdn::fabric::{ + FabricConfig, frr::build_fabric, section_config::node::NodeId, +}; +use proxmox_ve_config::sdn::static_route::{StaticRoute, ZoneRoutesConfig}; +use serde_json::json; + +#[test] +fn simple_zone_routes_to_frr() -> Result<(), Error> { + // This is the zones.cfg representation in the SDN running configuration. Repeated route + // properties remain an array, including routes with the same prefix for ECMP and failover. + let zones: ZoneRoutesConfig = serde_json::from_value(json!({"ids": { + "isolated": { + "type": "simple", + "dedicated-vrf": 1, + "nodes": {"pve1": 1}, + "route": [ + "prefix=0.0.0.0/0,via=192.0.2.1", + "prefix=0.0.0.0/0,via=192.0.2.2,distance=1", + "prefix=0.0.0.0/0,via=192.0.2.3,distance=200", + "prefix=::/0,via=fe80::1,iface=uplink0", + "prefix=2001:db8:20::/64,iface=uplink1,distance=10" + ] + }, + "shared": { + "type": "simple", + "dedicated-vrf": 0, + "route": [ + "prefix=0.0.0.0/0,via=198.51.100.1,iface=eth0,distance=5", + "prefix=::/0,via=2001:db8::1", + "prefix=203.0.113.0/24,iface=ppp0" + ] + }, + "disabled": { + "type": "simple", + "nodes": {}, + "route": ["prefix=192.0.2.0/24,iface=unused0"] + }, + "unused": {"type": "vlan"} + }}))?; + let config = FrrConfig { + ip_routes: zones.routes_for_node("pve1"), + ..Default::default() + }; + let output = dump(&config)?; + insta::assert_snapshot!("simple_zone_routes_pve1", output); + + let config = FrrConfig { + ip_routes: zones.routes_for_node("pve2"), + ..Default::default() + }; + let output = dump(&config)?; + insta::assert_snapshot!("simple_zone_routes_pve2", output); + Ok(()) +} + +#[test] +fn validate_route_properties() { + for value in [ + "prefix=0.0.0.0/0,via=192.0.2.1", + "prefix=::/0,via=fe80::1,iface=eth0", + "prefix=10.0.0.0/8,iface=eth0.100,distance=255", + "prefix=::/0,via=2001:db8::1", + ] { + let route = value.parse::>().unwrap(); + route.validate().unwrap(); + let encoded = route.to_property_string().unwrap(); + encoded + .parse::>() + .unwrap() + .validate() + .unwrap(); + } + + for value in [ + "prefix=0.0.0.0/0", + "via=192.0.2.1", + "prefix=0.0.0.0/33,via=192.0.2.1", + "prefix=10.0.0.1/24,via=192.0.2.1", + "prefix=2001:db8::1/64,via=2001:db8::ffff", + "prefix=0.0.0.0/0,via=2001:db8::1", + "prefix=::/0,via=192.0.2.1", + "prefix=::/0,via=fe80::1", + "prefix=0.0.0.0/0,iface=", + "prefix=0.0.0.0/0,iface=interface-too-long", + "prefix=0.0.0.0/0,iface=eth0 vrf default", + "prefix=0.0.0.0/0,iface=eth0\nexit", + "prefix=0.0.0.0/0,iface=blackhole", + "prefix=0.0.0.0/0,iface=Null0", + "prefix=0.0.0.0/0,iface=192.0.2.1", + "prefix=0.0.0.0/0,via=192.0.2.1,distance=0", + "prefix=0.0.0.0/0,via=192.0.2.1,distance=256", + "prefix=0.0.0.0/0,via=192.0.2.1,vrf=vrf_other", + "prefix=0.0.0.0/0,via=192.0.2.1,nexthop-vrf=default", + "prefix=0.0.0.0/0,via=192.0.2.1,via=192.0.2.2", + ] { + let result = value + .parse::>() + .map_err(Error::from) + .and_then(|route| route.validate()); + assert!(result.is_err(), "accepted invalid route: {value}"); + } +} + +#[test] +fn skip_routes_in_other_zone_types() -> Result<(), Error> { + for ty in ["vlan", "qinq", "vxlan", "evpn", "faucet"] { + let zones: ZoneRoutesConfig = serde_json::from_value(json!({"ids": { + "zone1": {"type": ty, "route": ["prefix=0.0.0.0/0,via=192.0.2.1"]} + }}))?; + assert!(zones.routes_for_node("pve1").is_empty()); + } + Ok(()) +} + +#[test] +fn skip_invalid_routes() -> Result<(), Error> { + // Invalid routes must not prevent generating the valid ones, or the rest of the FRR config. + let zones: ZoneRoutesConfig = serde_json::from_value(json!({"ids": { + "zone1": { + "type": "simple", + "route": [ + "prefix=10.0.0.1/24,via=192.0.2.1", + "prefix=0.0.0.0/0,via=192.0.2.1", + "prefix=0.0.0.0/0,via=192.0.2.1,unknown=1", + "prefix=::/0,via=fe80::1" + ] + } + }}))?; + let config = FrrConfig { + ip_routes: zones.routes_for_node("pve1"), + ..Default::default() + }; + assert_eq!(config.ip_routes.len(), 1); + assert!(dump(&config)?.contains("ip route 0.0.0.0/0 192.0.2.1")); + Ok(()) +} + +#[test] +fn preserve_legacy_evpn_routes() -> Result<(), Error> { + // The historical 'vrf' field is actually the outgoing interface, not a destination VRF. + let route: IpRoute = serde_json::from_value(json!({ + "prefix": "203.0.113.0/24", "via": "10.255.255.2", "vrf": "xvrf_zone1" + }))?; + let mut config = FrrConfig::default(); + config.ip_routes.push(route); + config.ip_routes.push(serde_json::from_value(json!({ + "is_ipv6": 1, "prefix": "2001:db8::/64", "via": "fe80::2", "vrf": "xvrf_zone1" + }))?); + assert_eq!( + serde_json::to_value(&config.ip_routes[0])?["vrf"], + "xvrf_zone1" + ); + config.bgp.vrfs.insert( + "vrf_zone1".try_into()?, + serde_json::from_value(json!({ + "ip_routes": [{"prefix": "203.0.113.0/24", "via": "null0"}] + }))?, + ); + let output = dump(&config)?; + insta::assert_snapshot!(output); + Ok(()) +} + +#[test] +fn vrf_fabrics_with_static_routes() -> Result<(), Error> { + let fabrics = FabricConfig::parse_section_config(include_str!("cfg/fabrics.cfg"))?; + let zones: ZoneRoutesConfig = serde_json::from_str(include_str!("cfg/zones.json"))?; + let mut config = FrrConfig::default(); + + // Both fabrics use the same subnet, and both zones route the same IPv4 and IPv6 prefixes. + // Static routes must retain their installation VRF, even with a different next-hop VRF. + build_fabric( + NodeId::from_string("pve1".to_owned())?, + fabrics, + &mut config, + )?; + config.ip_routes.extend(zones.routes_for_node("pve1")); + + let output = dump(&config)?; + insta::assert_snapshot!(output); + Ok(()) +} diff --git a/proxmox-ve-config/tests/static_routes/snapshots/static_routes__preserve_legacy_evpn_routes.snap b/proxmox-ve-config/tests/static_routes/snapshots/static_routes__preserve_legacy_evpn_routes.snap new file mode 100644 index 000000000000..999c04522074 --- /dev/null +++ b/proxmox-ve-config/tests/static_routes/snapshots/static_routes__preserve_legacy_evpn_routes.snap @@ -0,0 +1,12 @@ +--- +source: proxmox-ve-config/tests/static_routes/main.rs +expression: output +--- +! +vrf vrf_zone1 + ip route 203.0.113.0/24 null0 +exit-vrf +! +ip route 203.0.113.0/24 10.255.255.2 xvrf_zone1 +! +ipv6 route 2001:db8::/64 fe80::2 xvrf_zone1 diff --git a/proxmox-ve-config/tests/static_routes/snapshots/static_routes__simple_zone_routes_pve1.snap b/proxmox-ve-config/tests/static_routes/snapshots/static_routes__simple_zone_routes_pve1.snap new file mode 100644 index 000000000000..c08421619c74 --- /dev/null +++ b/proxmox-ve-config/tests/static_routes/snapshots/static_routes__simple_zone_routes_pve1.snap @@ -0,0 +1,20 @@ +--- +source: proxmox-ve-config/tests/static_routes/main.rs +expression: output +--- +! +ip route 0.0.0.0/0 192.0.2.1 vrf vrf_isolated +! +ip route 0.0.0.0/0 192.0.2.2 vrf vrf_isolated +! +ip route 0.0.0.0/0 192.0.2.3 200 vrf vrf_isolated +! +ipv6 route ::/0 fe80::1 uplink0 vrf vrf_isolated +! +ipv6 route 2001:db8:20::/64 uplink1 10 vrf vrf_isolated +! +ip route 0.0.0.0/0 198.51.100.1 eth0 5 +! +ipv6 route ::/0 2001:db8::1 +! +ip route 203.0.113.0/24 ppp0 diff --git a/proxmox-ve-config/tests/static_routes/snapshots/static_routes__simple_zone_routes_pve2.snap b/proxmox-ve-config/tests/static_routes/snapshots/static_routes__simple_zone_routes_pve2.snap new file mode 100644 index 000000000000..ff327491d71a --- /dev/null +++ b/proxmox-ve-config/tests/static_routes/snapshots/static_routes__simple_zone_routes_pve2.snap @@ -0,0 +1,10 @@ +--- +source: proxmox-ve-config/tests/static_routes/main.rs +expression: output +--- +! +ip route 0.0.0.0/0 198.51.100.1 eth0 5 +! +ipv6 route ::/0 2001:db8::1 +! +ip route 203.0.113.0/24 ppp0 diff --git a/proxmox-ve-config/tests/static_routes/snapshots/static_routes__vrf_fabrics_with_static_routes.snap b/proxmox-ve-config/tests/static_routes/snapshots/static_routes__vrf_fabrics_with_static_routes.snap new file mode 100644 index 000000000000..da021eebe049 --- /dev/null +++ b/proxmox-ve-config/tests/static_routes/snapshots/static_routes__vrf_fabrics_with_static_routes.snap @@ -0,0 +1,70 @@ +--- +source: proxmox-ve-config/tests/static_routes/main.rs +expression: output +--- +! +router bgp 65001 vrf vrf_red + bgp router-id 10.0.0.1 + no bgp default ipv4-unicast + neighbor red peer-group + neighbor red remote-as external + neighbor ens19 interface peer-group red + ! + address-family ipv4 unicast + network 10.0.0.1/32 + neighbor red activate + neighbor red soft-reconfiguration inbound + neighbor red route-map pve_bgp_red_in in + exit-address-family +exit +! +router ospf vrf vrf_blue + ospf router-id 10.0.0.1 +exit +! +interface dummy_blue vrf vrf_blue + ip ospf area 0 + ip ospf passive +exit +! +interface ens18 vrf vrf_blue + ip ospf area 0 + ip ospf network point-to-point +exit +! +access-list pve_bgp_red_ips permit 10.0.0.0/24 +! +access-list pve_ospf_blue_ips permit 10.0.0.0/24 +! +route-map pve_bgp_red_in permit 10 + match ip address pve_bgp_red_ips +exit +! +route-map pve_bgp_vrf_red permit 110 + match ip address pve_bgp_red_ips + set src 10.0.0.1 +exit +! +route-map pve_bgp_vrf_red permit 65535 +exit +! +route-map pve_ospf_vrf_blue permit 100 + match ip address pve_ospf_blue_ips + set src 10.0.0.1 +exit +! +ip route 203.0.113.0/24 10.0.0.2 vrf vrf_blue +! +ipv6 route 2001:db8:42::/64 fe80::2 ens19 vrf vrf_blue +! +ip route 203.0.113.0/24 10.0.0.3 ens19 20 vrf vrf_red +! +ipv6 route 2001:db8:42::/64 ens19 30 vrf vrf_red +! +vrf vrf_blue + ip protocol ospf route-map pve_ospf_vrf_blue +exit-vrf +! +vrf vrf_red + ip protocol bgp route-map pve_bgp_vrf_red +exit-vrf -- 2.47.3