all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Stefan Hanreich <s.hanreich@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH proxmox-ve-rs 02/16] frr: add support for extcommunity lists
Date: Tue, 14 Apr 2026 18:32:59 +0200	[thread overview]
Message-ID: <20260414163315.419384-3-s.hanreich@proxmox.com> (raw)
In-Reply-To: <20260414163315.419384-1-s.hanreich@proxmox.com>

Extended Communities are used for encoding Route Targets in the EVPN
AF, among other things. FRR provides a mechanism to match based on
them via the extcommunity lists. Implement support for creating them,
so they can be used by the SDN stack for matching extended communities
in route maps. Initially, this will be used to filter outgoing routes
in EVPN controllers, but in the future it is planned to expose
creating extcommunity lists via our API / UI as well.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
 proxmox-frr/src/ser/bgp.rs       | 81 +++++++++++++++++++++++++++++++-
 proxmox-frr/src/ser/mod.rs       | 23 ++++++++-
 proxmox-frr/src/ser/route_map.rs | 43 +++++++++++++----
 3 files changed, 134 insertions(+), 13 deletions(-)

diff --git a/proxmox-frr/src/ser/bgp.rs b/proxmox-frr/src/ser/bgp.rs
index 79bc920..0bf4a1d 100644
--- a/proxmox-frr/src/ser/bgp.rs
+++ b/proxmox-frr/src/ser/bgp.rs
@@ -1,10 +1,11 @@
+use std::fmt::Display;
 use std::net::{IpAddr, Ipv4Addr};
 
 use proxmox_network_types::ip_address::{Ipv4Cidr, Ipv6Cidr};
 use serde::{Deserialize, Serialize};
 
 use crate::ser::route_map::RouteMapName;
-use crate::ser::{FrrWord, InterfaceName, IpRoute};
+use crate::ser::{AccessAction, FrrWord, InterfaceName, IpRoute};
 
 #[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
 pub struct BgpRouterName {
@@ -195,3 +196,81 @@ pub struct BgpRouter {
     #[serde(default)]
     pub custom_frr_config: Vec<String>,
 }
+
+#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
+pub struct CommunityListName(String);
+
+impl Display for CommunityListName {
+    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
+        Display::fmt(&self.0, f)
+    }
+}
+
+impl CommunityListName {
+    pub fn new(name: String) -> Self {
+        Self(name)
+    }
+}
+
+#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
+pub struct ExtCommunityRouteTarget {
+    asn: u16,
+    value: u32,
+}
+
+impl std::str::FromStr for ExtCommunityRouteTarget {
+    type Err = anyhow::Error;
+
+    fn from_str(value: &str) -> Result<Self, Self::Err> {
+        if let Some((asn, value)) = value.split_once(':') {
+            return Ok(Self {
+                asn: asn.parse()?,
+                value: value.parse()?,
+            });
+        }
+
+        anyhow::bail!("can not parse route target: {value}")
+    }
+}
+
+impl Display for ExtCommunityRouteTarget {
+    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
+        write!(f, "{}:{}", self.asn, self.value)
+    }
+}
+
+proxmox_serde::forward_serialize_to_display!(ExtCommunityRouteTarget);
+proxmox_serde::forward_deserialize_to_from_str!(ExtCommunityRouteTarget);
+
+#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
+#[serde(tag = "type", content = "value")]
+pub enum StandardExtCommunityListMatch {
+    #[serde(rename = "rt")]
+    RouteTarget(ExtCommunityRouteTarget),
+}
+
+#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
+#[serde(tag = "type", content = "value")]
+pub enum ExtendedExtCommunityListMatch {
+    #[serde(rename = "rt")]
+    RouteTarget(String),
+}
+
+#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
+pub struct ExtendedExtCommunityListEntry {
+    pub action: AccessAction,
+    pub match_entry: ExtendedExtCommunityListMatch,
+}
+
+#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
+pub struct StandardExtCommunityListEntry {
+    pub action: AccessAction,
+    pub match_entry: StandardExtCommunityListMatch,
+}
+
+#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
+#[serde(tag = "type", content = "entries", rename_all = "kebab-case")]
+pub enum ExtCommunityList {
+    Standard(Vec<StandardExtCommunityListEntry>),
+    Extended(Vec<ExtendedExtCommunityListEntry>),
+}
diff --git a/proxmox-frr/src/ser/mod.rs b/proxmox-frr/src/ser/mod.rs
index 7bb4836..2ff2011 100644
--- a/proxmox-frr/src/ser/mod.rs
+++ b/proxmox-frr/src/ser/mod.rs
@@ -9,8 +9,11 @@ use std::collections::BTreeMap;
 use std::net::IpAddr;
 use std::str::FromStr;
 
