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 E963A1FF0BC for ; Mon, 16 Nov 2026 17:13:22 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 0168621740; Mon, 16 Nov 2026 17:12:38 +0100 (CET) From: Gabriel Goller To: pve-devel@lists.proxmox.com Subject: [PATCH proxmox-perl-rs v3 09/32] pve-rs: fabrics: assign network interfaces to configured VRFs Date: Mon, 16 Nov 2026 17:11:29 +0100 Message-ID: <20261116161154.343743-10-g.goller@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261116161154.343743-1-g.goller@proxmox.com> References: <20261116161154.343743-1-g.goller@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1794845520252 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.213 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) 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: 7SE57CDSOPUF5XGCA6T5GGTFYOSSGGTT X-Message-ID-Hash: 7SE57CDSOPUF5XGCA6T5GGTFYOSSGGTT X-MailFrom: g.goller@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: Add the VRF stanza to generated interface configuration when a fabric has a VRF. Apply it to dummy addresses, protocol interfaces, and BGP unnumbered interfaces so traffic enters the correct routing table. Fabrics without a VRF keep their existing configuration. Signed-off-by: Gabriel Goller --- pve-rs/src/bindings/sdn/fabrics.rs | 59 ++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 16 deletions(-) diff --git a/pve-rs/src/bindings/sdn/fabrics.rs b/pve-rs/src/bindings/sdn/fabrics.rs index 1d3e8b5bbf34..b7c2d91e5471 100644 --- a/pve-rs/src/bindings/sdn/fabrics.rs +++ b/pve-rs/src/bindings/sdn/fabrics.rs @@ -586,7 +586,12 @@ pub mod pve_rs_sdn_fabrics { } /// Helper function to generate the default `/etc/network/interfaces` config for a given CIDR. - fn render_interface(name: &str, cidr: Cidr, link_type: Option<&str>) -> Result { + fn render_interface( + name: &str, + cidr: Cidr, + link_type: Option<&str>, + vrf: Option<&str>, + ) -> Result { let mut interface = String::new(); writeln!(interface, "auto {name}")?; @@ -598,6 +603,9 @@ pub mod pve_rs_sdn_fabrics { if let Some(link_type) = link_type { writeln!(interface, "\tlink-type {link_type}")?; } + if let Some(vrf) = vrf { + writeln!(interface, "\tvrf {vrf}")?; + } writeln!(interface, "\tip-forward 1")?; Ok(interface) @@ -607,12 +615,14 @@ pub mod pve_rs_sdn_fabrics { interfaces: &mut String, fabric: &Fabric, node: &ConfigNode, + vrf: Option<&str>, ) -> Result<(), Error> { if let Some(ip) = node.ip() { let interface = render_interface( &format!("dummy_{}", fabric.id()), Cidr::new_v4(ip, 32)?, Some("dummy"), + vrf, )?; writeln!(interfaces)?; write!(interfaces, "{interface}")?; @@ -623,6 +633,7 @@ pub mod pve_rs_sdn_fabrics { &format!("dummy_{}", fabric.id()), Cidr::new_v6(ip6, 128)?, Some("dummy"), + vrf, )?; writeln!(interfaces)?; write!(interfaces, "{interface}")?; @@ -640,28 +651,35 @@ pub mod pve_rs_sdn_fabrics { let config = this.fabric_config.lock().unwrap(); let mut interfaces = String::new(); - let node_fabrics = config.values().filter_map(|entry| { - entry - .get_node(&node_id) - .map(|node| (entry.fabric(), node)) - .ok() - }); + let node_fabrics = config + .values() + .filter_map(|entry| entry.get_node(&node_id).map(|node| (entry, node)).ok()); - for (fabric, node) in node_fabrics { - render_dummy_interfaces(&mut interfaces, fabric, node)?; + for (entry, node) in node_fabrics { + let fabric = entry.fabric(); + let vrf = entry.fabric_vrf_name(); + render_dummy_interfaces(&mut interfaces, fabric, node, vrf.as_deref())?; match node { ConfigNode::Openfabric(node_section) => { for interface in node_section.properties().interfaces() { if let Some(ip) = interface.ip() { - let interface = - render_interface(interface.name(), Cidr::from(ip), None)?; + let interface = render_interface( + interface.name(), + Cidr::from(ip), + None, + vrf.as_deref(), + )?; writeln!(interfaces)?; write!(interfaces, "{interface}")?; } if let Some(ip) = interface.ip6() { - let interface = - render_interface(interface.name(), Cidr::from(ip), None)?; + let interface = render_interface( + interface.name(), + Cidr::from(ip), + None, + vrf.as_deref(), + )?; writeln!(interfaces)?; write!(interfaces, "{interface}")?; } @@ -678,7 +696,8 @@ pub mod pve_rs_sdn_fabrics { } else { anyhow::bail!("there has to be a ipv4 or ipv6 node address"); }); - let interface = render_interface(interface.name(), cidr, None)?; + let interface = + render_interface(interface.name(), cidr, None, vrf.as_deref())?; writeln!(interfaces)?; write!(interfaces, "{interface}")?; } @@ -688,8 +707,12 @@ pub mod pve_rs_sdn_fabrics { for interface in node_section.properties().interfaces() { writeln!(interfaces)?; if let Some(ip) = interface.ip() { - let interface = - render_interface(interface.name(), Cidr::from(ip), None)?; + let interface = render_interface( + interface.name(), + Cidr::from(ip), + None, + vrf.as_deref(), + )?; write!(interfaces, "{interface}")?; } else { let interface = render_interface( @@ -698,6 +721,7 @@ pub mod pve_rs_sdn_fabrics { anyhow::anyhow!("there has to be a ipv4 address") })?)), None, + vrf.as_deref(), )?; write!(interfaces, "{interface}")?; } @@ -765,6 +789,9 @@ pub mod pve_rs_sdn_fabrics { writeln!(interfaces)?; writeln!(interfaces, "auto {name}")?; writeln!(interfaces, "iface {name} inet manual")?; + if let Some(vrf) = &vrf { + writeln!(interfaces, "\tvrf {vrf}")?; + } writeln!(interfaces, "\tip-forward 1")?; writeln!(interfaces, "\tip6-forward 1")?; // BGP unnumbered uses RAs to discover peer link-local -- 2.47.3