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 <afs/param.h>
11 #include <afsconfig.h>
16 #include <sys/types.h>
20 #include <WINNT/afsevent.h>
29 #include <netinet/in.h>
34 #include <rx/rx_globals.h>
35 #include <afs/cellconfig.h>
40 #include <afs/afsutil.h>
45 const char *vl_dbaseName;
46 struct afsconf_dir *vldb_confdir = 0; /* vldb configuration dir */
49 struct vldstats dynamic_statistics;
50 struct ubik_dbase *VL_dbase;
51 afs_uint32 HostAddress[MAXSERVERID+1];
52 extern afs_int32 afsconf_GetKey();
53 extern int afsconf_CheckAuth();
54 extern int afsconf_ClientAuth();
55 extern int afsconf_ServerAuth();
57 extern afs_int32 ubik_lastYesTime;
58 extern afs_int32 ubik_nBuffers;
63 int rxJumbograms = 1; /* default is to send and receive jumbo grams */
65 static void CheckSignal_Signal() {IOMGR_SoftSig(CheckSignal, 0);}
69 register int i, errorcode;
70 struct ubik_trans *trans;
72 if (errorcode = Init_VLdbase(&trans, LOCKREAD, VLGETSTATS-VL_LOWEST_OPCODE))
74 VLog(0, ("Dump name hash table out\n"));
75 for (i = 0; i < HASHSIZE; i++) {
78 VLog(0, ("Dump id hash table out\n"));
79 for (i = 0; i < HASHSIZE; i++) {
82 return(ubik_EndTrans(trans));
86 /* Initialize the stats for the opcodes */
87 void initialize_dstats ()
90 dynamic_statistics.start_time = (afs_uint32) time(0);
91 for (i=0; i< MAX_NUMBER_OPCODES; i++) {
92 dynamic_statistics.requests[i] = 0;
93 dynamic_statistics.aborts[i] = 0;
97 /* check whether caller is authorized to manage RX statistics */
98 int vldb_rxstat_userok(call)
101 return afsconf_SuperUser(vldb_confdir, call, (char *)0);
104 /* Main server module */
106 #include "AFS_component_version_number.c"
112 register afs_int32 code;
114 struct rx_service *tservice;
115 struct rx_securityClass *sc[3];
116 extern struct rx_securityClass *rxnull_NewServerSecurityObject();
117 extern int VL_ExecuteRequest();
118 extern int RXSTATS_ExecuteRequest();
119 struct afsconf_dir *tdir;
120 struct ktc_encryptionKey tkey;
121 struct afsconf_cell info;
123 char hostname[VL_MAXNAMELEN];
124 int noAuth = 0, index, i;
125 extern int rx_extraPackets;
126 char commandLine[150];
127 char clones[MAXHOSTSPERCELL];
131 * The following signal action for AIX is necessary so that in case of a
132 * crash (i.e. core is generated) we can include the user's data section
133 * in the core dump. Unfortunately, by default, only a partial core is
134 * generated which, in many cases, isn't too useful.
136 struct sigaction nsa;
138 rx_extraPackets = 100; /* should be a switch, I guess... */
139 sigemptyset(&nsa.sa_mask);
140 nsa.sa_handler = SIG_DFL;
141 nsa.sa_flags = SA_FULLDUMP;
142 sigaction(SIGABRT, &nsa, NULL);
143 sigaction(SIGSEGV, &nsa, NULL);
145 /* Parse command line */
146 for (index=1; index < argc; index++) {
147 if (strcmp(argv[index], "-noauth") == 0) {
150 } else if (strcmp(argv[index], "-p") == 0) {
151 lwps = atoi(argv[++index]);
153 printf("Warning: '-p %d' is too big; using %d instead\n", lwps, MAXLWP);
157 } else if (strcmp(argv[index], "-nojumbo") == 0) {
160 } else if (strcmp(argv[index], "-smallmem") == 0) {
163 } else if (strcmp(argv[index], "-trace") == 0) {
164 extern char rxi_tracename[80];
165 strcpy (rxi_tracename, argv[++index]);
167 } else if (strcmp(argv[index], "-enable_peer_stats") == 0) {
168 rx_enablePeerRPCStats();
169 } else if (strcmp(argv[index], "-enable_process_stats") == 0) {
170 rx_enableProcessRPCStats();
172 } else if (strcmp(argv[index], "-syslog")==0) {
173 /* set syslog logging flag */
175 } else if (strncmp(argv[index], "-syslog=", 8)==0) {
177 serverLogSyslogFacility = atoi(argv[index]+8);
180 /* support help flag */
182 printf("Usage: vlserver [-p <number of processes>] [-nojumbo] "
183 "[-syslog[=FACILITY]] "
184 "[-enable_peer_stats] [-enable_process_stats] "
187 printf("Usage: vlserver [-p <number of processes>] [-nojumbo] "
188 "[-enable_peer_stats] [-enable_process_stats] "
196 /* Initialize dirpaths */
197 if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) {
199 ReportErrorEventAlt(AFSEVT_SVR_NO_INSTALL_DIR, 0, argv[0],0);
201 fprintf(stderr,"%s: Unable to obtain AFS server directory.\n", argv[0]);
204 vl_dbaseName = AFSDIR_SERVER_VLDB_FILEPATH;
206 OpenLog(AFSDIR_SERVER_VLOG_FILEPATH); /* set up logging */
209 tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
211 printf("vlserver: can't open configuration files in dir %s, giving up.\n", AFSDIR_SERVER_ETC_DIRPATH);
215 /* initialize winsock */
216 if (afs_winsockInit()<0) {
217 ReportErrorEventAlt(AFSEVT_SVR_WINSOCK_INIT_FAILED, 0,
219 fprintf(stderr, "vlserver: couldn't initialize winsock. \n");
224 gethostname(hostname,sizeof(hostname));
225 th = gethostbyname(hostname);
227 printf("vlserver: couldn't get address of this host (%s).\n", hostname);
230 bcopy(th->h_addr,&myHost,sizeof(afs_int32));
232 #if !defined(AFS_HPUX_ENV) && !defined(AFS_NT40_ENV) && !defined(AFS_DJGPP_ENV)
233 signal(SIGXCPU, CheckSignal_Signal);
235 /* get list of servers */
236 code = afsconf_GetExtendedCellInfo(tdir,(char *)0, AFSCONF_VLDBSERVICE,
239 printf("vlserver: Couldn't get cell server list for 'afsvldb'.\n");
243 vldb_confdir = tdir; /* Preserve our configuration dir */
244 /* rxvab no longer supported */
245 bzero(&tkey, sizeof(tkey));
247 if (noAuth) afsconf_SetNoAuthFlag(tdir, 1);
250 ubik_CRXSecurityProc = afsconf_ClientAuth;
251 ubik_CRXSecurityRock = (char *) tdir;
252 ubik_SRXSecurityProc = afsconf_ServerAuth;
253 ubik_SRXSecurityRock = (char *) tdir;
254 ubik_CheckRXSecurityProc = afsconf_CheckAuth;
255 ubik_CheckRXSecurityRock = (char *) tdir;
256 code = ubik_ServerInitByInfo(myHost, htons(AFSCONF_VLDBPORT), &info,
257 &clones, vl_dbaseName, &VL_dbase);
259 printf("vlserver: Ubik init failed with code %d\n",code);
263 rx_maxReceiveSize = OLD_MAX_PACKET_SIZE;
264 rxi_nSendFrags = rxi_nRecvFrags = 1;
266 rx_SetRxDeadTime(50);
268 bzero(HostAddress, sizeof(HostAddress));
271 sc[0] = rxnull_NewServerSecurityObject();
272 sc[1] = (struct rx_securityClass *) 0;
273 sc[2] = (struct rx_securityClass *) rxkad_NewServerSecurityObject(0, tdir, afsconf_GetKey, (char *) 0);
274 tservice = rx_NewService(0, USER_SERVICE_ID, "Vldb server", sc, 3, VL_ExecuteRequest);
275 if (tservice == (struct rx_service *)0) {
276 printf("vlserver: Could not create VLDB_SERVICE rx service\n");
279 rx_SetMinProcs(tservice, 2);
282 rx_SetMaxProcs(tservice, lwps);
284 tservice = rx_NewService(0, RX_STATS_SERVICE_ID, "rpcstats", sc, 3, RXSTATS_ExecuteRequest);
285 if (tservice == (struct rx_service *)0) {
286 printf("vlserver: Could not create rpc stats rx service\n");
289 rx_SetMinProcs(tservice, 2);
290 rx_SetMaxProcs(tservice, 4);
292 for (commandLine[0]='\0', i=0; i<argc; i++) {
293 if (i > 0) strcat(commandLine, " ");
294 strcat(commandLine, argv[i]);
296 ViceLog(0,("Starting AFS vlserver %d (%s)\n", VLDBVERSION_4, commandLine));
297 printf("%s\n", cml_version_number); /* Goes to the log */
299 /* allow super users to manage RX statistics */
300 rx_SetRxStatUserOk(vldb_rxstat_userok);
302 rx_StartServer(1); /* Why waste this idle process?? */