From: Gabriel Goller <g.goller@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH proxmox-ve-rs 1/1] ve-config: fabrics: force ip-prefix to be canonical
Date: Wed, 23 Jul 2025 16:32:00 +0200 [thread overview]
Message-ID: <20250723143200.737707-2-g.goller@proxmox.com> (raw)
In-Reply-To: <20250723143200.737707-1-g.goller@proxmox.com>
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@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
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2025-07-23 14:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-23 14:31 [pve-devel] [PATCH proxmox 1/1] network-types: add method to canonicalize IPv4 and IPv6 CIDRs Gabriel Goller
2025-07-23 14:32 ` Gabriel Goller [this message]
2025-07-30 12:00 ` [pve-devel] applied: " Thomas Lamprecht
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=20250723143200.737707-2-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.