Commit 7d087132 authored by Leigh B Stoller's avatar Leigh B Stoller

Small changes to support "direct" links between nodes. The main issue

is that the other side of the link is in the same place as switch info
would go, but which was generally ignored in the wrapper. Also, these
links do not need vlans, of course.
parent e550ccad
......@@ -3081,9 +3081,9 @@ sub AddNodeToSolution($$$)
return 0;
}
sub AddLinkToSolution($$$$$$$)
sub AddLinkToSolution($$$$$$$$)
{
my ($self, $vlink, $trivial, $nodeA, $portA, $nodeB, $portB) = @_;
my ($self, $vlink, $trivial, $direct, $nodeA, $portA, $nodeB, $portB) = @_;
#
# Map the solution back to our objects and store the results.
......@@ -3133,8 +3133,10 @@ sub AddLinkToSolution($$$$$$$)
$member0->_pnode($nodeA);
$member0->_pport($portA);
# For a special case, see below.
$member0->_lannode($nodeB);
$member0->_lanport($portB);
if (defined($nodeB)) {
$member0->_lannode($nodeB);
$member0->_lanport($portB);
}
}
}
elsif (($lan,$virtA) =
......@@ -3167,9 +3169,10 @@ sub AddLinkToSolution($$$$$$$)
}
$self->solution_plinks()->{$vlink} =
[$linktag,$virtlan,$trivial,$member0,$member1];
[$linktag,$virtlan,$trivial,$direct,$member0,$member1];
if (!$trivial) {
$self->printdb(" $vlink $nodeA$portA,$nodeB$portB\n");
$self->printdb(" $vlink $nodeA$portA,$nodeB$portB" .
($direct ? " (direct)" : "") . "\n");
}
else {
$self->printdb(" $vlink trivial\n");
......@@ -3233,6 +3236,7 @@ sub ReadTextSolution($$)
EDGEWHILE: while (<$input>) {
my ($vlink,$rawA,$rawB) = undef;
my $trivial = 0;
my $direct = 0;
/^End Edges$/ && last EDGEWHILE;
my @info = split;
......@@ -3249,6 +3253,7 @@ sub ReadTextSolution($$)
};
/^direct$/ && do {
($vlink,$rawA,$rawB) = @info[0,3,5];
$direct = 1;
last SWITCH1;
};
/^trivial$/ && do {
......@@ -3262,18 +3267,35 @@ sub ReadTextSolution($$)
}
my ($nodeportA,$nodeportB) = undef;
my ($switchportA,$switchportB) = undef;
my ($nodeA,$portA,$nodeB,$portB) = undef;
if (!$trivial) {
$nodeportA = getnodeport($rawA);
$nodeportB = getnodeport($rawB);
# Convert them back to node:iface format.
($nodeportA,$switchportA) = getnodeport($rawA);
print STDERR "*** Undefined nodeportA in $rawA\n"
if (!defined($nodeportA));
# Convert back to node:iface format.
$nodeportA =~ s/\//:/;
$nodeportB =~ s/\//:/;
($nodeA,$portA) = split(":", $nodeportA);
#
# A direct link between two nodes; $rawA holds both sides
# of the link (switchportA is really $nodeportB).
#
if ($direct && defined($switchportA)) {
$nodeportB = $switchportA;
$switchportB = undef;
}
else {
($nodeportB,$switchportB) = getnodeport($rawB);
print STDERR "*** Undefined nodeportB in $rawB\n"
if (!defined($nodeportB));
}
# Convert back to node:iface format.
$nodeportB =~ s/\//:/;
($nodeB,$portB) = split(":", $nodeportB);
}
$self->AddLinkToSolution($vlink, $trivial,
$self->AddLinkToSolution($vlink, $trivial, $direct,
$nodeA, $portA, $nodeB, $portB);
}
return 0;
......@@ -3355,7 +3377,7 @@ sub ReadRspecSolution($$)
my $vlink = "linksimple/$virtual_id/$virtA,$virtB";
$self->AddLinkToSolution($vlink, 0,
$self->AddLinkToSolution($vlink, 0, 0,
$nodeA, $portA, $nodeB, $portB);
}
else {
......@@ -3367,7 +3389,7 @@ sub ReadRspecSolution($$)
my $vlink = "linklan/$virtual_id/$virtA";
$self->AddLinkToSolution($vlink, 0, $nodeA, $portA);
$self->AddLinkToSolution($vlink, 0, 0, $nodeA, $portA);
}
}
}
......@@ -4184,7 +4206,8 @@ sub InterpLinks($)
my %plinks = %{ $self->solution_plinks() };
foreach my $plink (sort(keys(%plinks))) {
my ($linktag,$virtlan,$trivial,$member0,$member1) = @{$plinks{$plink}};
my ($linktag,$virtlan,$trivial,$direct,$member0,$member1) =
@{$plinks{$plink}};
my $lan = $virtlan->vname();
#
......@@ -4358,9 +4381,10 @@ sub InterpLinks($)
$self->printdb("LINK simple: $virtA,$virtB - ".
"$nodeA:$portA,$nodeB:$portB\n");
if ($virtlan->_layer() == 1) {
if ($virtlan->_layer() == 1 || $direct) {
#
# Just a wire.
# Just a wire. At layer two, its a wire between
# two nodes.
#
$protolink = ProtoLan->Create($experiment, $lan,
$self->impotent());
......@@ -6362,14 +6386,18 @@ sub UpLoadInterfaceSettings($)
}
# getnodeport(s)
# Takes a ports result from assign (mac0,mac1) and returns the
# first non-null one.
# Takes a ports result from assign (mac0,mac1) and converts null strings to undef.
sub getnodeport($)
{
my $macstring=$_[0];
my ($A,$B) = ($macstring =~ /^\(([^,]+),([^,]+)\)$/);
return (($A ne "(null)") ? $A : (($B ne "(null)") ? $B : "null/null"));
$A = undef
if ($A eq "(null)");
$B = undef
if ($B eq "(null)");
return ($A, $B);
}
# Get the type for an interface.
......
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