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 <sys/types.h>
24 #include <WINNT/afsevent.h>
26 #ifdef HAVE_SYS_FILE_H
33 #ifdef HAVE_NETINET_IN_H
34 #include <netinet/in.h>
48 #include <rx/rx_globals.h>
49 #include <afs/cellconfig.h>
54 #include <afs/afsutil.h>
59 const char *vl_dbaseName;
60 struct afsconf_dir *vldb_confdir = 0; /* vldb configuration dir */
63 struct vldstats dynamic_statistics;
64 struct ubik_dbase *VL_dbase;
65 afs_uint32 HostAddress[MAXSERVERID + 1];
66 extern int afsconf_CheckAuth();
67 extern int afsconf_ServerAuth();
72 int rxJumbograms = 1; /* default is to send and receive jumbo grams */
77 IOMGR_SoftSig(CheckSignal, 0);
83 register int i, errorcode;
84 struct ubik_trans *trans;
87 Init_VLdbase(&trans, LOCKREAD, VLGETSTATS - VL_LOWEST_OPCODE))
89 VLog(0, ("Dump name hash table out\n"));
90 for (i = 0; i < HASHSIZE; i++) {
93 VLog(0, ("Dump id hash table out\n"));
94 for (i = 0; i < HASHSIZE; i++) {
97 return (ubik_EndTrans(trans));
101 /* Initialize the stats for the opcodes */
107 dynamic_statistics.start_time = (afs_uint32) time(0);
108 for (i = 0; i < MAX_NUMBER_OPCODES; i++) {
109 dynamic_statistics.requests[i] = 0;
110 dynamic_statistics.aborts[i] = 0;
114 /* check whether caller is authorized to manage RX statistics */
116 vldb_rxstat_userok(call)
117 struct rx_call *call;
119 return afsconf_SuperUser(vldb_confdir, call, NULL);
122 /* Main server module */
124 #include "AFS_component_version_number.c"
130 register afs_int32 code;
132 struct rx_service *tservice;
133 struct rx_securityClass *sc[3];
134 extern int VL_ExecuteRequest();
135 extern int RXSTATS_ExecuteRequest();
136 struct afsconf_dir *tdir;
137 struct ktc_encryptionKey tkey;
138 struct afsconf_cell info;
140 char hostname[VL_MAXNAMELEN];
141 int noAuth = 0, index, i;
142 extern int rx_extraPackets;
143 char commandLine[150];
144 char clones[MAXHOSTSPERCELL];
148 * The following signal action for AIX is necessary so that in case of a
149 * crash (i.e. core is generated) we can include the user's data section
150 * in the core dump. Unfortunately, by default, only a partial core is
151 * generated which, in many cases, isn't too useful.
153 struct sigaction nsa;
155 rx_extraPackets = 100; /* should be a switch, I guess... */
156 sigemptyset(&nsa.sa_mask);
157 nsa.sa_handler = SIG_DFL;
158 nsa.sa_flags = SA_FULLDUMP;
159 sigaction(SIGABRT, &nsa, NULL);
160 sigaction(SIGSEGV, &nsa, NULL);
162 /* Parse command line */
163 for (index = 1; index < argc; index++) {
164 if (strcmp(argv[index], "-noauth") == 0) {
167 } else if (strcmp(argv[index], "-p") == 0) {
168 lwps = atoi(argv[++index]);
170 printf("Warning: '-p %d' is too big; using %d instead\n",
175 } else if (strcmp(argv[index], "-nojumbo") == 0) {
178 } else if (strcmp(argv[index], "-smallmem") == 0) {
181 } else if (strcmp(argv[index], "-trace") == 0) {
182 extern char rxi_tracename[80];
183 strcpy(rxi_tracename, argv[++index]);
185 } else if (strcmp(argv[index], "-enable_peer_stats") == 0) {
186 rx_enablePeerRPCStats();
187 } else if (strcmp(argv[index], "-enable_process_stats") == 0) {
188 rx_enableProcessRPCStats();
190 } else if (strcmp(argv[index], "-syslog") == 0) {
191 /* set syslog logging flag */
193 } else if (strncmp(argv[index], "-syslog=", 8) == 0) {
195 serverLogSyslogFacility = atoi(argv[index] + 8);
198 /* support help flag */
200 printf("Usage: vlserver [-p <number of processes>] [-nojumbo] "
201 "[-syslog[=FACILITY]] "
202 "[-enable_peer_stats] [-enable_process_stats] "
205 printf("Usage: vlserver [-p <number of processes>] [-nojumbo] "
206 "[-enable_peer_stats] [-enable_process_stats] "
214 /* Initialize dirpaths */
215 if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) {
217 ReportErrorEventAlt(AFSEVT_SVR_NO_INSTALL_DIR, 0, argv[0], 0);
219 fprintf(stderr, "%s: Unable to obtain AFS server directory.\n",
223 vl_dbaseName = AFSDIR_SERVER_VLDB_FILEPATH;
226 serverLogSyslogTag = "vlserver";
228 OpenLog(AFSDIR_SERVER_VLOG_FILEPATH); /* set up logging */
231 tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
234 ("vlserver: can't open configuration files in dir %s, giving up.\n",
235 AFSDIR_SERVER_ETC_DIRPATH);
239 /* initialize winsock */
240 if (afs_winsockInit() < 0) {
241 ReportErrorEventAlt(AFSEVT_SVR_WINSOCK_INIT_FAILED, 0, argv[0], 0);
242 fprintf(stderr, "vlserver: couldn't initialize winsock. \n");
247 gethostname(hostname, sizeof(hostname));
248 th = gethostbyname(hostname);
250 printf("vlserver: couldn't get address of this host (%s).\n",
254 memcpy(&myHost, th->h_addr, sizeof(afs_int32));
256 #if !defined(AFS_HPUX_ENV) && !defined(AFS_NT40_ENV) && !defined(AFS_DJGPP_ENV)
257 signal(SIGXCPU, CheckSignal_Signal);
259 /* get list of servers */
261 afsconf_GetExtendedCellInfo(tdir, NULL, AFSCONF_VLDBSERVICE, &info,
264 printf("vlserver: Couldn't get cell server list for 'afsvldb'.\n");
268 vldb_confdir = tdir; /* Preserve our configuration dir */
269 /* rxvab no longer supported */
270 memset(&tkey, 0, sizeof(tkey));
273 afsconf_SetNoAuthFlag(tdir, 1);
276 ubik_CRXSecurityProc = afsconf_ClientAuth;
277 ubik_CRXSecurityRock = (char *)tdir;
278 ubik_SRXSecurityProc = afsconf_ServerAuth;
279 ubik_SRXSecurityRock = (char *)tdir;
280 ubik_CheckRXSecurityProc = afsconf_CheckAuth;
281 ubik_CheckRXSecurityRock = (char *)tdir;
283 ubik_ServerInitByInfo(myHost, htons(AFSCONF_VLDBPORT), &info, &clones,
284 vl_dbaseName, &VL_dbase);
286 printf("vlserver: Ubik init failed with code %d\n", code);
292 rx_SetRxDeadTime(50);
294 memset(HostAddress, 0, sizeof(HostAddress));
297 sc[0] = rxnull_NewServerSecurityObject();
298 sc[1] = (struct rx_securityClass *)0;
299 sc[2] = rxkad_NewServerSecurityObject(0, tdir, afsconf_GetKey, NULL);
301 rx_NewService(0, USER_SERVICE_ID, "Vldb server", sc, 3,
303 if (tservice == (struct rx_service *)0) {
304 printf("vlserver: Could not create VLDB_SERVICE rx service\n");
307 rx_SetMinProcs(tservice, 2);
310 rx_SetMaxProcs(tservice, lwps);
313 rx_NewService(0, RX_STATS_SERVICE_ID, "rpcstats", sc, 3,
314 RXSTATS_ExecuteRequest);
315 if (tservice == (struct rx_service *)0) {
316 printf("vlserver: Could not create rpc stats rx service\n");
319 rx_SetMinProcs(tservice, 2);
320 rx_SetMaxProcs(tservice, 4);
322 for (commandLine[0] = '\0', i = 0; i < argc; i++) {
324 strcat(commandLine, " ");
325 strcat(commandLine, argv[i]);
328 ("Starting AFS vlserver %d (%s)\n", VLDBVERSION_4, commandLine));
329 printf("%s\n", cml_version_number); /* Goes to the log */
331 /* allow super users to manage RX statistics */
332 rx_SetRxStatUserOk(vldb_rxstat_userok);
334 rx_StartServer(1); /* Why waste this idle process?? */