From: Stefan Hanreich <s.hanreich@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH pve-common 2/3] iproute2: add helper for getting bridge port mappings
Date: Thu, 9 Jul 2026 15:28:54 +0200 [thread overview]
Message-ID: <20260709132857.239615-3-s.hanreich@proxmox.com> (raw)
In-Reply-To: <20260709132857.239615-1-s.hanreich@proxmox.com>
Add a new helper for getting all bridges and their enslaved ports.
This is particularly useful for the SDN VLAN and QinQ zones, which
require a list of all bridge ports for generating the configuration
when they utilize a non-VLAN-aware bridge. With this function, SDN can
pre-compute the list and then use it to lookup the bridge ports,
instead of recalculating the list for every vnet.
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
src/PVE/IPRoute2.pm | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/src/PVE/IPRoute2.pm b/src/PVE/IPRoute2.pm
index ae837dc..cef0cbc 100644
--- a/src/PVE/IPRoute2.pm
+++ b/src/PVE/IPRoute2.pm
@@ -127,4 +127,28 @@ sub get_vlan_information() {
return \%vlan_information;
}
+sub get_bridge_port_mapping($ip_links = undef) {
+ $ip_links = ip_link_details() if !defined($ip_links);
+
+ my $mapping = {};
+
+ for my $iface_name (keys $ip_links->%*) {
+ my $ip_link = $ip_links->{$iface_name};
+ next if !ip_link_is_bridge_member($ip_link);
+
+ if (!defined($ip_link->{master})) {
+ # should never happen, but handle the case nonetheless
+ warn "found bridge_member without master";
+ next;
+ }
+
+ push($mapping->{$ip_link->{master}}->@*, $iface_name)
+ if ip_link_is_physical($ip_link)
+ || ip_link_is_vlan($ip_link)
+ || ip_link_is_bond($ip_link);
+ }
+
+ return $mapping;
+}
+
1;
--
2.47.3
next prev parent reply other threads:[~2026-07-09 13:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-09 13:28 [PATCH common/network 0/3] Performance improvements for applying VLAN / QinQ zones Stefan Hanreich
2026-07-09 13:28 ` [PATCH pve-common 1/3] iproute2: restructure get_physical_bridge_ports Stefan Hanreich
2026-07-09 13:28 ` Stefan Hanreich [this message]
2026-07-09 13:28 ` [PATCH pve-network 3/3] fix #7738: zones: use pre-computed bridge port list Stefan Hanreich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260709132857.239615-3-s.hanreich@proxmox.com \
--to=s.hanreich@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox