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 62BC71FF0B3 for ; Wed, 11 Nov 2026 14:20:09 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id CA99E216F0; Wed, 11 Nov 2026 14:19:21 +0100 (CET) From: Arthur Bied-Charreton To: pve-devel@lists.proxmox.com Subject: [PATCH pve-firewall v6 08/28] firewall: ipset: add option to handle dangling references on delete Date: Wed, 11 Nov 2026 14:18:41 +0100 Message-ID: <20261111131901.1791124-9-a.bied-charreton@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261111131901.1791124-1-a.bied-charreton@proxmox.com> References: <20261111131901.1791124-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: 1794403148231 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.643 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: RYERRBOAC6V7NRPKLFLLTQUVJP5DA2XF X-Message-ID-Hash: RYERRBOAC6V7NRPKLFLLTQUVJP5DA2XF 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: Deleting an ipset referenced by rules or security groups leaves dangling references, which the firewall fails to parse and drops. Add a 'dangling-references' option to the delete endpoint, to either 'disable' the referencing rules or 'drop' them along with the ipset. The default, 'keep', leaves them as they are. For cluster ipsets, this also covers all downstream configs (host, guest and vnet). Signed-off-by: Arthur Bied-Charreton --- src/PVE/API2/Firewall/IPSet.pm | 14 ++++++++++++++ src/PVE/Firewall.pm | 12 ++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/PVE/API2/Firewall/IPSet.pm b/src/PVE/API2/Firewall/IPSet.pm index 9d3c562..144baf6 100644 --- a/src/PVE/API2/Firewall/IPSet.pm +++ b/src/PVE/API2/Firewall/IPSet.pm @@ -2,6 +2,7 @@ package PVE::API2::Firewall::IPSetBase; use strict; use warnings; +use PVE::Firewall::References qw(update_refs); use PVE::Exception qw(raise raise_param_exc); use PVE::JSONSchema qw(get_standard_option); @@ -135,6 +136,7 @@ sub register_delete_ipset { my $properties = $class->additional_parameters(); $properties->{name} = get_standard_option('ipset-name'); + $properties->{'dangling-references'} = get_standard_option('pve-dangling-references-delete'); $properties->{force} = { type => 'boolean', optional => 1, @@ -166,6 +168,18 @@ sub register_delete_ipset { die "IPSet '$param->{name}' is not empty\n" if scalar(@$ipset) && !$param->{force}; + my $action = $param->{'dangling-references'} + // $properties->{'dangling-references'}->{default}; + + update_refs({ + conf => $fw_conf, + kind => 'ipset', + old => $param->{name}, + env => $class->rule_env(), + action => $action eq 'keep' ? undef : $action, + subject => "ipset '$param->{name}' deleted", + }); + $class->save_ipset($param, $fw_conf, undef); }, diff --git a/src/PVE/Firewall.pm b/src/PVE/Firewall.pm index d4e1ad9..85ad23e 100644 --- a/src/PVE/Firewall.pm +++ b/src/PVE/Firewall.pm @@ -223,6 +223,18 @@ PVE::JSONSchema::register_standard_option( }, ); +PVE::JSONSchema::register_standard_option( + 'pve-dangling-references-delete', + { + type => 'string', + enum => ['keep', 'disable', 'drop'], + optional => 1, + description => "Handle references that deleting this object would leave dangling. Use " + . "'disable' to disable the referencing rules, or 'drop' to remove them entirely.", + default => 'keep', + }, +); + PVE::JSONSchema::register_standard_option( 'pve-dangling-references-force-rename', { -- 2.47.3