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 1D3261FF0DE for ; Thu, 19 Nov 2026 15:14:11 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id A4D01216B8; Thu, 19 Nov 2026 15:14:09 +0100 (CET) Date: Thu, 19 Nov 2026 15:14:02 +0100 From: Gabriel Goller To: Stefan Hanreich Subject: Re: [PATCH pve-network v3 16/32] sdn: allow fabrics to use simple zone VRFs Message-ID: References: <20261116161154.343743-1-g.goller@proxmox.com> <20261116161154.343743-17-g.goller@proxmox.com> <26c8b2b0-e107-49d7-b761-bfd5b5cc8e38@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <26c8b2b0-e107-49d7-b761-bfd5b5cc8e38@proxmox.com> User-Agent: NeoMutt/20260616 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1795097643990 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.772 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) KAM_MAILER 2 Automated Mailer Tag Left in Email 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 Message-ID-Hash: VSAKHG4NOSW6HDE3F3Y7XJBQTE5QTIZS X-Message-ID-Hash: VSAKHG4NOSW6HDE3F3Y7XJBQTE5QTIZS 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 18.11.2026 17:27, Stefan Hanreich wrote: > generally we should check in the API for where we should use the new _checked helpers > and which validate_property_references methods should get extended? Here are some, > and there are probably other in this series as well - please re-check this! > > > On 11/16/26 5:15 PM, Gabriel Goller wrote: > > Let BGP and OSPF fabrics use a simple zone with dedicated-vrf enabled > > to keep their routes separate from the default VRF. > > > > The zone must be enabled on every fabric node. Prevent zone changes > > or deletion that would leave a fabric without its VRF. A fabric's zone > > cannot be changed after creation, since that resets all its sessions > > anyway and other objects rely on the fabric staying in its VRF. > > > > Signed-off-by: Gabriel Goller > > --- > > src/PVE/API2/Network/SDN/Fabrics/Fabric.pm | 57 ++++++++++++++++--- > > .../API2/Network/SDN/Fabrics/FabricNode.pm | 18 ++++++ > > src/PVE/API2/Network/SDN/Zones.pm | 28 +++++++++ > > src/PVE/Network/SDN/Controllers/BgpPlugin.pm | 2 +- > > src/PVE/Network/SDN/Fabrics.pm | 26 +++++++++ > > 5 files changed, 122 insertions(+), 9 deletions(-) > > > > diff --git a/src/PVE/API2/Network/SDN/Fabrics/Fabric.pm b/src/PVE/API2/Network/SDN/Fabrics/Fabric.pm > > index bbc33e047154..20b7b1f98e4b 100644 > > --- a/src/PVE/API2/Network/SDN/Fabrics/Fabric.pm > > +++ b/src/PVE/API2/Network/SDN/Fabrics/Fabric.pm > > @@ -6,13 +6,51 @@ use warnings; > > use PVE::Network::SDN; > > use PVE::Network::SDN::Controllers; > > use PVE::Network::SDN::Fabrics; > > +use PVE::Network::SDN::Zones; > > > > +use PVE::Exception qw(raise_param_exc); > > use PVE::JSONSchema qw(get_standard_option); > > use PVE::Tools qw(extract_param); > > > > use PVE::RESTHandler; > > use base qw(PVE::RESTHandler); > > > > +sub validate_fabric_zone { > > + my ($fabric, $config) = @_; > > + > > + my $protocol = $fabric->{protocol} // ''; > > + if ($protocol eq 'bgp' && !$fabric->{zone}) { > > + my $controller_cfg = PVE::Network::SDN::Controllers::config(); > > + for my $controller_id (keys %{ $controller_cfg->{ids} // {} }) { > > + my $controller = $controller_cfg->{ids}->{$controller_id}; > > + if ($controller->{type} eq 'bgp') { > > + die "cannot configure a BGP fabric while BGP controller '$controller_id' exists:" > > + . " both target the default-VRF BGP router\n"; > > + } > > + } > > + } > > + > > + my $zone_id = $fabric->{zone}; > > + return if !$zone_id; > > + > > + raise_param_exc({ zone => 'VRF zones are only supported for BGP and OSPF fabrics' }) > > + if $protocol !~ /^(?:bgp|ospf)$/; > > + > > + my $zone = PVE::Network::SDN::Zones::get_zone($zone_id); > > should this use get_zone_checked instead? pulled this into `api_validate_property_references()` and used the _checked variant! > > + > > + raise_param_exc({ zone => "zone '$zone_id' does not exist" }) if !$zone; > > + raise_param_exc({ zone => "zone '$zone_id' is not a simple zone" }) > > + if $zone->{type} ne 'simple'; > > + raise_param_exc({ zone => "zone '$zone_id' is configured to use the default VRF" }) > > + if $zone->{'default-vrf'} // 1; > > Isn't that dedicated-vrf? Oof, yeah, fat-fingered this one. > > + > > + if ($config) { > > + PVE::Network::SDN::Fabrics::assert_fabric_nodes_in_zone( > > + $config, $fabric->{id}, $zone_id, $zone, > > + ); > > + } > > +} > > + > > __PACKAGE__->register_method({ > > name => 'index', > > path => '', > > @@ -129,6 +167,8 @@ __PACKAGE__->register_method({ > > protected => 1, > > permissions => { > > check => ['perm', '/sdn/fabrics', ['SDN.Allocate']], > > + description => "Assigning a VRF zone additionally requires 'SDN.Allocate' on" > > + . " '/sdn/zones/'.", > > }, > > parameters => { > > properties => PVE::Network::SDN::Fabrics::fabric_properties(0), > > @@ -148,14 +188,10 @@ __PACKAGE__->register_method({ > > my $digest = extract_param($param, 'digest'); > > PVE::Tools::assert_if_modified($config->digest(), $digest) if $digest; > > > > - if (($param->{protocol} // '') eq 'bgp') { > > - my $controller_cfg = PVE::Network::SDN::Controllers::config(); > > - for my $id (keys %{ $controller_cfg->{ids} // {} }) { > > - die "cannot add a BGP fabric while BGP controller '$id' exists:" > > - . " both target the default-VRF BGP router\n" > > - if $controller_cfg->{ids}->{$id}->{type} eq 'bgp'; > > - } > > - } > > + PVE::Network::SDN::Zones::api_get_zone_checked($param->{zone}, ['SDN.Allocate']) > > + if $param->{zone}; > > + > > + validate_fabric_zone($param); > > > > my $privs = ['SDN.Use', 'SDN.Allocate']; > > PVE::Network::SDN::Fabrics::api_validate_property_references($param, $privs); > > @@ -200,7 +236,12 @@ __PACKAGE__->register_method({ > > my $privs = ['SDN.Use', 'SDN.Allocate']; > > PVE::Network::SDN::Fabrics::api_validate_property_references($param, $privs); > > does this fn also cover the zone permissions now? It does now! > > > > + my $old_zone = $config->get_fabric($id)->{zone} // ''; > > + raise_param_exc({ zone => "cannot change the VRF zone of an existing fabric" }) > > + if defined($param->{zone}) && $param->{zone} ne $old_zone; > > this doesn't deny deleting the zone param. Hmm 'zone' is not in the delete enum, I think thats enough? > > + > > $config->update_fabric($id, $param); > > + validate_fabric_zone($config->get_fabric($id), $config); > > PVE::Network::SDN::Fabrics::write_config($config); > > }, > > "updating fabric failed", > > diff --git a/src/PVE/API2/Network/SDN/Fabrics/FabricNode.pm b/src/PVE/API2/Network/SDN/Fabrics/FabricNode.pm > > index 7a148b550f7d..eb3b429075e5 100644 > > --- a/src/PVE/API2/Network/SDN/Fabrics/FabricNode.pm > > +++ b/src/PVE/API2/Network/SDN/Fabrics/FabricNode.pm > > @@ -9,6 +9,7 @@ use PVE::Tools qw(extract_param run_command); > > use PVE::Network::SDN; > > use PVE::Network::SDN::Fabrics; > > use PVE::Network::SDN::WireGuard; > > +use PVE::Network::SDN::Zones; > > use PVE::RS::SDN::Fabrics; > > > > use PVE::RESTHandler; > > @@ -138,6 +139,21 @@ my sub is_internal_wireguard_node { > > return $node->{protocol} eq 'wireguard' && $node->{role} eq 'internal'; > > } > > > > +my sub validate_node_fabric_zone { > > + my ($config, $fabric_id, $node_id) = @_; > > + > > + my $fabric = $config->get_fabric($fabric_id); > > + my $zone_id = $fabric->{zone}; > > + return if !$zone_id; > > + > > + my $zone = PVE::Network::SDN::Zones::get_zone($zone_id); > > should this use get_zone_checked instead? done. > > + > > + die "zone '$zone_id' does not exist\n" if !$zone; > > + PVE::Network::SDN::Fabrics::assert_fabric_node_in_zone( > > + $fabric_id, $node_id, $zone_id, $zone, > > + ); > > +} > > + > > __PACKAGE__->register_method({ > > name => 'add_node', > > path => '', > > @@ -169,6 +185,8 @@ __PACKAGE__->register_method({ > > my $digest = extract_param($param, 'digest'); > > PVE::Tools::assert_if_modified($config->digest(), $digest) if $digest; > > > > + validate_node_fabric_zone($config, $param->{fabric_id}, $param->{node_id}); > > + > > if (is_internal_wireguard_node($param) && $param->{interfaces}) { > > my $private_keys = PVE::Network::SDN::WireGuard::private_keys(); > > > > [snip]