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 int afsconf_CheckAuth();
53 extern int afsconf_ServerAuth();
55 extern afs_int32 ubik_lastYesTime;
56 extern afs_int32 ubik_nBuffers;
61 int rxJumbograms = 1; /* default is to send and receive jumbo grams */
63 static void CheckSignal_Signal() {IOMGR_SoftSig(CheckSignal, 0);}
67 register int i, errorcode;
68 struct ubik_trans *trans;
70 if (errorcode = Init_VLdbase(&trans, LOCKREAD, VLGETSTATS-VL_LOWEST_OPCODE))
72 VLog(0, ("Dump name hash table out\n"));
73 for (i = 0; i < HASHSIZE; i++) {
76 VLog(0, ("Dump id hash table out\n"));
77 for (i = 0; i < HASHSIZE; i++) {
80 return(ubik_EndTrans(trans));
84 /* Initialize the stats for the opcodes */
85 void initialize_dstats ()
88 dynamic_statistics.start_time = (afs_uint32) time(0);
89 for (i=0; i< MAX_NUMBER_OPCODES; i++) {
90 dynamic_statistics.requests[i] = 0;
91 dynamic_statistics.aborts[i] = 0;
95 /* check whether caller is authorized to manage RX statistics */
96 int vldb_rxstat_userok(call)
99 return afsconf_SuperUser(vldb_confdir, call, (char *)0);
102 /* Main server module */
104 #include "AFS_component_version_number.c"
110 register afs_int32 code;
112 struct rx_service *tservice;
113 struct rx_securityClass *sc[3];
114 extern struct rx_securityClass *rxnull_NewServerSecurityObject();
115 extern int VL_ExecuteRequest();
116 extern int RXSTATS_ExecuteRequest();
117 struct afsconf_dir *tdir;
118 struct ktc_encryptionKey tkey;
119 struct afsconf_cell info;
121 char hostname[VL_MAXNAMELEN];
122 int noAuth = 0, index, i;
123 extern int rx_extraPackets;
124 char commandLine[150];
125 char clones[MAXHOSTSPERCELL];
129 * The following signal action for AIX is necessary so that in case of a
130 * crash (i.e. core is generated) we can include the user's data section
131 * in the core dump. Unfortunately, by default, only a partial core is
132 * generated which, in many cases, isn't too useful.
134 struct sigaction nsa;
136 rx_extraPackets = 100; /* should be a switch, I guess... */
137 sigemptyset(&nsa.sa_mask);
138 nsa.sa_handler = SIG_DFL;
139 nsa.sa_flags = SA_FULLDUMP;
140 sigaction(SIGABRT, &nsa, NULL);
141 sigaction(SIGSEGV, &nsa, NULL);
143 /* Parse command line */
144 for (index=1; index < argc; index++) {
145 if (strcmp(argv[index], "-noauth") == 0) {
148 } else if (strcmp(argv[index], "-p") == 0) {
149 lwps = atoi(argv[++index]);
151 printf("Warning: '-p %d' is too big; using %d instead\n", lwps, MAXLWP);
155 } else if (strcmp(argv[index], "-nojumbo") == 0) {
158 } else if (strcmp(argv[index], "-smallmem") == 0) {
161 } else if (strcmp(argv[index], "-trace") == 0) {
162 extern char rxi_tracename[80];
163 strcpy (rxi_tracename, argv[++index]);
165 } else if (strcmp(argv[index], "-enable_peer_stats") == 0) {
166 rx_enablePeerRPCStats();
167 } else if (strcmp(argv[index], "-enable_process_stats") == 0) {
168 rx_enableProcessRPCStats();
170 } else if (strcmp(argv[index], "-syslog")==0) {
171 /* set syslog logging flag */
173 } else if (strncmp(argv[index], "-syslog=", 8)==0) {
175 serverLogSyslogFacility = atoi(argv[index]+8);
178 /* support help flag */
180 printf("Usage: vlserver [-p <number of processes>] [-nojumbo] "
181 "[-syslog[=FACILITY]] "
182 "[-enable_peer_stats] [-enable_process_stats] "
185 printf("Usage: vlserver [-p <number of processes>] [-nojumbo] "
186 "[-enable_peer_stats] [-enable_process_stats] "
194 /* Initialize dirpaths */
195 if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) {
197 ReportErrorEventAlt(AFSEVT_SVR_NO_INSTALL_DIR, 0, argv[0],0);
199 fprintf(stderr,"%s: Unable to obtain AFS server directory.\n", argv[0]);
202 vl_dbaseName = AFSDIR_SERVER_VLDB_FILEPATH;
204 OpenLog(AFSDIR_SERVER_VLOG_FILEPATH); /* set up logging */
207 tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
209 printf("vlserver: can't open configuration files in dir %s, giving up.\n", AFSDIR_SERVER_ETC_DIRPATH);
213 /* initialize winsock */
214 if (afs_winsockInit()<0) {
215 ReportErrorEventAlt(AFSEVT_SVR_WINSOCK_INIT_FAILED, 0,
217 fprintf(stderr, "vlserver: couldn't initialize winsock. \n");
222 gethostname(hostname,sizeof(hostname));
223 th = gethostbyname(hostname);
225 printf("vlserver: couldn't get address of this host (%s).\n", hostname);
228 bcopy(th->h_addr,&myHost,sizeof(afs_int32));
230 #if !defined(AFS_HPUX_ENV) && !defined(AFS_NT40_ENV) && !defined(AFS_DJGPP_ENV)
231 signal(SIGXCPU, CheckSignal_Signal);
233 /* get list of servers */
234 code = afsconf_GetExtendedCellInfo(tdir,(char *)0, AFSCONF_VLDBSERVICE,
237 printf("vlserver: Couldn't get cell server list for 'afsvldb'.\n");
241 vldb_confdir = tdir; /* Preserve our configuration dir */
242 /* rxvab no longer supported */
243 bzero(&tkey, sizeof(tkey));
245 if (noAuth) afsconf_SetNoAuthFlag(tdir, 1);
248 ubik_CRXSecurityProc = afsconf_ClientAuth;
249 ubik_CRXSecurityRock = (char *) tdir;
250 ubik_SRXSecurityProc = afsconf_ServerAuth;
251 ubik_SRXSecurityRock = (char *) tdir;
252 ubik_CheckRXSecurityProc = afsconf_CheckAuth;
253 ubik_CheckRXSecurityRock = (char *) tdir;
254 code = ubik_ServerInitByInfo(myHost, htons(AFSCONF_VLDBPORT), &info,
255 &clones, vl_dbaseName, &VL_dbase);
257 printf("vlserver: Ubik init failed with code %d\n",code);
261 rx_maxReceiveSize = OLD_MAX_PACKET_SIZE;
262 rxi_nSendFrags = rxi_nRecvFrags = 1;
264 rx_SetRxDeadTime(50);
266 bzero(HostAddress, sizeof(HostAddress));
269 sc[0] = rxnull_NewServerSecurityObject();
270 sc[1] = (struct rx_securityClass *) 0;
271 sc[2] = (struct rx_securityClass *) rxkad_NewServerSecurityObject(0, tdir, afsconf_GetKey, (char *) 0);
272 tservice = rx_NewService(0, USER_SERVICE_ID, "Vldb server", sc, 3, VL_ExecuteRequest);
273 if (tservice == (struct rx_service *)0) {
274 printf("vlserver: Could not create VLDB_SERVICE rx service\n");
277 rx_SetMinProcs(tservice, 2);
280 rx_SetMaxProcs(tservice, lwps);
282 tservice = rx_NewService(0, RX_STATS_SERVICE_ID, "rpcstats", sc, 3, RXSTATS_ExecuteRequest);
283 if (tservice == (struct rx_service *)0) {
284 printf("vlserver: Could not create rpc stats rx service\n");
287 rx_SetMinProcs(tservice, 2);
288 rx_SetMaxProcs(tservice, 4);
290 for (commandLine[0]='\0', i=0; i<argc; i++) {
291 if (i > 0) strcat(commandLine, " ");
292 strcat(commandLine, argv[i]);
294 ViceLog(0,("Starting AFS vlserver %d (%s)\n", VLDBVERSION_4, commandLine));
295 printf("%s\n", cml_version_number); /* Goes to the log */
297 /* allow super users to manage RX statistics */
298 rx_SetRxStatUserOk(vldb_rxstat_userok);
300 rx_StartServer(1); /* Why waste this idle process?? */