-use crate::ser::route_map::{
-    AccessListName, AccessListRule, PrefixListName, PrefixListRule, RouteMapEntry, RouteMapName,
+use crate::ser::{
+    bgp::{CommunityListName, ExtCommunityList},
+    route_map::{
+        AccessListName, AccessListRule, PrefixListName, PrefixListRule, RouteMapEntry, RouteMapName,
+    },
 };
 
 use proxmox_network_types::{
@@ -21,6 +24,19 @@ use proxmox_serde::forward_deserialize_to_from_str;
 use serde::{Deserialize, Serialize};
 use thiserror::Error;
 
+/// The action for a [`AccessListRule`] or [`ExtCommunityList`].
+///
+/// The default is Permit. Deny can be used to create a NOT match (e.g. match all routes that are
+/// NOT in 10.10.10.0/24 using `ip access-list TEST deny 10.10.10.0/24`).
+#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
+#[serde(rename_all = "kebab-case")]
+pub enum AccessAction {
+    Permit,
+    Deny,
+}
+
+proxmox_serde::forward_display_to_serialize!(AccessAction);
+
 #[derive(Error, Debug)]
 pub enum FrrWordError {
     #[error("word is empty")]
@@ -255,4 +271,7 @@ pub struct BgpFrrConfig {
 
     #[serde(default)]
     pub vrfs: BTreeMap<InterfaceName, bgp::Vrf>,
+
+    #[serde(default)]
+    pub ext_community_lists: BTreeMap<CommunityListName, ExtCommunityList>,
 }
diff --git a/proxmox-frr/src/ser/route_map.rs b/proxmox-frr/src/ser/route_map.rs
index 54d88e7..958a1c8 100644
--- a/proxmox-frr/src/ser/route_map.rs
+++ b/proxmox-frr/src/ser/route_map.rs
@@ -7,16 +7,8 @@ use proxmox_sdn_types::{
 };
 use serde::{Deserialize, Serialize};
 
-/// The action for a [`AccessListRule`].
-///
-/// The default is Permit. Deny can be used to create a NOT match (e.g. match all routes that are
-/// NOT in 10.10.10.0/24 using `ip access-list TEST deny 10.10.10.0/24`).
-#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
-#[serde(rename_all = "kebab-case")]
-pub enum AccessAction {
-    Permit,
-    Deny,
-}
+use crate::ser::bgp::CommunityListName;
+pub use crate::ser::AccessAction;
 
 /// A single [`AccessList`] rule.
 ///
@@ -66,6 +58,35 @@ pub struct PrefixListRule {
     pub is_ipv6: bool,
 }
 
+#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Deserialize, Serialize)]
+#[serde(rename_all = "kebab-case")]
+pub enum CommunityMatchMode {
+    ExactMatch,
+    Any,
+}
+
+proxmox_serde::forward_display_to_serialize!(CommunityMatchMode);
+
+#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Deserialize)]
+pub struct ExtendedCommunityMatch {
+    pub name: CommunityListName,
+    pub mode: Option<CommunityMatchMode>,
+}
+
+impl std::fmt::Display for ExtendedCommunityMatch {
+    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        let mode = self
+            .mode
+            .as_ref()
+            .map(|mode| format!(" {mode}"))
+            .unwrap_or_else(|| String::new());
+
+        write!(f, "{}{mode}", self.name)
+    }
+}
+
+proxmox_serde::forward_serialize_to_display!(ExtendedCommunityMatch);
+
 /// A match statement inside a route-map.
 ///
 /// A route-map has one or more match statements which decide on which routes the route-map will
@@ -102,6 +123,8 @@ pub enum RouteMapMatch {
     Peer(String),
     #[serde(rename = "tag")]
     Tag(SetTagValue),
+    #[serde(rename = "extcommunity")]
+    ExtendedCommunity(ExtendedCommunityMatch),
 }
 
 /// Defines the Action a route-map takes when it matches on a route.
-- 
2.47.3





  parent reply	other threads:[~2026-04-14 16:34 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-14 16:32 [RFC docs/manager/network/proxmox-ve-rs 00/16] Extend EVPN controller functionality Stefan Hanreich
2026-04-14 16:32 ` [PATCH proxmox-ve-rs 01/16] frr: add local-as setting Stefan Hanreich
2026-04-14 16:32 ` Stefan Hanreich [this message]
2026-04-14 16:33 ` [PATCH proxmox-ve-rs 03/16] frr-templates: render " Stefan Hanreich
2026-04-14 16:33 ` [PATCH proxmox-ve-rs 04/16] frr-templates: render community lists in templates Stefan Hanreich
2026-04-14 16:33 ` [PATCH pve-network 05/16] evpn controller: make nodes configurable Stefan Hanreich
2026-04-14 16:33 ` [PATCH pve-network 06/16] evpn controller: allow multiple evpn controllers in a cluster Stefan Hanreich
2026-04-14 16:33 ` [PATCH pve-network 07/16] evpn controller: add bgp-mode setting Stefan Hanreich
2026-04-14 16:33 ` [PATCH pve-network 08/16] evpn zone: add secondary-controllers and rt filtering Stefan Hanreich
2026-04-14 16:33 ` [PATCH pve-network 09/16] evpn controller: add ebgp-multihop setting Stefan Hanreich
2026-04-14 16:33 ` [PATCH pve-network 10/16] test: evpn: add test for ibgp + ebgp evpn controller Stefan Hanreich
2026-04-14 16:33 ` [PATCH pve-network 11/16] test: evpn: add legacy test Stefan Hanreich
2026-04-14 16:33 ` [PATCH pve-network 12/16] tests: evpn: force ibgp over ebgp bgp controller with ebgp wan session Stefan Hanreich
2026-04-14 16:33 ` [PATCH pve-network 13/16] tests: test route filtering mechanism with multiple zones/controllers Stefan Hanreich
2026-04-14 16:33 ` [PATCH pve-manager 14/16] sdn: evpn: zone: controller: add new advanced fields Stefan Hanreich
2026-04-14 16:33 ` [PATCH pve-docs 15/16] sdn: evpn: document new zone / controller options Stefan Hanreich
2026-04-14 16:33 ` [PATCH pve-docs 16/16] sdn: fix typo in bgp controller 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=20260414163315.419384-3-s.hanreich@proxmox.com \
    --to=s.hanreich@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