Commit a368b5a1 authored by Jonathon Duerig's avatar Jonathon Duerig

Explicitly check for switch flag in libvtop_test.

Previously, distinguishing between node-node and node-switch direct links had
been done implicitly by using (null) interfaces as a magic value. We can't
do that any more now that switches have proper interfaces.
parent ba1810f7
...@@ -4086,28 +4086,42 @@ sub ReadTextSolution($$) ...@@ -4086,28 +4086,42 @@ sub ReadTextSolution($$)
if (!$trivial) { if (!$trivial) {
($nodeportA,$switchportA) = getnodeport($rawA); ($nodeportA,$switchportA) = getnodeport($rawA);
if (defined($nodeportA)) {
# Convert back to node:iface format. if (! defined($nodeportA) || ! defined($switchportA)) {
$nodeportA =~ s/\//:/; tberror("Malformed interface pair A: $rawA\n");
($nodeA,$portA) = split(":", $nodeportA); return -1;
} }
# Convert back to node:iface format.
$nodeportA =~ s/\//:/;
($nodeA,$portA) = split(":", $nodeportA);
$switchportA =~ s/\//:/;
my ($switchA, $swportA) = split(":", $switchportA);
# #
# A direct link between two nodes; $rawA holds both sides # If the link is direct and switchA is not a switch, this is
# of the link (switchportA is really $nodeportB). # a link directly between two nodes:
# #
if ($direct && defined($switchportA)) { # $rawA hold both sides of the link (switchportA is really
# $nodeportB).
my $noderef = Node->Lookup($switchA);
if ($direct && ! $noderef->isswitch()) {
$nodeportB = $switchportA; $nodeportB = $switchportA;
$switchportB = undef; $switchportB = undef;
} }
else { else {
($nodeportB,$switchportB) = getnodeport($rawB); ($nodeportB,$switchportB) = getnodeport($rawB);
} }
if (defined($nodeportB)) {
# Convert back to node:iface format. if (! defined($nodeportA)) {
$nodeportB =~ s/\//:/; tberror("Malformed interface pair B: $rawB\n");
($nodeB,$portB) = split(":", $nodeportB); return -1;
} }
# Convert back to node:iface format.
$nodeportB =~ s/\//:/;
($nodeB,$portB) = split(":", $nodeportB);
} }
$self->AddLinkToSolution($vlink, $trivial, $direct, $self->AddLinkToSolution($vlink, $trivial, $direct,
$nodeA, $portA, $nodeB, $portB, $swpath); $nodeA, $portA, $nodeB, $portB, $swpath);
...@@ -8141,11 +8155,6 @@ sub getnodeport($) ...@@ -8141,11 +8155,6 @@ sub getnodeport($)
my $macstring=$_[0]; my $macstring=$_[0];
my ($A,$B) = ($macstring =~ /^\(([^,]+),([^,]+)\)$/); my ($A,$B) = ($macstring =~ /^\(([^,]+),([^,]+)\)$/);
$A = undef
if ($A eq "(null)");
$B = undef
if ($B eq "(null)");
return ($A, $B); return ($A, $B);
} }
......
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