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 A82911FF133 for ; Mon, 11 May 2026 15:38:17 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id F171D1832D; Mon, 11 May 2026 15:37:35 +0200 (CEST) From: Stefan Hanreich To: pve-devel@lists.proxmox.com Subject: [PATCH proxmox-perl-rs v8 04/25] sdn: prefix lists: add crud methods for prefix list entries Date: Mon, 11 May 2026 15:36:23 +0200 Message-ID: <20260511133650.310040-5-s.hanreich@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260511133650.310040-1-s.hanreich@proxmox.com> References: <20260511133650.310040-1-s.hanreich@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1778506506690 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.424 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_MAILER 2 Automated Mailer Tag Left in Email POISEN_SPAM_PILL_3 0.1 random spam to be learned in bayes SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: RD6EPG3YF3356TOAD3HEK5IIHXUX4PX6 X-Message-ID-Hash: RD6EPG3YF3356TOAD3HEK5IIHXUX4PX6 X-MailFrom: s.hanreich@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Prefix list entries get exposed via their own subfolder under the /prefix-lists folder - so they can be modified easier via the UI. The respective logic for the API handlers is implemented directly in ve-config, which enforces the invariants and sequence number auto-generation. Signed-off-by: Stefan Hanreich --- pve-rs/src/bindings/sdn/prefix_lists.rs | 86 +++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/pve-rs/src/bindings/sdn/prefix_lists.rs b/pve-rs/src/bindings/sdn/prefix_lists.rs index 4ca6999..8087a9e 100644 --- a/pve-rs/src/bindings/sdn/prefix_lists.rs +++ b/pve-rs/src/bindings/sdn/prefix_lists.rs @@ -170,4 +170,90 @@ pub mod pve_rs_sdn_prefix_lists { .map(|_| ()) .ok_or_else(|| anyhow!("could not find prefix list with id: {id}")) } + + /// Method: Get a specific prefix list entry. + #[export] + pub fn list_entries( + #[try_from_ref] this: &PerlPrefixListConfig, + id: PrefixListId, + ) -> Result, Error> { + let prefix_lists = this.prefix_lists.lock().unwrap(); + + let ConfigPrefixList::PrefixList(prefix_list) = prefix_lists + .get(&id.to_string()) + .ok_or_else(|| anyhow!("could not find prefix list with id: {id}"))?; + + Ok(prefix_list.entries().into_iter().cloned().collect()) + } + + /// Method: Get a specific prefix list entry. + #[export] + pub fn get_entry( + #[try_from_ref] this: &PerlPrefixListConfig, + id: PrefixListId, + seq: u32, + ) -> Option { + this.prefix_lists + .lock() + .unwrap() + .get(&id.to_string()) + .and_then(|prefix_list| { + let ConfigPrefixList::PrefixList(prefix_list) = prefix_list; + prefix_list.entry(seq) + }) + .cloned() + } + + /// Method: Get a specific prefix list entry. + #[export] + pub fn create_entry( + #[try_from_ref] this: &PerlPrefixListConfig, + id: PrefixListId, + entry: ApiPrefixListEntry, + ) -> Result<(), Error> { + let mut prefix_lists = this.prefix_lists.lock().unwrap(); + + let ConfigPrefixList::PrefixList(prefix_list) = prefix_lists + .get_mut(&id.to_string()) + .ok_or_else(|| anyhow::anyhow!("could not find prefix list with id {id}"))?; + + prefix_list.try_insert_api_entry(entry) + } + + /// Method: Get a specific prefix list entry. + #[export] + pub fn update_entry( + #[try_from_ref] this: &PerlPrefixListConfig, + id: PrefixListId, + seq: u32, + updater: PrefixListEntryUpdater, + delete: Option>, + ) -> Result<(), Error> { + let mut prefix_lists = this.prefix_lists.lock().unwrap(); + + let ConfigPrefixList::PrefixList(prefix_list) = prefix_lists + .get_mut(&id.to_string()) + .ok_or_else(|| anyhow::anyhow!("could not find prefix list with id {id}"))?; + + prefix_list.try_update_entry(seq, updater, delete.unwrap_or_default()) + } + + /// Method: Remove a specific prefix list entry. + #[export] + pub fn delete_entry( + #[try_from_ref] this: &PerlPrefixListConfig, + id: PrefixListId, + seq: u32, + ) -> Result<(), Error> { + this.prefix_lists + .lock() + .unwrap() + .get_mut(&id.to_string()) + .and_then(|prefix_list| { + let ConfigPrefixList::PrefixList(prefix_list) = prefix_list; + prefix_list.remove_entry(seq) + }) + .map(|_| ()) + .ok_or_else(|| anyhow::anyhow!("could not find prefix list entry with seq {seq}")) + } } -- 2.47.3