Commit 2572b356 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Fix to -ns output. Mike noticed that I was not outputting valid NS

stsyle routes for nodes that have multiple interfaces (thats a
restriction in our parser borne of expediency). So, when routing to
nodes that have more than one interface, force a net route instead of
a host route. No biggie.
parent f050b8c4
......@@ -132,13 +132,19 @@ my $index = 0;
# A map of lans, where each is a list of the members, indexed by lan.
my %lans = ();
# A reverse map (sorta). Map a pair of links back to the lan.
# A reverse map (sorta). Map a pair of links back to the lan they belong to.
my %rlans = ();
# The costs, indexed by lan This is kinda bogus, but since the cost
# The costs, indexed by lan. This is kinda bogus, but since the cost
# is the same for each member of a lan, no big deal.
my %costs = ();
# Number of links per node, indexed by node (vname). This is strictly
# for generating NS style output. When there is more than one link on
# a node, we *must* generate net routes instead of host routes, or the
# parser will be unhappy.
my %linkcount= ();
#
# Convert list of nodes into a map of $vname:$port to IP. We will need the
# IPs later when filling in the virt_routes table.
......@@ -149,6 +155,8 @@ while (my ($vname,$ips,$routertype) = $query_result->fetchrow_array) {
}
$dostatic++;
$linkcount{$vname} = 0;
foreach my $ipinfo (split(" ", $ips)) {
my ($port,$ip) = split(":", $ipinfo);
$ips{"$vname:$port"} = $ip;
......@@ -157,6 +165,7 @@ while (my ($vname,$ips,$routertype) = $query_result->fetchrow_array) {
$rmap{$index} = $vname;
$index++;
}
$linkcount{$vname} += 1;
}
}
......@@ -406,7 +415,7 @@ foreach my $route (keys(%routes)) {
}
if ($format eq "ns") {
print "\$${src} add-route ";
if ($type eq "host") {
if ($type eq "host" && $linkcount{$dst} == 1) {
print "\$${dst} \$${hop}\n";
}
else {
......
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