From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 73B871FF15C for ; Fri, 5 Sep 2025 13:45:11 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 442B81333A; Fri, 5 Sep 2025 13:45:13 +0200 (CEST) From: Gabriel Goller To: pve-devel@lists.proxmox.com Date: Fri, 5 Sep 2025 13:44:58 +0200 Message-ID: <20250905114504.195110-4-g.goller@proxmox.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250905114504.195110-1-g.goller@proxmox.com> References: <20250905114504.195110-1-g.goller@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1757072690536 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.005 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [evpn.rs, mod.rs] Subject: [pve-devel] [PATCH proxmox-ve-rs 3/3] frr: add deserialization types for EVPN X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" Add deserialization types for the `show bgp l2vpn evpn route vni ` command. This command shows all the L2VPN (EVPN) routes that are distributed over BGP. Signed-off-by: Gabriel Goller --- proxmox-frr/Cargo.toml | 1 + proxmox-frr/debian/control | 2 + proxmox-frr/src/de/evpn.rs | 165 +++++++++++++++++++++++++++++++++++++ proxmox-frr/src/de/mod.rs | 1 + 4 files changed, 169 insertions(+) create mode 100644 proxmox-frr/src/de/evpn.rs diff --git a/proxmox-frr/Cargo.toml b/proxmox-frr/Cargo.toml index 8ada547301e8..1b241a03e60d 100644 --- a/proxmox-frr/Cargo.toml +++ b/proxmox-frr/Cargo.toml @@ -14,6 +14,7 @@ thiserror = { workspace = true } anyhow = "1" tracing = "0.1" serde = { workspace = true, features = [ "derive" ] } +serde_repr = "0.1" proxmox-network-types = { workspace = true } proxmox-sdn-types = { workspace = true } diff --git a/proxmox-frr/debian/control b/proxmox-frr/debian/control index bce0c709b13e..3a73732de962 100644 --- a/proxmox-frr/debian/control +++ b/proxmox-frr/debian/control @@ -11,6 +11,7 @@ Build-Depends-Arch: cargo:native , librust-proxmox-sdn-types-0.1+default-dev , librust-serde-1+default-dev , librust-serde-1+derive-dev , + librust-serde-repr-0.1+default-dev , librust-thiserror-2+default-dev , librust-tracing-0.1+default-dev Maintainer: Proxmox Support Team @@ -31,6 +32,7 @@ Depends: librust-proxmox-sdn-types-0.1+default-dev, librust-serde-1+default-dev, librust-serde-1+derive-dev, + librust-serde-repr-0.1+default-dev, librust-thiserror-2+default-dev, librust-tracing-0.1+default-dev Provides: diff --git a/proxmox-frr/src/de/evpn.rs b/proxmox-frr/src/de/evpn.rs new file mode 100644 index 000000000000..bbc44c9a9522 --- /dev/null +++ b/proxmox-frr/src/de/evpn.rs @@ -0,0 +1,165 @@ +use std::{collections::HashMap, net::IpAddr}; + +use proxmox_network_types::mac_address::MacAddress; +use serde::Deserialize; +use serde_repr::Deserialize_repr; + +/// All EVPN routes +#[derive(Debug, Default, Deserialize)] +pub struct Routes(pub HashMap); + +/// The evpn routes a stored in a hashtable, which has a numPrefix and numPath key at +/// the end which stores the number of paths and prefixes. These two keys have a i32 +/// value, while the other entries have a normal [`Route`] entry. +#[derive(Debug, Deserialize)] +#[serde(untagged)] +pub enum Entry { + /// Route + Route(Route), + // This stores the numPrefix and numPath properties (which are not used) (this is + // a workaround) + Metadata(i32), +} + +/// An EVPN route +#[derive(Debug, Deserialize)] +pub struct Route { + /// The full EVPN prefix + pub prefix: String, + /// Length of the prefix + #[serde(rename = "prefixLen")] + pub prefix_len: i32, + /// Paths to the EVPN route + pub paths: Vec>, +} + +/// An EVPN Route Path +#[derive(Debug, Deserialize)] +pub struct Path { + /// Is this path valid + pub valid: bool, + /// Is this the best path + pub bestpath: bool, + /// Reason for selection (longer explanatory string) + #[serde(rename = "selectionReason")] + pub selection_reason: String, + /// From where the EVPN Route path comes + #[serde(rename = "pathFrom")] + pub path_from: PathFrom, + /// EVPN route type + #[serde(rename = "routeType")] + pub route_type: RouteType, + /// Ethernet tag + #[serde(rename = "ethTag")] + pub ethernet_tag: i32, + /// Mac Address length + #[serde(rename = "macLen")] + pub mac_length: Option, + /// Mac Address + pub mac: Option, + /// IP Address lenght + #[serde(rename = "ipLen")] + pub ip_length: Option, + /// IP Address + pub ip: Option, + /// Local Preference of the path + #[serde(rename = "locPrf")] + pub local_preference: Option, + /// Weight of the path + pub weight: i32, + /// PeerId, can be either IP or unspecified + #[serde(rename = "peerId")] + pub peer_id: PeerId, + /// AS path of the EVPN route + #[serde(rename = "path")] + pub as_path: String, + /// Origin of the route + pub origin: Origin, + /// Extended BGP Community + #[serde(rename = "extendedCommunity")] + pub extended_community: ExtendedCommunity, + /// Nexthops + pub nexthops: Vec, +} + +/// PeerId of the EVPN route path +#[derive(Debug, Deserialize)] +#[serde(untagged)] +pub enum PeerId { + /// IP Address + IpAddr(IpAddr), + /// Not specified + Unspec(String), +} + +/// Nexthop of a EVPN path +#[derive(Debug, Deserialize)] +pub struct Nexthop { + /// IP of the nexthop + pub ip: IpAddr, + /// Hostname of the nexthop + pub hostname: String, + /// Afi of the ip + pub afi: Option, + /// Used + pub used: bool, +} + +/// Protocol AFI for a EVPN nexthop +#[derive(Debug, Deserialize)] +pub enum Protocol { + /// IPV4 + #[serde(rename = "ipv4")] + IPv4, + /// IPV6 + #[serde(rename = "ipv6")] + IPv6, +} + +/// Extended Community for EVPN route +#[derive(Debug, Deserialize)] +pub struct ExtendedCommunity { + /// String with all the BGP ExtendedCommunities (this also contains the + /// RouteTarget) + pub string: String, +} + +/// Origin of the EVPN route +#[derive(Debug, Deserialize)] +pub enum Origin { + /// Interior Gateway Protocol + #[serde(rename = "IGP")] + Igp, + #[serde(rename = "EGP")] + /// Exterior Gateway Protocol + Egp, + #[serde(rename = "incomplete")] + /// Incomplete + Incomplete, +} + +/// EVPN RouteType +#[derive(Debug, Deserialize_repr)] +#[repr(u8)] +pub enum RouteType { + /// EthernetAutoDiscovery + EthernetAutoDiscovery = 1, + /// MacIpAdvertisement + MacIpAdvertisement = 2, + /// InclusiveMulticastEthernetTag + InclusiveMulticastEthernetTag = 3, + /// EthernetSegment + EthernetSegment = 4, + /// IpPrefix + IpPrefix = 5, +} + +/// From where the EVPN route path comes +#[derive(Debug, Deserialize)] +#[serde(rename_all = "lowercase")] +pub enum PathFrom { + /// Internal + Internal, + /// External + External, +} diff --git a/proxmox-frr/src/de/mod.rs b/proxmox-frr/src/de/mod.rs index 2771a1c36661..c0f262e410ee 100644 --- a/proxmox-frr/src/de/mod.rs +++ b/proxmox-frr/src/de/mod.rs @@ -3,6 +3,7 @@ use std::{collections::HashMap, net::IpAddr}; use proxmox_network_types::ip_address::Cidr; use serde::{Deserialize, Serialize}; +pub mod evpn; pub mod openfabric; pub mod ospf; -- 2.47.2 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel