From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 963751FF17E for ; Thu, 30 Oct 2025 16:48:53 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 9192226DA5; Thu, 30 Oct 2025 16:49:00 +0100 (CET) From: Stefan Hanreich To: pve-devel@lists.proxmox.com Date: Thu, 30 Oct 2025 16:48:13 +0100 Message-ID: <20251030154851.540408-7-s.hanreich@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251030154851.540408-1-s.hanreich@proxmox.com> References: <20251030154851.540408-1-s.hanreich@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.185 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 KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Subject: [pve-devel] [PATCH proxmox-ve-rs 4/6] ve-config: add optional tag property to vnet X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" From: Gabriel Goller 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 Signed-off-by: Stefan Hanreich --- 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 031fedc..afc5175 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, zone: ZoneName, } @@ -295,14 +296,16 @@ impl SubnetConfig { #[derive(Clone, Debug, Deserialize, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct VnetConfig { name: VnetName, + tag: Option, subnets: BTreeMap, } impl VnetConfig { - pub fn new(name: VnetName) -> Self { + pub fn new(name: VnetName, tag: Option) -> Self { Self { name, subnets: BTreeMap::default(), + tag, } } @@ -310,7 +313,18 @@ impl VnetConfig { name: VnetName, subnets: impl IntoIterator, ) -> Result { - 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, + subnets: impl IntoIterator, + ) -> Result { + 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 { + &self.tag + } } #[derive(Clone, Debug, Deserialize, PartialEq, Eq, Hash, PartialOrd, Ord)] @@ -617,7 +635,10 @@ impl TryFrom 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 94039ad..bd38bbf 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 b03c20f..d6054ba 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.3 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel