Commit c0818bff authored by Leigh B. Stoller's avatar Leigh B. Stoller

Back out previous revision (-j); linkmap is now generated on

experimental nodes from the topomap.

"static" routing now implies ddijk routing, but since old images won't
have any of that support, we still have to generate routes and store
them in the DB. However, only doing this when the number of nodes in
the experiment is less than 250; otherwise print a warning and refuse
to generate the routes.

Also add "static-old" so that people can request/force old static
routing no matter how big the experiment.
parent 423bcbb7
......@@ -18,8 +18,6 @@ sub usage()
{
print("Usage: staticroutes [-n [-s|-l|-b]] [-d] [-m] [-f] [-t] <pid> <eid>".
"\n".
" staticroutes -j [-n] [-f] [-d] <pid> <eid>\n".
" Use -j to generate linkmap only and exit.\n".
" Use -n to print routes, but leave the DB alone.\n".
" Use -s (with -n) to print routes in NS format.\n".
" Use -b (with -n) to print routes in Freebsd format.\n".
......@@ -44,8 +42,6 @@ my $memdebug = 0;
my $routecalc = "$TB/libexec/routecalc";
my $impotent = 0;
my $force = 0;
my $dolinkmap = 0;
my $linkmapname = "linkmap";
my $optimize = 1;
my $edgeoptimize= 0; # Turned off till netmask problem can be fixed
my $format = "";
......@@ -101,9 +97,6 @@ if (defined($options{"b"})) {
if (defined($options{"l"})) {
$format = "suxs";
}
if (defined($options{"j"})) {
$dolinkmap = 1;
}
if ($format && !$impotent) {
usage();
}
......@@ -140,9 +133,6 @@ if (!$query_result->numrows) {
exit(0);
}
# A Flag.
my $dostatic = 0;
# A map of ips for each node, indexed by vname:port.
my %ips = ();
......@@ -175,16 +165,46 @@ my %nodeportlist = ();
# Map vname:port (member) to the lan its in.
my %nodeport2lan = ();
#
# Look to see if any nodes want static routing. We create static routes
# if any node specifies static-old, or if any node specifies static and
# the number of nodes is less then 250. More then 250 nodes, the user has
# to be using a current image that supports ddijk, and so do not want to
# clog the DB with a zillion routes.
#
my $staticO = 0;
my $staticN = 0;
if (!$force) {
while (my (undef,undef,$routertype) = $query_result->fetchrow_array()) {
if ($routertype eq "static-old") {
$staticO++;
}
elsif ($routertype eq "static") {
$staticN++;
}
}
# No static routing of any kind.
exit(0)
if (! ($staticO || $staticN));
if ($staticN > 250) {
warn("*** $0:\n".
" WARNING: More then 250 nodes; ".
"refusing to use centralized static routes!\n".
" You must use an image that supports distributed static ".
"route calculation.\n");
exit(0);
}
$query_result->dataseek(0);
}
#
# 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.
#
while (my ($vname,$ips,$routertype) = $query_result->fetchrow_array) {
if (!$force && $routertype ne "static") {
next;
}
$dostatic++;
while (my ($vname,$ips,undef) = $query_result->fetchrow_array) {
$linkcount{$vname} = 0;
if (! defined($nodeportlist{$vname}) ) {
......@@ -204,11 +224,6 @@ while (my ($vname,$ips,$routertype) = $query_result->fetchrow_array) {
}
}
if (! $dostatic) {
warn("No nodes requested static routing in $pid/$eid. This is okay!\n");
exit(0);
}
#
# Now get the lans.
#
......@@ -231,73 +246,6 @@ while (my ($vname,$member,$cost,$mask) = $query_result->fetchrow_array) {
$masks{$vname} = $mask;
}
#
# if generating just a linkmap, so that and exit. This format was specified
# by Jon, and is intended to be used as input to his route calculator that
# runs on the nodes.
#
if ($dolinkmap) {
if (!$impotent) {
open(MAP, "> $linkmapname") or
die("Could not create $linkmapname: $!\n");
}
my $edges = 0;
foreach my $lan (keys(%lans)) {
my @members = @{$lans{$lan}};
for (my $i = 0; $i < scalar(@members); $i++) {
for (my $j = $i; $j < scalar(@members); $j++) {
my $member1 = $members[$i];
my $member2 = $members[$j];
$edges++
if ($member1 ne $member2);
}
}
}
if ($impotent) {
print "$index $edges\n";
}
else {
print MAP "$index $edges\n";
}
foreach my $lan (keys(%lans)) {
my @members = @{$lans{$lan}};
for (my $i = 0; $i < scalar(@members); $i++) {
for (my $j = $i; $j < scalar(@members); $j++) {
my $member1 = $members[$i];
my $member2 = $members[$j];
if ($member1 ne $member2) {
my ($node1,$port1) = split(":", $member1);
my ($node2,$port2) = split(":", $member2);
my $id1 = $map{$node1};
my $id2 = $map{$node2};
if ($debug) {
print STDERR "$member1($id1) $member2($id2)\n";
}
if ($impotent) {
print "$node1 " . $ips{$member1} . " " .
"$node2 " . $ips{$member2} . " $costs{$lan}\n";
}
else {
print MAP "$node1 " . $ips{$member1} . " " .
"$node2 " . $ips{$member2} . " $costs{$lan}\n";
}
}
}
}
}
close(MAP)
if (!$impotent);
exit(0);
}
#
# We use perl IPC goo to create a child we can both write to and read from
# (normal perl I/O provides just unidirectional I/O to a process).
......
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