Commit 142fd18e authored by Leigh Stoller's avatar Leigh Stoller

Fix up some inconsistencies between the parser and delay config that

was causing lans to get improper delay/loss settings. Also add stern
warnings about using linktest or some other testing mechanism to make
sure that traffic shaping is set properly.
parent 60f03ff7
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# #
# EMULAB-COPYRIGHT # EMULAB-COPYRIGHT
# Copyright (c) 2000-2005 University of Utah and the Flux Group. # Copyright (c) 2000-2006 University of Utah and the Flux Group.
# All rights reserved. # All rights reserved.
# #
...@@ -40,7 +40,7 @@ sub usage() ...@@ -40,7 +40,7 @@ sub usage()
# Web interface cares about this return value! # Web interface cares about this return value!
exit(2); exit(2);
} }
my $optlist = "dms:"; my $optlist = "dms:c";
# #
# Configure variables # Configure variables
...@@ -50,6 +50,7 @@ my $TBOPS = "@TBOPSEMAIL@"; ...@@ -50,6 +50,7 @@ my $TBOPS = "@TBOPSEMAIL@";
my $TEVC = "$TB/bin/tevc"; my $TEVC = "$TB/bin/tevc";
my $GENTOPO = "$TB/libexec/gentopofile"; my $GENTOPO = "$TB/libexec/gentopofile";
my $debug = 0; my $debug = 0;
my $compatmode = 0;
# #
# Testbed Support libraries # Testbed Support libraries
...@@ -83,6 +84,9 @@ if (! getopts($optlist, \%options)) { ...@@ -83,6 +84,9 @@ if (! getopts($optlist, \%options)) {
if (defined($options{"d"})) { if (defined($options{"d"})) {
$debug = 1; $debug = 1;
} }
if (defined($options{"c"})) {
$compatmode = 1;
}
# Functions # Functions
...@@ -239,7 +243,7 @@ foreach my $key (keys(%config)) { ...@@ -239,7 +243,7 @@ foreach my $key (keys(%config)) {
} }
# #
# These map the names I'm using in the config hash (which correspond # These map the names I am using in the config hash (which correspond
# to the DB slot names) into the event parameter names to send over to the # to the DB slot names) into the event parameter names to send over to the
# delay agent. # delay agent.
# #
...@@ -309,7 +313,25 @@ $inject_string .= " modify "; ...@@ -309,7 +313,25 @@ $inject_string .= " modify ";
foreach my $key (keys(%config)) { foreach my $key (keys(%config)) {
my $val = $config{$key}; my $val = $config{$key};
my $str = $agentmap{$key}; my $str = $agentmap{$key};
#
# When changing an entire lan, we have to adjust delay/loss since
# there is a delay *to* the lan and a delay *from* the lan.
# We do not do this for links since there is just a single delay.
# When changing a single node in a lan, we fall back to the way things
# operate in the parser, which is that the user intended to change both
# directions to exactly this value.
#
if (!$islink && !defined($srcvnode) && !$compatmode) {
if ($key eq "delay") {
# This follows what is done in the parser.
$val = $val / 2.0;
}
else {
# This follows what is done in the parser.
$val = 1-sqrt(1-$val);
}
}
$inject_string .= "${str}=$val "; $inject_string .= "${str}=$val ";
} }
if ($debug) { if ($debug) {
...@@ -319,6 +341,13 @@ if ($debug) { ...@@ -319,6 +341,13 @@ if ($debug) {
system($inject_string) && system($inject_string) &&
die("*** $0:\n". die("*** $0:\n".
" Failed to inject delay update event!\n"); " Failed to inject delay update event!\n");
print "*** WARNING:\n";
print " You should *always* test your links and lans to make sure they\n";
print " are behaving as you expect. You can do this by hand with ping,\n";
print " or you can use Emulab's LinkTest feature.\n";
print " Type 'linktest' into the Emulab search box to find out how to ".
"use it.\n";
exit(0); exit(0);
...@@ -395,6 +424,25 @@ sub ChangeDelayConfig() { ...@@ -395,6 +424,25 @@ sub ChangeDelayConfig() {
$query_clause .= "q0_${1}=$val,q1_${1}=$val"; $query_clause .= "q0_${1}=$val,q1_${1}=$val";
} }
else { else {
#
# When changing an entire lan, we have to adjust delay/loss
# since there is a delay *to* the lan and a delay *from*
# the lan. We do not do this for links since there is just
# a single delay. When changing a single node in a lan, we
# fall back to the way things operate in the parser, which
# is that the user intended to change both directions to
# exactly this value.
#
if (!$islink && !defined($srcvnode) && !$compatmode) {
if ($key eq "delay") {
# This follows what is done in the parser.
$val = $val / 2.0;
}
else {
# This follows what is done in the parser.
$val = 1-sqrt(1-$val);
}
}
$query_clause .= "${key}0=$val,${key}1=$val"; $query_clause .= "${key}0=$val,${key}1=$val";
} }
} }
...@@ -460,6 +508,16 @@ sub ChangeLinkDelayConfig() { ...@@ -460,6 +508,16 @@ sub ChangeLinkDelayConfig() {
foreach my $key (keys(%config)) { foreach my $key (keys(%config)) {
my $val = $config{$key}; my $val = $config{$key};
if (!$islink && !defined($srcvnode) && !$compatmode) {
if ($key eq "delay") {
# This follows what is done in the parser.
$val = $val / 2.0;
}
else {
# This follows what is done in the parser.
$val = 1-sqrt(1-$val);
}
}
push(@query_clauses, "${key}=$val"); push(@query_clauses, "${key}=$val");
# #
...@@ -498,114 +556,118 @@ sub ChangeVirtLans() { ...@@ -498,114 +556,118 @@ sub ChangeVirtLans() {
my @query_clauses; my @query_clauses;
my $query_string; my $query_string;
my @query_clauses2; my @query_clauses2;
# #
# When changing an entire link or lan symmetrically its easy; they can # The first case is for changing a node in a duplex link asymmetrically.
# be done the same. When changing one node in a lan (symmetrically),
# the numbers are slightly different for delay/lossrate, but otherwise
# its the same operation, except for operating on a single node.
# #
if (!defined($srcvnode) || !$islink) { if ($islink && defined($srcvnode)) {
#
# In a duplex link the delay/bw/plr params are split between the
# two virt_lan members using the "r" params to hold the "from
# switch" half of the value. This makes it rather confusing.
#
foreach my $key (keys(%config)) { foreach my $key (keys(%config)) {
my $val = $config{$key}; my $val = $config{$key};
if ($key eq "delay") { if ($key eq "delay") {
my $delay = $val; my $delay = $val / 2.0;
# This follows what is done in the parser.
$delay = $delay / 2.0
if ($islink);
push(@query_clauses, "delay=$delay"); push(@query_clauses, "delay=$delay");
push(@query_clauses, "rdelay=$delay"); push(@query_clauses2, "rdelay=$delay");
} }
elsif ($key eq "lossrate") { elsif ($key eq "lossrate") {
my $lossrate = $val; my $lossrate = 1-sqrt(1-$val);
# This follows what is done in the parser.
$lossrate = 1-sqrt(1-$lossrate)
if ($islink);
push(@query_clauses, "lossrate=$lossrate"); push(@query_clauses, "lossrate=$lossrate");
push(@query_clauses, "rlossrate=$lossrate"); push(@query_clauses2, "rlossrate=$lossrate");
} }
elsif ($key eq "bandwidth") { elsif ($key eq "bandwidth") {
push(@query_clauses, "bandwidth=$val"); push(@query_clauses, "bandwidth=$val");
push(@query_clauses, "rbandwidth=$val"); push(@query_clauses2, "rbandwidth=$val");
} }
else { else {
push(@query_clauses, "$key=$val"); push(@query_clauses, "$key=$val");
} }
} }
$query_string = "update virt_lans set ". $query_string = "update virt_lans set ".
join(",", @query_clauses) . join(",", @query_clauses) .
" where pid='$pid' and eid='$eid' and vname='$link'"; " where pid='$pid' and eid='$eid' and ".
" vname='$link' and member like '${srcvnode}:%'";
#
# A lan node change since it cannot be a link if srcvnode defined.
#
if (defined($srcvnode)) {
$query_string .= " and member like '${srcvnode}:%'";
}
if ($debug) { if ($debug) {
print "$query_string\n"; print "$query_string\n";
} }
DBQueryFatal($query_string); DBQueryFatal($query_string);
if (@query_clauses2) {
$query_string =
"update virt_lans set ".
join(",", @query_clauses2) .
" where pid='$pid' and eid='$eid' and ".
" vname='$link' and member not like '${srcvnode}:%'";
if ($debug) {
print "$query_string\n";
}
DBQueryFatal($query_string);
}
} }
else { else {
# #
# Here we change a duplex link asymmetrically. In a duplex link # When changing an entire link or lan symmetrically its easy; they can
# the delay/bw/plr params are split between the two virt_lan # be done the same. When changing one node in a lan (symmetrically),
# members using the "r" params to hold the "from switch" half of # the numbers are slightly different for delay/lossrate, but otherwise
# the value. This makes it rather confusing. # its the same operation, except for operating on a single node.
# #
foreach my $key (keys(%config)) { foreach my $key (keys(%config)) {
my $val = $config{$key}; my $val = $config{$key};
if ($key eq "delay") { if ($key eq "delay") {
my $delay = $val / 2.0; my $delay = $val;
push(@query_clauses, "delay=$delay"); # This follows what is done in the parser;
push(@query_clauses2, "rdelay=$delay"); # See tb-set-node-lan-delay
$delay = $delay / 2.0
if (!defined($srcvnode));
push(@query_clauses, "delay=$delay");
push(@query_clauses, "rdelay=$delay");
} }
elsif ($key eq "lossrate") { elsif ($key eq "lossrate") {
my $lossrate = 1-sqrt(1-$val); my $lossrate = $val;
# This follows what is done in the parser.
# See tb-set-node-lan-lossrate
$lossrate = 1-sqrt(1-$lossrate)
if (!defined($srcvnode));
push(@query_clauses, "lossrate=$lossrate"); push(@query_clauses, "lossrate=$lossrate");
push(@query_clauses2, "rlossrate=$lossrate"); push(@query_clauses, "rlossrate=$lossrate");
} }
elsif ($key eq "bandwidth") { elsif ($key eq "bandwidth") {
push(@query_clauses, "bandwidth=$val"); push(@query_clauses, "bandwidth=$val");
push(@query_clauses2, "rbandwidth=$val"); push(@query_clauses, "rbandwidth=$val");
} }
else { else {
push(@query_clauses, "$key=$val"); push(@query_clauses, "$key=$val");
} }
} }
$query_string = "update virt_lans set ". $query_string = "update virt_lans set ".
join(",", @query_clauses) . join(",", @query_clauses) .
" where pid='$pid' and eid='$eid' and ". " where pid='$pid' and eid='$eid' and vname='$link'";
" vname='$link' and member like '${srcvnode}:%'";
#
# A lan node change since it cannot be a link if srcvnode defined.
#
if (defined($srcvnode)) {
$query_string .= " and member like '${srcvnode}:%'";
}
if ($debug) { if ($debug) {
print "$query_string\n"; print "$query_string\n";
} }
DBQueryFatal($query_string); DBQueryFatal($query_string);
if (@query_clauses2) {
$query_string =
"update virt_lans set ".
join(",", @query_clauses2) .
" where pid='$pid' and eid='$eid' and ".
" vname='$link' and member not like '${srcvnode}:%'";
if ($debug) {
print "$query_string\n";
}
DBQueryFatal($query_string);
}
} }
# #
# Now we need to regen the linktest map file ... # Now we need to regen the linktest map file ...
......
<?php <?php
# #
# EMULAB-COPYRIGHT # EMULAB-COPYRIGHT
# Copyright (c) 2000-2005 University of Utah and the Flux Group. # Copyright (c) 2000-2006 University of Utah and the Flux Group.
# All rights reserved. # All rights reserved.
# #
include("defs.php3"); include("defs.php3");
...@@ -491,6 +491,12 @@ echo "<br> ...@@ -491,6 +491,12 @@ echo "<br>
<a href=linktest.php3?pid=$pid&eid=$eid>Linktest</a> to make sure the <a href=linktest.php3?pid=$pid&eid=$eid>Linktest</a> to make sure the
links are configured properly,<br> links are configured properly,<br>
but <b><em>only</em></b> if you clicked the 'Save' box above!\n"; but <b><em>only</em></b> if you clicked the 'Save' box above!\n";
echo "<br><br>
<b>We strongly recommend that you always use
<a href=linktest.php3?pid=$pid&eid=$eid>Linktest</a> or some
other testing mechanism to ensure that your links and lans are
behaving as you expect them to.</b>\n";
} }
PAGEFOOTER(); PAGEFOOTER();
......
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