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 841281FF0B6 for ; Thu, 12 Nov 2026 16:12:50 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 1237C21820; Thu, 12 Nov 2026 16:11:32 +0100 (CET) From: Arthur Bied-Charreton To: pve-devel@lists.proxmox.com Subject: [PATCH pve-container v7 18/28] api: destroy_vm: add option to handle dangling IPSet references Date: Thu, 12 Nov 2026 16:10:35 +0100 Message-ID: <20261112151045.577923-19-a.bied-charreton@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261112151045.577923-1-a.bied-charreton@proxmox.com> References: <20261112151045.577923-1-a.bied-charreton@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1794496255387 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.530 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) POISEN_SPAM_PILL_3 0.1 random spam to be learned in bayes 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: 4DCYDCPUM44BVDR5M3LYRN3DCN62373L X-Message-ID-Hash: 4DCYDCPUM44BVDR5M3LYRN3DCN62373L X-MailFrom: a.bied-charreton@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: For each guest with IPAM entries, a 'guest-ipam-' IPSet is auto-generated [0]. Therefore, deleting a guest can lead to firewall rules referencing non-existing IPSets, which the firewall fails to parse and ignores. Add a 'dangling-ipset-references' option for DELETE /nodes/{node}/lxc/{vmid} allowing to 'drop' rules referencing now-deleted IPSets, to 'disable' them, or to 'keep' them as they are. [0] https://pve.proxmox.com/wiki/Software-Defined_Network#pvesdn_firewall_integration Signed-off-by: Arthur Bied-Charreton --- src/PVE/API2/LXC.pm | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm index d736dac..7c7cdca 100644 --- a/src/PVE/API2/LXC.pm +++ b/src/PVE/API2/LXC.pm @@ -13,6 +13,7 @@ use PVE::Cluster qw(cfs_read_file); use PVE::DataCenterConfig; use PVE::Exception qw(raise raise_param_exc raise_perm_exc); use PVE::Firewall; +use PVE::Firewall::References; use PVE::GuestHelpers; use PVE::INotify; use PVE::JSONSchema qw(get_standard_option); @@ -849,6 +850,15 @@ __PACKAGE__->register_method({ . " enabled storages which are not referenced in the config.", optional => 1, }, + 'dangling-ipset-references' => get_standard_option( + 'pve-dangling-references-delete', + { + description => + 'Handle firewall rules referencing the IPSet auto-generated for ' + . 'this guest (\'guest-ipam-\'). Use \'disable\' to disable them, or ' + . '\'drop\' to remove them entirely.', + }, + ), }, }, returns => { @@ -930,7 +940,13 @@ __PACKAGE__->register_method({ PVE::LXC::Config->destroy_config($vmid); }; - my $realcmd = sub { PVE::LXC::Config->lock_config($vmid, $code); }; + my $realcmd = sub { + PVE::LXC::Config->lock_config($vmid, $code); + PVE::Firewall::References::update_guest_ipam_ipset_refs( + $vmid, + $param->{'dangling-ipset-references'} // 'keep', + ); + }; return $rpcenv->fork_worker('vzdestroy', $vmid, $authuser, $realcmd); }, -- 2.47.3