* [PATCH access-control/network 0/2] fix #7520: sdn: clean up dangling ACLs on resource deletion
@ 2026-05-05 14:22 David Riley
2026-05-05 14:22 ` [PATCH pve-network 1/2] " David Riley
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: David Riley @ 2026-05-05 14:22 UTC (permalink / raw)
To: pve-devel; +Cc: David Riley
Add pruning mechanism to clean up orphaned SDN ACL entries by
comparing the current `running-config` with the newly compiled state
during `commit_config`.
This ensures state consistency for manual applies via the UI/API
as well as during the automatic configuration reload on system boot.
Covers resources tracked in the `running-config`:
* Zones
* VNets
* Fabrics
* Controllers
Does not cover IPAMs and DNS as these are not staged.
pve-network:
David Riley (1):
fix #7520: sdn: clean up dangling ACLs on resource deletion
src/PVE/Network/SDN.pm | 45 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
pve-access-control:
David Riley (1):
fix #7520: access-control: add SDN ACL cleanup helper
src/PVE/AccessControl.pm | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
Summary over all repositories:
2 files changed, 85 insertions(+), 0 deletions(-)
--
Generated by murpp 0.11.0
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH pve-network 1/2] fix #7520: sdn: clean up dangling ACLs on resource deletion
2026-05-05 14:22 [PATCH access-control/network 0/2] fix #7520: sdn: clean up dangling ACLs on resource deletion David Riley
@ 2026-05-05 14:22 ` David Riley
2026-05-05 14:22 ` [PATCH pve-access-control 2/2] fix #7520: access-control: add SDN ACL cleanup helper David Riley
2026-05-07 13:03 ` [PATCH access-control/network 0/2] fix #7520: sdn: clean up dangling ACLs on resource deletion Stefan Hanreich
2 siblings, 0 replies; 4+ messages in thread
From: David Riley @ 2026-05-05 14:22 UTC (permalink / raw)
To: pve-devel; +Cc: David Riley
Add pruning mechanism to clean up orphaned SDN ACL entries by
comparing the current `running-config` with the newly compiled state
during `commit_config`.
This ensures state consistency for manual applies via the UI/API
as well as during the automatic configuration reload on system boot.
Covers resources tracked in the `running-config`:
* Zones
* VNets
* Fabrics
* Controllers
Signed-off-by: David Riley <d.riley@proxmox.com>
---
src/PVE/Network/SDN.pm | 45 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/src/PVE/Network/SDN.pm b/src/PVE/Network/SDN.pm
index 0bb36bf..0e802d6 100644
--- a/src/PVE/Network/SDN.pm
+++ b/src/PVE/Network/SDN.pm
@@ -12,6 +12,7 @@ use UUID;
use PVE::Cluster qw(cfs_read_file cfs_write_file cfs_lock_file);
use PVE::INotify;
+use PVE::AccessControl;
use PVE::RESTEnvironment qw(log_warn);
use PVE::RPCEnvironment;
use PVE::Tools qw(file_get_contents file_set_contents extract_param dir_glob_regex run_command);
@@ -227,11 +228,55 @@ sub compile_running_cfg {
}
sub commit_config {
+ my $old_cfg = cfs_read_file($RUNNING_CFG_FILENAME);
my $cfg = compile_running_cfg();
+ cleanup_sdn_acls($old_cfg, $cfg);
+
cfs_write_file($RUNNING_CFG_FILENAME, $cfg);
}
+sub cleanup_sdn_acls {
+ my ($old_cfg, $new_cfg) = @_;
+ return if !$old_cfg || !$new_cfg;
+
+ my @paths_to_delete = ();
+
+ my @types = qw(zones controllers fabrics);
+ foreach my $type (@types) {
+ if (my $old_ids = $old_cfg->{$type}->{ids}) {
+ my $new_ids = $new_cfg->{$type}->{ids} // {};
+
+ foreach my $id (keys %$old_ids) {
+ if (!$new_ids->{$id}) {
+ push @paths_to_delete, [$type, $id];
+ }
+ }
+ }
+ }
+
+ if (my $old_vnets = $old_cfg->{vnets}->{ids}) {
+ my $new_vnets = $new_cfg->{vnets}->{ids} // {};
+
+ foreach my $vnetid (keys %$old_vnets) {
+ if (!$new_vnets->{$vnetid}) {
+ my $zoneid = $old_vnets->{$vnetid}->{zone};
+
+ if ($zoneid) {
+ push @paths_to_delete, ['zones', $zoneid, $vnetid];
+ } else {
+ log_warn(
+ "SDN Cleanup: Could not find zone for VNet $vnetid, skipping ACL cleanup");
+ }
+ }
+ }
+ }
+
+ if (scalar(@paths_to_delete) > 0) {
+ PVE::AccessControl::remove_sdn_resource_access(\@paths_to_delete);
+ }
+}
+
sub has_pending_changes {
my $running_cfg = PVE::Network::SDN::running_config();
--
2.47.3
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH pve-access-control 2/2] fix #7520: access-control: add SDN ACL cleanup helper
2026-05-05 14:22 [PATCH access-control/network 0/2] fix #7520: sdn: clean up dangling ACLs on resource deletion David Riley
2026-05-05 14:22 ` [PATCH pve-network 1/2] " David Riley
@ 2026-05-05 14:22 ` David Riley
2026-05-07 13:03 ` [PATCH access-control/network 0/2] fix #7520: sdn: clean up dangling ACLs on resource deletion Stefan Hanreich
2 siblings, 0 replies; 4+ messages in thread
From: David Riley @ 2026-05-05 14:22 UTC (permalink / raw)
To: pve-devel; +Cc: David Riley
Add a helper to prune ACL nodes under the `/sdn/` path.
Traverse the internal tree to delete target nodes.
Signed-off-by: David Riley <d.riley@proxmox.com>
---
src/PVE/AccessControl.pm | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/src/PVE/AccessControl.pm b/src/PVE/AccessControl.pm
index 10e1f27..fe0c7a8 100644
--- a/src/PVE/AccessControl.pm
+++ b/src/PVE/AccessControl.pm
@@ -1891,6 +1891,46 @@ sub roles {
return $roles;
}
+sub remove_sdn_resource_access {
+ # $paths is e.g. [ ['zones', '<zone>'], ['zones', '<zone>', '<vnet>'] ]
+ my ($paths) = @_;
+
+ my $delSDNResourceFn = sub {
+ my $usercfg = cfs_read_file("user.cfg");
+ my $modified = 0;
+
+ foreach my $segments (@$paths) {
+ my @full_path = ('sdn', @$segments);
+ my $current = $usercfg->{acl_root};
+ my $parent = undef;
+ my $last_key = undef;
+ my $found = 1;
+
+ foreach my $step (@full_path) {
+ if ($current->{children} && $current->{children}->{$step}) {
+ $parent = $current;
+ $last_key = $step;
+ $current = $current->{children}->{$step};
+ } else {
+ $found = 0;
+ last;
+ }
+ }
+
+ if ($found && $parent && $last_key) {
+ delete $parent->{children}->{$last_key};
+ $modified = 1;
+ }
+ }
+
+ if ($modified) {
+ cfs_write_file("user.cfg", $usercfg);
+ }
+ };
+
+ lock_user_config($delSDNResourceFn, "SDN ACL cleanup failed");
+}
+
sub remove_vm_access {
my ($vmid) = @_;
my $delVMaccessFn = sub {
--
2.47.3
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH access-control/network 0/2] fix #7520: sdn: clean up dangling ACLs on resource deletion
2026-05-05 14:22 [PATCH access-control/network 0/2] fix #7520: sdn: clean up dangling ACLs on resource deletion David Riley
2026-05-05 14:22 ` [PATCH pve-network 1/2] " David Riley
2026-05-05 14:22 ` [PATCH pve-access-control 2/2] fix #7520: access-control: add SDN ACL cleanup helper David Riley
@ 2026-05-07 13:03 ` Stefan Hanreich
2 siblings, 0 replies; 4+ messages in thread
From: Stefan Hanreich @ 2026-05-07 13:03 UTC (permalink / raw)
To: pve-devel
Thanks for the series!
Would it be possible to send a v2 that also includes route-maps and
prefix-lists?
On 5/5/26 4:21 PM, David Riley wrote:
> Add pruning mechanism to clean up orphaned SDN ACL entries by
> comparing the current `running-config` with the newly compiled state
> during `commit_config`.
>
> This ensures state consistency for manual applies via the UI/API
> as well as during the automatic configuration reload on system boot.
> Covers resources tracked in the `running-config`:
> * Zones
> * VNets
> * Fabrics
> * Controllers
>
> Does not cover IPAMs and DNS as these are not staged.
>
>
> pve-network:
>
> David Riley (1):
> fix #7520: sdn: clean up dangling ACLs on resource deletion
>
> src/PVE/Network/SDN.pm | 45 ++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 45 insertions(+)
>
>
> pve-access-control:
>
> David Riley (1):
> fix #7520: access-control: add SDN ACL cleanup helper
>
> src/PVE/AccessControl.pm | 40 ++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 40 insertions(+)
>
>
> Summary over all repositories:
> 2 files changed, 85 insertions(+), 0 deletions(-)
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-05-07 13:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-05 14:22 [PATCH access-control/network 0/2] fix #7520: sdn: clean up dangling ACLs on resource deletion David Riley
2026-05-05 14:22 ` [PATCH pve-network 1/2] " David Riley
2026-05-05 14:22 ` [PATCH pve-access-control 2/2] fix #7520: access-control: add SDN ACL cleanup helper David Riley
2026-05-07 13:03 ` [PATCH access-control/network 0/2] fix #7520: sdn: clean up dangling ACLs on resource deletion Stefan Hanreich
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.