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 053611FF09C for ; Mon, 02 Nov 2026 12:07:09 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id AC77921775; Mon, 02 Nov 2026 12:06:35 +0100 (CET) From: Hannes Laimer To: pve-devel@lists.proxmox.com Subject: [PATCH pve-network 05/10] sdn: ipam: release an address the built-in IPAM no longer holds Date: Mon, 2 Nov 2026 12:05:59 +0100 Message-ID: <20261102110604.915693-6-h.laimer@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261102110604.915693-1-h.laimer@proxmox.com> References: <20261102110604.915693-1-h.laimer@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1793617578507 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.371 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 Message-ID-Hash: MMOW6XI3YO6YJRQOXTNZ2WBMFXH5RFUY X-Message-ID-Hash: MMOW6XI3YO6YJRQOXTNZ2WBMFXH5RFUY X-MailFrom: h.laimer@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: The built-in IPAM died on releasing an address it had no record of, before the cache entry of the address was cleared. The entry kept answering with the address, and the API could not delete the mapping either. NetBox and phpIPAM warn and release nothing in that case. The built-in IPAM now does the same, so the cache entry is cleared and the API deletion succeeds. Signed-off-by: Hannes Laimer --- src/PVE/Network/SDN/Ipams/PVEPlugin.pm | 7 ++++++- src/test/run_test_vnets_blackbox.pl | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/PVE/Network/SDN/Ipams/PVEPlugin.pm b/src/PVE/Network/SDN/Ipams/PVEPlugin.pm index a26da57a877a..77a7b2a7c144 100644 --- a/src/PVE/Network/SDN/Ipams/PVEPlugin.pm +++ b/src/PVE/Network/SDN/Ipams/PVEPlugin.pm @@ -265,7 +265,12 @@ sub del_ip { die "subnet $cidr don't exist in ipam db" if !$dbzone->{subnets}->{$cidr}; my $dbsubnet = $dbzone->{subnets}->{$cidr}; - die "IP '$ip' does not exist in IPAM DB\n" if !defined($dbsubnet->{ips}->{$ip}); + # a record that is gone was released already, and the address still + # has to leave the cache, so this is no error + if (!defined($dbsubnet->{ips}->{$ip})) { + warn "IP '$ip' does not exist in IPAM DB\n"; + return; + } delete $dbsubnet->{ips}->{$ip}; write_db($db); }, diff --git a/src/test/run_test_vnets_blackbox.pl b/src/test/run_test_vnets_blackbox.pl index 0f1b181d8a33..fc301a54de5f 100755 --- a/src/test/run_test_vnets_blackbox.pl +++ b/src/test/run_test_vnets_blackbox.pl @@ -533,6 +533,23 @@ sub test_ipam_cache_lookup { { uc($mac) => { ip4 => '10.0.0.50' }, $mac => { ip4 => '10.0.0.50' } }, "$test_name: and its write brings both spellings in line", ); + + # a mapping whose record is gone is still deleted, and its cache entry + # with it + $test_state->{macdb} = {}; + create_ip({ zone => $zoneid, vnet => $vnetid, mac => $mac, ip => "10.0.0.70" }); + delete $test_state->{ipamdb}->{zones}->{$zoneid}->{subnets}->{"10.0.0.0/24"}->{ips} + ->{"10.0.0.70"}; + eval { + PVE::API2::Network::SDN::Ips->ipdelete( + { zone => $zoneid, vnet => $vnetid, mac => $mac, ip => "10.0.0.70" }); + }; + is($@, '', "$test_name: a mapping whose record is gone is deleted without an error"); + is( + (PVE::Network::SDN::Vnets::get_ips_from_mac($vnetid, $mac))[0], + '10.0.0.50', + "$test_name: and the cache no longer answers with its address", + ); } run_test(\&test_ipam_cache_lookup); -- 2.47.3