[pve-devel] [PATCH 3/3] Delayed vlan interface creation until all checks are done.

Pablo Ruiz Garcia pablo.ruiz at gmail.com
Wed Feb 12 08:55:30 CET 2014


Signed-off-by: Pablo Ruiz Garcia <pablo.ruiz at gmail.com>
---
 data/PVE/Network.pm |   20 +++++++++++---------
 1 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/data/PVE/Network.pm b/data/PVE/Network.pm
index 96cf20b..2fbb715 100644
--- a/data/PVE/Network.pm
+++ b/data/PVE/Network.pm
@@ -166,6 +166,14 @@ 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+)', sub {
+        push(@ifaces, $_[0]);
+    });
+
+    die "no physical interface on bridge '$bridge'\n" if $ifcount == 0;
+
     # add bridgevlan if it doesn't already exist
     if (! -d "/sys/class/net/$bridgevlan") {
         system("/sbin/brctl addbr $bridgevlan") == 0 ||
@@ -173,15 +181,9 @@ sub activate_bridge_vlan {
     }
 
     # for each physical interface (eth or bridge) bind them to bridge vlan
-    my $ifcount = 0;
-    my $dir = "/sys/class/net/$bridge/brif";
-    PVE::Tools::dir_glob_foreach($dir, '((eth|bond)\d+)', sub {
-        my ($slave) = @_;
-        activate_bridge_vlan_slave($bridgevlan, $slave, $tag);
-        $ifcount++;
-    });
-
-    die "no physical interface on bridge '$bridge'\n" if $ifcount == 0;
+    foreach my $iface (@ifaces) {
+        activate_bridge_vlan_slave($bridgevlan, $iface, $tag);
+    }
 
     #fixme: set other bridge flags
 
-- 
1.7.9




More information about the pve-devel mailing list