Commit 1dfb77af authored by Leigh Stoller's avatar Leigh Stoller

Add new syntax for modifying a link in link_config (with changes in

the link agent). You can now do this:

	link_config -s nodew1 testbed three-wireless lan0 ENABLE=yes

to bring a link up (or down; ENABLE=no). This just gets passed along
in the event arguments. Basically an alias for "tevc now lan0 UP/DOWN"
to make things a little easier. At present, wireless lans are brought
up/down with ifconfig since "txpower off" does not work properly.

I suppose I should add the equivalent changes to delay_config ...
parent 72b3d734
......@@ -317,6 +317,8 @@ callback(event_handle_t handle, event_notification_t notification, void *data)
char eventtype[TBDB_FLEN_EVEVENTTYPE];
char args[2 * BUFSIZ];
char cmd[2 * BUFSIZ];
char updown[BUFSIZ];
int doupdown = 0; /* 1 = before, 2 = after */
ifmap_t *mp;
event_notification_get_objname(handle, notification,
......@@ -351,11 +353,13 @@ callback(event_handle_t handle, event_notification_t notification, void *data)
* is also listening to these events.
*/
if (strcmp(eventtype, TBDB_EVENTTYPE_UP) == 0) {
sprintf(cmd, "iwconfig %s txpower auto", mp->iface);
/* sprintf(cmd, "iwconfig %s txpower auto", mp->iface); */
sprintf(cmd, "ifconfig %s up", mp->iface);
runcommand(cmd);
}
else if (strcmp(eventtype, TBDB_EVENTTYPE_DOWN) == 0) {
sprintf(cmd, "iwconfig %s txpower off", mp->iface);
/* sprintf(cmd, "iwconfig %s txpower off", mp->iface); */
sprintf(cmd, "ifconfig %s down", mp->iface);
runcommand(cmd);
}
else if (strcmp(eventtype, TBDB_EVENTTYPE_MODIFY) == 0) {
......@@ -419,7 +423,28 @@ callback(event_handle_t handle, event_notification_t notification, void *data)
/*
* Okay, now do something with setting and value.
*/
if (! strcasecmp("sensitivity", setting)) {
if (! strcasecmp("enable", setting)) {
/*
* Alias for UP/DOWN events above. Note that
* we want to run this first/last.
*/
if (! strcasecmp("yes", value)) {
doupdown = 2;
sprintf(updown,
"ifconfig %s up", mp->iface);
}
else if (! strcasecmp("no", value)) {
doupdown = 1;
sprintf(updown,
"ifconfig %s down", mp->iface);
}
else {
error("Ignoring setting: %s=%s\n",
setting, value);
continue;
}
}
else if (! strcasecmp("sensitivity", setting)) {
cp += OUTPUT(cp, ecp - cp, " sens %s", value);
}
else if (! strcasecmp("txpower", setting)) {
......@@ -469,8 +494,16 @@ callback(event_handle_t handle, event_notification_t notification, void *data)
}
info("%s\n", cmd);
}
if (doupdown == 1) {
runcommand(updown);
}
if (strlen(cmd) > cmdlen)
runcommand(cmd);
if (doupdown == 2) {
runcommand(updown);
}
}
else if (debug) {
info("Ignoring event: %s %s %s\n", objname, eventtype, args);
......
......@@ -16,7 +16,7 @@ sub usage()
{
print(STDERR
"Usage: link_config [-m] [-d] [-s vnode] <pid> <eid> <link>".
" PARAM=VALUE ...\n".
" [PARAM=VALUE ...\n".
"Required: pid, eid, link, and at least one parameter to change!\n".
" pid = Project ID\n".
" eid = Experiment ID\n".
......@@ -25,8 +25,10 @@ sub usage()
"Options:\n".
" -d = turn on debugging\n".
" -s = Select the source of the link to determine which pipe\n".
" -m = Modify the base experiment in addition to current state.\n"
);
" -m = Modify the base experiment in addition to current state.\n".
"Special PARAM:\n".
" ENABLE=yes/no - Bring the link up or down (or ENABLE=up/down)".
"\n");
# Web interface cares about this return value!
exit(2);
}
......@@ -77,6 +79,7 @@ my $pid = shift(@ARGV);
my $eid = shift(@ARGV);
my $link = shift(@ARGV);
my $modify = 0;
my $enable; # Special case for bringing interface up/down.
my $srcvnode;
my $member; # For operating on virt_lans table (vname:port)
my %physmap; # For operating on the interface_settings table (pcXXX)
......@@ -203,6 +206,20 @@ while (@ARGV) {
my $key = $1;
my $val = $2;
if ($key eq "enable" || $key eq "ENABLE") {
if ($val eq "yes" || $val eq "up") {
$enable = "yes";
}
elsif ($val eq "no" || $val eq "no") {
$enable = "no";
}
else {
die("*** $0:\n".
" Should be ENABLE=yes/no or ENABLE=up/down!\n");
}
next;
}
if (! TBcheck_dbslot($key, "virt_lan_settings", "capkey",
TBDB_CHECKDBSLOT_WARN|TBDB_CHECKDBSLOT_ERROR)) {
die("*** $0:\n".
......@@ -348,6 +365,11 @@ $inject_string .= "-${srcvnode} "
$inject_string .= " modify ";
# Add in enable=yes/no first.
if (defined($enable)) {
$inject_string .= "enable=${enable} ";
}
# Append the parameters.
foreach my $key (keys(%config)) {
my $val = $config{$key};
......
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