[PATCH pve-network v5 31/46] bgp controller: allow configuring custom route maps

Stefan Hanreich
2026-05-05T15:39:10Z

Allows specifying custom route maps, as created in our SDN stack, to
the BGP controller. This can e.g. be used for only selectively
exporting routes from the default routing table via BGP instead of
having to export the whole routing table.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
src/PVE/Network/SDN/Controllers/BgpPlugin.pm | 30 +++++++++++++++++---
1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/src/PVE/Network/SDN/Controllers/BgpPlugin.pm b/src/PVE/Network/SDN/Controllers/BgpPlugin.pm
index d54c9ec..d68db40 100644
--- a/src/PVE/Network/SDN/Controllers/BgpPlugin.pm
+++ b/src/PVE/Network/SDN/Controllers/BgpPlugin.pm
@@ -52,6 +52,8 @@ sub options {
'ebgp' => { optional => 1 },
'ebgp-multihop' => { optional => 1 },
'loopback' => { optional => 1 },
+ 'route-map-in' => { optional => 1 },
+ 'route-map-out' => { optional => 1 },
};
}

@@ -111,12 +113,19 @@ sub generate_frr_config {
my $mask = Net::IP::ip_is_ipv6($ifaceip) ? "128" : "32";
my $af_key = "${ipversion}_unicast";

+ my $bgp_neighbor = {
+ name => "BGP",
+ soft_reconfiguration_inbound => 1,
+ };
+
+ $bgp_neighbor->{route_map_in} = $plugin_config->{'route-map-in'}
+ if $plugin_config->{'route-map-in'};
+ $bgp_neighbor->{route_map_out} = $plugin_config->{'route-map-out'}
+ if $plugin_config->{'route-map-out'};
+
$bgp_router->{address_families}->{$af_key} //= {
networks => [],
- neighbors => [{
- name => "BGP",
- soft_reconfiguration_inbound => 1,
- }],
+ neighbors => [$bgp_neighbor],
};

push @{ $bgp_router->{address_families}->{$af_key}->{networks} }, "$ifaceip/$mask"
@@ -181,6 +190,19 @@ sub on_update_hook {
$controllernb++;
die "only 1 bgp controller can be defined" if $controllernb > 1;
}
+
+ my $controller = $controller_cfg->{ids}->{$controllerid};
+ my $route_map_config = PVE::Network::SDN::RouteMaps::config(0);
+
+ if ($controller->{'route-map-in'}) {
+ my $entries = $route_map_config->list_route_map($controller->{'route-map-in'});
+ die "route map $controller->{'route-map-in'} does not exist!" if !$entries->%*;
+ }
+
+ if ($controller->{'route-map-out'}) {
+ my $entries = $route_map_config->list_route_map($controller->{'route-map-out'});
+ die "route map $controller->{'route-map-out'} does not exist!" if !$entries->%*;
+ }
}

1;
--
2.47.3