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 <[email protected]>
---
 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
[email protected]
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to