all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Gabriel Goller <g.goller@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH proxmox-perl-rs 06/15] pve-rs: fabrics: assign network interfaces to configured VRFs
Date: Fri, 21 Aug 2026 16:03:50 +0200	[thread overview]
Message-ID: <20260821140404.322081-7-g.goller@proxmox.com> (raw)
In-Reply-To: <20260821140404.322081-1-g.goller@proxmox.com>

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 <g.goller@proxmox.com>
---
 pve-rs/src/bindings/sdn/fabrics.rs | 69 +++++++++++++++++++++++-------
 1 file changed, 53 insertions(+), 16 deletions(-)

diff --git a/pve-rs/src/bindings/sdn/fabrics.rs b/pve-rs/src/bindings/sdn/fabrics.rs
index f96b6b1c656f..98470eeaa397 100644
--- a/pve-rs/src/bindings/sdn/fabrics.rs
+++ b/pve-rs/src/bindings/sdn/fabrics.rs
@@ -582,8 +582,23 @@ pub mod pve_rs_sdn_fabrics {
         Ok(interface)
     }
 
+    pub(crate) fn fabric_vrf_name(fabric: &FabricEntry) -> Option<String> {
+        let zone = match fabric {
+            FabricEntry::Ospf(entry) => entry.fabric_section().properties().zone(),
+            FabricEntry::Bgp(entry) => entry.fabric_section().properties().zone(),
+            FabricEntry::Openfabric(_) | FabricEntry::WireGuard(_) => None,
+        };
+
+        zone.map(|zone| format!("vrf_{zone}"))
+    }
+
     /// 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<String, Error> {
+    fn render_interface(
+        name: &str,
+        cidr: Cidr,
+        link_type: Option<&str>,
+        vrf: Option<&str>,
+    ) -> Result<String, Error> {
         let mut interface = String::new();
 
         writeln!(interface, "auto {name}")?;
@@ -595,6 +610,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)
@@ -604,12 +622,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}")?;
@@ -620,6 +640,7 @@ pub mod pve_rs_sdn_fabrics {
                 &format!("dummy_{}", fabric.id()),
                 Cidr::new_v6(ip6, 128)?,
                 Some("dummy"),
+                vrf,
             )?;
             writeln!(interfaces)?;
             write!(interfaces, "{interface}")?;
@@ -637,28 +658,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 = fabric_vrf_name(entry);
+            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}")?;
                         }
@@ -675,7 +703,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}")?;
                         }
@@ -685,8 +714,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(
@@ -695,6 +728,7 @@ pub mod pve_rs_sdn_fabrics {
                                     anyhow::anyhow!("there has to be a ipv4 address")
                                 })?)),
                                 None,
+                                vrf.as_deref(),
                             )?;
                             write!(interfaces, "{interface}")?;
                         }
@@ -762,6 +796,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





  parent reply	other threads:[~2026-08-21 14:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-21 14:03 [RFC manager/network/proxmox{-ve-rs,-perl-rs} 00/15] SDN VRF support Gabriel Goller
2026-08-21 14:03 ` [PATCH proxmox-ve-rs 01/15] frr: add VRF-aware OSPF rendering Gabriel Goller
2026-08-21 14:03 ` [PATCH proxmox-ve-rs 02/15] sdn: add zone references to OSPF and BGP fabrics Gabriel Goller
2026-08-21 14:03 ` [PATCH proxmox-ve-rs 03/15] sdn: generate fabric routing configuration in zone VRFs Gabriel Goller
2026-08-21 14:03 ` [PATCH proxmox-ve-rs 04/15] sdn: fix VRF route-map scoping and zone ID validation Gabriel Goller
2026-08-21 14:03 ` [PATCH proxmox-ve-rs 05/15] tests: fabrics: add test for fabrics in VRFs Gabriel Goller
2026-08-21 14:03 ` Gabriel Goller [this message]
2026-08-21 14:03 ` [PATCH proxmox-perl-rs 07/15] pve-rs: fabrics: make per-fabric status queries VRF-aware Gabriel Goller
2026-08-21 14:03 ` [PATCH proxmox-perl-rs 08/15] pve-rs: fabrics: include VRF routes in aggregate status Gabriel Goller
2026-08-21 14:03 ` [PATCH pve-network 09/15] sdn: add optional VRFs for simple zones Gabriel Goller
2026-08-21 14:03 ` [PATCH pve-network 10/15] sdn: allow fabrics to use simple zone VRFs Gabriel Goller
2026-08-21 14:03 ` [PATCH pve-network 11/15] sdn: always generate EVPN " Gabriel Goller
2026-08-21 14:03 ` [PATCH pve-network 12/15] api: sdn: allow EVPN zones as fabric VRFs Gabriel Goller
2026-08-21 14:03 ` [PATCH pve-network 13/15] api: sdn: disallow BGP fabrics in EVPN zone VRFs Gabriel Goller
2026-08-21 14:03 ` [PATCH pve-manager 14/15] ui: sdn: add VRF zone selection for fabrics Gabriel Goller
2026-08-21 14:03 ` [PATCH pve-manager 15/15] ui: sdn: expose EVPN zones as fabric VRFs Gabriel Goller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260821140404.322081-7-g.goller@proxmox.com \
    --to=g.goller@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal