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 984A41FF15C for ; Fri, 5 Sep 2025 13:44:59 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 7AECD132E7; Fri, 5 Sep 2025 13:45:12 +0200 (CEST) From: Gabriel Goller To: pve-devel@lists.proxmox.com Date: Fri, 5 Sep 2025 13:44:56 +0200 Message-ID: <20250905114504.195110-2-g.goller@proxmox.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250905114504.195110-1-g.goller@proxmox.com> References: <20250905114504.195110-1-g.goller@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1757072690497 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.005 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 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [config.rs, self.name, main.rs] Subject: [pve-devel] [PATCH proxmox-ve-rs 1/3] 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" 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 --- 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, 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 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