2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
17 #include <WINNT/afsevent.h>
20 #ifdef HAVE_SYS_FILE_H
26 #include <rx/rx_globals.h>
27 #include <rx/rxstat.h>
28 #include <afs/cellconfig.h>
31 #include <afs/audit.h>
32 #include <afs/com_err.h>
35 #include <afs/afsutil.h>
38 #include "vlserver_internal.h"
41 const char *vl_dbaseName;
42 struct afsconf_dir *vldb_confdir = 0; /* vldb configuration dir */
45 struct vldstats dynamic_statistics;
46 struct ubik_dbase *VL_dbase;
47 afs_uint32 rd_HostAddress[MAXSERVERID + 1];
48 afs_uint32 wr_HostAddress[MAXSERVERID + 1];
50 static void *CheckSignal(void*);
53 int rxJumbograms = 0; /* default is to not send and receive jumbo grams */
56 int rxkadDisableDotCheck = 0;
59 #define ADDRSPERSITE 16 /* Same global is in rx/rx_user.c */
60 afs_uint32 SHostAddrs[ADDRSPERSITE];
63 CheckSignal_Signal(int unused)
65 #if defined(AFS_PTHREAD_ENV)
68 IOMGR_SoftSig(CheckSignal, 0);
73 CheckSignal(void *unused)
79 Init_VLdbase(&ctx, LOCKREAD, VLGETSTATS - VL_LOWEST_OPCODE)))
80 return (void *)(intptr_t)errorcode;
81 VLog(0, ("Dump name hash table out\n"));
82 for (i = 0; i < HASHSIZE; i++) {
85 VLog(0, ("Dump id hash table out\n"));
86 for (i = 0; i < HASHSIZE; i++) {
89 return ((void *)(intptr_t)ubik_EndTrans(ctx.trans));
93 /* Initialize the stats for the opcodes */
95 initialize_dstats(void)
99 dynamic_statistics.start_time = (afs_uint32) time(0);
100 for (i = 0; i < MAX_NUMBER_OPCODES; i++) {
101 dynamic_statistics.requests[i] = 0;
102 dynamic_statistics.aborts[i] = 0;
106 /* check whether caller is authorized to manage RX statistics */
108 vldb_rxstat_userok(struct rx_call *call)
110 return afsconf_SuperUser(vldb_confdir, call, NULL);
113 /* Main server module */
115 #include "AFS_component_version_number.c"
118 main(int argc, char **argv)
122 struct rx_service *tservice;
123 struct rx_securityClass **securityClasses;
124 afs_int32 numClasses;
125 struct afsconf_dir *tdir;
126 struct ktc_encryptionKey tkey;
127 struct afsconf_cell info;
129 char hostname[VL_MAXNAMELEN];
130 int noAuth = 0, index;
131 char clones[MAXHOSTSPERCELL];
132 char *auditFileName = NULL;
133 afs_uint32 host = ntohl(INADDR_ANY);
137 * The following signal action for AIX is necessary so that in case of a
138 * crash (i.e. core is generated) we can include the user's data section
139 * in the core dump. Unfortunately, by default, only a partial core is
140 * generated which, in many cases, isn't too useful.
142 struct sigaction nsa;
144 rx_extraPackets = 100; /* should be a switch, I guess... */
145 sigemptyset(&nsa.sa_mask);
146 nsa.sa_handler = SIG_DFL;
147 nsa.sa_flags = SA_FULLDUMP;
148 sigaction(SIGABRT, &nsa, NULL);
149 sigaction(SIGSEGV, &nsa, NULL);
153 /* Parse command line */
154 for (index = 1; index < argc; index++) {
155 if (strcmp(argv[index], "-noauth") == 0) {
157 } else if (strcmp(argv[index], "-p") == 0) {
158 lwps = atoi(argv[++index]);
160 printf("Warning: '-p %d' is too big; using %d instead\n",
164 } else if (strcmp(argv[index], "-d") == 0) {
165 if ((index + 1) >= argc) {
166 fprintf(stderr, "missing argument for -d\n");
169 debuglevel = atoi(argv[++index]);
170 LogLevel = debuglevel;
171 } else if (strcmp(argv[index], "-nojumbo") == 0) {
173 } else if (strcmp(argv[index], "-jumbo") == 0) {
175 } else if (strcmp(argv[index], "-rxbind") == 0) {
177 } else if (strcmp(argv[index], "-allow-dotted-principals") == 0) {
178 rxkadDisableDotCheck = 1;
179 } else if (!strcmp(argv[index], "-rxmaxmtu")) {
180 if ((index + 1) >= argc) {
181 fprintf(stderr, "missing argument for -rxmaxmtu\n");
184 rxMaxMTU = atoi(argv[++index]);
185 if ((rxMaxMTU < RX_MIN_PACKET_SIZE) ||
186 (rxMaxMTU > RX_MAX_PACKET_DATA_SIZE)) {
187 printf("rxMaxMTU %d invalid; must be between %d-%" AFS_SIZET_FMT "\n",
188 rxMaxMTU, RX_MIN_PACKET_SIZE,
189 RX_MAX_PACKET_DATA_SIZE);
193 } else if (strcmp(argv[index], "-smallmem") == 0) {
196 } else if (strcmp(argv[index], "-trace") == 0) {
197 extern char rxi_tracename[80];
198 strcpy(rxi_tracename, argv[++index]);
200 } else if (strcmp(argv[index], "-auditlog") == 0) {
201 auditFileName = argv[++index];
203 } else if (strcmp(argv[index], "-audit-interface") == 0) {
204 char *interface = argv[++index];
206 if (osi_audit_interface(interface)) {
207 printf("Invalid audit interface '%s'\n", interface);
211 } else if (strcmp(argv[index], "-enable_peer_stats") == 0) {
212 rx_enablePeerRPCStats();
213 } else if (strcmp(argv[index], "-enable_process_stats") == 0) {
214 rx_enableProcessRPCStats();
216 } else if (strcmp(argv[index], "-syslog") == 0) {
217 /* set syslog logging flag */
219 } else if (strncmp(argv[index], "-syslog=", 8) == 0) {
221 serverLogSyslogFacility = atoi(argv[index] + 8);
224 /* support help flag */
225 printf("Usage: vlserver [-p <number of processes>] [-nojumbo] "
226 "[-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals] "
227 "[-auditlog <log path>] [-jumbo] [-d <debug level>] ");
229 printf("[-syslog[=FACILITY]] ");
231 printf("[-enable_peer_stats] [-enable_process_stats] "
239 osi_audit_file(auditFileName);
242 /* Initialize dirpaths */
243 if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) {
245 ReportErrorEventAlt(AFSEVT_SVR_NO_INSTALL_DIR, 0, argv[0], 0);
247 fprintf(stderr, "%s: Unable to obtain AFS server directory.\n",
251 vl_dbaseName = AFSDIR_SERVER_VLDB_FILEPATH;
254 serverLogSyslogTag = "vlserver";
256 OpenLog(AFSDIR_SERVER_VLOG_FILEPATH); /* set up logging */
259 tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
262 ("vlserver: can't open configuration files in dir %s, giving up.\n",
263 AFSDIR_SERVER_ETC_DIRPATH);
267 /* initialize winsock */
268 if (afs_winsockInit() < 0) {
269 ReportErrorEventAlt(AFSEVT_SVR_WINSOCK_INIT_FAILED, 0, argv[0], 0);
270 fprintf(stderr, "vlserver: couldn't initialize winsock. \n");
275 gethostname(hostname, sizeof(hostname));
276 th = gethostbyname(hostname);
278 printf("vlserver: couldn't get address of this host (%s).\n",
282 memcpy(&myHost, th->h_addr, sizeof(afs_uint32));
284 #if !defined(AFS_HPUX_ENV) && !defined(AFS_NT40_ENV)
285 signal(SIGXCPU, CheckSignal_Signal);
287 /* get list of servers */
289 afsconf_GetExtendedCellInfo(tdir, NULL, AFSCONF_VLDBSERVICE, &info,
292 printf("vlserver: Couldn't get cell server list for 'afsvldb'.\n");
296 vldb_confdir = tdir; /* Preserve our configuration dir */
297 /* rxvab no longer supported */
298 memset(&tkey, 0, sizeof(tkey));
301 afsconf_SetNoAuthFlag(tdir, 1);
306 if (AFSDIR_SERVER_NETRESTRICT_FILEPATH ||
307 AFSDIR_SERVER_NETINFO_FILEPATH) {
309 ccode = parseNetFiles(SHostAddrs, NULL, NULL,
310 ADDRSPERSITE, reason,
311 AFSDIR_SERVER_NETINFO_FILEPATH,
312 AFSDIR_SERVER_NETRESTRICT_FILEPATH);
316 ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
319 host = SHostAddrs[0];
320 rx_InitHost(host, htons(AFSCONF_VLDBPORT));
325 ubik_SetClientSecurityProcs(afsconf_ClientAuth, afsconf_UpToDate, tdir);
326 ubik_SetServerSecurityProcs(afsconf_BuildServerSecurityObjects,
327 afsconf_CheckAuth, tdir);
329 ubik_SyncWriterCacheProc = vlsynccache;
331 ubik_ServerInitByInfo(myHost, htons(AFSCONF_VLDBPORT), &info, clones,
332 vl_dbaseName, &VL_dbase);
334 printf("vlserver: Ubik init failed: %s\n", afs_error_message(code));
340 if (rxMaxMTU != -1) {
341 rx_SetMaxMTU(rxMaxMTU);
343 rx_SetRxDeadTime(50);
345 memset(rd_HostAddress, 0, sizeof(rd_HostAddress));
346 memset(wr_HostAddress, 0, sizeof(wr_HostAddress));
349 afsconf_BuildServerSecurityObjects(tdir, &securityClasses, &numClasses);
352 rx_NewServiceHost(host, 0, USER_SERVICE_ID, "Vldb server",
353 securityClasses, numClasses,
355 if (tservice == (struct rx_service *)0) {
356 printf("vlserver: Could not create VLDB_SERVICE rx service\n");
359 rx_SetMinProcs(tservice, 2);
362 rx_SetMaxProcs(tservice, lwps);
364 if (rxkadDisableDotCheck) {
365 rx_SetSecurityConfiguration(tservice, RXS_CONFIG_FLAGS,
366 (void *)RXS_CONFIG_FLAGS_DISABLE_DOTCHECK);
370 rx_NewServiceHost(host, 0, RX_STATS_SERVICE_ID, "rpcstats",
371 securityClasses, numClasses,
372 RXSTATS_ExecuteRequest);
373 if (tservice == (struct rx_service *)0) {
374 printf("vlserver: Could not create rpc stats rx service\n");
377 rx_SetMinProcs(tservice, 2);
378 rx_SetMaxProcs(tservice, 4);
380 LogCommandLine(argc, argv, "vlserver", VldbVersion, "Starting AFS", FSLog);
381 printf("%s\n", cml_version_number); /* Goes to the log */
383 /* allow super users to manage RX statistics */
384 rx_SetRxStatUserOk(vldb_rxstat_userok);
386 rx_StartServer(1); /* Why waste this idle process?? */
388 return 0; /* not reachable */