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 B12E81FF0DA for ; Thu, 19 Nov 2026 20:45:43 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id AA95821B1C; Thu, 19 Nov 2026 20:42:19 +0100 (CET) From: Gabriel Goller To: pve-devel@lists.proxmox.com Subject: [PATCH proxmox-ve-rs v3 06/28] tests: fabrics: add tests for fabrics in VRFs Date: Thu, 19 Nov 2026 20:40:52 +0100 Message-ID: <20261119194116.575520-7-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: 1795117281686 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.215 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: 5L6MZIBNZKSQESNDXKZWEUUJ3DWUMHFN X-Message-ID-Hash: 5L6MZIBNZKSQESNDXKZWEUUJ3DWUMHFN 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 integration tests covering OSPF and BGP fabrics in SDN zone VRFs, alongside fabrics in the default VRF, with redistributions, route filters and IPv6. Signed-off-by: Gabriel Goller --- .../tests/fabric/cfg/vrf/fabrics.cfg | 43 ++++ .../tests/fabric/cfg/vrf/route-maps.cfg | 15 ++ .../tests/fabric/cfg/vrf_default/fabrics.cfg | 37 ++++ .../tests/fabric/cfg/vrf_ipv6/fabrics.cfg | 25 +++ .../tests/fabric/cfg/vrf_ipv6/route-maps.cfg | 7 + .../fabric/cfg/vrf_redistribute/fabrics.cfg | 23 ++ .../cfg/vrf_redistribute/route-maps.cfg | 7 + .../fabric/cfg/vrf_route_filter/fabrics.cfg | 23 ++ .../cfg/vrf_route_filter/prefix-lists.cfg | 8 + proxmox-ve-config/tests/fabric/helper.rs | 40 ++++ proxmox-ve-config/tests/fabric/main.rs | 204 +++++++++++++++++- .../snapshots/fabric__vrf_default_pve.snap | 113 ++++++++++ .../snapshots/fabric__vrf_ipv6_pve.snap | 102 +++++++++ .../fabric/snapshots/fabric__vrf_pve.snap | 134 ++++++++++++ .../fabric__vrf_redistribute_pve.snap | 74 +++++++ .../fabric__vrf_route_filter_pve.snap | 85 ++++++++ 16 files changed, 931 insertions(+), 9 deletions(-) create mode 100644 proxmox-ve-config/tests/fabric/cfg/vrf/fabrics.cfg create mode 100644 proxmox-ve-config/tests/fabric/cfg/vrf/route-maps.cfg create mode 100644 proxmox-ve-config/tests/fabric/cfg/vrf_default/fabrics.cfg create mode 100644 proxmox-ve-config/tests/fabric/cfg/vrf_ipv6/fabrics.cfg create mode 100644 proxmox-ve-config/tests/fabric/cfg/vrf_ipv6/route-maps.cfg create mode 100644 proxmox-ve-config/tests/fabric/cfg/vrf_redistribute/fabrics.cfg create mode 100644 proxmox-ve-config/tests/fabric/cfg/vrf_redistribute/route-maps.cfg create mode 100644 proxmox-ve-config/tests/fabric/cfg/vrf_route_filter/fabrics.cfg create mode 100644 proxmox-ve-config/tests/fabric/cfg/vrf_route_filter/prefix-lists.cfg create mode 100644 proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_default_pve.snap create mode 100644 proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_ipv6_pve.snap create mode 100644 proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_pve.snap create mode 100644 proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_redistribute_pve.snap create mode 100644 proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_route_filter_pve.snap diff --git a/proxmox-ve-config/tests/fabric/cfg/vrf/fabrics.cfg b/proxmox-ve-config/tests/fabric/cfg/vrf/fabrics.cfg new file mode 100644 index 000000000000..05a1cb57642a --- /dev/null +++ b/proxmox-ve-config/tests/fabric/cfg/vrf/fabrics.cfg @@ -0,0 +1,43 @@ +ospf_fabric: ospfred + area 0 + ip_prefix 10.0.0.0/24 + zone red + +ospf_fabric: ospfblue + area 0 + ip_prefix 10.0.0.0/24 + zone blue + +ospf_node: ospfred_pve + interfaces name=ens18 + ip 10.0.0.1 + +ospf_node: ospfblue_pve + interfaces name=ens19 + ip 10.0.0.1 + +bgp_fabric: bgpred + bfd 0 + ip_prefix 10.1.0.0/24 + route_map_in red-in + route_map_out red-out + zone red + +bgp_fabric: bgpblue + bfd 0 + ip_prefix 10.1.0.0/24 + route_map_in blue-in + route_map_out blue-out + zone blue + +bgp_node: bgpred_pve + asn 65001 + interfaces name=ens20 + ip 10.1.0.1 + role internal + +bgp_node: bgpblue_pve + asn 65002 + interfaces name=ens21 + ip 10.1.0.1 + role internal diff --git a/proxmox-ve-config/tests/fabric/cfg/vrf/route-maps.cfg b/proxmox-ve-config/tests/fabric/cfg/vrf/route-maps.cfg new file mode 100644 index 000000000000..b382fc369b51 --- /dev/null +++ b/proxmox-ve-config/tests/fabric/cfg/vrf/route-maps.cfg @@ -0,0 +1,15 @@ +route-map-entry: blue-in_10 + action permit + set key=local-preference,value=200 + +route-map-entry: blue-out_10 + action permit + set key=metric,value=20 + +route-map-entry: red-in_10 + action permit + set key=local-preference,value=100 + +route-map-entry: red-out_10 + action permit + set key=metric,value=10 diff --git a/proxmox-ve-config/tests/fabric/cfg/vrf_default/fabrics.cfg b/proxmox-ve-config/tests/fabric/cfg/vrf_default/fabrics.cfg new file mode 100644 index 000000000000..e93b590b18a3 --- /dev/null +++ b/proxmox-ve-config/tests/fabric/cfg/vrf_default/fabrics.cfg @@ -0,0 +1,37 @@ +ospf_fabric: underlay + area 0 + ip_prefix 10.0.0.0/24 + +ospf_fabric: ospfred + area 0 + ip_prefix 10.0.0.0/24 + zone red + +ospf_node: underlay_pve + interfaces name=ens18 + ip 10.0.0.1 + +ospf_node: ospfred_pve + interfaces name=ens19 + ip 10.0.0.2 + +bgp_fabric: bgpdef + bfd 0 + ip_prefix 10.1.0.0/24 + +bgp_fabric: bgpred + bfd 0 + ip_prefix 10.1.0.0/24 + zone red + +bgp_node: bgpdef_pve + asn 65001 + interfaces name=ens20 + ip 10.1.0.1 + role internal + +bgp_node: bgpred_pve + asn 65002 + interfaces name=ens21 + ip 10.1.0.2 + role internal diff --git a/proxmox-ve-config/tests/fabric/cfg/vrf_ipv6/fabrics.cfg b/proxmox-ve-config/tests/fabric/cfg/vrf_ipv6/fabrics.cfg new file mode 100644 index 000000000000..ad2e3451333f --- /dev/null +++ b/proxmox-ve-config/tests/fabric/cfg/vrf_ipv6/fabrics.cfg @@ -0,0 +1,25 @@ +bgp_fabric: bgpred + bfd 0 + ip6_prefix fd00:10::/64 + route_map_in red-in + route_map_out red-out + zone red + +bgp_fabric: bgpblue + bfd 0 + ip_prefix 10.1.0.0/24 + ip6_prefix fd00:20::/64 + zone blue + +bgp_node: bgpred_pve + asn 65001 + interfaces name=ens18 + ip6 fd00:10::1 + role internal + +bgp_node: bgpblue_pve + asn 65002 + interfaces name=ens19 + ip 10.1.0.1 + ip6 fd00:20::1 + role internal diff --git a/proxmox-ve-config/tests/fabric/cfg/vrf_ipv6/route-maps.cfg b/proxmox-ve-config/tests/fabric/cfg/vrf_ipv6/route-maps.cfg new file mode 100644 index 000000000000..c65af38666ca --- /dev/null +++ b/proxmox-ve-config/tests/fabric/cfg/vrf_ipv6/route-maps.cfg @@ -0,0 +1,7 @@ +route-map-entry: red-in_10 + action permit + set key=local-preference,value=100 + +route-map-entry: red-out_10 + action permit + set key=metric,value=10 diff --git a/proxmox-ve-config/tests/fabric/cfg/vrf_redistribute/fabrics.cfg b/proxmox-ve-config/tests/fabric/cfg/vrf_redistribute/fabrics.cfg new file mode 100644 index 000000000000..5ea790ca6798 --- /dev/null +++ b/proxmox-ve-config/tests/fabric/cfg/vrf_redistribute/fabrics.cfg @@ -0,0 +1,23 @@ +ospf_fabric: ospfred + area 0 + ip_prefix 10.0.0.0/24 + redistribute source=connected + redistribute source=static,metric=50,route-map=redistribute-static + zone red + +ospf_node: ospfred_pve + interfaces name=ens18 + ip 10.0.0.1 + +bgp_fabric: bgpblue + bfd 0 + ip_prefix 10.1.0.0/24 + redistribute source=connected + redistribute source=ospf,metric=100,route-map=redistribute-ospf + zone blue + +bgp_node: bgpblue_pve + asn 65001 + interfaces name=ens19 + ip 10.1.0.1 + role internal diff --git a/proxmox-ve-config/tests/fabric/cfg/vrf_redistribute/route-maps.cfg b/proxmox-ve-config/tests/fabric/cfg/vrf_redistribute/route-maps.cfg new file mode 100644 index 000000000000..d85b7ce58040 --- /dev/null +++ b/proxmox-ve-config/tests/fabric/cfg/vrf_redistribute/route-maps.cfg @@ -0,0 +1,7 @@ +route-map-entry: redistribute-ospf_10 + action permit + set key=local-preference,value=150 + +route-map-entry: redistribute-static_10 + action permit + set key=metric,value=30 diff --git a/proxmox-ve-config/tests/fabric/cfg/vrf_route_filter/fabrics.cfg b/proxmox-ve-config/tests/fabric/cfg/vrf_route_filter/fabrics.cfg new file mode 100644 index 000000000000..4cc0f893d876 --- /dev/null +++ b/proxmox-ve-config/tests/fabric/cfg/vrf_route_filter/fabrics.cfg @@ -0,0 +1,23 @@ +ospf_fabric: ospfred + area 0 + ip_prefix 10.0.0.0/24 + route_filter red-allowed + zone red + +ospf_node: ospfred_pve + interfaces name=ens18 + ip 10.0.0.1 + +bgp_fabric: bgpblue + bfd 0 + ip_prefix 10.1.0.0/24 + ip6_prefix fd00:10::/64 + route_filter blue-allowed + zone blue + +bgp_node: bgpblue_pve + asn 65001 + interfaces name=ens19 + ip 10.1.0.1 + ip6 fd00:10::1 + role internal diff --git a/proxmox-ve-config/tests/fabric/cfg/vrf_route_filter/prefix-lists.cfg b/proxmox-ve-config/tests/fabric/cfg/vrf_route_filter/prefix-lists.cfg new file mode 100644 index 000000000000..624b03ae1b3f --- /dev/null +++ b/proxmox-ve-config/tests/fabric/cfg/vrf_route_filter/prefix-lists.cfg @@ -0,0 +1,8 @@ +prefix-list: blue-allowed + entries action=permit,prefix=10.1.0.0/24,le=32,seq=10 + entries action=permit,prefix=192.0.2.0/24,seq=20 + entries action=permit,prefix=fd00:10::/64,le=128,seq=30 + +prefix-list: red-allowed + entries action=permit,prefix=10.0.0.0/24,le=32,seq=10 + entries action=permit,prefix=198.51.100.0/24,seq=20 diff --git a/proxmox-ve-config/tests/fabric/helper.rs b/proxmox-ve-config/tests/fabric/helper.rs index 93404b8eb7af..31d15a6428e3 100644 --- a/proxmox-ve-config/tests/fabric/helper.rs +++ b/proxmox-ve-config/tests/fabric/helper.rs @@ -18,6 +18,42 @@ macro_rules! get_fabrics_config { }}; } +#[allow(unused_macros)] +macro_rules! get_route_maps_config { + () => {{ + fn f() {} + fn type_name_of(_: T) -> &'static str { + std::any::type_name::() + } + let mut name = type_name_of(f); + + name = match &name[..name.len() - 3].rfind(':') { + Some(pos) => &name[pos + 1..name.len() - 3], + None => &name[..name.len() - 3], + }; + let real_filename = format!("tests/fabric/cfg/{name}/route-maps.cfg"); + &std::fs::read_to_string(real_filename).expect("cannot find route-map config file") + }}; +} + +#[allow(unused_macros)] +macro_rules! get_prefix_lists_config { + () => {{ + fn f() {} + fn type_name_of(_: T) -> &'static str { + std::any::type_name::() + } + let mut name = type_name_of(f); + + name = match &name[..name.len() - 3].rfind(':') { + Some(pos) => &name[pos + 1..name.len() - 3], + None => &name[..name.len() - 3], + }; + let real_filename = format!("tests/fabric/cfg/{name}/prefix-lists.cfg"); + &std::fs::read_to_string(real_filename).expect("cannot find prefix-list config file") + }}; +} + #[allow(unused_macros)] macro_rules! reference_name { ($suffix:expr) => {{ @@ -40,4 +76,8 @@ macro_rules! reference_name { #[allow(unused_imports)] pub(crate) use get_fabrics_config; #[allow(unused_imports)] +pub(crate) use get_prefix_lists_config; +#[allow(unused_imports)] +pub(crate) use get_route_maps_config; +#[allow(unused_imports)] pub(crate) use reference_name; diff --git a/proxmox-ve-config/tests/fabric/main.rs b/proxmox-ve-config/tests/fabric/main.rs index 88a24fa4afec..213d8cc0e262 100644 --- a/proxmox-ve-config/tests/fabric/main.rs +++ b/proxmox-ve-config/tests/fabric/main.rs @@ -3,10 +3,15 @@ use std::net::Ipv4Addr; use std::str::FromStr; use proxmox_frr::ser::bgp::{AddressFamilies, BgpRouter, CommonAddressFamilyOptions, L2vpnEvpnAF}; -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, +use proxmox_frr::ser::route_map::{AccessAction, RouteMapEntry, RouteMapName}; +use proxmox_frr::ser::{ + FrrConfig, FrrProtocol, FrrWord, IpProtocolRouteMap, VrfName, serializer::dump, +}; +use proxmox_section_config::typed::ApiSectionDataEntry; +use proxmox_ve_config::sdn::{ + fabric::{FabricConfig, frr::build_fabric, section_config::node::NodeId}, + prefix_list::{PrefixList, frr::build_frr_prefix_lists}, + route_map::{RouteMap, frr::build_frr_route_maps}, }; mod helper; @@ -219,9 +224,31 @@ bgp_node: bgp_pve "#; let config = FabricConfig::parse_section_config(raw).unwrap(); let mut frr_config = FrrConfig::default(); + let correct_src = RouteMapName::new("correct_src").unwrap(); + let correct_src_entry = RouteMapEntry { + seq: 1, + action: AccessAction::Permit, + matches: Vec::new(), + sets: Vec::new(), + custom_frr_config: Vec::new(), + call: None, + exit_action: None, + }; + frr_config + .routemaps + .insert(correct_src.clone(), vec![correct_src_entry.clone()]); + frr_config.protocol_routemaps.insert( + FrrProtocol::Bgp, + IpProtocolRouteMap { + v4: Some(correct_src.clone()), + v6: None, + }, + ); build_fabric(NodeId::from_str("pve").unwrap(), config, &mut frr_config).unwrap(); + assert_eq!(frr_config.routemaps[&correct_src], vec![correct_src_entry]); + let ospf_routemap = &frr_config.vrf_protocol_routemaps [&VrfName::Custom(FrrWord::new("vrf_zoneone").unwrap())][&FrrProtocol::Ospf]; assert_eq!( @@ -240,14 +267,173 @@ bgp_node: bgp_pve .get(&FrrProtocol::Ospf) .is_none() ); - assert!( - frr_config - .protocol_routemaps - .get(&FrrProtocol::Bgp) - .is_none() + assert_eq!( + frr_config.protocol_routemaps[&FrrProtocol::Bgp].v4, + Some(correct_src) ); } +#[test] +fn ospf_router_id_is_selected_per_vrf() { + let raw = r#" +ospf_fabric: red + area 0 + ip_prefix 10.0.0.0/24 + zone red + +ospf_node: red_pve + interfaces name=eth0 + ip 10.0.0.1 + +ospf_fabric: blue + area 0 + ip_prefix 10.0.0.0/24 + zone blue + +ospf_node: blue_pve + interfaces name=eth1 + ip 10.0.0.2 + +ospf_node: blue_pve2 + interfaces name=eth1 + ip 10.0.0.1 +"#; + 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 router_id = |vrf: &str| { + frr_config.ospf.vrf_router[&VrfName::Custom(FrrWord::new(vrf).unwrap())].router_id + }; + assert_eq!(router_id("vrf_red"), Ipv4Addr::new(10, 0, 0, 1)); + assert_eq!(router_id("vrf_blue"), Ipv4Addr::new(10, 0, 0, 2)); +} + +#[test] +fn vrf() { + let config = FabricConfig::parse_section_config(helper::get_fabrics_config!()).unwrap(); + let route_maps = + RouteMap::parse_section_config("route-maps.cfg", helper::get_route_maps_config!()).unwrap(); + let mut frr_config = FrrConfig::default(); + + build_frr_route_maps( + route_maps + .into_iter() + .map(|(_, route_map_entry)| route_map_entry), + &mut frr_config, + ) + .unwrap(); + build_fabric( + NodeId::from_str("pve").expect("invalid nodeid"), + config, + &mut frr_config, + ) + .unwrap(); + + let output = dump(&frr_config).expect("error dumping stuff"); + + insta::assert_snapshot!(helper::reference_name!("pve"), output); +} + +/// Fabrics in the default VRF and in a zone VRF on the same node. +#[test] +fn vrf_default() { + let config = FabricConfig::parse_section_config(helper::get_fabrics_config!()).unwrap(); + let mut frr_config = FrrConfig::default(); + + build_fabric( + NodeId::from_str("pve").expect("invalid nodeid"), + config, + &mut frr_config, + ) + .unwrap(); + + let output = dump(&frr_config).expect("error dumping stuff"); + + insta::assert_snapshot!(helper::reference_name!("pve"), output); +} + +/// Redistributions of OSPF and BGP fabrics in zone VRFs. +#[test] +fn vrf_redistribute() { + let config = FabricConfig::parse_section_config(helper::get_fabrics_config!()).unwrap(); + let route_maps = + RouteMap::parse_section_config("route-maps.cfg", helper::get_route_maps_config!()).unwrap(); + let mut frr_config = FrrConfig::default(); + + build_frr_route_maps( + route_maps + .into_iter() + .map(|(_, route_map_entry)| route_map_entry), + &mut frr_config, + ) + .unwrap(); + build_fabric( + NodeId::from_str("pve").expect("invalid nodeid"), + config, + &mut frr_config, + ) + .unwrap(); + + let output = dump(&frr_config).expect("error dumping stuff"); + + insta::assert_snapshot!(helper::reference_name!("pve"), output); +} + +/// Route filters of OSPF and BGP fabrics in zone VRFs. +#[test] +fn vrf_route_filter() { + let config = FabricConfig::parse_section_config(helper::get_fabrics_config!()).unwrap(); + let prefix_lists = + PrefixList::parse_section_config("prefix-lists.cfg", helper::get_prefix_lists_config!()) + .unwrap(); + let mut frr_config = FrrConfig::default(); + + build_frr_prefix_lists( + prefix_lists.into_iter().map(|(_, prefix_list)| prefix_list), + &mut frr_config, + ) + .unwrap(); + build_fabric( + NodeId::from_str("pve").expect("invalid nodeid"), + config, + &mut frr_config, + ) + .unwrap(); + + let output = dump(&frr_config).expect("error dumping stuff"); + + insta::assert_snapshot!(helper::reference_name!("pve"), output); +} + +/// IPv6-only and dual-stack BGP fabrics in zone VRFs. +#[test] +fn vrf_ipv6() { + let config = FabricConfig::parse_section_config(helper::get_fabrics_config!()).unwrap(); + let route_maps = + RouteMap::parse_section_config("route-maps.cfg", helper::get_route_maps_config!()).unwrap(); + let mut frr_config = FrrConfig::default(); + + build_frr_route_maps( + route_maps + .into_iter() + .map(|(_, route_map_entry)| route_map_entry), + &mut frr_config, + ) + .unwrap(); + build_fabric( + NodeId::from_str("pve").expect("invalid nodeid"), + config, + &mut frr_config, + ) + .unwrap(); + + let output = dump(&frr_config).expect("error dumping stuff"); + + insta::assert_snapshot!(helper::reference_name!("pve"), output); +} + #[test] fn bgp_default() { let config = FabricConfig::parse_section_config(helper::get_fabrics_config!()).unwrap(); diff --git a/proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_default_pve.snap b/proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_default_pve.snap new file mode 100644 index 000000000000..1a612b5ffb7a --- /dev/null +++ b/proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_default_pve.snap @@ -0,0 +1,113 @@ +--- +source: proxmox-ve-config/tests/fabric/main.rs +expression: output +--- +! +router bgp 65001 + bgp router-id 10.1.0.1 + no bgp default ipv4-unicast + neighbor bgpdef peer-group + neighbor bgpdef remote-as external + neighbor ens20 interface peer-group bgpdef + ! + address-family ipv4 unicast + network 10.1.0.1/32 + neighbor bgpdef activate + neighbor bgpdef soft-reconfiguration inbound + neighbor bgpdef route-map pve_bgp_bgpdef_in in + exit-address-family +exit +! +router bgp 65002 vrf vrf_red + bgp router-id 10.1.0.2 + no bgp default ipv4-unicast + neighbor bgpred peer-group + neighbor bgpred remote-as external + neighbor ens21 interface peer-group bgpred + ! + address-family ipv4 unicast + network 10.1.0.2/32 + neighbor bgpred activate + neighbor bgpred soft-reconfiguration inbound + neighbor bgpred route-map pve_bgp_bgpred_in in + exit-address-family +exit +! +router ospf + ospf router-id 10.0.0.1 +exit +! +router ospf vrf vrf_red + ospf router-id 10.0.0.2 +exit +! +interface dummy_ospfred vrf vrf_red + ip ospf area 0 + ip ospf passive +exit +! +interface dummy_underlay + ip ospf area 0 + ip ospf passive +exit +! +interface ens18 + ip ospf area 0 + ip ospf network point-to-point +exit +! +interface ens19 vrf vrf_red + ip ospf area 0 + ip ospf network point-to-point +exit +! +access-list pve_bgp_bgpdef_ips permit 10.1.0.0/24 +! +access-list pve_bgp_bgpred_ips permit 10.1.0.0/24 +! +access-list pve_ospf_ospfred_ips permit 10.0.0.0/24 +! +access-list pve_ospf_underlay_ips permit 10.0.0.0/24 +! +route-map pve_bgp permit 100 + match ip address pve_bgp_bgpdef_ips + set src 10.1.0.1 +exit +! +route-map pve_bgp permit 65535 +exit +! +route-map pve_bgp_bgpdef_in permit 10 + match ip address pve_bgp_bgpdef_ips +exit +! +route-map pve_bgp_bgpred_in permit 10 + match ip address pve_bgp_bgpred_ips +exit +! +route-map pve_bgp_vrf_red permit 110 + match ip address pve_bgp_bgpred_ips + set src 10.1.0.2 +exit +! +route-map pve_bgp_vrf_red permit 65535 +exit +! +route-map pve_ospf permit 130 + match ip address pve_ospf_underlay_ips + set src 10.0.0.1 +exit +! +route-map pve_ospf_vrf_red permit 120 + match ip address pve_ospf_ospfred_ips + set src 10.0.0.2 +exit +! +ip protocol bgp route-map pve_bgp +! +ip protocol ospf route-map pve_ospf +! +vrf vrf_red + ip protocol bgp route-map pve_bgp_vrf_red + ip protocol ospf route-map pve_ospf_vrf_red +exit-vrf diff --git a/proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_ipv6_pve.snap b/proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_ipv6_pve.snap new file mode 100644 index 000000000000..9ce4701a0d0d --- /dev/null +++ b/proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_ipv6_pve.snap @@ -0,0 +1,102 @@ +--- +source: proxmox-ve-config/tests/fabric/main.rs +expression: output +--- +! +router bgp 65002 vrf vrf_blue + bgp router-id 10.1.0.1 + no bgp default ipv4-unicast + neighbor bgpblue peer-group + neighbor bgpblue remote-as external + neighbor ens19 interface peer-group bgpblue + ! + address-family ipv4 unicast + network 10.1.0.1/32 + neighbor bgpblue activate + neighbor bgpblue soft-reconfiguration inbound + neighbor bgpblue route-map pve_bgp_bgpblue_in in + exit-address-family + ! + address-family ipv6 unicast + network fd00:20::1/128 + neighbor bgpblue activate + neighbor bgpblue soft-reconfiguration inbound + neighbor bgpblue route-map pve_bgp6_bgpblue_in in + exit-address-family +exit +! +router bgp 65001 vrf vrf_red + bgp router-id 5.76.46.251 + no bgp default ipv4-unicast + neighbor bgpred peer-group + neighbor bgpred remote-as external + neighbor ens18 interface peer-group bgpred + ! + address-family ipv6 unicast + network fd00:10::1/128 + neighbor bgpred activate + neighbor bgpred soft-reconfiguration inbound + neighbor bgpred route-map pve_bgp6_bgpred_in in + neighbor bgpred route-map red-out out + exit-address-family +exit +! +ipv6 access-list pve_bgp_bgpblue_ip6s permit fd00:20::/64 +! +access-list pve_bgp_bgpblue_ips permit 10.1.0.0/24 +! +ipv6 access-list pve_bgp_bgpred_ip6s permit fd00:10::/64 +! +route-map pve_bgp6_bgpblue_in permit 10 + match ipv6 address pve_bgp_bgpblue_ip6s +exit +! +route-map pve_bgp6_bgpred_in permit 10 + match ipv6 address pve_bgp_bgpred_ip6s + call red-in +exit +! +route-map pve_bgp6_vrf_blue permit 110 + match ipv6 address pve_bgp_bgpblue_ip6s + set src fd00:20::1 +exit +! +route-map pve_bgp6_vrf_blue permit 65535 +exit +! +route-map pve_bgp6_vrf_red permit 120 + match ipv6 address pve_bgp_bgpred_ip6s + set src fd00:10::1 +exit +! +route-map pve_bgp6_vrf_red permit 65535 +exit +! +route-map pve_bgp_bgpblue_in permit 10 + match ip address pve_bgp_bgpblue_ips +exit +! +route-map pve_bgp_vrf_blue permit 100 + match ip address pve_bgp_bgpblue_ips + set src 10.1.0.1 +exit +! +route-map pve_bgp_vrf_blue permit 65535 +exit +! +route-map red-in permit 10 + set local-preference 100 +exit +! +route-map red-out permit 10 + set metric 10 +exit +! +vrf vrf_blue + ip protocol bgp route-map pve_bgp_vrf_blue + ipv6 protocol bgp route-map pve_bgp6_vrf_blue +exit-vrf +! +vrf vrf_red + ipv6 protocol bgp route-map pve_bgp6_vrf_red +exit-vrf diff --git a/proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_pve.snap b/proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_pve.snap new file mode 100644 index 000000000000..84973240deb4 --- /dev/null +++ b/proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_pve.snap @@ -0,0 +1,134 @@ +--- +source: proxmox-ve-config/tests/fabric/main.rs +expression: output +--- +! +router bgp 65002 vrf vrf_blue + bgp router-id 10.1.0.1 + no bgp default ipv4-unicast + neighbor bgpblue peer-group + neighbor bgpblue remote-as external + neighbor ens21 interface peer-group bgpblue + ! + address-family ipv4 unicast + network 10.1.0.1/32 + neighbor bgpblue activate + neighbor bgpblue soft-reconfiguration inbound + neighbor bgpblue route-map pve_bgp_bgpblue_in in + neighbor bgpblue route-map blue-out out + exit-address-family +exit +! +router bgp 65001 vrf vrf_red + bgp router-id 10.1.0.1 + no bgp default ipv4-unicast + neighbor bgpred peer-group + neighbor bgpred remote-as external + neighbor ens20 interface peer-group bgpred + ! + address-family ipv4 unicast + network 10.1.0.1/32 + neighbor bgpred activate + neighbor bgpred soft-reconfiguration inbound + neighbor bgpred route-map pve_bgp_bgpred_in in + neighbor bgpred route-map red-out out + exit-address-family +exit +! +router ospf vrf vrf_blue + ospf router-id 10.0.0.1 +exit +! +router ospf vrf vrf_red + ospf router-id 10.0.0.1 +exit +! +interface dummy_ospfblue vrf vrf_blue + ip ospf area 0 + ip ospf passive +exit +! +interface dummy_ospfred vrf vrf_red + ip ospf area 0 + ip ospf passive +exit +! +interface ens18 vrf vrf_red + ip ospf area 0 + ip ospf network point-to-point +exit +! +interface ens19 vrf vrf_blue + ip ospf area 0 + ip ospf network point-to-point +exit +! +access-list pve_bgp_bgpblue_ips permit 10.1.0.0/24 +! +access-list pve_bgp_bgpred_ips permit 10.1.0.0/24 +! +access-list pve_ospf_ospfblue_ips permit 10.0.0.0/24 +! +access-list pve_ospf_ospfred_ips permit 10.0.0.0/24 +! +route-map blue-in permit 10 + set local-preference 200 +exit +! +route-map blue-out permit 10 + set metric 20 +exit +! +route-map pve_bgp_bgpblue_in permit 10 + match ip address pve_bgp_bgpblue_ips + call blue-in +exit +! +route-map pve_bgp_bgpred_in permit 10 + match ip address pve_bgp_bgpred_ips + call red-in +exit +! +route-map pve_bgp_vrf_blue permit 100 + match ip address pve_bgp_bgpblue_ips + set src 10.1.0.1 +exit +! +route-map pve_bgp_vrf_blue permit 65535 +exit +! +route-map pve_bgp_vrf_red permit 110 + match ip address pve_bgp_bgpred_ips + set src 10.1.0.1 +exit +! +route-map pve_bgp_vrf_red permit 65535 +exit +! +route-map pve_ospf_vrf_blue permit 120 + match ip address pve_ospf_ospfblue_ips + set src 10.0.0.1 +exit +! +route-map pve_ospf_vrf_red permit 130 + match ip address pve_ospf_ospfred_ips + set src 10.0.0.1 +exit +! +route-map red-in permit 10 + set local-preference 100 +exit +! +route-map red-out permit 10 + set metric 10 +exit +! +vrf vrf_blue + ip protocol bgp route-map pve_bgp_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 + ip protocol ospf route-map pve_ospf_vrf_red +exit-vrf diff --git a/proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_redistribute_pve.snap b/proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_redistribute_pve.snap new file mode 100644 index 000000000000..af7afd7b9fea --- /dev/null +++ b/proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_redistribute_pve.snap @@ -0,0 +1,74 @@ +--- +source: proxmox-ve-config/tests/fabric/main.rs +expression: output +--- +! +router bgp 65001 vrf vrf_blue + bgp router-id 10.1.0.1 + no bgp default ipv4-unicast + neighbor bgpblue peer-group + neighbor bgpblue remote-as external + neighbor ens19 interface peer-group bgpblue + ! + address-family ipv4 unicast + network 10.1.0.1/32 + neighbor bgpblue activate + neighbor bgpblue soft-reconfiguration inbound + neighbor bgpblue route-map pve_bgp_bgpblue_in in + redistribute connected + redistribute ospf metric 100 route-map redistribute-ospf + exit-address-family +exit +! +router ospf vrf vrf_red + ospf router-id 10.0.0.1 + redistribute connected + redistribute static metric 50 route-map redistribute-static +exit +! +interface dummy_ospfred vrf vrf_red + ip ospf area 0 + ip ospf passive +exit +! +interface ens18 vrf vrf_red + ip ospf area 0 + ip ospf network point-to-point +exit +! +access-list pve_bgp_bgpblue_ips permit 10.1.0.0/24 +! +access-list pve_ospf_ospfred_ips permit 10.0.0.0/24 +! +route-map pve_bgp_bgpblue_in permit 10 + match ip address pve_bgp_bgpblue_ips +exit +! +route-map pve_bgp_vrf_blue permit 100 + match ip address pve_bgp_bgpblue_ips + set src 10.1.0.1 +exit +! +route-map pve_bgp_vrf_blue permit 65535 +exit +! +route-map pve_ospf_vrf_red permit 110 + match ip address pve_ospf_ospfred_ips + set src 10.0.0.1 +exit +! +route-map redistribute-ospf permit 10 + set local-preference 150 +exit +! +route-map redistribute-static permit 10 + set metric 30 +exit +! +vrf vrf_blue + ip protocol bgp route-map pve_bgp_vrf_blue +exit-vrf +! +vrf vrf_red + ip protocol ospf route-map pve_ospf_vrf_red +exit-vrf diff --git a/proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_route_filter_pve.snap b/proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_route_filter_pve.snap new file mode 100644 index 000000000000..fa4a3f71e55b --- /dev/null +++ b/proxmox-ve-config/tests/fabric/snapshots/fabric__vrf_route_filter_pve.snap @@ -0,0 +1,85 @@ +--- +source: proxmox-ve-config/tests/fabric/main.rs +expression: output +--- +! +router bgp 65001 vrf vrf_blue + bgp router-id 10.1.0.1 + no bgp default ipv4-unicast + neighbor bgpblue peer-group + neighbor bgpblue remote-as external + neighbor ens19 interface peer-group bgpblue + ! + address-family ipv4 unicast + network 10.1.0.1/32 + neighbor bgpblue activate + neighbor bgpblue soft-reconfiguration inbound + neighbor bgpblue route-map pve_bgp_bgpblue_in in + exit-address-family + ! + address-family ipv6 unicast + network fd00:10::1/128 + neighbor bgpblue activate + neighbor bgpblue soft-reconfiguration inbound + neighbor bgpblue route-map pve_bgp6_bgpblue_in in + exit-address-family +exit +! +ip prefix-list blue-allowed seq 10 permit 10.1.0.0/24 le 32 +ip prefix-list blue-allowed seq 20 permit 192.0.2.0/24 +ipv6 prefix-list blue-allowed seq 30 permit fd00:10::/64 le 128 +! +ip prefix-list red-allowed seq 10 permit 10.0.0.0/24 le 32 +ip prefix-list red-allowed seq 20 permit 198.51.100.0/24 +! +router ospf vrf vrf_red + ospf router-id 10.0.0.1 +exit +! +interface dummy_ospfred vrf vrf_red + ip ospf area 0 + ip ospf passive +exit +! +interface ens18 vrf vrf_red + ip ospf area 0 + ip ospf network point-to-point +exit +! +route-map pve_bgp6_bgpblue_in permit 10 + match ipv6 address prefix-list blue-allowed +exit +! +route-map pve_bgp6_vrf_blue permit 110 + match ipv6 address prefix-list blue-allowed + set src fd00:10::1 +exit +! +route-map pve_bgp6_vrf_blue permit 65535 +exit +! +route-map pve_bgp_bgpblue_in permit 10 + match ip address prefix-list blue-allowed +exit +! +route-map pve_bgp_vrf_blue permit 100 + match ip address prefix-list blue-allowed + set src 10.1.0.1 +exit +! +route-map pve_bgp_vrf_blue permit 65535 +exit +! +route-map pve_ospf_vrf_red permit 120 + match ip address prefix-list red-allowed + set src 10.0.0.1 +exit +! +vrf vrf_blue + ip protocol bgp route-map pve_bgp_vrf_blue + ipv6 protocol bgp route-map pve_bgp6_vrf_blue +exit-vrf +! +vrf vrf_red + ip protocol ospf route-map pve_ospf_vrf_red +exit-vrf -- 2.47.3