Commit c6b8cf83 authored by Kirk Webb's avatar Kirk Webb

Changes to support reporting back the port elvind bound to in the
management slice, and also sending this back to non-MS slivers.
parent ee658933
......@@ -30,7 +30,7 @@ use Exporter;
TMCCCMD_FIREWALLINFO TMCCCMD_EMULABCONFIG
TMCCCMD_CREATOR TMCCCMD_HOSTINFO TMCCCMD_LOCALIZATION
TMCCCMD_BOOTERRNO TMCCCMD_BOOTLOG TMCCCMD_BATTERY TMCCCMD_USERENV
TMCCCMD_TIPTUNNELS TMCCCMD_TRACEINFO
TMCCCMD_TIPTUNNELS TMCCCMD_TRACEINFO TMCCCMD_ELVINDPORT
);
# Must come after package declaration!
......@@ -170,6 +170,7 @@ my %commandset =
"userenv" => {TAG => "userenv"},
"tiptunnels" => {TAG => "tiptunnels"},
"traceinfo" => {TAG => "traceinfo"},
"elvindport" => {TAG => "elvindport"},
);
#
......@@ -224,6 +225,7 @@ sub TMCCCMD_BATTERY (){ $commandset{"battery"}->{TAG}; }
sub TMCCCMD_USERENV (){ $commandset{"userenv"}->{TAG}; }
sub TMCCCMD_TIPTUNNELS (){ $commandset{"tiptunnels"}->{TAG}; }
sub TMCCCMD_TRACEINFO (){ $commandset{"traceinfo"}->{TAG}; }
sub TMCCCMD_ELVINDPORT (){ $commandset{"elvindport"}->{TAG}; }
#
# Caller uses this routine to set configuration of this library
......
......@@ -240,6 +240,7 @@ COMMAND_PROTOTYPE(dotiptunnels);
COMMAND_PROTOTYPE(dorelayconfig);
COMMAND_PROTOTYPE(dotraceconfig);
COMMAND_PROTOTYPE(doltmap);
COMMAND_PROTOTYPE(doelvindport);
/*
* The fullconfig slot determines what routines get called when pushing
......@@ -324,7 +325,9 @@ struct command {
{ "userenv", FULLCONFIG_ALL, F_ALLOCATED, douserenv},
{ "tiptunnels", FULLCONFIG_ALL, F_ALLOCATED, dotiptunnels},
{ "traceinfo", FULLCONFIG_ALL, F_ALLOCATED, dotraceconfig },
{ "ltmap", FULLCONFIG_NONE, F_MINLOG|F_ALLOCATED, doltmap},
{ "ltmap", FULLCONFIG_NONE, F_MINLOG|F_ALLOCATED, doltmap},
{ "elvindport", FULLCONFIG_NONE, 0, doelvindport},
};
static int numcommands = sizeof(command_array)/sizeof(struct command);
......@@ -4536,9 +4539,10 @@ COMMAND_PROTOTYPE(dojailconfig)
*/
COMMAND_PROTOTYPE(doplabconfig)
{
MYSQL_RES *res;
MYSQL_RES *res, *res2;
MYSQL_ROW row;
char buf[MYBUFSIZE];
char *bufp = buf, *ebufp = &buf[MYBUFSIZE];
if (!reqp->isvnode) {
/* Silent error is fine */
......@@ -4552,22 +4556,47 @@ COMMAND_PROTOTYPE(doplabconfig)
res = mydb_query("select sshdport from nodes "
"where node_id='%s'",
1, reqp->nodeid);
/*
* .. And the elvind port.
*/
res2 = mydb_query("select attrvalue from node_attributes "
" where node_id='%s' and attrkey='elvind_port'",
1, reqp->pnodeid);
if (!res) {
if (res) {
if ((int)mysql_num_rows(res) > 0) {
row = mysql_fetch_row(res);
bufp += OUTPUT(bufp, ebufp-bufp, "SSHDPORT=%d ",
atoi(row[0]));
}
mysql_free_result(res);
}
if (res2) {
if ((int)mysql_num_rows(res2) > 0) {
row = mysql_fetch_row(res2);
bufp += OUTPUT(bufp, ebufp-bufp, "ELVIND_PORT=%d ",
atoi(row[0]));
}
else {
/*
* XXX: should not hardwire port number here, but what should
* I reference for it?
*/
bufp += OUTPUT(bufp, ebufp-bufp, "ELVIND_PORT=%d ", 2917);
}
mysql_free_result(res2);
}
if (!res || !res2) {
error("PLABCONFIG: %s: DB Error getting config!\n",
reqp->nodeid);
return 1;
}
if ((int)mysql_num_rows(res) == 0) {
mysql_free_result(res);
return 0;
}
row = mysql_fetch_row(res);
OUTPUT(buf, sizeof(buf), "SSHDPORT=%d\n", atoi(row[0]));
OUTPUT(bufp, ebufp-bufp, "\n");
client_writeback(sock, buf, strlen(buf), tcp);
mysql_free_result(res);
/* XXX Anything else? */
......@@ -6207,3 +6236,34 @@ COMMAND_PROTOTYPE(dotraceconfig)
return 0;
}
/*
* Acquire plab node elvind port update.
*
* Since there is (currently) no way to hard reserve a port on a plab node
* we might bind to a non-default port, and so must track this so that
* client vservers on the plab node know where to connect.
*
* XXX: should make sure it's the service slice reporting this.
*/
COMMAND_PROTOTYPE(doelvindport)
{
char buf[MYBUFSIZE];
unsigned int elvport = 0;
if (sscanf(rdata, "%u",
&elvport) != 1) {
strncpy(buf, rdata, 64);
error("ELVIND_PORT: %s: Bad arguments: %s...\n", reqp->nodeid,
buf);
return 1;
}
/*
* Now shove the elvin port # we got into the db.
*/
mydb_update("replace into node_attributes "
" values ('%s', '%s', %u)",
reqp->pnodeid, "elvind_port", elvport);
return 0;
}
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