#include <afsconfig.h>
#include <afs/param.h>
+#include <afs/stds.h>
#include <roken.h>
-#include <afs/stds.h>
-#include <sys/types.h>
-#ifdef HAVE_TIME_H
-#include <time.h>
-#endif
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
#ifdef AFS_NT40_ENV
-#include <winsock2.h>
#include <WINNT/afsevent.h>
#endif
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
#ifdef HAVE_SYS_FILE_H
#include <sys/file.h>
#endif
-#ifdef HAVE_NETDB_H
-#include <netdb.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif
-#include <stdio.h>
-#include <string.h>
#include <ctype.h>
#include <afs/afsutil.h>
#include <afs/cmd.h>
#include <lock.h>
#include <ubik.h>
+
#include "vlserver.h"
void fill_listattributes_entry(struct VldbListByAttributes *, char **, int);
"ListAttributes",
"LinkedList",
"GetStats",
- "Probe",
+ "Probe", /* RPC is ProbeServer */
"GetAddrs",
"ChangeAddr",
"CreateEntryN",
/* Almost identical's to pr_Initialize in vlserver/pruser.c */
afs_int32
-vl_Initialize(int auth, char *confDir, int server, char *cellp)
+vl_Initialize(char *confDir, int secFlags, int server, char *cellp)
{
- return ugen_ClientInit(auth?0:1, confDir, cellp, 0,
- &cstruct, NULL, "vl_Initialize", rxkad_clear,
- MAXSERVERS, AFSCONF_VLDBSERVICE, 50, server,
- htons(AFSCONF_VLDBPORT), USER_SERVICE_ID);
+ return ugen_ClientInitServer(confDir, cellp, secFlags, &cstruct,
+ MAXSERVERS, AFSCONF_VLDBSERVICE, 90,
+ server, htons(AFSCONF_VLDBPORT));
}
/* return host address in network byte order */
char *cellp = 0;
struct VldbUpdateEntry updateentry;
struct VldbListByAttributes listbyattributes;
- int noAuth = 1; /* Default is authenticated connections */
+ int secFlags = AFSCONF_SECOPTS_FALLBACK_NULL;
if ((ti = as->parms[0].items)) /* -cellpath <dir> */
strcpy(confdir, ti->data);
if (as->parms[1].items) /* -server */
strcpy(confdir, AFSDIR_SERVER_ETC_DIRPATH);
if (as->parms[2].items) /* -noauth */
- noAuth = 0;
+ secFlags |= AFSCONF_SECOPTS_NOAUTH;
if ((ti = as->parms[3].items)) { /* -host */
server = GetServer(ti->data);
if (server == 0) {
}
sawserver = 1;
}
- if (!sawserver && noAuth && (!(ti = as->parms[4].items))) {
+ if (sawserver && !as->parms[2].items && (!(ti = as->parms[4].items))) {
printf
("Must also specify the -cell' option along with -host for authenticated conns\n");
exit(1);
if ((ti = as->parms[4].items)) { /* -cell */
cellp = ti->data;
}
- if ((code = vl_Initialize(noAuth, confdir, server, cellp))) {
+ if ((code = vl_Initialize(confdir, secFlags, server, cellp))) {
printf("Couldn't initialize vldb library (code=%d).\n", code);
exit(1);
}
- if (as->parms[5].items) { /* -gstats */
+ if (as->parms[6].items) { /* -probe */
+ int nconns = 0;
+ int status = 0;
+ int i;
+ char hoststr[16];
+ afs_uint32 addr;
+
+ for (i = 0; cstruct->conns[i]; i++, nconns++) {
+ rx_SetConnDeadTime(cstruct->conns[i], 6);
+ addr = rx_HostOf(rx_PeerOf(cstruct->conns[i]));
+ if (!nconns) {
+ printf("probing");
+ }
+ printf(" %s", afs_inet_ntoa_r(addr, hoststr));
+ }
+ if (nconns == 0) {
+ printf("no connections\n");
+ return 255;
+ }
+ printf("\n");
+ multi_Rx(cstruct->conns, nconns) {
+ multi_VL_ProbeServer();
+ addr = rx_HostOf(rx_PeerOf(cstruct->conns[multi_i]));
+ if (!multi_error) {
+ printf(" ok: %s\n", afs_inet_ntoa_r(addr, hoststr));
+ } else {
+ status = 255;
+ printf(" not ok (%d): %s\n", multi_error,
+ afs_inet_ntoa_r(addr, hoststr));
+ }
+ }
+ multi_End;
+ return status;
+ }
+
+ if (as->parms[5].items) { /* -getstats */
vldstats stats;
vital_vlheader vital_header;
code = ubik_VL_GetStats(cstruct, 0, &stats, &vital_header);
afs_int32 index, count, num = 0, num1 = 0, next_index;
struct Vlent *vl1;
- VL = SVL =
- (struct Vlent *)malloc(ALLOCNT * sizeof(struct Vlent));
+ VL = SVL = malloc(ALLOCNT * sizeof(struct Vlent));
if (VL == NULL) {
printf("Can't allocate memory...\n");
exit(1);
0, num31 = 0, num4 = 0, num41 = 0, next_index;
struct vldbentry tentry;
- VL = SVL =
- (struct Vlent *)malloc(ALLOCNT * sizeof(struct Vlent));
+ VL = SVL = malloc(ALLOCNT * sizeof(struct Vlent));
if (VL == NULL) {
printf("Can't allocate memory...\n");
exit(1);
0;
struct vldbentry tentry;
- VL = SVL =
- (struct Vlent *)malloc(ALLOCNT * sizeof(struct Vlent));
+ VL = SVL = malloc(ALLOCNT * sizeof(struct Vlent));
if (VL == NULL) {
printf("Can't allocate memory...\n");
exit(1);
for (i = 0; i < nentries; i++, entry++)
display_entry(entry, 0);
if (entries.bulkentries_val)
- free((char *)entries.bulkentries_val);
+ free(entries.bulkentries_val);
} else if (!strcmp(oper, "lan2")) {
int nentries, i, si, nsi, t = 0;
nbulkentries entries;
for (i = 0; i < nentries; i++, entry++)
display_entryN(entry, 0);
if (entries.nbulkentries_val)
- free((char *)entries.nbulkentries_val);
+ free(entries.nbulkentries_val);
}
printf("--- %d volumes ---\n", t);
} else if (!strcmp(oper, "ln")) {
for (vllist = linkedvldbs.node; vllist; vllist = vllist1) {
vllist1 = vllist->next_vldb;
display_entry((struct vldbentry *)&vllist->VldbEntry, 0);
- free((char *)vllist);
+ free(vllist);
}
} else if (!strcmp(oper, "di")) {
sscanf(&(*argp)[0], "%d", &id);
printf("[0x%x %u] %s\n", *addrp, *addrp,
hostutil_GetNameByINet(ntohl(*addrp)));
}
- free((char *)addrs.bulkaddrs_val);
+ free(addrs.bulkaddrs_val);
} else if (!strcmp(oper, "gau")) {
int nentries, i, j;
afs_uint32 *addrp;
printf("[0x%x %u] (special multi-homed entry)\n",
*addrp, *addrp);
+ memset(&attrs, 0, sizeof(attrs));
attrs.Mask = VLADDR_INDEX;
mhaddrs.bulkaddrs_val = 0;
mhaddrs.bulkaddrs_len = 0;
hostutil_GetNameByINet(mhaddrp[j]));
}
if (mhaddrs.bulkaddrs_val)
- free((char *)mhaddrs.bulkaddrs_val);
+ free(mhaddrs.bulkaddrs_val);
} else {
printf("[0x%x %u] %s\n", *addrp, *addrp,
hostutil_GetNameByINet(ntohl(*addrp)));
}
}
- free((char *)addrs.bulkaddrs_val);
+ free(addrs.bulkaddrs_val);
} else if (!strcmp(oper, "mhc")) {
afs_uint32 serveraddrs[MAXSERVERID + 1][VL_MAXIPADDRS_PERMH];
afs_int32 serveraddrtype[MAXSERVERID + 1];
addrs2.bulkaddrs_val = 0;
addrs2.bulkaddrs_len = 0;
+ memset(&attrs, 0, sizeof(attrs));
attrs.Mask = VLADDR_INDEX;
attrs.index = (base * VL_MHSRV_PERBLK) + index;
code =
for (j = 0; j < nentries2; j++) {
serveraddrs[i][j] = ntohl(addrp2[j]);
}
- free((char *)addrs2.bulkaddrs_val);
+ free(addrs2.bulkaddrs_val);
}
if (nargs) {
}
}
}
- free((char *)addrs1.bulkaddrs_val);
+ free(addrs1.bulkaddrs_val);
/* Look for any duplicates */
for (i = 0; i < MAXSERVERID + 1; i++) {
printf("Illegal # entries = %d\n", nargs);
continue;
}
- addrp = (afs_uint32 *) malloc(20 * 4);
+ addrp = malloc(20 * 4);
addrs.bulkaddrs_val = addrp;
addrs.bulkaddrs_len = nargs;
while (nargs > 0) {
afs_int32 code;
strcpy(confdir, AFSDIR_CLIENT_ETC_DIRPATH);
- ts = cmd_CreateSyntax("initcmd", handleit, NULL, "initialize the program");
+ ts = cmd_CreateSyntax("initcmd", handleit, NULL, 0, "initialize the program");
cmd_AddParm(ts, "-cellpath", CMD_LIST, CMD_OPTIONAL,
"Cell configuration directory");
cmd_AddParm(ts, "-server", CMD_LIST, CMD_OPTIONAL,
"cellname '-host' belongs to (required for auth conns)");
cmd_AddParm(ts, "-getstats", CMD_FLAG, CMD_OPTIONAL,
"print vldb statistics (non interactive)");
+ cmd_AddParm(ts, "-probe", CMD_FLAG, CMD_OPTIONAL,
+ "probe vldb servers, use with -host to probe only one. (non interactive)");
code = cmd_Dispatch(argc, argv);
exit(code);
}
int i;
char strg[30];
time_t start_time = stats->start_time;
+ struct tm tm;
- afs_ctime(&start_time, strg, sizeof(strg));
- strg[strlen(strg) - 1] = 0;
+ strftime(strg, sizeof(strg), "%a %b %d %H:%M:%S %Y",
+ localtime_r(&start_time, &tm));
printf("Dynamic statistics stats (starting time: %s):\n", strg);
printf("OpcodeName\t# Requests\t# Aborts\n");
for (i = 0; i < VL_NUMBER_OPCODESX; i++)