From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pve-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
	by lore.proxmox.com (Postfix) with ESMTPS id 2446E1FF164
	for <inbox@lore.proxmox.com>; Fri, 28 Mar 2025 18:14:07 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id A6C2D81B8;
	Fri, 28 Mar 2025 18:13:51 +0100 (CET)
From: Gabriel Goller <g.goller@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Fri, 28 Mar 2025 18:12:56 +0100
Message-Id: <20250328171340.885413-9-g.goller@proxmox.com>
X-Mailer: git-send-email 2.39.5
In-Reply-To: <20250328171340.885413-1-g.goller@proxmox.com>
References: <20250328171340.885413-1-g.goller@proxmox.com>
MIME-Version: 1.0
X-SPAM-LEVEL: Spam detection results:  0
 AWL -0.026 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DMARC_MISSING             0.1 Missing DMARC policy
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
Subject: [pve-devel] [PATCH proxmox-ve-rs 07/17] frr: add openfabric types
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: pve-devel-bounces@lists.proxmox.com
Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com>

Implement OpenFabric-specific variants of common enums that encapsulate
protocol properties defined in proxmox-network-types. The primary addition
is OpenFabricInterface, which stores protocol-specific timing parameters:
HelloInterval (neighbor discovery frequency), CsnpInterval (database
synchronization frequency), and HelloMultiplier (neighbor failure detection).
Added `is_ipv6` flag to support FRR's command prefixing requirements during
serialization for IPv6-specific commands (we need to add a 'ipv6' prefix
to some commands).

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 proxmox-frr/src/lib.rs        |  1 +
 proxmox-frr/src/openfabric.rs | 93 +++++++++++++++++++++++++++++++++++
 2 files changed, 94 insertions(+)
 create mode 100644 proxmox-frr/src/openfabric.rs

diff --git a/proxmox-frr/src/lib.rs b/proxmox-frr/src/lib.rs
index 926ca42917a9..d54f83127501 100644
--- a/proxmox-frr/src/lib.rs
+++ b/proxmox-frr/src/lib.rs
@@ -1,3 +1,4 @@
+pub mod openfabric;
 use std::{collections::BTreeMap, fmt::Display, str::FromStr};
 
 use serde::{Deserialize, Serialize};
diff --git a/proxmox-frr/src/openfabric.rs b/proxmox-frr/src/openfabric.rs
new file mode 100644
index 000000000000..f814a82af006
--- /dev/null
+++ b/proxmox-frr/src/openfabric.rs
@@ -0,0 +1,93 @@
+use std::fmt::Debug;
+use std::fmt::Display;
+
+use proxmox_network_types::net::Net;
+use serde::{Deserialize, Serialize};
+use serde_with::SerializeDisplay;
+
+use thiserror::Error;
+
+use crate::FrrWord;
+use crate::FrrWordError;
+use crate::RouterNameError;
+
+#[derive(Clone, Debug, PartialEq, Eq, Hash, Deserialize, SerializeDisplay, PartialOrd, Ord)]
+pub struct OpenFabricRouterName(FrrWord);
+
+impl From<FrrWord> for OpenFabricRouterName {
+    fn from(value: FrrWord) -> Self {
+        Self(value)
+    }
+}
+
+impl OpenFabricRouterName {
+    pub fn new(name: FrrWord) -> Self {
+        Self(name)
+    }
+}
+
+impl Display for OpenFabricRouterName {
+    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        write!(f, "openfabric {}", self.0)
+    }
+}
+
+#[derive(Clone, Debug, PartialEq, Eq, Hash, Deserialize, Serialize, PartialOrd, Ord)]
+pub struct OpenFabricRouter {
+    pub net: Net,
+}
+
+impl OpenFabricRouter {
+    pub fn new(net: Net) -> Self {
+        Self { net }
+    }
+
+    pub fn net(&self) -> &Net {
+        &self.net
+    }
+}
+
+#[derive(Clone, Debug, PartialEq, Eq, Hash, Deserialize, Serialize, PartialOrd, Ord)]
+pub struct OpenFabricInterface {
+    // Note: an interface can only be a part of a single fabric (so no vec needed here)
+    pub fabric_id: OpenFabricRouterName,
+    pub passive: Option<bool>,
+    pub hello_interval: Option<proxmox_network_types::openfabric::HelloInterval>,
+    pub csnp_interval: Option<proxmox_network_types::openfabric::CsnpInterval>,
+    pub hello_multiplier: Option<proxmox_network_types::openfabric::HelloMultiplier>,
+    pub is_ipv6: bool,
+}
+
+impl OpenFabricInterface {
+    pub fn fabric_id(&self) -> &OpenFabricRouterName {
+        &self.fabric_id
+    }
+    pub fn passive(&self) -> Option<bool> {
+        self.passive
+    }
+    pub fn hello_interval(&self) -> Option<proxmox_network_types::openfabric::HelloInterval> {
+        self.hello_interval
+    }
+    pub fn csnp_interval(&self) -> Option<proxmox_network_types::openfabric::CsnpInterval> {
+        self.csnp_interval
+    }
+    pub fn hello_multiplier(&self) -> Option<proxmox_network_types::openfabric::HelloMultiplier> {
+        self.hello_multiplier
+    }
+    pub fn set_hello_interval(
+        &mut self,
+        interval: impl Into<Option<proxmox_network_types::openfabric::HelloInterval>>,
+    ) {
+        self.hello_interval = interval.into();
+    }
+}
+
+#[derive(Error, Debug)]
+pub enum OpenFabricInterfaceError {
+    #[error("Unknown error converting to OpenFabricInterface")]
+    UnknownError,
+    #[error("Error converting router name")]
+    RouterNameError(#[from] RouterNameError),
+    #[error("Error parsing frr word")]
+    FrrWordParse(#[from] FrrWordError),
+}
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel