Commit 170541f1 authored by Leigh B Stoller's avatar Leigh B Stoller

Add call to SpanningTree() to create loop free version of path on

lans.
parent a87e7f4a
...@@ -27,6 +27,7 @@ use Lan; ...@@ -27,6 +27,7 @@ use Lan;
use OSinfo; use OSinfo;
use Port; use Port;
use English; use English;
use emutil qw(SpanningTree);
use Data::Dumper; use Data::Dumper;
use Carp; use Carp;
use POSIX; use POSIX;
...@@ -7572,6 +7573,12 @@ sub UploadVlans($) ...@@ -7572,6 +7573,12 @@ sub UploadVlans($)
} }
} }
$self->printdb("Merged $protolanB into $protolanA\n"); $self->printdb("Merged $protolanB into $protolanA\n");
if (defined($protolanA->GetAttribute("switchpath")) ||
defined($protolanB->GetAttribute("switchpath"))) {
$protolanA->SetAttribute("switchpath",
AddToSwitchPath($protolanA->GetAttribute("switchpath"),
$protolanB->GetAttribute("switchpath")));
}
$protolanB->Destroy(); $protolanB->Destroy();
goto again; goto again;
} }
...@@ -7579,6 +7586,34 @@ sub UploadVlans($) ...@@ -7579,6 +7586,34 @@ sub UploadVlans($)
} }
} }
} }
#
# Compute spanning tree for lan switch paths.
#
foreach my $protolan (ProtoLan->ProtoLanList()) {
my $swpath = $protolan->GetAttribute("switchpath");
if (defined($swpath) && $swpath ne "") {
my @edges = ();
# Convert from string to [[], []]
foreach my $edge (split(" ", $swpath)) {
my ($a,$b) = split(":", $edge);
push(@edges, [$a, $b]);
}
@edges = SpanningTree(\@edges);
# Convert back to string.
my @swpath = ();
foreach my $edge (@edges) {
my ($a, $b) = @$edge;
push(@swpath, "$a:$b");
}
$swpath = join(" ", @swpath);
if ($self->verbose()) {
print STDERR "$protolan Spanning Tree: @swpath\n";
}
$protolan->SetAttribute("switchpath", $swpath);
}
}
if (!($self->impotent() || $self->alloconly())) { if (!($self->impotent() || $self->alloconly())) {
$self->printdb("Uploading protolans table.\n"); $self->printdb("Uploading protolans table.\n");
...@@ -8710,6 +8745,8 @@ sub AddToSwitchPath($$) ...@@ -8710,6 +8745,8 @@ sub AddToSwitchPath($$)
return $new return $new
if (!defined($cur)); if (!defined($cur));
return $cur
if (!defined($new));
my @cur = split(" ", $cur); my @cur = split(" ", $cur);
my @new = split(" ", $new); my @new = split(" ", $new);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment