From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 138FE1FF13F for ; Thu, 26 Mar 2026 14:49:15 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 6D21313BB0; Thu, 26 Mar 2026 14:49:37 +0100 (CET) Message-ID: <0aa01d27-a09f-4ef4-8cd3-347dc12ad8cd@proxmox.com> Date: Thu, 26 Mar 2026 14:49:33 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH proxmox-ve-rs 7/9] ve-config: add route map section config To: pve-devel@lists.proxmox.com References: <20260325094142.174364-1-s.hanreich@proxmox.com> <20260325094142.174364-10-s.hanreich@proxmox.com> <5iohvs5qsusyt3bfk7hwmkrxcus7v3eiafqitfp7peil3lccug@cvrs5d4xlbjf> Content-Language: en-US From: Stefan Hanreich In-Reply-To: <5iohvs5qsusyt3bfk7hwmkrxcus7v3eiafqitfp7peil3lccug@cvrs5d4xlbjf> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.714 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 SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: ICDZNORP33HIUZUFRQZ6Q6ASP5UQZ4GD X-Message-ID-Hash: ICDZNORP33HIUZUFRQZ6Q6ASP5UQZ4GD X-MailFrom: s.hanreich@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: ah, forgot to remove this again during development - fixed! 3/25/26 3:35 PM, Gabriel Goller wrote: > On 25.03.2026 10:41, Stefan Hanreich wrote: >> Those types represent FRR route maps inside a section config format. >> For an example of the exact format and its FRR representation see the >> module-level documentation. >> >> One section config entry maps to one route map entry. A route map >> consists of one or more route map entries inside the section config. >> The ID of a section encodes the name of the route map as well as the >> order # of the entry. >> >> The route map module exports specific types for the API that handle >> converting the section config ID, because currently it is only >> possible to deserialize section config IDs to Strings. To avoid >> having to implement the parsing logic along every step of the stack >> (Perl backend, UI), use specific API types in the public API that >> handle parsing the section ID into route map name and order. >> >> Contrary to most SDN entities, route maps IDs can be 32 characters >> long instead of 8 and support underscores as well as hyphens. This is >> because the restriction of having to generate network interface names >> does not apply to FRR entities, so we can be more lenient with IDs >> here, allowing users to specify more descriptive names. >> >> Signed-off-by: Stefan Hanreich >> --- >> proxmox-ve-config/debian/control | 2 + >> proxmox-ve-config/src/sdn/mod.rs | 1 + >> proxmox-ve-config/src/sdn/route_map.rs | 491 +++++++++++++++++++++++++ >> 3 files changed, 494 insertions(+) >> create mode 100644 proxmox-ve-config/src/sdn/route_map.rs >> >> diff --git a/proxmox-ve-config/debian/control b/proxmox-ve-config/debian/control >> index 440cf73..5206340 100644 >> --- a/proxmox-ve-config/debian/control >> +++ b/proxmox-ve-config/debian/control >> @@ -24,6 +24,7 @@ Build-Depends-Arch: cargo:native , >> librust-serde-1+default-dev , >> librust-serde-1+derive-dev , >> librust-serde-json-1+default-dev , >> + librust-serde-with-3+default-dev , >> librust-thiserror-2+default-dev , >> librust-tracing-0.1+default-dev (>= 0.1.37-~~) >> Maintainer: Proxmox Support Team >> @@ -55,6 +56,7 @@ Depends: >> librust-serde-1+default-dev, >> librust-serde-1+derive-dev, >> librust-serde-json-1+default-dev, >> + librust-serde-with-3+default-dev, >> librust-thiserror-2+default-dev, >> librust-tracing-0.1+default-dev (>= 0.1.37-~~) >> Suggests: > > serde-with is not import and used AFAICS. > >> diff --git a/proxmox-ve-config/src/sdn/mod.rs b/proxmox-ve-config/src/sdn/mod.rs >> index 344c02c..24069ad 100644 >> --- a/proxmox-ve-config/src/sdn/mod.rs >> +++ b/proxmox-ve-config/src/sdn/mod.rs >> @@ -2,6 +2,7 @@ pub mod config; >> pub mod fabric; >> pub mod ipam; >> pub mod prefix_list; >> +pub mod route_map; >> >> use std::{error::Error, fmt::Display, str::FromStr}; >> >> diff --git a/proxmox-ve-config/src/sdn/route_map.rs b/proxmox-ve-config/src/sdn/route_map.rs >> new file mode 100644 >> index 0000000..3f4da56 >> --- /dev/null >> +++ b/proxmox-ve-config/src/sdn/route_map.rs >> @@ -0,0 +1,491 @@ >> +//! Section config types for FRR Route Maps. >> +//! >> +//! This module contains the API types required for representing FRR Route Maps as section config. >> +//! Each entry in the section config maps to a Route Map entry, *not* a route map as a whole, the >> +//! order of the entry is encoded in the ID of the Route Map. >> +//! >> +//! Route maps in FRR consists of at least one entry, which are ordered by their given sequence >> +//! number / order. Each entry has a default matching policy, which is applied if the matching >> +//! conditions of the entry are met. >> +//! >> +//! An example for a simple FRR Route Map entry loooks like this: >> +//! >> +//! ```text >> +//! route-map test permit 10 >> +//! match ip next-hop address 192.0.2.1 >> +//! set local-preference 200 >> +//! ``` >> +//! >> +//! The corresponding representation as a section config entry looks like this: >> +//! >> +//! ```text >> +//! route-map-entry: test_10 >> +//! action permit >> +//! match key=ip-next-hop-address,value=192.0.2.1 >> +//! set key=local-preference,value=200 >> +//! ``` >> +//! >> +//! Match and Set Actions are encoded as an array with a property string that has a key and an >> +//! optional value paramter, because some options do not require an additional value. >> +//! >> +//! This abstraction currently supports Match and Set actions, but not call actions and exit >> +//! actions. >> + >> +use core::net::IpAddr; > > We usually always use imports from std:: (also in libraries). Note that this > series introduces core:: imports in a few ve-rs patches. > >> + >> +use anyhow::format_err; >> +use const_format::concatcp; >> + >> +use proxmox_network_types::ip_address::api_types::{Ipv4Addr, Ipv6Addr}; >> +use proxmox_sdn_types::{ >> + bgp::{EvpnRouteType, SetMetricValue, SetTagValue}, >> + IntegerWithSign, Vni, >> [snip]