From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 723821FF09C for ; Mon, 19 Oct 2026 13:26:56 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 50FC221625; Mon, 19 Oct 2026 13:26:53 +0200 (CEST) From: Stefan Hanreich To: pve-devel@lists.proxmox.com Subject: [PATCH pve-common v2 1/3] iproute2: restructure get_physical_bridge_ports Date: Mon, 19 Oct 2026 13:26:34 +0200 Message-ID: <20261019112640.181849-2-s.hanreich@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261019112640.181849-1-s.hanreich@proxmox.com> References: <20261019112640.181849-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: 1792409207906 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.453 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust 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: R27HXMIT6PBQPI23DT2J2YDFKVDY6ZTN X-Message-ID-Hash: R27HXMIT6PBQPI23DT2J2YDFKVDY6ZTN 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 CC: Lukas Sichert , Gabriel Goller 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 Reviewed-by: Lukas Sichert Tested-by: Lukas Sichert Reviewed-by: Gabriel Goller Tested-by: Gabriel Goller --- 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