public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Gabriel Goller <g.goller@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH proxmox-ve-rs 1/3] ve-config: add optional tag property to vnet
Date: Fri,  5 Sep 2025 13:44:56 +0200	[thread overview]
Message-ID: <20250905114504.195110-2-g.goller@proxmox.com> (raw)
In-Reply-To: <20250905114504.195110-1-g.goller@proxmox.com>

When parsing the vnet.cfg config file we also want to get the tag
(vni or vlan). We need this so that we can lookup the vni of the passed
vnet on the status api call. We need the vni so that we can filter the
frr output.

In the future we would probably want to do this better with an enum per
vnet type and parse all possible options.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 proxmox-ve-config/src/sdn/config.rs           | 27 ++++++++++++++++---
 proxmox-ve-config/tests/sdn/main.rs           |  5 ++--
 .../tests/sdn/resources/running-config.json   |  1 +
 3 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/proxmox-ve-config/src/sdn/config.rs b/proxmox-ve-config/src/sdn/config.rs
index 031fedcebbfc..afc5175002b1 100644
--- a/proxmox-ve-config/src/sdn/config.rs
+++ b/proxmox-ve-config/src/sdn/config.rs
@@ -196,6 +196,7 @@ pub struct SubnetsRunningConfig {
 /// Struct for deserializing a vnet entry of the SDN running config
 #[derive(Clone, Debug, Deserialize, PartialEq, Eq, Hash, PartialOrd, Ord)]
 pub struct VnetRunningConfig {
+    tag: Option<u32>,
     zone: ZoneName,
 }
 
@@ -295,14 +296,16 @@ impl SubnetConfig {
 #[derive(Clone, Debug, Deserialize, PartialEq, Eq, Hash, PartialOrd, Ord)]
 pub struct VnetConfig {
     name: VnetName,
+    tag: Option<u32>,
     subnets: BTreeMap<Cidr, SubnetConfig>,
 }
 
 impl VnetConfig {
-    pub fn new(name: VnetName) -> Self {
+    pub fn new(name: VnetName, tag: Option<u32>) -> Self {
         Self {
             name,
             subnets: BTreeMap::default(),
+            tag,
         }
     }
 
@@ -310,7 +313,18 @@ impl VnetConfig {
         name: VnetName,
         subnets: impl IntoIterator<Item = SubnetConfig>,
     ) -> Result<Self, SdnConfigError> {
-        let mut config = Self::new(name);
+        let mut config = Self::new(name, None);
+        config.add_subnets(subnets)?;
+        Ok(config)
+    }
+
+    pub fn from_subnets_and_tag(
+        name: VnetName,
+        tag: Option<u32>,
+        subnets: impl IntoIterator<Item = SubnetConfig>,
+    ) -> Result<Self, SdnConfigError> {
+        let mut config = Self::new(name, None);
+        config.tag = tag;
         config.add_subnets(subnets)?;
         Ok(config)
     }
@@ -342,6 +356,10 @@ impl VnetConfig {
     pub fn name(&self) -> &VnetName {
         &self.name
     }
+
+    pub fn tag(&self) -> &Option<u32> {
+        &self.tag
+    }
 }
 
 #[derive(Clone, Debug, Deserialize, PartialEq, Eq, Hash, PartialOrd, Ord)]
@@ -617,7 +635,10 @@ impl TryFrom<RunningConfig> for SdnConfig {
 
         if let Some(running_vnets) = value.vnets.take() {
             for (name, running_config) in running_vnets.ids {
-                config.add_vnet(&running_config.zone, VnetConfig::new(name))?;
+                config.add_vnet(
+                    &running_config.zone,
+                    VnetConfig::new(name, running_config.tag),
+                )?;
             }
         }
 
diff --git a/proxmox-ve-config/tests/sdn/main.rs b/proxmox-ve-config/tests/sdn/main.rs
index 94039ad5550e..bd38bbfc71f4 100644
--- a/proxmox-ve-config/tests/sdn/main.rs
+++ b/proxmox-ve-config/tests/sdn/main.rs
@@ -25,8 +25,9 @@ fn parse_running_config() {
         ZoneName::from_str("zone0").unwrap(),
         ZoneType::Simple,
         [
-            VnetConfig::from_subnets(
+            VnetConfig::from_subnets_and_tag(
                 VnetName::from_str("vnet0").unwrap(),
+                Some(100),
                 [
                     SubnetConfig::new(
                         SubnetName::from_str("zone0-fd80::-64").unwrap(),
@@ -84,7 +85,7 @@ fn sdn_config() {
     let zone0 = ZoneConfig::new(zone0_name.clone(), ZoneType::Qinq);
     sdn_config.add_zone(zone0).unwrap();
 
-    let vnet0 = VnetConfig::new(vnet0_name.clone());
+    let vnet0 = VnetConfig::new(vnet0_name.clone(), None);
     assert_eq!(
         sdn_config.add_vnet(&zone1_name, vnet0.clone()),
         Err(SdnConfigError::ZoneNotFound)
diff --git a/proxmox-ve-config/tests/sdn/resources/running-config.json b/proxmox-ve-config/tests/sdn/resources/running-config.json
index b03c20fa6ff9..d6054ba8d023 100644
--- a/proxmox-ve-config/tests/sdn/resources/running-config.json
+++ b/proxmox-ve-config/tests/sdn/resources/running-config.json
@@ -43,6 +43,7 @@
     "ids": {
       "vnet0": {
         "type": "vnet",
+        "tag": 100,
         "zone": "zone0"
       },
       "vnet1": {
-- 
2.47.2



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


  reply	other threads:[~2025-09-05 11:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-05 11:44 [pve-devel] [PATCH network/proxmox{-ve-rs, -perl-rs} 0/6] Add status endpoints for EVPN statistics Gabriel Goller
2025-09-05 11:44 ` Gabriel Goller [this message]
2025-09-05 11:44 ` [pve-devel] [PATCH proxmox-ve-rs 2/3] frr: fix some route deserialization types Gabriel Goller
2025-09-05 11:44 ` [pve-devel] [PATCH proxmox-ve-rs 3/3] frr: add deserialization types for EVPN Gabriel Goller
2025-09-05 11:44 ` [pve-devel] [PATCH proxmox-perl-rs 1/2] pve-rs: sdn: fabrics: update openfabric/ospf route filtering Gabriel Goller
2025-09-05 11:45 ` [pve-devel] [PATCH proxmox-perl-rs 2/2] pve-rs: sdn: add functions to retrieve the Zone/Vnet routes Gabriel Goller
2025-09-05 11:45 ` [pve-devel] [PATCH pve-network 1/1] sdn: add vnet and zone status endpoints Gabriel Goller

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=20250905114504.195110-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal