If a bridge has `bridge_ports` set to `none` we just skip the field.
Later we use the existance of the field to determine whether the type
should be `bridge`. This led to bridges without `bridge_ports` not
being recognized as bridges.

In the `/nodes/{}/network` we do permissions checks but only for ifaces
with type `bridge`(or `OVSBridge`). So interfaces were returned by the
endpoint even if the user did not have permissions the correct
permissions because the interface did not have type `bridge`.

This fixes this by also setting the type to `bridge` for empty bridges.

Signed-off-by: Hannes Laimer <h.lai...@proxmox.com>
---
 src/PVE/INotify.pm | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/PVE/INotify.pm b/src/PVE/INotify.pm
index bbcb9f8..5a42ddd 100644
--- a/src/PVE/INotify.pm
+++ b/src/PVE/INotify.pm
@@ -994,7 +994,10 @@ SECTION: while (defined($line = <$fh>)) {
                     } elsif ($id eq 'slaves' || $id eq 'bridge_ports') {
                         my $devs = {};
                         foreach my $p (split(/\s+/, $value)) {
-                            next if $p eq 'none';
+                            if ($p eq 'none') {
+                                $d->{'is_empty_bridge'} = 1;
+                                next;
+                            }
                             $devs->{$p} = 1;
                         }
                         my $str = join(' ', sort keys %{$devs});
@@ -1077,7 +1080,8 @@ OUTER:
 
         my $ip_link = $ip_links->{$altnames->{$iface} // $iface};
 
-        if (defined $d->{'bridge_ports'}) {
+        if (defined $d->{'bridge_ports'} || $d->{'is_empty_bridge'}) {
+            delete $d->{'is_empty_bridge'} if defined $d->{'is_empty_bridge'};
             $d->{type} = 'bridge';
             if (!defined($d->{bridge_stp})) {
                 $d->{bridge_stp} = 'off';
-- 
2.47.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to