From: Stefan Hanreich <s.hanreich@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH proxmox-datacenter-manager v2 10/15] ui: add view for showing ip vrfs
Date: Fri, 22 Aug 2025 15:49:33 +0200 [thread overview]
Message-ID: <20250822134942.380480-28-s.hanreich@proxmox.com> (raw)
In-Reply-To: <20250822134942.380480-1-s.hanreich@proxmox.com>
This component shows the content of all IP-VRFs from all remotes
configured in the PDM. It merges the contents of IP-VRFs that have the
same ASN:VNI (= Route Target) combination. Practically speaking, it
shows a list of VNets who would have the Route Target of the IP-VRF in
their EVPN route target. This means that when importing the IP-VRF in
a different zone, routes from guests in those VNets would be imported
into the routing table.
The component operates under the assumption that zones that are in the
same ASN, are also interconnected - since it merges the VNets of all
zones with the same route target (= ASN + VRF VNI). This means ASNs
cannot be reused across remotes, if they are not connected, in order
for this view to correctly show the contents of the IP-VRFs. In the
future this could be improved by storing IDs or tags on the PVE side,
reading them from PDM and then only merging the zones of remotes that
have the same ID / tag.
In addition to the terms zones / vnets, the terms IP-VRF and MAC-VRF
are introduced. For EVPN a zone maps to a routing table and a vnet
maps to a bridging table. FRR [1] uses the terms in their
documentation and they are also referred to as such in the EVPN RFC
[2]. In order to make this relationship more clear, particularly to
users that are familiar with EVPN but not necessarily Proxmox VE SDN,
those terms are now used in addition to the existing terms zone /
vnet.
[1] https://docs.frrouting.org/en/latest/evpn.html
[2] https://datatracker.ietf.org/doc/html/rfc8365
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
ui/src/lib.rs | 2 +
ui/src/sdn/evpn/mod.rs | 3 +
ui/src/sdn/evpn/vrf_tree.rs | 345 ++++++++++++++++++++++++++++++++++++
ui/src/sdn/mod.rs | 1 +
4 files changed, 351 insertions(+)
create mode 100644 ui/src/sdn/evpn/vrf_tree.rs
create mode 100644 ui/src/sdn/mod.rs
diff --git a/ui/src/lib.rs b/ui/src/lib.rs
index e3755ec..bde8917 100644
--- a/ui/src/lib.rs
+++ b/ui/src/lib.rs
@@ -30,6 +30,8 @@ mod widget;
pub mod pbs;
pub mod pve;
+pub mod sdn;
+
pub mod renderer;
mod tasks;
diff --git a/ui/src/sdn/evpn/mod.rs b/ui/src/sdn/evpn/mod.rs
index c2958f0..da020a9 100644
--- a/ui/src/sdn/evpn/mod.rs
+++ b/ui/src/sdn/evpn/mod.rs
@@ -1,6 +1,9 @@
mod remote_tree;
pub use remote_tree::RemoteTree;
+mod vrf_tree;
+pub use vrf_tree::VrfTree;
+
#[derive(Clone, Copy, Debug, PartialEq, Eq, Ord, PartialOrd, Hash)]
pub struct EvpnRouteTarget {
asn: u32,
diff --git a/ui/src/sdn/evpn/vrf_tree.rs b/ui/src/sdn/evpn/vrf_tree.rs
new file mode 100644
index 0000000..8b01b00
--- /dev/null
+++ b/ui/src/sdn/evpn/vrf_tree.rs
@@ -0,0 +1,345 @@
+use std::cmp::Ordering;
+use std::collections::HashSet;
+use std::rc::Rc;
+
+use yew::virtual_dom::{Key, VNode};
+use yew::{Component, Context, Html, Properties};
+
+use pdm_client::types::{ListController, ListVnet, ListZone};
+use pwt::css;
+use pwt::props::{ContainerBuilder, ExtractPrimaryKey, WidgetBuilder};
+use pwt::state::{Selection, SlabTree, TreeStore};
+use pwt::tr;
+use pwt::widget::data_table::{
+ DataTable, DataTableColumn, DataTableHeader, DataTableRowRenderArgs,
+};
+use pwt::widget::{Column, Fa, Row};
+use pwt_macros::widget;
+
+use crate::sdn::evpn::EvpnRouteTarget;
+
+#[widget(comp=VrfTreeComponent)]
+#[derive(Clone, PartialEq, Properties, Default)]
+pub struct VrfTree {
+ zones: Rc<Vec<ListZone>>,
+ vnets: Rc<Vec<ListVnet>>,
+ controllers: Rc<Vec<ListController>>,
+}
+
+impl VrfTree {
+ pub fn new(
+ zones: Rc<Vec<ListZone>>,
+ vnets: Rc<Vec<ListVnet>>,
+ controllers: Rc<Vec<ListController>>,
+ ) -> Self {
+ yew::props!(Self {
+ zones,
+ vnets,
+ controllers,
+ })
+ }
+}
+
+pub enum VrfTreeMsg {
+ SelectionChange,
+}
+
+#[derive(Clone, PartialEq, Debug)]
+struct VrfData {
+ route_target: EvpnRouteTarget,
+}
+
+#[derive(Clone, PartialEq, Debug)]
+struct FdbData {
+ vrf_route_target: EvpnRouteTarget,
+ route_target: EvpnRouteTarget,
+}
+
+#[derive(Clone, PartialEq, Debug)]
+struct RemoteData {
+ remote: String,
+ zone: String,
+ vnet: String,
+}
+
+#[derive(Clone, PartialEq, Debug)]
+enum VrfTreeEntry {
+ Root,
+ Vrf(VrfData),
+ Fdb(FdbData),
+ Remote(RemoteData),
+}
+
+impl VrfTreeEntry {
+ fn vni(&self) -> Option<u32> {
+ match self {
+ VrfTreeEntry::Vrf(vrf) => Some(vrf.route_target.vni),
+ VrfTreeEntry::Fdb(fdb) => Some(fdb.route_target.vni),
+ _ => None,
+ }
+ }
+
+ fn asn(&self) -> Option<u32> {
+ match self {
+ VrfTreeEntry::Vrf(vrf) => Some(vrf.route_target.asn),
+ _ => None,
+ }
+ }
+
+ fn heading(&self) -> Option<String> {
+ Some(match self {
+ VrfTreeEntry::Root => return None,
+ VrfTreeEntry::Vrf(_) => "IP-VRF".to_string(),
+ VrfTreeEntry::Fdb(_) => "VNet".to_string(),
+ VrfTreeEntry::Remote(remote) => remote.vnet.clone(),
+ })
+ }
+}
+
+impl ExtractPrimaryKey for VrfTreeEntry {
+ fn extract_key(&self) -> Key {
+ match self {
+ Self::Root => Key::from("root"),
+ Self::Vrf(vrf) => Key::from(vrf.route_target.to_string()),
+ Self::Fdb(fdb) => Key::from(format!("{}/{}", fdb.vrf_route_target, fdb.route_target)),
+ Self::Remote(remote) => {
+ Key::from(format!("{}/{}/{}", remote.remote, remote.zone, remote.vnet,))
+ }
+ }
+ }
+}
+
+fn zones_to_vrf_view(
+ controllers: &[ListController],
+ zones: &[ListZone],
+ vnets: &[ListVnet],
+) -> SlabTree<VrfTreeEntry> {
+ let mut tree = SlabTree::new();
+
+ let mut root = tree.set_root(VrfTreeEntry::Root);
+ root.set_expanded(true);
+
+ let mut existing_vrfs: HashSet<EvpnRouteTarget> = HashSet::new();
+
+ for zone in zones {
+ let zone_data = &zone.zone;
+
+ let controller = controllers
+ .iter()
+ .find(|controller| {
+ controller.remote == zone.remote
+ && zone_data
+ .controller
+ .as_ref()
+ .expect("EVPN zone has a controller")
+ == &controller.controller.controller
+ })
+ .expect("controller of EVPN zone exists");
+
+ let route_target = EvpnRouteTarget {
+ asn: controller
+ .controller
+ .asn
+ .expect("EVPN controller as an ASN"),
+ vni: zone.zone.vrf_vxlan.expect("EVPN zone has a VXLAN ID"),
+ };
+
+ if !existing_vrfs.insert(route_target) {
+ continue;
+ }
+
+ let mut vrf_entry = root.append(VrfTreeEntry::Vrf(VrfData { route_target }));
+ vrf_entry.set_expanded(true);
+ }
+
+ for vnet in vnets {
+ let vnet_data = &vnet.vnet;
+
+ let zone = zones
+ .iter()
+ .find(|zone| {
+ zone.remote == vnet.remote
+ && vnet_data.zone.as_ref().expect("vnet has zone") == &zone.zone.zone
+ })
+ .expect("zone of vnet exists");
+
+ let controller = controllers
+ .iter()
+ .find(|controller| {
+ controller.remote == zone.remote
+ && zone
+ .zone
+ .controller
+ .as_ref()
+ .expect("EVPN zone has a controller")
+ == &controller.controller.controller
+ })
+ .expect("controller of EVPN zone exists");
+
+ let zone_target = EvpnRouteTarget {
+ asn: controller.controller.asn.expect("EVPN controller has ASN"),
+ vni: zone.zone.vrf_vxlan.expect("EVPN zone has a VRF VNI"),
+ };
+
+ let vnet_target = EvpnRouteTarget {
+ asn: controller.controller.asn.expect("EVPN controller has ASN"),
+ vni: vnet.vnet.tag.expect("EVPN vnet has a VNI"),
+ };
+
+ for mut vrf_entry in root.children_mut() {
+ if let VrfTreeEntry::Vrf(vrf_data) = vrf_entry.record() {
+ if vrf_data.route_target != zone_target {
+ continue;
+ }
+
+ let searched_entry = vrf_entry.children_mut().find(|entry| {
+ if let VrfTreeEntry::Fdb(fdb_data) = entry.record() {
+ return fdb_data.route_target == vnet_target;
+ }
+
+ false
+ });
+
+ let mut fdb_entry = if let Some(fdb_entry) = searched_entry {
+ fdb_entry
+ } else {
+ let fdb_entry = vrf_entry.append(VrfTreeEntry::Fdb(FdbData {
+ vrf_route_target: zone_target,
+ route_target: vnet_target,
+ }));
+
+ fdb_entry
+ };
+
+ fdb_entry.append(VrfTreeEntry::Remote(RemoteData {
+ remote: vnet.remote.clone(),
+ zone: vnet.vnet.zone.clone().expect("vnet has a zone"),
+ vnet: vnet.vnet.vnet.clone(),
+ }));
+ }
+ }
+ }
+
+ tree
+}
+
+pub struct VrfTreeComponent {
+ store: TreeStore<VrfTreeEntry>,
+ selection: Selection,
+}
+
+fn default_sorter(a: &VrfTreeEntry, b: &VrfTreeEntry) -> Ordering {
+ (a.asn(), a.vni()).cmp(&(b.asn(), b.vni()))
+}
+
+impl VrfTreeComponent {
+ fn columns(store: TreeStore<VrfTreeEntry>) -> Rc<Vec<DataTableHeader<VrfTreeEntry>>> {
+ Rc::new(vec![
+ DataTableColumn::new(tr!("Type / Name"))
+ .tree_column(store)
+ .render(|item: &VrfTreeEntry| {
+ let heading = item.heading();
+
+ heading
+ .map(|heading| {
+ let mut row = Row::new().class(css::AlignItems::Baseline).gap(2);
+
+ row = match item {
+ VrfTreeEntry::Vrf(_) => row.with_child(Fa::new("th")),
+ VrfTreeEntry::Fdb(_) => row.with_child(Fa::new("sdn-vnet")),
+ _ => row,
+ };
+
+ row = row.with_child(heading);
+
+ Html::from(row)
+ })
+ .unwrap_or_default()
+ })
+ .sorter(default_sorter)
+ .into(),
+ DataTableColumn::new(tr!("ASN"))
+ .render(|item: &VrfTreeEntry| item.asn().map(VNode::from).unwrap_or_default())
+ .sorter(|a: &VrfTreeEntry, b: &VrfTreeEntry| a.asn().cmp(&b.asn()))
+ .into(),
+ DataTableColumn::new(tr!("VNI"))
+ .render(|item: &VrfTreeEntry| item.vni().map(VNode::from).unwrap_or_default())
+ .sorter(|a: &VrfTreeEntry, b: &VrfTreeEntry| a.vni().cmp(&b.vni()))
+ .into(),
+ DataTableColumn::new(tr!("Zone"))
+ .get_property(|item: &VrfTreeEntry| match item {
+ VrfTreeEntry::Remote(remote) => remote.zone.as_str(),
+ _ => "",
+ })
+ .into(),
+ DataTableColumn::new(tr!("Remote"))
+ .get_property(|item: &VrfTreeEntry| match item {
+ VrfTreeEntry::Remote(remote) => remote.remote.as_str(),
+ _ => "",
+ })
+ .into(),
+ ])
+ }
+}
+
+impl Component for VrfTreeComponent {
+ type Properties = VrfTree;
+ type Message = VrfTreeMsg;
+
+ fn create(ctx: &Context<Self>) -> Self {
+ let store = TreeStore::new().view_root(false);
+
+ let data = zones_to_vrf_view(
+ &ctx.props().controllers,
+ &ctx.props().zones,
+ &ctx.props().vnets,
+ );
+
+ store.set_data(data);
+ store.set_sorter(default_sorter);
+
+ let selection =
+ Selection::new().on_select(ctx.link().callback(|_| Self::Message::SelectionChange));
+
+ Self { store, selection }
+ }
+
+ fn view(&self, _ctx: &Context<Self>) -> Html {
+ let columns = Self::columns(self.store.clone());
+
+ let table = DataTable::new(columns, self.store.clone())
+ .striped(false)
+ .selection(self.selection.clone())
+ .row_render_callback(|args: &mut DataTableRowRenderArgs<VrfTreeEntry>| {
+ if let VrfTreeEntry::Vrf(_) = args.record() {
+ args.add_class("pwt-bg-color-surface");
+ }
+ })
+ .class(css::FlexFit);
+
+ Column::new()
+ .class(pwt::css::FlexFit)
+ .with_child(table)
+ .into()
+ }
+
+ fn changed(&mut self, ctx: &Context<Self>, old_props: &Self::Properties) -> bool {
+ if !Rc::ptr_eq(&ctx.props().zones, &old_props.zones)
+ || !Rc::ptr_eq(&ctx.props().vnets, &old_props.vnets)
+ || !Rc::ptr_eq(&ctx.props().controllers, &old_props.controllers)
+ {
+ let data = zones_to_vrf_view(
+ &ctx.props().controllers,
+ &ctx.props().zones,
+ &ctx.props().vnets,
+ );
+
+ self.store.set_data(data);
+ self.store.set_sorter(default_sorter);
+
+ return true;
+ }
+
+ false
+ }
+}
diff --git a/ui/src/sdn/mod.rs b/ui/src/sdn/mod.rs
new file mode 100644
index 0000000..ef2eab9
--- /dev/null
+++ b/ui/src/sdn/mod.rs
@@ -0,0 +1 @@
+pub mod evpn;
--
2.47.2
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
next prev parent reply other threads:[~2025-08-22 13:50 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-22 13:49 [pdm-devel] [RFC network/proxmox{, -backup, -api-types, -yew-comp, -datacenter-manager} v2 00/32] Add initial SDN / EVPN integration Stefan Hanreich
2025-08-22 13:49 ` [pdm-devel] [PATCH proxmox v2 1/2] schema: use i64 for minimum / maximum / default integer values Stefan Hanreich
2025-08-22 13:49 ` [pdm-devel] [PATCH proxmox v2 2/2] pbs-api-types: fix values for integer schemas Stefan Hanreich
2025-08-22 13:49 ` [pdm-devel] [PATCH proxmox-backup v2 1/1] api: change integer schema parameters to i64 Stefan Hanreich
2025-08-22 13:49 ` [pdm-devel] [PATCH pve-network v2 1/6] sdn: api: return null for rollback / lock endpoints Stefan Hanreich
2025-08-22 13:49 ` [pdm-devel] [PATCH pve-network v2 2/6] controllers: fix maximum value for ASN Stefan Hanreich
2025-08-22 13:49 ` [pdm-devel] [PATCH pve-network v2 3/6] api: add state standard option Stefan Hanreich
2025-08-22 13:49 ` [pdm-devel] [PATCH pve-network v2 4/6] api: controllers: update schema of endpoints Stefan Hanreich
2025-08-22 13:49 ` [pdm-devel] [PATCH pve-network v2 5/6] api: vnets: " Stefan Hanreich
2025-08-22 13:49 ` [pdm-devel] [PATCH pve-network v2 6/6] api: zones: " Stefan Hanreich
2025-08-22 13:49 ` [pdm-devel] [PATCH proxmox-api-types v2 1/7] add QemuMigratePreconditionsNotAllowedNodesBlockingHaResources struct Stefan Hanreich
2025-08-22 13:49 ` [pdm-devel] [PATCH proxmox-api-types v2 2/7] sdn: add list/create zone endpoints Stefan Hanreich
2025-08-22 13:49 ` [pdm-devel] [PATCH proxmox-api-types v2 3/7] sdn: add list/create vnet endpoints Stefan Hanreich
2025-08-22 13:49 ` [pdm-devel] [PATCH proxmox-api-types v2 4/7] sdn: add list/create controller endpoints Stefan Hanreich
2025-08-22 13:49 ` [pdm-devel] [PATCH proxmox-api-types v2 5/7] sdn: add sdn configuration locking endpoints Stefan Hanreich
2025-08-22 13:49 ` [pdm-devel] [PATCH proxmox-api-types v2 6/7] tasks: add helper for querying successfully finished tasks Stefan Hanreich
2025-08-22 13:49 ` [pdm-devel] [PATCH proxmox-api-types v2 7/7] sdn: add helpers for pending values Stefan Hanreich
2025-08-22 13:49 ` [pdm-devel] [PATCH proxmox-yew-comp v2 1/1] sdn: add descriptions for sdn tasks Stefan Hanreich
2025-08-26 13:22 ` Dominik Csapak
2025-08-26 14:06 ` Stefan Hanreich
2025-08-22 13:49 ` [pdm-devel] [PATCH proxmox-datacenter-manager v2 01/15] server: add locked sdn client helpers Stefan Hanreich
2025-08-22 13:49 ` [pdm-devel] [PATCH proxmox-datacenter-manager v2 02/15] api: sdn: add list_zones endpoint Stefan Hanreich
2025-08-22 13:49 ` [pdm-devel] [PATCH proxmox-datacenter-manager v2 03/15] api: sdn: add create_zone endpoint Stefan Hanreich
2025-08-22 13:49 ` [pdm-devel] [PATCH proxmox-datacenter-manager v2 04/15] api: sdn: add list_vnets endpoint Stefan Hanreich
2025-08-22 13:49 ` [pdm-devel] [PATCH proxmox-datacenter-manager v2 05/15] api: sdn: add create_vnet endpoint Stefan Hanreich
2025-08-22 13:49 ` [pdm-devel] [PATCH proxmox-datacenter-manager v2 06/15] api: sdn: add list_controllers endpoint Stefan Hanreich
2025-08-22 13:49 ` [pdm-devel] [PATCH proxmox-datacenter-manager v2 07/15] ui: sdn: add EvpnRouteTarget type Stefan Hanreich
2025-08-22 13:49 ` [pdm-devel] [PATCH proxmox-datacenter-manager v2 08/15] ui: sdn: add vnet icon Stefan Hanreich
2025-08-22 13:49 ` [pdm-devel] [PATCH proxmox-datacenter-manager v2 09/15] ui: sdn: add remote tree component Stefan Hanreich
2025-08-22 13:49 ` Stefan Hanreich [this message]
2025-08-22 13:49 ` [pdm-devel] [PATCH proxmox-datacenter-manager v2 11/15] ui: sdn: add AddVnetWindow component Stefan Hanreich
2025-08-22 13:49 ` [pdm-devel] [PATCH proxmox-datacenter-manager v2 12/15] ui: sdn: add AddZoneWindow component Stefan Hanreich
2025-08-22 13:49 ` [pdm-devel] [PATCH proxmox-datacenter-manager v2 13/15] ui: sdn: add EvpnPanel Stefan Hanreich
2025-08-22 13:49 ` [pdm-devel] [PATCH proxmox-datacenter-manager v2 14/15] ui: sdn: add EvpnPanel to main menu Stefan Hanreich
2025-08-22 13:49 ` [pdm-devel] [PATCH proxmox-datacenter-manager v2 15/15] pve: sdn: add descriptions for sdn tasks Stefan Hanreich
2025-08-26 12:22 ` [pdm-devel] [RFC network/proxmox{, -backup, -api-types, -yew-comp, -datacenter-manager} v2 00/32] Add initial SDN / EVPN integration Gabriel Goller
2025-08-26 14:06 ` Stefan Hanreich
2025-08-26 14:12 ` Dominik Csapak
2025-08-26 14:13 ` Stefan Hanreich
2025-08-26 14:24 ` Dominik Csapak
2025-08-26 14:25 ` Stefan Hanreich
2025-08-27 11:35 ` [pdm-devel] superseded: " Stefan Hanreich
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=20250822134942.380480-28-s.hanreich@proxmox.com \
--to=s.hanreich@proxmox.com \
--cc=pdm-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