[pve-devel] [PATCH manager v3 5/6] fix #3893: api: network: add bridge_vids parameter

Aaron Lauterer a.lauterer at proxmox.com
Wed Jul 3 10:01:46 CEST 2024


Signed-off-by: Aaron Lauterer <a.lauterer at proxmox.com>
---
changes since v2:
* added checks to handle empty lists

 PVE/API2/Network.pm | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/PVE/API2/Network.pm b/PVE/API2/Network.pm
index f39f04f5..dd3855d1 100644
--- a/PVE/API2/Network.pm
+++ b/PVE/API2/Network.pm
@@ -66,6 +66,11 @@ my $confdesc = {
 	type => 'boolean',
 	optional => 1,
     },
+    bridge_vids => {
+	description => "Specify the allowed vlans. For example: '2 4 100-200'. Only used if the bridge is VLAN aware.",
+	optional => 1,
+	type => 'string', format => 'pve-vlan-id-or-range-list',
+    },
     bridge_ports => {
 	description => "Specify the interfaces you want to add to your bridge.",
 	optional => 1,
@@ -469,6 +474,10 @@ __PACKAGE__->register_method({
 		    if ! grep { $_ eq $iface } @ports;
 	    }
 
+	    if ($param->{bridge_vids} && !PVE::Tools::check_list_empty($param->{bridge_vids})) {
+		raise_param_exc({ bridge_vids => "VLAN list items are empty" });
+	    }
+
 	    $ifaces->{$iface} = $param;
 
 	    PVE::INotify::write_file('interfaces', $config);
@@ -558,7 +567,11 @@ __PACKAGE__->register_method({
 	    foreach my $k (keys %$param) {
 		$ifaces->{$iface}->{$k} = $param->{$k};
 	    }
-	    
+
+	    if ($param->{bridge_vids} && !PVE::Tools::check_list_empty($param->{bridge_vids})) {
+		raise_param_exc({ bridge_vids => "VLAN list items are empty" });
+	    }
+
 	    PVE::INotify::write_file('interfaces', $config);
 	};
 
-- 
2.39.2





More information about the pve-devel mailing list