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($$$) ...@@ -3081,9 +3081,9 @@ sub AddNodeToSolution($$$)
return 0; 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. # Map the solution back to our objects and store the results.
...@@ -3133,8 +3133,10 @@ sub AddLinkToSolution($$$$$$$) ...@@ -3133,8 +3133,10 @@ sub AddLinkToSolution($$$$$$$)
$member0->_pnode($nodeA); $member0->_pnode($nodeA);
$member0->_pport($portA); $member0->_pport($portA);
# For a special case, see below. # For a special case, see below.
$member0->_lannode($nodeB); if (defined($nodeB)) {
$member0->_lanport($portB); $member0->_lannode($nodeB);
$member0->_lanport($portB);
}
} }
} }
elsif (($lan,$virtA) = elsif (($lan,$virtA) =
...@@ -3167,9 +3169,10 @@ sub AddLinkToSolution($$$$$$$) ...@@ -3167,9 +3169,10 @@ sub AddLinkToSolution($$$$$$$)
} }
$self->solution_plinks()->{$vlink} = $self->solution_plinks()->{$vlink} =
[$linktag,$virtlan,$trivial,$member0,$member1]; [$linktag,$virtlan,$trivial,$direct,$member0,$member1];
if (!$trivial) { if (!$trivial) {
$self->printdb(" $vlink $nodeA$portA,$nodeB$portB\n"); $self->printdb(" $vlink $nodeA$portA,$nodeB$portB" .
($direct ? " (direct)" : "") . "\n");
} }
else { else {
$self->printdb(" $vlink trivial\n"); $self->printdb(" $vlink trivial\n");
...@@ -3233,6 +3236,7 @@ sub ReadTextSolution($$) ...@@ -3233,6 +3236,7 @@ sub ReadTextSolution($$)
EDGEWHILE: while (<$input>) { EDGEWHILE: while (<$input>) {
my ($vlink,$rawA,$rawB) = undef; my ($vlink,$rawA,$rawB) = undef;
my $trivial = 0; my $trivial = 0;
my $direct = 0;
/^End Edges$/ && last EDGEWHILE; /^End Edges$/ && last EDGEWHILE;
my @info = split; my @info = split;
...@@ -3249,6 +3253,7 @@ sub ReadTextSolution($$) ...@@ -3249,6 +3253,7 @@ sub ReadTextSolution($$)
}; };
/^direct$/ && do { /^direct$/ && do {
($vlink,$rawA,$rawB) = @info[0,3,5]; ($vlink,$rawA,$rawB) = @info[0,3,5];
$direct = 1;
last SWITCH1; last SWITCH1;
}; };
/^trivial$/ && do { /^trivial$/ && do {
...@@ -3262,18 +3267,35 @@ sub ReadTextSolution($$) ...@@ -3262,18 +3267,35 @@ sub ReadTextSolution($$)
} }
my ($nodeportA,$nodeportB) = undef; my ($nodeportA,$nodeportB) = undef;
my ($switchportA,$switchportB) = undef;
my ($nodeA,$portA,$nodeB,$portB) = undef; my ($nodeA,$portA,$nodeB,$portB) = undef;
if (!$trivial) { if (!$trivial) {
$nodeportA = getnodeport($rawA); ($nodeportA,$switchportA) = getnodeport($rawA);
$nodeportB = getnodeport($rawB); print STDERR "*** Undefined nodeportA in $rawA\n"
# Convert them back to node:iface format. if (!defined($nodeportA));
# Convert back to node:iface format.
$nodeportA =~ s/\//:/; $nodeportA =~ s/\//:/;
$nodeportB =~ s/\//:/;
($nodeA,$portA) = split(":", $nodeportA); ($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); ($nodeB,$portB) = split(":", $nodeportB);
} }
$self->AddLinkToSolution($vlink, $trivial, $self->AddLinkToSolution($vlink, $trivial, $direct,
$nodeA, $portA, $nodeB, $portB); $nodeA, $portA, $nodeB, $portB);
} }
return 0; return 0;
...@@ -3355,7 +3377,7 @@ sub ReadRspecSolution($$) ...@@ -3355,7 +3377,7 @@ sub ReadRspecSolution($$)
my $vlink = "linksimple/$virtual_id/$virtA,$virtB"; my $vlink = "linksimple/$virtual_id/$virtA,$virtB";
$self->AddLinkToSolution($vlink, 0, $self->AddLinkToSolution($vlink, 0, 0,
$nodeA, $portA, $nodeB, $portB); $nodeA, $portA, $nodeB, $portB);
} }
else { else {
...@@ -3367,7 +3389,7 @@ sub ReadRspecSolution($$) ...@@ -3367,7 +3389,7 @@ sub ReadRspecSolution($$)
my $vlink = "linklan/$virtual_id/$virtA"; 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($) ...@@ -4184,7 +4206,8 @@ sub InterpLinks($)
my %plinks = %{ $self->solution_plinks() }; my %plinks = %{ $self->solution_plinks() };
foreach my $plink (sort(keys(%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(); my $lan = $virtlan->vname();
# #
...@@ -4358,9 +4381,10 @@ sub InterpLinks($) ...@@ -4358,9 +4381,10 @@ sub InterpLinks($)
$self->printdb("LINK simple: $virtA,$virtB - ". $self->printdb("LINK simple: $virtA,$virtB - ".
"$nodeA:$portA,$nodeB:$portB\n"); "$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, $protolink = ProtoLan->Create($experiment, $lan,
$self->impotent()); $self->impotent());
...@@ -6362,14 +6386,18 @@ sub UpLoadInterfaceSettings($) ...@@ -6362,14 +6386,18 @@ sub UpLoadInterfaceSettings($)
} }
# getnodeport(s) # getnodeport(s)
# Takes a ports result from assign (mac0,mac1) and returns the # Takes a ports result from assign (mac0,mac1) and converts null strings to undef.
# first non-null one.
sub getnodeport($) sub getnodeport($)
{ {
my $macstring=$_[0]; my $macstring=$_[0];
my ($A,$B) = ($macstring =~ /^\(([^,]+),([^,]+)\)$/); 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. # 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