From: Gabriel Goller <g.goller@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH proxmox-perl-rs v3 09/28] pve-rs: fabrics: make per-fabric status queries VRF-aware
Date: Thu, 19 Nov 2026 20:40:55 +0100 [thread overview]
Message-ID: <20261119194116.575520-10-g.goller@proxmox.com> (raw)
In-Reply-To: <20261119194116.575520-1-g.goller@proxmox.com>
Use the fabric VRF in FRR route, neighbor, and interface queries for
OSPF and BGP.
Keep the existing commands for fabrics in the default routing table.
Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
pve-rs/src/bindings/sdn/fabrics.rs | 101 ++++++++++++++++-------------
1 file changed, 55 insertions(+), 46 deletions(-)
diff --git a/pve-rs/src/bindings/sdn/fabrics.rs b/pve-rs/src/bindings/sdn/fabrics.rs
index b7c2d91e5471..06ecd0d07eaf 100644
--- a/pve-rs/src/bindings/sdn/fabrics.rs
+++ b/pve-rs/src/bindings/sdn/fabrics.rs
@@ -827,6 +827,23 @@ pub mod pve_rs_sdn_fabrics {
.transpose()
}
+ /// Run a single `vtysh` command and return its stdout.
+ ///
+ /// The command is passed as a single argument, so it is not interpreted by a shell. Like
+ /// before, when it was run through `sh`, a missing `vtysh` binary yields empty output.
+ fn vtysh(command: &str) -> Result<String, Error> {
+ let output = match Command::new("vtysh")
+ .env("VTYSH_HISTFILE", "/dev/null")
+ .args(["-c", command])
+ .output()
+ {
+ Ok(output) => output,
+ Err(err) if err.kind() == std::io::ErrorKind::NotFound => return Ok(String::new()),
+ Err(err) => return Err(err.into()),
+ };
+ Ok(String::from_utf8(output.stdout)?)
+ }
+
/// Get the routes that have been learned and distributed by this specific fabric on this node.
///
/// Read and parse the fabric config to get the protocol and the interfaces. Parse the vtysh
@@ -841,6 +858,7 @@ pub mod pve_rs_sdn_fabrics {
};
let fabric = config.get_fabric(&fabric_id)?;
+ let vrf = fabric.fabric_vrf_name();
match fabric {
FabricEntry::Openfabric(_) => {
let openfabric_ipv4_routes_string = String::from_utf8(
@@ -878,12 +896,11 @@ pub mod pve_rs_sdn_fabrics {
)
}
FabricEntry::Ospf(_) => {
- let ospf_routes_string = String::from_utf8(
- Command::new("sh")
- .args(["-c", "vtysh -c 'show ip route ospf json'"])
- .output()?
- .stdout,
- )?;
+ let command = match &vrf {
+ Some(vrf) => format!("show ip route vrf {vrf} ospf json"),
+ None => "show ip route ospf json".to_string(),
+ };
+ let ospf_routes_string = vtysh(&command)?;
let ospf_routes: proxmox_frr::de::Routes = if ospf_routes_string.is_empty() {
proxmox_frr::de::Routes::default()
} else {
@@ -895,21 +912,17 @@ pub mod pve_rs_sdn_fabrics {
}
FabricEntry::WireGuard(_) => Ok(Vec::new()),
FabricEntry::Bgp(_) => {
- let bgp_ipv4_routes_string = String::from_utf8(
- Command::new("sh")
- .env("VTYSH_HISTFILE", "/dev/null")
- .args(["-c", "vtysh -c 'show ip route bgp json'"])
- .output()?
- .stdout,
- )?;
+ let ipv4_command = match &vrf {
+ Some(vrf) => format!("show ip route vrf {vrf} bgp json"),
+ None => "show ip route bgp json".to_string(),
+ };
+ let ipv6_command = match &vrf {
+ Some(vrf) => format!("show ipv6 route vrf {vrf} bgp json"),
+ None => "show ipv6 route bgp json".to_string(),
+ };
+ let bgp_ipv4_routes_string = vtysh(&ipv4_command)?;
- let bgp_ipv6_routes_string = String::from_utf8(
- Command::new("sh")
- .env("VTYSH_HISTFILE", "/dev/null")
- .args(["-c", "vtysh -c 'show ipv6 route bgp json'"])
- .output()?
- .stdout,
- )?;
+ let bgp_ipv6_routes_string = vtysh(&ipv6_command)?;
let mut bgp_routes: proxmox_frr::de::Routes = if bgp_ipv4_routes_string.is_empty() {
proxmox_frr::de::Routes::default()
@@ -941,6 +954,7 @@ pub mod pve_rs_sdn_fabrics {
};
let fabric = config.get_fabric(&fabric_id)?;
+ let vrf = fabric.fabric_vrf_name();
match fabric {
FabricEntry::Openfabric(_) => {
@@ -961,12 +975,11 @@ pub mod pve_rs_sdn_fabrics {
status::get_neighbors_openfabric(fabric_id, openfabric_neighbors).map(|v| v.into())
}
FabricEntry::Ospf(fabric) => {
- let ospf_neighbors_string = String::from_utf8(
- Command::new("sh")
- .args(["-c", "vtysh -c 'show ip ospf neighbor json'"])
- .output()?
- .stdout,
- )?;
+ let command = match &vrf {
+ Some(vrf) => format!("show ip ospf vrf {vrf} neighbor json"),
+ None => "show ip ospf neighbor json".to_string(),
+ };
+ let ospf_neighbors_string = vtysh(&command)?;
let ospf_neighbors: proxmox_frr::de::ospf::Neighbors =
if ospf_neighbors_string.is_empty() {
proxmox_frr::de::ospf::Neighbors::default()
@@ -985,13 +998,11 @@ pub mod pve_rs_sdn_fabrics {
}
FabricEntry::WireGuard(_) => Ok(status::NeighborStatus::WireGuard(Vec::new())),
FabricEntry::Bgp(_) => {
- let bgp_neighbors_string = String::from_utf8(
- Command::new("sh")
- .env("VTYSH_HISTFILE", "/dev/null")
- .args(["-c", "vtysh -c 'show bgp neighbors json'"])
- .output()?
- .stdout,
- )?;
+ let command = match &vrf {
+ Some(vrf) => format!("show bgp vrf {vrf} neighbors json"),
+ None => "show bgp neighbors json".to_string(),
+ };
+ let bgp_neighbors_string = vtysh(&command)?;
let bgp_neighbors: std::collections::BTreeMap<String, status::BgpNeighborInfo> =
if bgp_neighbors_string.is_empty() {
std::collections::BTreeMap::new()
@@ -1018,6 +1029,7 @@ pub mod pve_rs_sdn_fabrics {
};
let fabric = config.get_fabric(&fabric_id)?;
+ let vrf = fabric.fabric_vrf_name();
match fabric {
FabricEntry::Openfabric(_) => {
@@ -1039,12 +1051,11 @@ pub mod pve_rs_sdn_fabrics {
.map(|v| v.into())
}
FabricEntry::Ospf(fabric) => {
- let ospf_interfaces_string = String::from_utf8(
- Command::new("sh")
- .args(["-c", "vtysh -c 'show ip ospf interface json'"])
- .output()?
- .stdout,
- )?;
+ let command = match &vrf {
+ Some(vrf) => format!("show ip ospf vrf {vrf} interface json"),
+ None => "show ip ospf interface json".to_string(),
+ };
+ let ospf_interfaces_string = vtysh(&command)?;
let ospf_interfaces: proxmox_frr::de::ospf::Interfaces =
if ospf_interfaces_string.is_empty() {
proxmox_frr::de::ospf::Interfaces::default()
@@ -1063,13 +1074,11 @@ pub mod pve_rs_sdn_fabrics {
}
FabricEntry::WireGuard(_) => Ok(status::InterfaceStatus::WireGuard(Vec::new())),
FabricEntry::Bgp(_) => {
- let bgp_neighbors_string = String::from_utf8(
- Command::new("sh")
- .env("VTYSH_HISTFILE", "/dev/null")
- .args(["-c", "vtysh -c 'show bgp neighbors json'"])
- .output()?
- .stdout,
- )?;
+ let command = match &vrf {
+ Some(vrf) => format!("show bgp vrf {vrf} neighbors json"),
+ None => "show bgp neighbors json".to_string(),
+ };
+ let bgp_neighbors_string = vtysh(&command)?;
let bgp_neighbors: std::collections::BTreeMap<String, status::BgpNeighborInfo> =
if bgp_neighbors_string.is_empty() {
std::collections::BTreeMap::new()
--
2.47.3
next prev parent reply other threads:[~2026-11-19 19:42 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 19:40 [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/28] SDN VRF support Gabriel Goller
2026-11-19 19:40 ` [PATCH pve-common v3 01/28] interfaces: preserve VRF membership across address family changes Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-ve-rs v3 02/28] frr: add VRF-aware OSPF rendering Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-ve-rs v3 03/28] sdn: add zone references to OSPF and BGP fabrics Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-ve-rs v3 04/28] sdn: generate fabric routing configuration in zone VRFs Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-ve-rs v3 05/28] sdn: fix VRF route-map scoping and zone ID validation Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-ve-rs v3 06/28] tests: fabrics: add tests for fabrics in VRFs Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-ve-rs v3 07/28] sdn: allow static routes in simple zone VRFs Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-perl-rs v3 08/28] pve-rs: fabrics: assign network interfaces to configured VRFs Gabriel Goller
2026-11-19 19:40 ` Gabriel Goller [this message]
2026-11-19 19:40 ` [PATCH proxmox-perl-rs v3 10/28] pve-rs: fabrics: include VRF routes in aggregate status Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-perl-rs v3 11/28] pve-rs: fabrics: expose host interface membership Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-perl-rs v3 12/28] sdn: expose static routes for simple zone uplinks Gabriel Goller
2026-11-19 19:40 ` [PATCH pve-network v3 13/28] sdn: evpn: add unreachable IPv6 default route to zone VRFs Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-network v3 14/28] sdn: add optional VRFs for simple zones Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-network v3 15/28] sdn: allow fabrics to use simple zone VRFs Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-network v3 16/28] sdn: require underlay fabrics to use the default VRF Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-network v3 17/28] sdn: move full range CIDR formats into a separate module Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-network v3 18/28] sdn: simple: support static routes in zone routing tables Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-network v3 19/28] sdn: dhcp: only configure DHCP for zones on the local node Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-network v3 20/28] sdn: dhcp: run dnsmasq in the zone VRF Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-network v3 21/28] sdn: dhcp: fix DNS server option for IPv4 subnets without gateway Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-network v3 22/28] sdn: evpn: no exit node null routes for simple zone VRFs Gabriel Goller
2026-11-19 19:41 ` [PATCH proxmox-widget-toolkit v3 23/28] ui: network: allow selecting a VRF for host interfaces Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-manager v3 24/28] ui: sdn: add VRF zone selection for fabrics Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-manager v3 25/28] network: allow setting the VRF of host interfaces Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-manager v3 26/28] ui: sdn: allow static routes for Simple zone VRFs Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-manager v3 27/28] network: generate SDN DHCP config after ifreload Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-manager v3 28/28] ui: sdn: subnet: allow setting the DHCP DNS server 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=20261119194116.575520-10-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox