From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 413811FF142 for ; Fri, 03 Jul 2026 12:48:40 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 6069921435; Fri, 03 Jul 2026 12:48:39 +0200 (CEST) From: Daniel Kral To: pve-devel@lists.proxmox.com Subject: [PATCH network 2/2] api: vnets: assert vnet zone exists on create and update Date: Fri, 3 Jul 2026 12:47:50 +0200 Message-ID: <20260703104750.117988-3-d.kral@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260703104750.117988-1-d.kral@proxmox.com> References: <20260703104750.117988-1-d.kral@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1783075669460 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.050 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) 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: ZK35XMBMDNXG7PL533LG3OOD3A42WFLR X-Message-ID-Hash: ZK35XMBMDNXG7PL533LG3OOD3A42WFLR X-MailFrom: d.kral@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: If a VNet is created or updated with an empty zone '' or a non-existing zone identifier, the API handler will die with a slighly confusing error message: create sdn vnet object failed: cannot lookup undefined type! at /usr/share/perl5/PVE/API2/Network/SDN/Vnets.pm line 326. Therefore, use the helper sdn_zones_config(), which asserts whether the zone identifier is non-empty and existing. Signed-off-by: Daniel Kral --- src/PVE/API2/Network/SDN/Vnets.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/PVE/API2/Network/SDN/Vnets.pm b/src/PVE/API2/Network/SDN/Vnets.pm index b8faeac..3f1cb1b 100644 --- a/src/PVE/API2/Network/SDN/Vnets.pm +++ b/src/PVE/API2/Network/SDN/Vnets.pm @@ -322,8 +322,8 @@ __PACKAGE__->register_method({ my $zone_cfg = PVE::Network::SDN::Zones::config(); my $zoneid = $cfg->{ids}->{$id}->{zone}; - my $plugin_config = $zone_cfg->{ids}->{$zoneid}; - my $plugin = PVE::Network::SDN::Zones::Plugin->lookup($plugin_config->{type}); + my $zone_scfg = PVE::Network::SDN::Zones::sdn_zones_config($zone_cfg, $zoneid); + my $plugin = PVE::Network::SDN::Zones::Plugin->lookup($zone_scfg->{type}); $plugin->vnet_update_hook($cfg, $id, $zone_cfg); PVE::Network::SDN::VnetPlugin->on_update_hook($id, $cfg); @@ -398,8 +398,8 @@ __PACKAGE__->register_method({ my $zone_cfg = PVE::Network::SDN::Zones::config(); my $zoneid = $cfg->{ids}->{$id}->{zone}; - my $plugin_config = $zone_cfg->{ids}->{$zoneid}; - my $plugin = PVE::Network::SDN::Zones::Plugin->lookup($plugin_config->{type}); + my $zone_scfg = PVE::Network::SDN::Zones::sdn_zones_config($zone_cfg, $zoneid); + my $plugin = PVE::Network::SDN::Zones::Plugin->lookup($zone_scfg->{type}); $plugin->vnet_update_hook($cfg, $id, $zone_cfg); PVE::Network::SDN::VnetPlugin->on_update_hook($id, $cfg); -- 2.47.3