[pve-devel] [PATCH proxmox-ve-rs 1/1] ve-config: fabrics: force ip-prefix to be canonical
Gabriel Goller
g.goller at proxmox.com
Wed Jul 23 16:32:00 CEST 2025
FRR spits out a warning if the address of the access-list is not
canonicalized (i.e. not a network address). So when the user creates a new
fabric, just store the canonicalized version of the passed ip-prefix.
Signed-off-by: Gabriel Goller <g.goller at proxmox.com>
---
proxmox-ve-config/src/sdn/fabric/mod.rs | 9 ++++++++-
.../src/sdn/fabric/section_config/fabric.rs | 20 +++++++++++++++++++
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/proxmox-ve-config/src/sdn/fabric/mod.rs b/proxmox-ve-config/src/sdn/fabric/mod.rs
index 9ec2f615c8f1..58a06f9423cb 100644
--- a/proxmox-ve-config/src/sdn/fabric/mod.rs
+++ b/proxmox-ve-config/src/sdn/fabric/mod.rs
@@ -587,11 +587,18 @@ impl FabricConfig {
/// Add a fabric to the [`FabricConfig`].
///
/// Returns an error if a fabric with the same name exists.
- pub fn add_fabric(&mut self, fabric: Fabric) -> Result<(), FabricConfigError> {
+ pub fn add_fabric(&mut self, mut fabric: Fabric) -> Result<(), FabricConfigError> {
if self.fabrics.contains_key(fabric.id()) {
return Err(FabricConfigError::DuplicateFabric(fabric.id().to_string()));
}
+ if let Some(prefix) = fabric.ip_prefix() {
+ fabric.set_ip_prefix(prefix.canonical());
+ }
+ if let Some(prefix) = fabric.ip6_prefix() {
+ fabric.set_ip6_prefix(prefix.canonical());
+ }
+
self.fabrics.insert(fabric.id().clone(), fabric.into());
Ok(())
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 d41c6d82fd88..38911a624740 100644
--- a/proxmox-ve-config/src/sdn/fabric/section_config/fabric.rs
+++ b/proxmox-ve-config/src/sdn/fabric/section_config/fabric.rs
@@ -186,6 +186,16 @@ impl Fabric {
}
}
+ /// Set the ip-prefix (IPv4 CIDR) of the [`Fabric`].
+ ///
+ /// This is a common property for all protocols.
+ pub fn set_ip_prefix(&mut self, ipv4_cidr: Ipv4Cidr) {
+ match self {
+ Fabric::Openfabric(fabric_section) => fabric_section.ip_prefix = Some(ipv4_cidr),
+ Fabric::Ospf(fabric_section) => fabric_section.ip_prefix = Some(ipv4_cidr),
+ }
+ }
+
/// Get the ip6-prefix (IPv6 CIDR) of the [`Fabric`].
///
/// This is a common property for all protocols.
@@ -195,6 +205,16 @@ impl Fabric {
Fabric::Ospf(fabric_section) => fabric_section.ip6_prefix(),
}
}
+
+ /// Set the ip6-prefix (IPv6 CIDR) of the [`Fabric`].
+ ///
+ /// This is a common property for all protocols.
+ pub fn set_ip6_prefix(&mut self, ipv6_cidr: Ipv6Cidr) {
+ match self {
+ Fabric::Openfabric(fabric_section) => fabric_section.ip6_prefix = Some(ipv6_cidr),
+ Fabric::Ospf(fabric_section) => fabric_section.ip6_prefix = Some(ipv6_cidr),
+ }
+ }
}
impl Validatable for Fabric {
--
2.39.5
More information about the pve-devel
mailing list