Delayed vlan interface creation until all checks are done.

Signed-off-by: Pablo Ruiz Garcia <pablo.ruiz@gmail.com>
This commit is contained in:
Pablo Ruiz Garcia 2014-02-12 08:55:30 +01:00 committed by Dietmar Maurer
parent eee4b32a65
commit c9030d977c

View File

@ -165,6 +165,14 @@ sub activate_bridge_vlan {
my $bridgevlan = "${bridge}v$tag"; 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 # add bridgevlan if it doesn't already exist
if (! -d "/sys/class/net/$bridgevlan") { if (! -d "/sys/class/net/$bridgevlan") {
system("/sbin/brctl addbr $bridgevlan") == 0 || system("/sbin/brctl addbr $bridgevlan") == 0 ||
@ -172,15 +180,9 @@ sub activate_bridge_vlan {
} }
# for each physical interface (eth or bridge) bind them to bridge vlan # for each physical interface (eth or bridge) bind them to bridge vlan
my $ifcount = 0; foreach my $iface (@ifaces) {
my $dir = "/sys/class/net/$bridge/brif"; activate_bridge_vlan_slave($bridgevlan, $iface, $tag);
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;
#fixme: set other bridge flags #fixme: set other bridge flags