From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 416B81FF0E0 for ; Thu, 09 Jul 2026 15:29:11 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 4DEBF214AC; Thu, 09 Jul 2026 15:29:10 +0200 (CEST) From: Stefan Hanreich To: pve-devel@lists.proxmox.com Subject: [PATCH pve-common 1/3] iproute2: restructure get_physical_bridge_ports Date: Thu, 9 Jul 2026 15:28:53 +0200 Message-ID: <20260709132857.239615-2-s.hanreich@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260709132857.239615-1-s.hanreich@proxmox.com> References: <20260709132857.239615-1-s.hanreich@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1783603736891 X-SPAM-LEVEL: Spam detection results: 0 DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: ZWCK2FAWF2P3HVPX3T6ED55SXOXWPST7 X-Message-ID-Hash: ZWCK2FAWF2P3HVPX3T6ED55SXOXWPST7 X-MailFrom: s.hanreich@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: By checking first if the interface is a member of the bridge, instead of determining its type, a lot of unnecessary checks are not performed since checking for membership first is a lot more discriminatory. When applying a SDN configuration with 100 VLAN VNets on a non-VLAN-aware bridge, this saves a significant amount of statements executed: without this optimization: Executed 438813 statements in 110ms with this optimization: Executed 3693 statements in 10.2ms Signed-off-by: Stefan Hanreich --- Notes: This is a remnant from an earlier approach where only the ip_link_details output was used, but the bridge ports were still recalculated. Nevertheless I decided to still include this patch instead of dropping it, since other call sites also profit from it. src/PVE/IPRoute2.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PVE/IPRoute2.pm b/src/PVE/IPRoute2.pm index 53a17b0..ae837dc 100644 --- a/src/PVE/IPRoute2.pm +++ b/src/PVE/IPRoute2.pm @@ -83,11 +83,11 @@ sub get_physical_bridge_ports($bridge, $ip_links = undef) { } return grep { - (ip_link_is_physical($ip_links->{$_}) + defined($ip_links->{$_}->{master}) + && $ip_links->{$_}->{master} eq $bridge + && (ip_link_is_physical($ip_links->{$_}) || ip_link_is_bond($ip_links->{$_}) || ip_link_is_vlan($ip_links->{$_})) - && defined($ip_links->{$_}->{master}) - && $ip_links->{$_}->{master} eq $bridge } keys $ip_links->%*; } -- 2.47.3