From: Stefan Hanreich <s.hanreich@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH pve-common 1/2] fix #7118: fix bridge port detection when plugging netdev with vlan
Date: Wed, 10 Dec 2025 19:42:31 +0100 [thread overview]
Message-ID: <20251210184236.448600-2-s.hanreich@proxmox.com> (raw)
In-Reply-To: <20251210184236.448600-1-s.hanreich@proxmox.com>
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 <s.hanreich@proxmox.com>
---
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
next prev parent reply other threads:[~2025-12-10 18:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-10 18:42 [pve-devel] [PATCH common/manager/network 0/4] trixie: fix VLAN handling on vlan-unaware bridges with pinned NIC names Stefan Hanreich
2025-12-10 18:42 ` Stefan Hanreich [this message]
2025-12-10 18:42 ` [pve-devel] [PATCH pve-common 2/2] iproute2: add helpers for detecting vlan-aware bridges Stefan Hanreich
2025-12-10 19:29 ` [pve-devel] applied: " Thomas Lamprecht
2025-12-10 18:42 ` [pve-devel] [PATCH pve-manager 1/1] pve-sdn-commit: run for vlan/qinq zones on non-vlan-aware bridges Stefan Hanreich
2025-12-10 18:42 ` [pve-devel] [PATCH pve-network 1/1] fix #6806: vlan: qinq: fix bridge port detection Stefan Hanreich
2025-12-10 19:32 ` [pve-devel] applied: " 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=20251210184236.448600-2-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