all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Stefan Hanreich <s.hanreich@proxmox.com>
To: pve-devel@lists.proxmox.com
Cc: Lukas Sichert <l.sichert@proxmox.com>,
	Gabriel Goller <g.goller@proxmox.com>
Subject: [PATCH pve-common v2 2/3] iproute2: add helper for getting bridge port mappings
Date: Mon, 19 Oct 2026 13:26:35 +0200	[thread overview]
Message-ID: <20261019112640.181849-3-s.hanreich@proxmox.com> (raw)
In-Reply-To: <20261019112640.181849-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>
Reviewed-by: Lukas Sichert <l.sichert@proxmox.com>
Tested-by: Lukas Sichert <l.sichert@proxmox.com>
Reviewed-by: Gabriel Goller <g.goller@proxmox.com>
Tested-by: Gabriel Goller <g.goller@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..1e440b8 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





  parent reply	other threads:[~2026-10-19 11:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-19 11:26 [PATCH common/network v2 0/3] Performance improvements for applying VLAN / QinQ zones Stefan Hanreich
2026-10-19 11:26 ` [PATCH pve-common v2 1/3] iproute2: restructure get_physical_bridge_ports Stefan Hanreich
2026-10-19 11:26 ` Stefan Hanreich [this message]
2026-10-19 11:26 ` [PATCH pve-network v2 3/3] fix #7738: zones: use pre-computed bridge port list Stefan Hanreich
2026-10-19 20:31 ` applied: [PATCH common/network v2 0/3] Performance improvements for applying VLAN / QinQ zones Thomas Lamprecht

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=20261019112640.181849-3-s.hanreich@proxmox.com \
    --to=s.hanreich@proxmox.com \
    --cc=g.goller@proxmox.com \
    --cc=l.sichert@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 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.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal