From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id B0D041FF179 for ; Wed, 10 Dec 2025 19:42:02 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 702CD3028; Wed, 10 Dec 2025 19:42:40 +0100 (CET) From: Stefan Hanreich To: pve-devel@lists.proxmox.com Date: Wed, 10 Dec 2025 19:42:31 +0100 Message-ID: <20251210184236.448600-2-s.hanreich@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251210184236.448600-1-s.hanreich@proxmox.com> References: <20251210184236.448600-1-s.hanreich@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.224 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [network.pm, iproute2.pm] URIBL_SBL_A 0.1 Contains URL's A record listed in the Spamhaus SBL blocklist [188.114.96.3] Subject: [pve-devel] [PATCH pve-common 1/2] fix #7118: fix bridge port detection when plugging netdev with vlan X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" When tagging a network device with a VLAN tag, tap_plug checks if the bridge is vlan-aware and, if it isn't, creates a VLAN subinterface and a respective bridge for that VLAN for the physical interfaces that are enslaved on the bridge. The detection of physical interfaces relied on a regex that only allowed certain prefixes. Since the introduction of network-interface-pinning, the rules for network interface naming have been changed, and physical network interfaces are not restricted to certain prefixes anymore. Therefore, use the newly provided helper from IPRoute2 that uses `ip link` to obtain the physical bridge ports, instead of a regex. Signed-off-by: Stefan Hanreich --- src/PVE/IPRoute2.pm | 13 +++++++++++++ src/PVE/Network.pm | 12 ++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/PVE/IPRoute2.pm b/src/PVE/IPRoute2.pm index 128ad72..5f7b94c 100644 --- a/src/PVE/IPRoute2.pm +++ b/src/PVE/IPRoute2.pm @@ -39,6 +39,19 @@ sub ip_link_is_bridge_member($ip_link) { && $ip_link->{linkinfo}->{info_slave_kind} eq "bridge"; } +sub get_physical_bridge_ports($bridge, $ip_links = undef) { + $ip_links = ip_link_details() if !defined($ip_links); + + if (!ip_link_is_bridge($ip_links->{$bridge})) { + warn "passed link that isn't a bridge to get_physical_bridge_ports"; + return (); + } + + return grep { + ip_link_is_physical($ip_links->{$_}) && $ip_links->{$_}->{master} eq $bridge + } keys $ip_links->%*; +} + sub altname_mapping($ip_links) { $ip_links = ip_link_details() if !defined($ip_links); diff --git a/src/PVE/Network.pm b/src/PVE/Network.pm index 5100833..573e34e 100644 --- a/src/PVE/Network.pm +++ b/src/PVE/Network.pm @@ -4,6 +4,7 @@ use strict; use warnings; use PVE::INotify; +use PVE::IPRoute2; use PVE::ProcFSTools; use PVE::Tools qw(run_command lock_file); @@ -684,16 +685,7 @@ sub activate_bridge_vlan { my $bridgevlan = "${bridge}v$tag"; - my @ifaces = (); - my $dir = "/sys/class/net/$bridge/brif"; - PVE::Tools::dir_glob_foreach( - $dir, - '(((eth|bond)\d+|en[^.]+)(\.\d+)?)', - sub { - push @ifaces, $_[0]; - }, - ); - + my @ifaces = PVE::IPRoute2::get_physical_bridge_ports($bridge); die "no physical interface on bridge '$bridge'\n" if scalar(@ifaces) == 0; lock_network(sub { -- 2.47.3 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel