From: Gabriel Goller <g.goller@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH pve-network v3 18/28] sdn: simple: support static routes in zone routing tables
Date: Thu, 19 Nov 2026 20:41:04 +0100 [thread overview]
Message-ID: <20261119194116.575520-19-g.goller@proxmox.com> (raw)
In-Reply-To: <20261119194116.575520-1-g.goller@proxmox.com>
Allow simple zones to reach outside networks through static routes,
without needing a fabric. Routes use the zone's dedicated VRF, or the
default routing table if dedicated-vrf is disabled.
Support IPv4 and IPv6 routes, including default routes, with a gateway
or an outgoing interface.
Routes can change the host's routing, e.g. through a host interface or
the default table, so changing them requires Sys.Modify on all nodes of
the zone. This includes changing the nodes or VRF of a zone with routes,
or deleting it, while changing other properties does not.
Routes are managed by FRR, so zones with static routes need FRR even
without a controller or fabric. This requires the matching pve-rs
support for route validation and FRR config generation.
Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
src/PVE/API2/Network/SDN/Zones.pm | 24 ++
src/PVE/Network/SDN.pm | 22 +-
src/PVE/Network/SDN/Zones.pm | 42 +++
src/PVE/Network/SDN/Zones/Plugin.pm | 53 ++++
src/PVE/Network/SDN/Zones/SimplePlugin.pm | 1 +
src/test/Makefile | 5 +-
src/test/run_test_static_routes.pl | 313 ++++++++++++++++++++++
7 files changed, 456 insertions(+), 4 deletions(-)
create mode 100644 src/test/run_test_static_routes.pl
diff --git a/src/PVE/API2/Network/SDN/Zones.pm b/src/PVE/API2/Network/SDN/Zones.pm
index e4f4b174466e..5952f407593f 100644
--- a/src/PVE/API2/Network/SDN/Zones.pm
+++ b/src/PVE/API2/Network/SDN/Zones.pm
@@ -3,6 +3,8 @@ package PVE::API2::Network::SDN::Zones;
use strict;
use warnings;
+use Storable qw(dclone);
+
use PVE::Cluster qw(cfs_read_file cfs_write_file);
use PVE::Exception qw(raise raise_param_exc);
use PVE::JSONSchema qw(get_standard_option);
@@ -68,6 +70,15 @@ my $ZONE_PROPERTIES = {
optional => 1,
description => 'Create a dedicated VRF for a simple zone.',
},
+ route => {
+ type => 'array',
+ optional => 1,
+ description => 'Static routes in the zone routing table. Simple zone only.',
+ items => {
+ type => 'string',
+ format => 'pve-sdn-static-route',
+ },
+ },
'rt-import' => {
type => 'string',
optional => 1,
@@ -379,6 +390,8 @@ __PACKAGE__->register_method({
description => "Create a new sdn zone object.",
permissions => {
check => ['perm', '/sdn/zones', ['SDN.Allocate']],
+ description => "Static routes additionally require 'Sys.Modify' on '/nodes/<node>' for"
+ . " all nodes of the zone.",
},
parameters => PVE::Network::SDN::Zones::Plugin->createSchema(
undef,
@@ -413,6 +426,7 @@ __PACKAGE__->register_method({
my $privs = ['SDN.Use', 'SDN.Allocate'];
PVE::Network::SDN::Zones::api_validate_property_references($opts, $privs);
+ PVE::Network::SDN::Zones::api_check_route_privs($opts, undef);
my $dnsserver = $opts->{dns};
my $dnszone = $opts->{dnszone};
@@ -441,6 +455,9 @@ __PACKAGE__->register_method({
description => "Update sdn zone object configuration.",
permissions => {
check => ['perm', '/sdn/zones/{zone}', ['SDN.Allocate']],
+ description =>
+ "Changing static routes, or the nodes or VRF of a zone with static routes,"
+ . " additionally requires 'Sys.Modify' on '/nodes/<node>' for all nodes of the zone.",
},
parameters => PVE::Network::SDN::Zones::Plugin->updateSchema(
undef,
@@ -474,6 +491,7 @@ __PACKAGE__->register_method({
my $plugin = PVE::Network::SDN::Zones::Plugin->lookup($scfg->{type});
my $opts = $plugin->check_config($id, $param, 0, 1);
+ my $old_scfg = dclone($scfg);
my $old_ipam = $scfg->{ipam};
if ($delete) {
@@ -517,6 +535,7 @@ __PACKAGE__->register_method({
my $privs = ['SDN.Use', 'SDN.Allocate'];
PVE::Network::SDN::Zones::api_validate_property_references($opts, $privs);
+ PVE::Network::SDN::Zones::api_check_route_privs($scfg, $old_scfg);
my $dnsserver = $opts->{dns};
my $dnszone = $opts->{dnszone};
@@ -543,6 +562,9 @@ __PACKAGE__->register_method({
description => "Delete sdn zone object configuration.",
permissions => {
check => ['perm', '/sdn/zones/{zone}', ['SDN.Allocate']],
+ description =>
+ "Deleting a zone with static routes additionally requires 'Sys.Modify' on"
+ . " '/nodes/<node>' for all nodes of the zone.",
},
parameters => {
additionalProperties => 0,
@@ -571,6 +593,8 @@ __PACKAGE__->register_method({
my $plugin = PVE::Network::SDN::Zones::Plugin->lookup($scfg->{type});
my $vnet_cfg = PVE::Network::SDN::Vnets::config();
+ PVE::Network::SDN::Zones::api_check_route_privs(undef, $scfg);
+
my $fabric_config = PVE::Network::SDN::Fabrics::config();
my @fabric_ids = fabrics_using_zone($id, $fabric_config);
die "zone is still used as VRF by fabric '$fabric_ids[0]'\n" if @fabric_ids;
diff --git a/src/PVE/Network/SDN.pm b/src/PVE/Network/SDN.pm
index cdb4faddfde4..78fa906dcea8 100644
--- a/src/PVE/Network/SDN.pm
+++ b/src/PVE/Network/SDN.pm
@@ -18,6 +18,7 @@ use PVE::RESTEnvironment qw(log_warn);
use PVE::RPCEnvironment;
use PVE::Tools qw(file_get_contents file_set_contents extract_param dir_glob_regex run_command);
+use PVE::RS::SDN;
use PVE::RS::SDN::Fabrics;
use PVE::Network::SDN::Vnets;
@@ -131,10 +132,19 @@ sub running_config_has_frr {
my $fabrics = $running_config->{fabrics}->{ids} // {};
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 $local_frr_config = PVE::Network::SDN::Frr::local_frr_config_exists();
- return %$controllers || %$fabrics || %$route_maps || %$prefix_lists || $local_frr_config;
+ return
+ %$controllers
+ || %$fabrics
+ || %$route_maps
+ || %$prefix_lists
+ || $zone_routes
+ || $local_frr_config;
}
sub pending_config {
@@ -564,11 +574,14 @@ sub generate_frr_raw_config {
my $frr_config = {};
+ my $nodename = PVE::INotify::nodename();
+
PVE::Network::SDN::Controllers::generate_frr_config($frr_config, $running_config);
+ my $routes =
+ PVE::RS::SDN::get_zone_routes($running_config->{zones} // { ids => {} }, $nodename);
+ push @{ $frr_config->{frr}->{ip_routes} }, @$routes;
PVE::Network::SDN::Frr::append_local_config($frr_config);
- my $nodename = PVE::INotify::nodename();
-
return PVE::RS::SDN::get_frr_raw_config(
$frr_config->{'frr'},
$prefix_list_config,
@@ -644,6 +657,9 @@ sub canonicalize_property_strings {
sub encode_value {
my ($type, $key, $value) = @_;
+ # Route strings contain commas themselves, so preserve array element boundaries.
+ return join("\n", sort @$value) if $key eq 'route' && ref($value) eq 'ARRAY';
+
if (
$key eq 'nodes'
|| $key eq 'exitnodes'
diff --git a/src/PVE/Network/SDN/Zones.pm b/src/PVE/Network/SDN/Zones.pm
index 1d3ad22c1cd5..3b59f4fecef5 100644
--- a/src/PVE/Network/SDN/Zones.pm
+++ b/src/PVE/Network/SDN/Zones.pm
@@ -472,6 +472,48 @@ sub api_get_zone_checked {
return api_get_zone($cfg, $zoneid);
}
+=head3 api_check_route_privs($zone, $old_zone, $rpcenv, $authuser)
+
+Static routes are installed on the zone nodes and can change the host's routing, e.g. via a host
+interface or the default routing table, so require C<Sys.Modify> on these nodes to change them.
+
+C<$old_zone> and C<$zone> are the zone configs before and after the change, either may be undef
+on create or delete. If the routes, or the nodes or VRF they are installed on, change, the
+permission is checked for all nodes that have the routes before or after the change. Zones
+without nodes use all cluster nodes.
+
+=cut
+
+sub api_check_route_privs {
+ my ($zone, $old_zone, $rpcenv, $authuser) = @_;
+
+ my @nodes;
+ for my $z ($zone, $old_zone) {
+ next if !$z || !$z->{route} || !$z->{route}->@*;
+ push @nodes, $z->{nodes} ? keys $z->{nodes}->%* : PVE::Cluster::get_nodelist()->@*;
+ }
+ return if !@nodes;
+
+ if ($zone && $old_zone) {
+ my $changed = 0;
+ for my $key ('route', 'nodes', 'dedicated-vrf') {
+ my $new = PVE::Network::SDN::encode_value(undef, $key, $zone->{$key}) // '';
+ my $old = PVE::Network::SDN::encode_value(undef, $key, $old_zone->{$key}) // '';
+ $changed = 1 if $new ne $old;
+ }
+ return if !$changed;
+ }
+
+ $rpcenv = PVE::RPCEnvironment::get() if !defined($rpcenv);
+ $authuser = $rpcenv->get_user() if !defined($authuser);
+
+ my %seen;
+ for my $node (sort grep { !$seen{$_}++ } @nodes) {
+ next if $rpcenv->check_any($authuser, "/nodes/$node", ['Sys.Modify'], 1);
+ raise_param_exc({ route => "permission check failed: missing 'Sys.Modify' on node $node" });
+ }
+}
+
=head3 api_validate_property_references($zone, $privs, $rpcenv, $authuser)
For properties that reference another SDN entity in C<$zone> this function
diff --git a/src/PVE/Network/SDN/Zones/Plugin.pm b/src/PVE/Network/SDN/Zones/Plugin.pm
index 2de538607710..2c561eabbd40 100644
--- a/src/PVE/Network/SDN/Zones/Plugin.pm
+++ b/src/PVE/Network/SDN/Zones/Plugin.pm
@@ -8,6 +8,8 @@ use Net::IP qw(ip_get_version);
use PVE::JSONSchema;
use PVE::Cluster;
use PVE::Network;
+use PVE::Network::SDN::Formats;
+use PVE::RS::SDN;
use PVE::JSONSchema qw(get_standard_option);
use base qw(PVE::SectionConfig);
@@ -29,6 +31,47 @@ PVE::JSONSchema::register_standard_option(
},
);
+my $static_route_fmt = {
+ prefix => {
+ type => 'string',
+ format => 'FullRangeCIDR',
+ description => 'Destination prefix in CIDR notation, including default routes.',
+ },
+ via => {
+ type => 'string',
+ format => 'ip',
+ optional => 1,
+ description => 'Next-hop IP address. IPv6 link-local addresses require an interface.',
+ },
+ iface => {
+ type => 'string',
+ format => 'pve-iface',
+ optional => 1,
+ description => 'Outgoing interface. At least one of via or iface is required.',
+ },
+ distance => {
+ type => 'integer',
+ minimum => 1,
+ maximum => 255,
+ optional => 1,
+ description => 'Administrative distance.',
+ },
+};
+
+PVE::JSONSchema::register_format(
+ 'pve-sdn-static-route',
+ $static_route_fmt,
+ sub {
+ my ($route) = @_;
+
+ PVE::RS::SDN::validate_static_route(
+ PVE::JSONSchema::print_property_string($route, $static_route_fmt),
+ );
+
+ return $route;
+ },
+);
+
my $defaultData = {
propertyList => {
@@ -39,6 +82,16 @@ my $defaultData = {
type => 'string',
},
nodes => get_standard_option('pve-node-list', { optional => 1 }),
+ route => {
+ type => 'array',
+ optional => 1,
+ description =>
+ 'Static routes in the zone VRF, or the default table for Simple zones without dedicated-vrf.',
+ items => {
+ type => 'string',
+ format => 'pve-sdn-static-route',
+ },
+ },
zone => get_standard_option(
'pve-sdn-zone-id',
{
diff --git a/src/PVE/Network/SDN/Zones/SimplePlugin.pm b/src/PVE/Network/SDN/Zones/SimplePlugin.pm
index bc591839819d..1d44f0b078f5 100644
--- a/src/PVE/Network/SDN/Zones/SimplePlugin.pm
+++ b/src/PVE/Network/SDN/Zones/SimplePlugin.pm
@@ -53,6 +53,7 @@ sub options {
ipam => { optional => 1 },
dhcp => { optional => 1 },
'dedicated-vrf' => { optional => 1 },
+ route => { optional => 1 },
};
}
diff --git a/src/test/Makefile b/src/test/Makefile
index 3df96852f27f..0d5f3c128125 100644
--- a/src/test/Makefile
+++ b/src/test/Makefile
@@ -1,10 +1,13 @@
all: test
-test: test_zones test_fabric_host_vrf test_ipams test_dns test_subnets test_vnets_blackbox test_running_config test_api_index
+test: test_zones test_static_routes test_fabric_host_vrf test_ipams test_dns test_subnets test_vnets_blackbox test_running_config test_api_index
test_zones: run_test_zones.pl
./run_test_zones.pl
+test_static_routes: run_test_static_routes.pl
+ perl ./run_test_static_routes.pl
+
test_fabric_host_vrf: run_test_fabric_host_vrf.pl
./run_test_fabric_host_vrf.pl
diff --git a/src/test/run_test_static_routes.pl b/src/test/run_test_static_routes.pl
new file mode 100644
index 000000000000..96edecc61930
--- /dev/null
+++ b/src/test/run_test_static_routes.pl
@@ -0,0 +1,313 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use lib qw(..);
+
+use Storable qw(dclone);
+use Test::More;
+use Test::MockModule;
+
+use PVE::API2::Network::SDN::Zones;
+use PVE::Network::SDN;
+
+my $routes = [
+ 'prefix=0.0.0.0/0,via=192.0.2.1,iface=uplink0,distance=20',
+ 'prefix=::/0,via=fe80::1,iface=uplink0',
+ 'prefix=10.20.0.0/16,iface=vnet0',
+];
+my $zones = {
+ ids => {
+ isolated => {
+ type => 'simple',
+ 'dedicated-vrf' => 1,
+ nodes => { localhost => 1 },
+ route => $routes,
+ },
+ plain => {
+ type => 'simple',
+ route => ['prefix=198.51.100.0/24,via=192.0.2.1'],
+ },
+ remote => {
+ type => 'simple',
+ nodes => { othernode => 1 },
+ route => ['prefix=192.0.2.0/24,iface=remote0'],
+ },
+ },
+};
+
+subtest 'route API schema and Rust validation' => sub {
+ my $create = PVE::API2::Network::SDN::Zones->map_method_by_name('create');
+ my $schema = $create->{parameters}->{properties}->{route};
+ is($schema->{type}, 'array', 'API accepts repeatable routes');
+
+ my $errors = {};
+ PVE::JSONSchema::check_prop($routes, $schema, 'route', $errors);
+ is_deeply($errors, {}, 'default routes and interface-only routes are valid');
+
+ for my $route (
+ 'via=192.0.2.1',
+ 'prefix=0.0.0.0/0',
+ 'prefix=::/0,via=fe80::1',
+ 'prefix=0.0.0.0/0,via=2001:db8::1',
+ 'prefix=::/0,via=192.0.2.1',
+ 'prefix=0.0.0.0/0,via=192.0.2.1,distance=256',
+ 'prefix=10.0.0.0/33,via=192.0.2.1',
+ 'prefix=example,via=192.0.2.1',
+ 'prefix=10.0.0.0/8,iface=-uplink',
+ ) {
+ my $errors = {};
+ PVE::JSONSchema::check_prop([$route], $schema, 'route', $errors);
+ ok(scalar(keys %$errors), "reject invalid route: $route");
+ }
+
+ for my $method ('index', 'read') {
+ my $info = PVE::API2::Network::SDN::Zones->map_method_by_name($method);
+ my $properties =
+ $method eq 'index'
+ ? $info->{returns}->{items}->{properties}
+ : $info->{returns}->{properties};
+ is_deeply(
+ $properties->{route}->{items},
+ $schema->{items},
+ "$method returns route strings",
+ );
+ is(
+ $properties->{pending}->{properties}->{route}->{type},
+ 'array',
+ "$method pending routes are arrays",
+ );
+ }
+
+ eval {
+ PVE::Network::SDN::Zones::VlanPlugin->check_config(
+ 'vlanzone',
+ { bridge => 'vmbr0', route => $routes },
+ 1,
+ 1,
+ );
+ };
+ like($@, qr/unexpected property 'route'/, 'routes are only supported on simple zones');
+};
+
+subtest 'repeatable config persistence' => sub {
+ my $raw = PVE::Network::SDN::Zones::Plugin->write_config('zones.cfg', dclone($zones));
+ is(scalar(() = $raw =~ /^\s+route /gm), 5, 'one config line per route');
+ my $parsed = PVE::Network::SDN::Zones::Plugin->parse_config('zones.cfg', $raw);
+ ok(!$parsed->{errors}, 'all routes parse without errors');
+ is_deeply($parsed->{ids}, $zones->{ids}, 'routes and node restrictions survive round trip');
+};
+
+subtest 'pending arrays compare by value' => sub {
+ my $running = { zones => dclone($zones) };
+ my $configured = dclone($zones);
+ my $pending = PVE::Network::SDN::pending_config($running, $configured, 'zones');
+ ok(!$pending->{ids}->{isolated}->{state}, 'equal arrays are unchanged');
+
+ $configured->{ids}->{isolated}->{route} = [reverse @$routes];
+ $pending = PVE::Network::SDN::pending_config($running, $configured, 'zones');
+ ok(!$pending->{ids}->{isolated}->{state}, 'route ordering does not cause pending changes');
+
+ $configured->{ids}->{isolated}->{route} = ['prefix=::/0,iface=vnet1'];
+ $pending = PVE::Network::SDN::pending_config($running, $configured, 'zones');
+ is($pending->{ids}->{isolated}->{state}, 'changed', 'route modification detected');
+ is_deeply(
+ $pending->{ids}->{isolated}->{pending}->{route},
+ ['prefix=::/0,iface=vnet1'],
+ 'pending retains an array',
+ );
+
+ delete $configured->{ids}->{isolated}->{route};
+ $pending = PVE::Network::SDN::pending_config($running, $configured, 'zones');
+ is($pending->{ids}->{isolated}->{pending}->{route}, 'deleted', 'route removal detected');
+};
+
+my $running = { zones => $zones, controllers => { ids => {} }, vnets => { ids => {} } };
+my $sdn = Test::MockModule->new('PVE::Network::SDN');
+$sdn->mock(running_config => sub { return $running; });
+my $inotify = Test::MockModule->new('PVE::INotify');
+$inotify->mock(nodename => sub { return 'localhost'; });
+my $controllers = Test::MockModule->new('PVE::Network::SDN::Controllers');
+$controllers->mock(read_etc_network_interfaces => sub { return { ifaces => {} }; });
+my $frr = Test::MockModule->new('PVE::Network::SDN::Frr');
+$frr->mock(local_frr_config_exists => sub { return 0; });
+$frr->mock(
+ read_local_frr_config => sub { return 'ip prefix-list LOCAL seq 5 permit 203.0.113.0/24'; },
+);
+
+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');
+};
+
+subtest 'zone routes reach FRR with local config' => sub {
+ my $fabric_config = PVE::RS::SDN::Fabrics->running_config({});
+ my $route_maps = PVE::RS::SDN::RouteMaps->running_config({});
+ my $prefix_lists = PVE::RS::SDN::PrefixLists->running_config({});
+ my $raw = PVE::Network::SDN::generate_frr_raw_config(
+ $running, $fabric_config, $route_maps, $prefix_lists,
+ );
+ my $config = join("\n", @$raw);
+ like(
+ $config,
+ qr/^ip route 0\.0\.0\.0\/0 192\.0\.2\.1 uplink0 20 vrf vrf_isolated$/m,
+ 'IPv4 default route with distance',
+ );
+ like(
+ $config,
+ qr/^ipv6 route ::\/0 fe80::1 uplink0 vrf vrf_isolated$/m,
+ 'IPv6 link-local default route',
+ );
+ like(
+ $config,
+ qr/^ip route 10\.20\.0\.0\/16 vnet0 vrf vrf_isolated$/m,
+ 'interface-only route in zone VRF',
+ );
+ like(
+ $config,
+ qr/^ip route 198\.51\.100\.0\/24 192\.0\.2\.1(?: vrf default)?$/m,
+ 'zone without dedicated VRF uses default table',
+ );
+ unlike($config, qr/remote0/, 'routes restricted to another node are omitted');
+ like(
+ $config,
+ qr/^ip prefix-list LOCAL seq 5 permit 203\.0\.113\.0\/24$/m,
+ 'local FRR configuration coexists with zone routes',
+ );
+};
+
+subtest 'static routes require Sys.Modify on the zone nodes' => sub {
+ my $zone_cfg;
+ my $allowed = {};
+ my $zones_module = Test::MockModule->new('PVE::Network::SDN::Zones');
+ $zones_module->mock(
+ config => sub { return dclone($zone_cfg); },
+ write_config => sub { $zone_cfg = $_[0]; },
+ api_validate_property_references => sub { },
+ );
+ my $config_modules = [
+ map {
+ my $module = Test::MockModule->new("PVE::Network::SDN::$_");
+ $module->mock(config => sub { return { ids => {} }; });
+ $module;
+ } qw(Controllers Dns Subnets Vnets)
+ ];
+ my $fabrics_module = Test::MockModule->new('PVE::Network::SDN::Fabrics');
+ $fabrics_module->mock(config => sub { return PVE::RS::SDN::Fabrics->running_config({}); });
+ my $sdn_module = Test::MockModule->new('PVE::Network::SDN');
+ $sdn_module->mock(lock_sdn_config => sub { return $_[0]->(); });
+ my $cluster = Test::MockModule->new('PVE::Cluster');
+ $cluster->mock(
+ check_cfs_quorum => sub { },
+ get_nodelist => sub { return ['node1', 'node2']; },
+ );
+ my $api = Test::MockModule->new('PVE::API2::Network::SDN::Zones');
+ $api->mock(create_etc_interfaces_sdn_dir => sub { });
+
+ my $rpcenv = Test::MockModule->new('PVE::RPCEnvironment');
+ $rpcenv->mock(
+ get => sub { return bless {}, 'PVE::RPCEnvironment'; },
+ get_user => sub { return 'delegate@pve'; },
+ check_any => sub {
+ my ($self, $user, $path, $privs, $noerr) = @_;
+ return 1 if $allowed->{$path};
+ die "permission check failed\n" if !$noerr;
+ return 0;
+ },
+ );
+
+ my $call = sub {
+ my ($method, $param) = @_;
+ eval { PVE::API2::Network::SDN::Zones->$method(dclone($param)) };
+ return $@;
+ };
+ my $route = 'prefix=0.0.0.0/0,via=192.0.2.1';
+ my $missing = qr/missing 'Sys.Modify' on node/;
+
+ my $reset = sub {
+ $allowed = {};
+ $zone_cfg = {
+ ids => {
+ plain => { type => 'simple' },
+ routed => { type => 'simple', 'dedicated-vrf' => 1, route => [$route] },
+ pinned => { type => 'simple', nodes => { node1 => 1 }, route => [$route] },
+ },
+ };
+ };
+
+ $reset->();
+ like(
+ $call->('create', { zone => 'new', type => 'simple', route => [$route] }),
+ $missing,
+ 'create with routes requires Sys.Modify',
+ );
+ ok(!$zone_cfg->{ids}->{new}, 'rejected zone is not created');
+ is(
+ $call->('create', { zone => 'new', type => 'simple' }),
+ '',
+ 'create without routes does not require Sys.Modify',
+ );
+
+ like(
+ $call->('update', { zone => 'plain', route => [$route] }),
+ $missing,
+ 'adding routes requires Sys.Modify',
+ );
+ ok(!$zone_cfg->{ids}->{plain}->{route}, 'rejected route is not stored');
+ like(
+ $call->('update', { zone => 'routed', delete => 'route' }),
+ $missing,
+ 'removing routes requires Sys.Modify',
+ );
+ like(
+ $call->('update', { zone => 'routed', nodes => 'node1' }),
+ $missing,
+ 'changing the nodes of a zone with routes requires Sys.Modify',
+ );
+ like(
+ $call->('update', { zone => 'routed', delete => 'dedicated-vrf' }),
+ $missing,
+ 'moving routes into the default table requires Sys.Modify',
+ );
+ like($call->('delete', { zone => 'routed' }), $missing, 'deleting a zone with routes');
+ is(
+ $call->('update', { zone => 'routed', mtu => 1400 }),
+ '',
+ 'unrelated changes are allowed',
+ );
+ is(
+ $call->('update', { zone => 'plain', mtu => 1400 }),
+ '',
+ 'zones without routes unaffected',
+ );
+ is($call->('delete', { zone => 'plain' }), '', 'deleting a zone without routes');
+
+ $allowed->{'/nodes/node1'} = 1;
+ like(
+ $call->(
+ 'update',
+ { zone => 'routed', route => [$route, 'prefix=::/0,via=2001:db8::1'] },
+ ),
+ qr/missing 'Sys.Modify' on node node2/,
+ 'zones without nodes require Sys.Modify on all cluster nodes',
+ );
+ is(
+ $call->('update', { zone => 'pinned', route => ['prefix=::/0,via=2001:db8::1'] }),
+ '',
+ 'Sys.Modify on the zone nodes is sufficient',
+ );
+ like(
+ $call->('update', { zone => 'pinned', nodes => 'node1,node2' }),
+ qr/missing 'Sys.Modify' on node node2/,
+ 'adding a node to a zone with routes requires Sys.Modify on it',
+ );
+
+ $allowed->{'/nodes/node2'} = 1;
+ is($call->('update', { zone => 'new', route => [$route] }), '', 'allowed with Sys.Modify');
+ is_deeply($zone_cfg->{ids}->{new}->{route}, [$route], 'route stored');
+ is($call->('delete', { zone => 'routed' }), '', 'delete allowed with Sys.Modify');
+};
+
+done_testing();
--
2.47.3
next prev parent reply other threads:[~2026-11-19 19:45 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 19:40 [PATCH common/manager/network/proxmox{-ve-rs,-perl-rs,-widget-toolkit} v3 00/28] SDN VRF support Gabriel Goller
2026-11-19 19:40 ` [PATCH pve-common v3 01/28] interfaces: preserve VRF membership across address family changes Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-ve-rs v3 02/28] frr: add VRF-aware OSPF rendering Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-ve-rs v3 03/28] sdn: add zone references to OSPF and BGP fabrics Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-ve-rs v3 04/28] sdn: generate fabric routing configuration in zone VRFs Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-ve-rs v3 05/28] sdn: fix VRF route-map scoping and zone ID validation Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-ve-rs v3 06/28] tests: fabrics: add tests for fabrics in VRFs Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-ve-rs v3 07/28] sdn: allow static routes in simple zone VRFs Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-perl-rs v3 08/28] pve-rs: fabrics: assign network interfaces to configured VRFs Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-perl-rs v3 09/28] pve-rs: fabrics: make per-fabric status queries VRF-aware Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-perl-rs v3 10/28] pve-rs: fabrics: include VRF routes in aggregate status Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-perl-rs v3 11/28] pve-rs: fabrics: expose host interface membership Gabriel Goller
2026-11-19 19:40 ` [PATCH proxmox-perl-rs v3 12/28] sdn: expose static routes for simple zone uplinks Gabriel Goller
2026-11-19 19:40 ` [PATCH pve-network v3 13/28] sdn: evpn: add unreachable IPv6 default route to zone VRFs Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-network v3 14/28] sdn: add optional VRFs for simple zones Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-network v3 15/28] sdn: allow fabrics to use simple zone VRFs Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-network v3 16/28] sdn: require underlay fabrics to use the default VRF Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-network v3 17/28] sdn: move full range CIDR formats into a separate module Gabriel Goller
2026-11-19 19:41 ` Gabriel Goller [this message]
2026-11-19 19:41 ` [PATCH pve-network v3 19/28] sdn: dhcp: only configure DHCP for zones on the local node Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-network v3 20/28] sdn: dhcp: run dnsmasq in the zone VRF Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-network v3 21/28] sdn: dhcp: fix DNS server option for IPv4 subnets without gateway Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-network v3 22/28] sdn: evpn: no exit node null routes for simple zone VRFs Gabriel Goller
2026-11-19 19:41 ` [PATCH proxmox-widget-toolkit v3 23/28] ui: network: allow selecting a VRF for host interfaces Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-manager v3 24/28] ui: sdn: add VRF zone selection for fabrics Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-manager v3 25/28] network: allow setting the VRF of host interfaces Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-manager v3 26/28] ui: sdn: allow static routes for Simple zone VRFs Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-manager v3 27/28] network: generate SDN DHCP config after ifreload Gabriel Goller
2026-11-19 19:41 ` [PATCH pve-manager v3 28/28] ui: sdn: subnet: allow setting the DHCP DNS server Gabriel Goller
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=20261119194116.575520-19-g.goller@proxmox.com \
--to=g.goller@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox