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 639DA1FF13B for ; Wed, 25 Mar 2026 15:36:06 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D270E1CCD0; Wed, 25 Mar 2026 15:36:27 +0100 (CET) Date: Wed, 25 Mar 2026 15:35:52 +0100 From: Gabriel Goller To: Stefan Hanreich Subject: Re: [PATCH proxmox-ve-rs 7/9] ve-config: add route map section config Message-ID: <5iohvs5qsusyt3bfk7hwmkrxcus7v3eiafqitfp7peil3lccug@cvrs5d4xlbjf> Mail-Followup-To: Stefan Hanreich , pve-devel@lists.proxmox.com References: <20260325094142.174364-1-s.hanreich@proxmox.com> <20260325094142.174364-10-s.hanreich@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20260325094142.174364-10-s.hanreich@proxmox.com> User-Agent: NeoMutt/20241002-35-39f9a6 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1774449305350 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.023 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: TQKM6LHAV6W3TF5NUR73ZFUKEBW4XJYO X-Message-ID-Hash: TQKM6LHAV6W3TF5NUR73ZFUKEBW4XJYO X-MailFrom: g.goller@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 CC: pve-devel@lists.proxmox.com X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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]