[pve-devel] [PATCH pve-common 2/2] iproute2: add helper for querying vlan information
Stefan Hanreich
s.hanreich at proxmox.com
Thu Oct 30 16:48:09 CET 2025
'-compressvlans' is used by default, because PVE configures VLAN
1-4094 by default on all ports on a VLAN-aware bridge and having one
entry per VLAN in this case is quite excessive.
Signed-off-by: Stefan Hanreich <s.hanreich at proxmox.com>
---
src/PVE/IPRoute2.pm | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/src/PVE/IPRoute2.pm b/src/PVE/IPRoute2.pm
index 4e31376..fcacabf 100644
--- a/src/PVE/IPRoute2.pm
+++ b/src/PVE/IPRoute2.pm
@@ -55,4 +55,22 @@ sub altname_mapping($ip_links) {
return $altnames;
}
+sub get_vlan_information() {
+ my $bridge_output = '';
+
+ run_command(
+ [
+ 'bridge', '-compressvlan', '-json', 'vlan', 'show',
+ ],
+ outfunc => sub {
+ $bridge_output .= shift;
+ },
+ );
+
+ my $data = decode_json($bridge_output);
+ my %vlan_information = map { $_->{ifname} => $_ } $data->@*;
+
+ return \%vlan_information;
+}
+
1;
--
2.47.3
More information about the pve-devel
mailing list