From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 7421A1FF0BC for ; Mon, 16 Nov 2026 17:15:34 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 99EB62197E; Mon, 16 Nov 2026 17:12:54 +0100 (CET) From: Gabriel Goller To: pve-devel@lists.proxmox.com Subject: [PATCH pve-network v3 22/32] sdn: evpn: allow static routes Date: Mon, 16 Nov 2026 17:11:42 +0100 Message-ID: <20261116161154.343743-23-g.goller@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261116161154.343743-1-g.goller@proxmox.com> References: <20261116161154.343743-1-g.goller@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1794845521355 X-SPAM-LEVEL: Spam detection results: 0 AWL -2.278 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_DBL_SPAM 5 Contains a spam URL listed in the Spamhaus DBL blocklist [sdn.pm] Message-ID-Hash: BDR2ING5KVNGRTPC2YMBUBNATAJY4R5R X-Message-ID-Hash: BDR2ING5KVNGRTPC2YMBUBNATAJY4R5R 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 X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Allow EVPN zones to reach networks through a configured gateway or interface, using the same route options as simple zones. Routes are installed in the zone VRF on each node where the zone is enabled, and can also use a next hop in another VRF. Configuring a route does not enable static-route redistribution into BGP. The unreachable default routes and exit-node behavior stay as they are, so adding static routes does not change how other traffic leaves the zone. Signed-off-by: Gabriel Goller --- src/PVE/API2/Network/SDN/Zones.pm | 2 +- src/PVE/Network/SDN.pm | 5 +- src/PVE/Network/SDN/Zones/EvpnPlugin.pm | 1 + src/test/run_test_static_routes.pl | 47 +++++++++++++++++-- .../expected_controller_config | 6 +++ .../zones/evpn/advertise_subnets/sdn_config | 8 +++- 6 files changed, 61 insertions(+), 8 deletions(-) diff --git a/src/PVE/API2/Network/SDN/Zones.pm b/src/PVE/API2/Network/SDN/Zones.pm index 8df1bf8527fd..25e0aed017dc 100644 --- a/src/PVE/API2/Network/SDN/Zones.pm +++ b/src/PVE/API2/Network/SDN/Zones.pm @@ -71,7 +71,7 @@ my $ZONE_PROPERTIES = { route => { type => 'array', optional => 1, - description => 'Static routes in the zone routing table. Simple zone only.', + description => 'Static routes in the zone routing table. Simple and EVPN zones only.', items => { type => 'string', format => 'pve-sdn-static-route', diff --git a/src/PVE/Network/SDN.pm b/src/PVE/Network/SDN.pm index 626fe7387f54..ea7372213394 100644 --- a/src/PVE/Network/SDN.pm +++ b/src/PVE/Network/SDN.pm @@ -132,8 +132,9 @@ sub running_config_has_frr { my $route_maps = $running_config->{'route-maps'}->{ids} // {}; my $prefix_lists = $running_config->{'prefix-lists'}->{ids} // {}; my $zones = $running_config->{zones}->{ids} // {}; - my $zone_routes = - grep { $_->{type} eq 'simple' && scalar(@{ $_->{route} // [] }) } values %$zones; + my $zone_routes = grep { + ($_->{type} eq 'simple' || $_->{type} eq 'evpn') && scalar(@{ $_->{route} // [] }) + } values %$zones; my $local_frr_config = PVE::Network::SDN::Frr::local_frr_config_exists(); diff --git a/src/PVE/Network/SDN/Zones/EvpnPlugin.pm b/src/PVE/Network/SDN/Zones/EvpnPlugin.pm index e5b8ea16446f..1933ce86f997 100644 --- a/src/PVE/Network/SDN/Zones/EvpnPlugin.pm +++ b/src/PVE/Network/SDN/Zones/EvpnPlugin.pm @@ -113,6 +113,7 @@ sub options { return { nodes => { optional => 1 }, 'vrf-vxlan' => { optional => 0 }, + route => { optional => 1 }, controller => { optional => 0 }, 'secondary-controllers' => { optional => 1 }, exitnodes => { optional => 1 }, diff --git a/src/test/run_test_static_routes.pl b/src/test/run_test_static_routes.pl index c6809fe4dc9c..8f3acc25d21f 100644 --- a/src/test/run_test_static_routes.pl +++ b/src/test/run_test_static_routes.pl @@ -85,7 +85,7 @@ subtest 'route API schema and Rust validation' => sub { 1, ); }; - like($@, qr/unexpected property 'route'/, 'routes are only supported on simple zones'); + like($@, qr/unexpected property 'route'/, 'routes are only supported on simple and evpn zones'); }; subtest 'repeatable config persistence' => sub { @@ -96,6 +96,39 @@ subtest 'repeatable config persistence' => sub { is_deeply($parsed->{ids}, $zones->{ids}, 'routes and node restrictions survive round trip'); }; +subtest 'EVPN routes reuse validation and persistence' => sub { + my $evpn = { + type => 'evpn', + controller => 'evpnctl', + 'vrf-vxlan' => 1000, + nodes => { localhost => 1 }, + route => $routes, + }; + my $plugin = PVE::Network::SDN::Zones::Plugin->lookup('evpn'); + for my $create (0, 1) { + my $params = dclone($evpn); + $params->{nodes} = 'localhost'; + my $opts = $plugin->check_config('overlay', $params, $create, 1); + is_deeply($opts->{route}, $routes, 'EVPN accepts the shared route property'); + } + + my $errors = {}; + PVE::JSONSchema::check_prop( + ['prefix=::/0,via=fe80::1'], + $plugin->get_property_schema('evpn', 'route'), + 'route', + $errors, + ); + ok(scalar(keys %$errors), 'EVPN uses the same Rust-backed validation'); + + my $config = dclone($zones); + $config->{ids}->{overlay} = $evpn; + my $raw = PVE::Network::SDN::Zones::Plugin->write_config('zones.cfg', $config); + my $parsed = PVE::Network::SDN::Zones::Plugin->parse_config('zones.cfg', $raw); + ok(!$parsed->{errors}, 'Simple and EVPN routes parse together'); + is_deeply($parsed->{ids}, $config->{ids}, 'both zone types preserve repeated routes'); +}; + subtest 'pending arrays compare by value' => sub { my $running = { zones => dclone($zones) }; my $configured = dclone($zones); @@ -134,9 +167,15 @@ $frr->mock( ); subtest 'route-only FRR detection' => sub { - ok(PVE::Network::SDN::running_config_has_frr(), 'routes without controllers require FRR'); - local $running->{zones} = { ids => { empty => { type => 'simple', route => [] } } }; - ok(!PVE::Network::SDN::running_config_has_frr(), 'empty route array does not require FRR'); + for my $type ('simple', 'evpn') { + local $running->{zones} = { ids => { zone1 => { type => $type, route => $routes } } }; + ok(PVE::Network::SDN::running_config_has_frr(), "$type routes require FRR"); + $running->{zones}->{ids}->{zone1}->{route} = []; + ok( + !PVE::Network::SDN::running_config_has_frr(), + "empty $type routes do not require FRR", + ); + } }; subtest 'zone routes reach FRR with local config' => sub { diff --git a/src/test/zones/evpn/advertise_subnets/expected_controller_config b/src/test/zones/evpn/advertise_subnets/expected_controller_config index 8ab18ef648fc..fd1ee333ba78 100644 --- a/src/test/zones/evpn/advertise_subnets/expected_controller_config +++ b/src/test/zones/evpn/advertise_subnets/expected_controller_config @@ -53,5 +53,11 @@ exit route-map MAP_VTEP_OUT permit 1 exit ! +ip route 0.0.0.0/0 10.0.0.2 vrf vrf_myzone +! +ip route 198.51.100.0/24 192.0.2.1 nexthop-vrf default vrf vrf_myzone +! +ipv6 route ::/0 fe80::2 myvnet vrf vrf_myzone +! line vty ! diff --git a/src/test/zones/evpn/advertise_subnets/sdn_config b/src/test/zones/evpn/advertise_subnets/sdn_config index 76f16a16af6a..aedcf40524a0 100644 --- a/src/test/zones/evpn/advertise_subnets/sdn_config +++ b/src/test/zones/evpn/advertise_subnets/sdn_config @@ -7,7 +7,13 @@ }, zones => { - ids => { myzone => { ipam => "pve", type => "evpn", controller => "evpnctl", 'vrf-vxlan' => 1000, 'mac' => 'A2:1D:CB:1A:C0:8B', 'advertise-subnets' => 1 } }, + ids => { myzone => { ipam => "pve", type => "evpn", controller => "evpnctl", 'vrf-vxlan' => 1000, 'mac' => 'A2:1D:CB:1A:C0:8B', 'advertise-subnets' => 1, + route => [ + 'prefix=0.0.0.0/0,via=10.0.0.2', + 'prefix=198.51.100.0/24,via=192.0.2.1,nexthop-vrf=default', + 'prefix=::/0,via=fe80::2,iface=myvnet', + ], + } }, }, controllers => { ids => { evpnctl => { type => "evpn", 'peers' => '192.168.0.1,192.168.0.2,192.168.0.3', asn => "65000" } }, -- 2.47.3