Commit 2d522296 authored by Leigh Stoller's avatar Leigh Stoller

Add versioning support. This has been a minor problem, and is going to

be a worse problem with remote nodes, where we will not be able to
keep everyone up to date like we can in the local testbed case. I ran
into this yesterday with the key distribution stuff for RON nodes,
which require incompatable changes to the accounts info that is
returned. So, tmcc now takes a [-v version] argument, which is passed
through to tmcd in the request field. tmcd passes that version number
(assumed to be an int) down, and the routines should look at that. We
will need to make some structural changes in tmcd as we get more
version skew, but for now this is fine. Anyway, tmcd/tmcc have a
compiled in DEFAULT_VERSION (see decls.h). If no version is supplied,
assume DEFAULT_VERSION (2), which covers all of the old images and yet
to be updated current images. As the new tmcc makes it out, versions
will be sent through. VERY IMPORTANT: The current version is placed in
libsetup.pm. When you make incompatible changes, bump the version
number is decls.h and libsetup.pm, recompile and install a new tmcc
and the new libsetup.pm on the clients (and of course, tmcd on the
server).

Fixes to termination; Add signal handlers for HUP,INT,TERM, and make
sure all the children get killed off before exiting. We still have
some problems though; I think the children should wait until the
current request is completed before exiting. I'll give that some more
thought though since it easy to mess that stuff up (leave zombies).

Add build_info[] to startup message to syslog. Good for debugging.
Some minor cleanup and restructuring. Mike is gonna hate it.
parent 89209d50
......@@ -4,3 +4,20 @@
#define TBSERVER_PORT 7777
#define MYBUFSIZE 1024
/*
* As the tmcd changes, incompatable changes with older version of
* the software cause problems. Starting with version 3, the client
* will tell tmcd what version they are. If no version is included,
* assume its DEFAULT_VERSION.
*
* Be sure to update the versions as the TMCD changes. Both the
* tmcc and tmcd have CURRENT_VERSION compiled in, so be sure to
* install new versions of each binary when the current version
* changes. libsetup.pm module also encodes a current version, so be
* sure to change it there too!
*
* Note, this is assumed to be an integer. No need for 3.23.479 ...
*/
#define DEFAULT_VERSION 2
#define CURRENT_VERSION 3
......@@ -24,14 +24,14 @@
void sigcatcher(int foo);
char *getbossnode(void);
#ifdef UDP
void doudp(int argc, char **argv, struct in_addr, int port);
void doudp(int, char **, int, struct in_addr, int);
#endif
char *usagestr =
"usage: tmcc [-u] [-p #] [-s server] <command>\n"
"usage: tmcc [-u] [-v versnum] [-p #] [-s server] <command>\n"
" -s server Specify a tmcd server to connect to\n"
" -p portnum Specify a port number to connect to\n"
" -v versnum Specify a version number for tmcd\n"
" -u Use UDP instead of TCP\n"
"\n";
......@@ -48,20 +48,18 @@ main(int argc, char **argv)
{
int sock, data, n, cc, ch, portnum;
struct sockaddr_in name;
#if 0
struct timeval tv;
#endif
struct hostent *he;
struct in_addr serverip;
char buf[MYBUFSIZE], *bp, *response = "";
char *bossnode = NULL;
int version = CURRENT_VERSION;
#ifdef UDP
int useudp = 0;
#endif
portnum = TBSERVER_PORT;
while ((ch = getopt(argc, argv, "s:p:u")) != -1)
while ((ch = getopt(argc, argv, "v:s:p:u")) != -1)
switch(ch) {
case 'p':
portnum = atoi(optarg);
......@@ -69,6 +67,9 @@ main(int argc, char **argv)
case 's':
bossnode = optarg;
break;
case 'v':
version = atoi(optarg);
break;
#ifdef UDP
case 'u':
useudp = 1;
......@@ -94,6 +95,9 @@ main(int argc, char **argv)
exit(1);
}
if (! version)
/*
* Handle built-in "bossinfo" command
*/
......@@ -104,7 +108,7 @@ main(int argc, char **argv)
#ifdef UDP
if (useudp) {
doudp(argc, argv, serverip, portnum);
doudp(argc, argv, version, serverip, portnum);
/*
* Never returns.
*/
......@@ -148,37 +152,20 @@ main(int argc, char **argv)
close(sock);
exit(1);
}
#if 0
#ifndef linux
tv.tv_sec = 30;
tv.tv_usec = 0;
if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) < 0) {
perror("setsockopt SO_RCVTIMEO");
close(sock);
exit(1);
}
#endif
#endif
/* Start with version number */
sprintf(buf, "VERSION=%d ", version);
/*
* Since we've gone through a getopt() pass, argv[0] is now the
* first argument
*/
switch(argc) {
case 1:
n = snprintf(buf, sizeof(buf) - 1, "%s", argv[0]);
break;
case 2:
n = snprintf(buf, sizeof(buf) - 1, "%s %s", argv[0], argv[1]);
break;
case 3:
n = snprintf(buf, sizeof(buf) - 1, "%s %s %s",
argv[0], argv[1], argv[2]);
break;
default:
fprintf(stderr, "Too many command arguments!\n");
exit(1);
n = strlen(buf);
while (argc && n < sizeof(buf)) {
n += snprintf(&buf[n], sizeof(buf) - n, "%s ", argv[0]);
argc--;
argv++;
}
if (n >= sizeof(buf)) {
fprintf(stderr, "Command too large!\n");
exit(1);
......@@ -253,7 +240,7 @@ getbossnode(void)
* Not very robust, send a single request, read a single reply.
*/
void
doudp(int argc, char **argv, struct in_addr serverip, int portnum)
doudp(int argc, char **argv, int vers, struct in_addr serverip, int portnum)
{
int sock, length, n, cc;
struct sockaddr_in name, client;
......@@ -271,26 +258,18 @@ doudp(int argc, char **argv, struct in_addr serverip, int portnum)
name.sin_addr = serverip;
name.sin_port = htons(portnum);
sprintf(buf, "VERSION=%d ", vers);
/*
* Since we've gone through a getopt() pass, argv[0] is now the
* first argument
*/
switch(argc) {
case 1:
n = snprintf(buf, sizeof(buf) - 1, "%s", argv[0]);
break;
case 2:
n = snprintf(buf, sizeof(buf) - 1, "%s %s", argv[0], argv[1]);
break;
case 3:
n = snprintf(buf, sizeof(buf) - 1, "%s %s %s",
argv[0], argv[1], argv[2]);
break;
default:
fprintf(stderr, "Too many command arguments!\n");
exit(1);
n = strlen(buf);
while (argc && n < sizeof(buf)) {
n += snprintf(&buf[n], sizeof(buf) - n, "%s ", argv[0]);
argc--;
argv++;
}
if (n >= sizeof(buf)) {
fprintf(stderr, "Command too large!\n");
exit(1);
......
This diff is collapsed.
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