From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 7E75A1FF0BC for ; Thu, 29 Oct 2026 15:44:29 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 063DB214DF; Thu, 29 Oct 2026 15:44:18 +0100 (CET) From: Hannes Laimer To: pve-devel@lists.proxmox.com Subject: [PATCH proxmox-perl-rs v4 1/9] pve-rs: sdn: add IPv6 RA builder binding Date: Thu, 29 Oct 2026 15:44:00 +0100 Message-ID: <20261029144408.2646288-2-h.laimer@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261029144408.2646288-1-h.laimer@proxmox.com> References: <20261029144408.2646288-1-h.laimer@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1793285052664 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.644 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) KAM_MAILER 2 Automated Mailer Tag Left in Email RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust 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: GMM6B6XMOBNKHPGBZCFKLXTSUF5T2HFJ X-Message-ID-Hash: GMM6B6XMOBNKHPGBZCFKLXTSUF5T2HFJ X-MailFrom: h.laimer@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: Perl builds the FRR config handed in for rendering, while the conversion of the IPv6 Router Advertisement settings for it lives in Rust. The binding takes a vnet and its subnets as the running config holds them and returns the vnet's entry for the RA part of that FRR config, with the prefix defaults applied. Signed-off-by: Hannes Laimer --- pve-rs/Makefile | 1 + pve-rs/src/bindings/sdn/ipv6_ra.rs | 40 ++++++++++++++++++++++++++++++ pve-rs/src/bindings/sdn/mod.rs | 1 + 3 files changed, 42 insertions(+) create mode 100644 pve-rs/src/bindings/sdn/ipv6_ra.rs diff --git a/pve-rs/Makefile b/pve-rs/Makefile index bb1cd2d5f73a..0dfd672fa496 100644 --- a/pve-rs/Makefile +++ b/pve-rs/Makefile @@ -33,6 +33,7 @@ PERLMOD_PACKAGES := \ PVE::RS::ResourceScheduling::Static \ PVE::RS::ResourceScheduling::Dynamic \ PVE::RS::SDN::Fabrics \ + PVE::RS::SDN::IPv6RA \ PVE::RS::SDN::PrefixLists \ PVE::RS::SDN::RouteMaps \ PVE::RS::SDN::WireGuard::PrivateKeys \ diff --git a/pve-rs/src/bindings/sdn/ipv6_ra.rs b/pve-rs/src/bindings/sdn/ipv6_ra.rs new file mode 100644 index 000000000000..7e7ed84c788b --- /dev/null +++ b/pve-rs/src/bindings/sdn/ipv6_ra.rs @@ -0,0 +1,40 @@ +#[perlmod::package(name = "PVE::RS::SDN::IPv6RA", lib = "pve_rs")] +pub mod pve_rs_sdn_ipv6_ra { + //! The `PVE::RS::SDN::IPv6RA` package. + //! + //! This builds the FRR IPv6 Router Advertisement configuration of a vnet from the + //! running config of the vnet and its subnets. + + use std::collections::BTreeMap; + + use anyhow::{Context, Error}; + + use proxmox_frr::ser::nd::NdInterface; + use proxmox_ve_config::sdn::{ + SubnetName, VnetName, + config::{SubnetConfig, SubnetRunningConfig, VnetConfig, VnetRunningConfig}, + nd::frr::build_nd_interface, + }; + + /// Method: Build the [`NdInterface`] of a vnet. Returns `None` when the vnet has RAs + /// off or no IPv6 subnet. + #[export] + pub fn build_interface( + vnet_name: VnetName, + vnet: VnetRunningConfig, + subnets: BTreeMap, + ) -> Result, Error> { + let mut vnet_config = VnetConfig::new(vnet_name, None); + vnet_config.set_ipv6_ra(vnet.ipv6_ra_config()); + + let mut subnet_configs: Vec = Vec::with_capacity(subnets.len()); + for (id, running) in subnets { + let name: SubnetName = id + .parse() + .with_context(|| format!("invalid subnet id: {id}"))?; + subnet_configs.push(SubnetConfig::try_from_running_config(name, running)?); + } + + Ok(build_nd_interface(&vnet_config, subnet_configs.iter())) + } +} diff --git a/pve-rs/src/bindings/sdn/mod.rs b/pve-rs/src/bindings/sdn/mod.rs index dcae046a7e46..fb50526785e5 100644 --- a/pve-rs/src/bindings/sdn/mod.rs +++ b/pve-rs/src/bindings/sdn/mod.rs @@ -1,4 +1,5 @@ pub(crate) mod fabrics; +pub(crate) mod ipv6_ra; pub(crate) mod prefix_lists; pub(crate) mod route_maps; pub(crate) mod wireguard; -- 2.47.3