[pve-devel] [PATCH proxmox-perl-rs 1/7] perl-rs: sdn: initial fabric infrastructure

Gabriel Goller g.goller at proxmox.com
Fri Mar 28 18:13:08 CET 2025


Add SDN fabric support with OpenFabric and OSPF configuration parsing.
Implements PerlSectionConfig wrapper and Perl module exports for fabric
configuration management.

Signed-off-by: Gabriel Goller <g.goller at proxmox.com>
---
 pve-rs/Cargo.toml         |  6 ++++-
 pve-rs/Makefile           |  1 +
 pve-rs/src/lib.rs         |  1 +
 pve-rs/src/sdn/fabrics.rs | 50 +++++++++++++++++++++++++++++++++++++++
 pve-rs/src/sdn/mod.rs     |  1 +
 5 files changed, 58 insertions(+), 1 deletion(-)
 create mode 100644 pve-rs/src/sdn/fabrics.rs
 create mode 100644 pve-rs/src/sdn/mod.rs

diff --git a/pve-rs/Cargo.toml b/pve-rs/Cargo.toml
index f2e495d33743..441b417a961a 100644
--- a/pve-rs/Cargo.toml
+++ b/pve-rs/Cargo.toml
@@ -39,9 +39,13 @@ proxmox-log = "0.2"
 proxmox-notify = { version = "0.5", features = ["pve-context"] }
 proxmox-openid = "0.10"
 proxmox-resource-scheduling = "0.3.0"
+proxmox-schema = "4.0.0"
+proxmox-section-config = "2.1.1"
 proxmox-shared-cache = "0.1.0"
 proxmox-subscription = "0.5"
 proxmox-sys = "0.6"
 proxmox-tfa = { version = "5", features = ["api"] }
 proxmox-time = "2"
-proxmox-ve-config = { version = "0.2.1" }
+proxmox-ve-config = { version = "0.2.1", features=["frr"] }
+proxmox-frr = { version = "0.1" }
+proxmox-network-types = { version = "0.1" }
diff --git a/pve-rs/Makefile b/pve-rs/Makefile
index d01da692d8c9..86af16eb5e04 100644
--- a/pve-rs/Makefile
+++ b/pve-rs/Makefile
@@ -31,6 +31,7 @@ PERLMOD_PACKAGES := \
 	  PVE::RS::Firewall::SDN \
 	  PVE::RS::OpenId \
 	  PVE::RS::ResourceScheduling::Static \
+	  PVE::RS::SDN::Fabrics \
 	  PVE::RS::TFA
 
 PERLMOD_PACKAGE_FILES := $(addsuffix .pm,$(subst ::,/,$(PERLMOD_PACKAGES)))
diff --git a/pve-rs/src/lib.rs b/pve-rs/src/lib.rs
index 3de37d17fab6..12ee87a91cc6 100644
--- a/pve-rs/src/lib.rs
+++ b/pve-rs/src/lib.rs
@@ -15,6 +15,7 @@ pub mod apt;
 pub mod firewall;
 pub mod openid;
 pub mod resource_scheduling;
+pub mod sdn;
 pub mod tfa;
 
 #[perlmod::package(name = "Proxmox::Lib::PVE", lib = "pve_rs")]
diff --git a/pve-rs/src/sdn/fabrics.rs b/pve-rs/src/sdn/fabrics.rs
new file mode 100644
index 000000000000..a761cea36ec0
--- /dev/null
+++ b/pve-rs/src/sdn/fabrics.rs
@@ -0,0 +1,50 @@
+#[perlmod::package(name = "PVE::RS::SDN::Fabrics", lib = "pve_rs")]
+pub mod export {
+    use std::sync::Mutex;
+
+    use anyhow::Error;
+    use proxmox_section_config::{
+        typed::ApiSectionDataEntry, typed::SectionConfigData as TypedSectionConfigData,
+    };
+    use proxmox_ve_config::sdn::fabric::{
+        openfabric::OpenFabricSectionConfig, ospf::OspfSectionConfig,
+    };
+    use serde::{Deserialize, Serialize};
+
+    pub struct PerlSectionConfig<T> {
+        pub section_config: Mutex<TypedSectionConfigData<T>>,
+    }
+
+    impl<T> PerlSectionConfig<T>
+    where
+        T: Send + Sync + Clone,
+    {
+        pub fn into_inner(self) -> Result<TypedSectionConfigData<T>, anyhow::Error> {
+            let value = self.section_config.into_inner().unwrap();
+            Ok(value)
+        }
+    }
+
+    #[derive(Serialize, Deserialize)]
+    struct AllConfigs {
+        openfabric: Vec<OpenFabricSectionConfig>,
+        ospf: Vec<OspfSectionConfig>,
+    }
+
+    /// Get all the config. This takes the raw openfabric and ospf config, parses, and returns
+    /// both.
+    #[export]
+    fn config(raw_openfabric: &[u8], raw_ospf: &[u8]) -> Result<AllConfigs, Error> {
+        let raw_openfabric = std::str::from_utf8(raw_openfabric)?;
+        let raw_ospf = std::str::from_utf8(raw_ospf)?;
+
+        let openfabric =
+            OpenFabricSectionConfig::parse_section_config("openfabric.cfg", raw_openfabric)?;
+        let ospf = OspfSectionConfig::parse_section_config("ospf.cfg", raw_ospf)?;
+
+        Ok(AllConfigs {
+            openfabric: openfabric.into_iter().map(|e| e.1).collect(),
+            ospf: ospf.into_iter().map(|e| e.1).collect(),
+        })
+    }
+}
diff --git a/pve-rs/src/sdn/mod.rs b/pve-rs/src/sdn/mod.rs
new file mode 100644
index 000000000000..3e3b1376f8d6
--- /dev/null
+++ b/pve-rs/src/sdn/mod.rs
@@ -0,0 +1 @@
+pub mod fabrics;
-- 
2.39.5





More information about the pve-devel mailing list