openafs-string-header-cleanup-20071030
[openafs.git] / src / ubik / beacon.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
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
8  */
9
10 #include <afsconfig.h>
11 #include <afs/param.h>
12
13 RCSID
14     ("$Header$");
15
16 #include <sys/types.h>
17 #ifdef AFS_NT40_ENV
18 #include <winsock2.h>
19 #include <time.h>
20 #else
21 #include <sys/file.h>
22 #include <sys/time.h>
23 #include <sys/socket.h>
24 #include <netinet/in.h>
25 #include <netdb.h>
26 #endif
27 #include <errno.h>
28 #include <lock.h>
29 #include <string.h>
30 #include <rx/xdr.h>
31 #include <rx/rx.h>
32 #include <rx/rx_multi.h>
33 #include <afs/cellconfig.h>
34 #ifndef AFS_NT40_ENV
35 #include <afs/afsutil.h>
36 #include <afs/netutils.h>
37 #endif
38
39 #define UBIK_INTERNALS
40 #include "ubik.h"
41 #include "ubik_int.h"
42
43 /* statics used to determine if we're the sync site */
44 static afs_int32 syncSiteUntil = 0;     /* valid only if amSyncSite */
45 int ubik_amSyncSite = 0;        /* flag telling if I'm sync site */
46 static nServers;                /* total number of servers */
47 static char amIMagic = 0;       /* is this host the magic host */
48 char amIClone = 0;              /* is this a clone which doesn't vote */
49 static char ubik_singleServer = 0;
50 int (*ubik_CRXSecurityProc) ();
51 char *ubik_CRXSecurityRock;
52 afs_int32 ubikSecIndex;
53 struct rx_securityClass *ubikSecClass;
54 static verifyInterfaceAddress();
55
56
57 /* Module responsible for both deciding if we're currently the sync site,
58  * and keeping collecting votes so as to stay sync site.
59  *
60  * The basic module contacts all of the servers it can, trying to get them to vote
61  * for this server for sync site.  The vote request message (called a beacon message)
62  * also specifies until which time this site claims to be the sync site, if at all, thus enabling
63  * receiving sites to know how long the sync site guarantee is made for.
64  *
65  * Each  of these beacon messages is thus both a declaration of how long this site will
66  * remain sync site, and an attempt to extend that time by collecting votes for a later
67  * sync site extension.
68  *
69  * The voting module is responsible for choosing a reasonable time until which it promises
70  * not to vote for someone else.  This parameter (BIG seconds) is not actually passed in
71  * the interface (perhaps it should be?) but is instead a compile time constant that both
72  * sides know about.
73  
74  * The beacon and vote modules work intimately together; the vote module decides how long
75  * it should promise the beacon module its vote, and the beacon module takes all of these
76  * votes and decides for how long it is the synchronization site.
77  */
78
79 /* procedure called from debug rpc call to get this module's state for debugging */
80 ubeacon_Debug(aparm)
81      register struct ubik_debug *aparm;
82 {
83     /* fill in beacon's state fields in the ubik_debug structure */
84     aparm->syncSiteUntil = syncSiteUntil;
85     aparm->nServers = nServers;
86 }
87
88 /* procedure that determines whether this site has enough current votes to remain sync site.
89  *  called from higher-level modules (everything but the vote module).
90  *
91  * If we're the sync site, check that our guarantees, obtained by the ubeacon_Interact
92  * light-weight process, haven't expired.  We're sync site as long as a majority of the
93  * servers in existence have promised us unexpired guarantees.  The variable ubik_syncSiteUntil
94  * contains the time at which the latest of the majority of the sync site guarantees expires
95  * (if the variable ubik_amSyncSite is true)
96  * This module also calls up to the recovery module if it thinks that the recovery module
97  * may have to pick up a new database (which offucr sif we lose the sync site votes).
98  */
99 ubeacon_AmSyncSite()
100 {
101     register afs_int32 now;
102     register afs_int32 rcode;
103
104     /* special case for fast startup */
105     if (nServers == 1 && !amIClone) {
106         return 1;               /* one guy is always the sync site */
107     }
108
109     if (ubik_amSyncSite == 0 || amIClone)
110         rcode = 0;              /* if I don't think I'm the sync site, say so */
111     else {
112         now = FT_ApproxTime();
113         if (syncSiteUntil <= now) {     /* if my votes have expired, say so */
114             if (ubik_amSyncSite)
115                 ubik_dprint("Ubik: I am no longer the sync site\n");
116             ubik_amSyncSite = 0;
117             rcode = 0;
118         } else {
119             rcode = 1;          /* otherwise still have the required votes */
120         }
121     }
122     if (rcode == 0)
123         urecovery_ResetState(); /* force recovery to re-execute */
124     ubik_dprint("beacon: amSyncSite is %d\n", rcode);
125     return rcode;
126 }
127
128 /* setup server list; called with two parms, first is my address, second is list of other servers
129  * called only at initialization to set up the list of servers to contact for votes.  Just creates
130  * the server structure.  Note that there are two connections in every server structure, one for
131  * vote calls (which must always go through quickly) and one for database operations, which
132  * are subject to waiting for locks.  If we used only one, the votes would sometimes get
133  * held up behind database operations, and the sync site guarantees would timeout
134  * even though the host would be up for communication.
135  *
136  * The "magic" host is the one with the lowest internet address.  It is
137  * magic because its vote counts epsilon more than the others.  This acts
138  * as a tie-breaker when we have an even number of hosts in the system.
139  * For example, if the "magic" host is up in a 2 site system, then it
140  * is sync site.  Without the magic host hack, if anyone crashed in a 2
141  * site system, we'd be out of business.
142  */
143 ubeacon_InitServerListByInfo(ame, info, clones)
144      afs_int32 ame;
145      struct afsconf_cell *info;
146      char clones[];
147 {
148     afs_int32 code;
149
150     code = ubeacon_InitServerListCommon(ame, info, clones, 0);
151     return code;
152 }
153
154 ubeacon_InitServerList(ame, aservers)
155      afs_int32 ame;
156      register afs_int32 aservers[];
157 {
158     afs_int32 code;
159
160     code =
161         ubeacon_InitServerListCommon(ame, (struct afsconf_cell *)0, 0,
162                                      aservers);
163     return code;
164 }
165
166 ubeacon_InitServerListCommon(ame, info, clones, aservers)
167      afs_int32 ame;
168      struct afsconf_cell *info;
169      char clones[];
170      register afs_int32 aservers[];
171 {
172     register struct ubik_server *ts;
173     afs_int32 me = -1;
174     register afs_int32 servAddr;
175     register afs_int32 i, code;
176     afs_int32 magicHost;
177     struct ubik_server *magicServer;
178
179     /* verify that the addresses passed in are correct */
180     if ((code = verifyInterfaceAddress(&ame, info, aservers)))
181         return code;
182
183     /* get the security index to use, if we can */
184     if (ubik_CRXSecurityProc) {
185         i = (*ubik_CRXSecurityProc) (ubik_CRXSecurityRock, &ubikSecClass,
186                                      &ubikSecIndex);
187     } else
188         i = 1;
189     if (i) {
190         /* don't have sec module yet */
191         ubikSecIndex = 0;
192         ubikSecClass = rxnull_NewClientSecurityObject();
193     }
194     magicHost = ntohl(ame);     /* do comparisons in host order */
195     magicServer = (struct ubik_server *)0;
196
197     if (info) {
198         for (i = 0; i < info->numServers; i++) {
199             if (ntohl((afs_uint32) info->hostAddr[i].sin_addr.s_addr) ==
200                 ntohl((afs_uint32) ame)) {
201                 me = i;
202                 if (clones[i]) {
203                     amIClone = 1;
204                     magicHost = 0;
205                 }
206             }
207         }
208         nServers = 0;
209         for (i = 0; i < info->numServers; i++) {
210             if (i == me)
211                 continue;
212             ts = (struct ubik_server *)malloc(sizeof(struct ubik_server));
213             memset(ts, 0, sizeof(struct ubik_server));
214             ts->next = ubik_servers;
215             ubik_servers = ts;
216             ts->addr[0] = info->hostAddr[i].sin_addr.s_addr;
217             if (clones[i]) {
218                 ts->isClone = 1;
219             } else {
220                 if (!magicHost
221                     || ntohl((afs_uint32) ts->addr[0]) <
222                     (afs_uint32) magicHost) {
223                     magicHost = ntohl(ts->addr[0]);
224                     magicServer = ts;
225                 }
226                 ++nServers;
227             }
228             /* for vote reqs */
229             ts->vote_rxcid =
230                 rx_NewConnection(info->hostAddr[i].sin_addr.s_addr,
231                                  ubik_callPortal, VOTE_SERVICE_ID,
232                                  ubikSecClass, ubikSecIndex);
233             /* for disk reqs */
234             ts->disk_rxcid =
235                 rx_NewConnection(info->hostAddr[i].sin_addr.s_addr,
236                                  ubik_callPortal, DISK_SERVICE_ID,
237                                  ubikSecClass, ubikSecIndex);
238             ts->up = 1;
239         }
240     } else {
241         i = 0;
242         while ((servAddr = *aservers++)) {
243             if (i >= MAXSERVERS)
244                 return UNHOSTS; /* too many hosts */
245             ts = (struct ubik_server *)malloc(sizeof(struct ubik_server));
246             memset(ts, 0, sizeof(struct ubik_server));
247             ts->next = ubik_servers;
248             ubik_servers = ts;
249             ts->addr[0] = servAddr;     /* primary address in  net byte order */
250             ts->vote_rxcid = rx_NewConnection(servAddr, ubik_callPortal, VOTE_SERVICE_ID, ubikSecClass, ubikSecIndex);  /* for vote reqs */
251             ts->disk_rxcid = rx_NewConnection(servAddr, ubik_callPortal, DISK_SERVICE_ID, ubikSecClass, ubikSecIndex);  /* for disk reqs */
252             ts->isClone = 0;    /* don't know about clones */
253             ts->up = 1;
254             if (ntohl((afs_uint32) servAddr) < (afs_uint32) magicHost) {
255                 magicHost = ntohl(servAddr);
256                 magicServer = ts;
257             }
258             i++;
259         }
260     }
261     if (magicServer)
262         magicServer->magic = 1; /* remember for when counting votes */
263
264     if (!amIClone && !magicServer)
265         amIMagic = 1;
266     if (info) {
267         if (!amIClone)
268             ++nServers;         /* count this server as well as the remotes */
269     } else
270         nServers = i + 1;       /* count this server as well as the remotes */
271
272     ubik_quorum = (nServers >> 1) + 1;  /* compute the majority figure */
273     /* send addrs to all other servers */
274     code = updateUbikNetworkAddress(ubik_host);
275     if (code)
276         return code;
277
278 /* Shoud we set some defaults for RX??
279     r_retryInterval = 2;        
280     r_nRetries = (RPCTIMEOUT/r_retryInterval);
281 */
282     if (info) {
283         if (!ubik_servers)      /* special case 1 server */
284             ubik_singleServer = 1;
285         if (nServers == 1 && !amIClone) {
286             ubik_amSyncSite = 1;        /* let's start as sync site */
287             syncSiteUntil = 0x7fffffff; /* and be it quite a while */
288         }
289     } else {
290         if (nServers == 1)      /* special case 1 server */
291             ubik_singleServer = 1;
292     }
293
294     if (ubik_singleServer) {
295         if (!ubik_amSyncSite)
296             ubik_dprint("Ubik: I am the sync site - 1 server\n");
297         ubik_amSyncSite = 1;
298         syncSiteUntil = 0x7fffffff;     /* quite a while */
299     }
300     return 0;
301 }
302
303 /* main lwp loop for code that sends out beacons.  This code only runs while
304  * we're sync site or we want to be the sync site.  It runs in its very own light-weight
305  * process.
306  */
307 ubeacon_Interact()
308 {
309     register afs_int32 code;
310     struct timeval tt;
311     struct rx_connection *connections[MAXSERVERS];
312     struct ubik_server *servers[MAXSERVERS];
313     register afs_int32 i;
314     register struct ubik_server *ts;
315     afs_int32 temp, yesVotes, lastWakeupTime, oldestYesVote, syncsite;
316     struct ubik_tid ttid;
317     afs_int32 startTime;
318
319     /* loop forever getting votes */
320     lastWakeupTime = 0;         /* keep track of time we last started a vote collection */
321     while (1) {
322
323         /* don't wakeup more than every POLLTIME seconds */
324         temp = (lastWakeupTime + POLLTIME) - FT_ApproxTime();
325         /* don't sleep if last collection phase took too long (probably timed someone out ) */
326         if (temp > 0) {
327             if (temp > POLLTIME)
328                 temp = POLLTIME;
329             tt.tv_sec = temp;
330             tt.tv_usec = 0;
331             code = IOMGR_Select(0, 0, 0, 0, &tt);
332         } else
333             code = 0;
334
335         lastWakeupTime = FT_ApproxTime();       /* started a new collection phase */
336
337         if (ubik_singleServer)
338             continue;           /* special-case 1 server for speedy startup */
339
340         if (!uvote_ShouldIRun())
341             continue;           /* if voter has heard from a better candidate than us, don't bother running */
342
343         /* otherwise we should run for election, or we're the sync site (and have already won);
344          * send out the beacon packets */
345         /* build list of all up hosts (noticing dead hosts are running again
346          * is a task for the recovery module, not the beacon module), and
347          * prepare to send them an r multi-call containing the beacon message */
348         i = 0;                  /* collect connections */
349         for (ts = ubik_servers; ts; ts = ts->next) {
350             if (ts->up && ts->addr[0] != ubik_host[0]) {
351                 servers[i] = ts;
352                 connections[i++] = ts->vote_rxcid;
353             }
354         }
355         servers[i] = (struct ubik_server *)0;   /* end of list */
356         /* note that we assume in the vote module that we'll always get at least BIGTIME 
357          * seconds of vote from anyone who votes for us, which means we can conservatively
358          * assume we'll be fine until SMALLTIME seconds after we start collecting votes */
359         /* this next is essentially an expansion of rgen's ServBeacon routine */
360
361         ttid.epoch = ubik_epochTime;
362         if (ubik_dbase->flags & DBWRITING) {
363             /*
364              * if a write is in progress, we have to send the writeTidCounter
365              * which holds the tid counter of the write transaction , and not
366              * send the tidCounter value which holds the tid counter of the
367              * last transaction.
368              */
369             ttid.counter = ubik_dbase->writeTidCounter;
370         } else
371             ttid.counter = ubik_dbase->tidCounter + 1;
372 #if defined(UBIK_PAUSE)
373         ubik_dbase->flags |= DBVOTING;
374 #endif /* UBIK_PAUSE */
375
376         /* now analyze return codes, counting up our votes */
377         yesVotes = 0;           /* count how many to ensure we have quorum */
378         oldestYesVote = 0x7fffffff;     /* time quorum expires */
379         syncsite = ubeacon_AmSyncSite();
380         startTime = FT_ApproxTime();
381         /*
382          * Don't waste time using mult Rx calls if there are no connections out there
383          */
384         if (i > 0) {
385             multi_Rx(connections, i) {
386                 multi_VOTE_Beacon(syncsite, startTime, &ubik_dbase->version,
387                                   &ttid);
388                 temp = FT_ApproxTime(); /* now, more or less */
389                 ts = servers[multi_i];
390                 ts->lastBeaconSent = temp;
391                 code = multi_error;
392                 /* note that the vote time (the return code) represents the time
393                  * the vote was computed, *not* the time the vote expires.  We compute
394                  * the latter down below if we got enough votes to go with */
395                 if (code > 0) {
396                     ts->lastVoteTime = code;
397                     if (code < oldestYesVote)
398                         oldestYesVote = code;
399                     ts->lastVote = 1;
400                     if (!ts->isClone)
401                         yesVotes += 2;
402                     if (ts->magic)
403                         yesVotes++;     /* the extra epsilon */
404                     ts->up = 1; /* server is up (not really necessary: recovery does this for real) */
405                     ts->beaconSinceDown = 1;
406                     ubik_dprint("yes vote from host %s\n",
407                                 afs_inet_ntoa(ts->addr[0]));
408                 } else if (code == 0) {
409                     ts->lastVoteTime = temp;
410                     ts->lastVote = 0;
411                     ts->beaconSinceDown = 1;
412                     ubik_dprint("no vote from %s\n",
413                                 afs_inet_ntoa(ts->addr[0]));
414                 } else if (code < 0) {
415                     ts->up = 0;
416                     ts->beaconSinceDown = 0;
417                     urecovery_LostServer();
418                     ubik_dprint("time out from %s\n",
419                                 afs_inet_ntoa(ts->addr[0]));
420                 }
421             }
422             multi_End;
423         }
424         /* now call our own voter module to see if we'll vote for ourself.  Note that
425          * the same restrictions apply for our voting for ourself as for our voting
426          * for anyone else. */
427         i = SVOTE_Beacon((struct rx_call *)0, ubeacon_AmSyncSite(), startTime,
428                          &ubik_dbase->version, &ttid);
429         if (i) {
430             yesVotes += 2;
431             if (amIMagic)
432                 yesVotes++;     /* extra epsilon */
433             if (i < oldestYesVote)
434                 oldestYesVote = i;
435         }
436 #if defined(UBIK_PAUSE)
437         ubik_dbase->flags &= ~DBVOTING;
438 #endif /* UBIK_PAUSE */
439
440         /* now decide if we have enough votes to become sync site.
441          * Note that we can still get enough votes even if we didn't for ourself. */
442         if (yesVotes > nServers) {      /* yesVotes is bumped by 2 or 3 for each site */
443             if (!ubik_amSyncSite)
444                 ubik_dprint("Ubik: I am the sync site\n");
445             ubik_amSyncSite = 1;
446             syncSiteUntil = oldestYesVote + SMALLTIME;
447             LWP_NoYieldSignal(&ubik_amSyncSite);
448         } else {
449             if (ubik_amSyncSite)
450                 ubik_dprint("Ubik: I am no longer the sync site\n");
451             ubik_amSyncSite = 0;
452             urecovery_ResetState();     /* tell recovery we're no longer the sync site */
453         }
454
455     }                           /* while loop */
456 }
457
458 /* 
459 * Input Param   : ame is the pointer to my IP address specified in the
460 *                 CellServDB file. aservers is an array containing IP 
461 *                 addresses of remote ubik servers. The array is 
462 *                 terminated by a zero address.
463 *
464 * Algorithm     : Verify that my IP addresses 'ame' does actually exist
465 *                 on this machine.  If any of my IP addresses are there 
466 *                 in the remote server list 'aserver', remove them from 
467 *                 this list.  Update global variable ubik_host[] with 
468 *                 my IP addresses.
469 *
470 * Return Values : 0 on success, non-zero on failure
471 */
472 static
473 verifyInterfaceAddress(ame, info, aservers)
474      afs_uint32 *ame;           /* one of my interface addr in net byte order */
475      struct afsconf_cell *info;
476      afs_uint32 aservers[];     /* list of all possible server addresses */
477 {
478     afs_uint32 myAddr[UBIK_MAX_INTERFACE_ADDR], *servList, tmpAddr;
479     afs_uint32 myAddr2[UBIK_MAX_INTERFACE_ADDR];
480     int tcount, count, found, i, j, totalServers, start, end, usednetfiles =
481         0;
482
483     if (info)
484         totalServers = info->numServers;
485     else {                      /* count the number of servers */
486         for (totalServers = 0, servList = aservers; *servList; servList++)
487             totalServers++;
488     }
489
490 #ifdef AFS_NT40_ENV
491     /* get all my interface addresses in net byte order */
492     count = rx_getAllAddr(myAddr, UBIK_MAX_INTERFACE_ADDR);
493 #else
494     if (AFSDIR_SERVER_NETRESTRICT_FILEPATH || AFSDIR_SERVER_NETINFO_FILEPATH) {
495         /*
496          * Find addresses we are supposed to register as per the netrestrict file
497          * if it exists, else just register all the addresses we find on this 
498          * host as returned by rx_getAllAddr (in NBO)
499          */
500         char reason[1024];
501         count =
502             parseNetFiles(myAddr, NULL, NULL, UBIK_MAX_INTERFACE_ADDR, reason,
503                           AFSDIR_SERVER_NETINFO_FILEPATH,
504                           AFSDIR_SERVER_NETRESTRICT_FILEPATH);
505         if (count < 0) {
506             ubik_print("ubik: Can't register any valid addresses:%s\n",
507                        reason);
508             ubik_print("Aborting..\n");
509             return UBADHOST;
510         }
511         usednetfiles++;
512     } else {
513         /* get all my interface addresses in net byte order */
514         count = rx_getAllAddr(myAddr, UBIK_MAX_INTERFACE_ADDR);
515     }
516 #endif
517
518     if (count <= 0) {           /* no address found */
519         ubik_print("ubik: No network addresses found, aborting..");
520         return UBADHOST;
521     }
522
523     /* verify that the My-address passed in by ubik is correct */
524     for (j = 0, found = 0; j < count; j++) {
525         if (*ame == myAddr[j]) {        /* both in net byte order */
526             found = 1;
527             break;
528         }
529     }
530
531     if (!found) {
532         ubik_print("ubik: primary address %s does not exist\n",
533                    afs_inet_ntoa(*ame));
534         /* if we had the result of rx_getAllAddr already, avoid subverting
535          * the "is gethostbyname(gethostname()) us" check. If we're
536          * using NetInfo/NetRestrict, we assume they have enough clue
537          * to avoid that big hole in their foot from the loaded gun. */
538         if (usednetfiles) {
539             /* take the address we did get, then see if ame was masked */
540             *ame = myAddr[0];
541             tcount = rx_getAllAddr(myAddr2, UBIK_MAX_INTERFACE_ADDR);
542             if (tcount <= 0) {  /* no address found */
543                 ubik_print("ubik: No network addresses found, aborting..");
544                 return UBADHOST;
545             }
546
547             /* verify that the My-address passed in by ubik is correct */
548             for (j = 0, found = 0; j < tcount; j++) {
549                 if (*ame == myAddr2[j]) {       /* both in net byte order */
550                     found = 1;
551                     break;
552                 }
553             }
554         }
555         if (!found)
556             return UBADHOST;
557     }
558
559     /* if any of my addresses are there in serverList, then
560      ** use that as my primary addresses : the higher level 
561      ** application screwed up in dealing with multihomed concepts
562      */
563     for (j = 0, found = 0; j < count; j++) {
564         for (i = 0; i < totalServers; i++) {
565             if (info)
566                 tmpAddr = (afs_uint32) info->hostAddr[i].sin_addr.s_addr;
567             else
568                 tmpAddr = aservers[i];
569             if (myAddr[j] == tmpAddr) {
570                 *ame = tmpAddr;
571                 if (!info)
572                     aservers[i] = 0;
573                 found = 1;
574             }
575         }
576     }
577     if (found)
578         ubik_print("Using %s as my primary address\n", afs_inet_ntoa(*ame));
579
580     if (!info) {
581         /* get rid of servers which were purged because all 
582          ** those interface addresses are myself 
583          */
584         for (start = 0, end = totalServers - 1; (start < end); start++, end--) {
585             /* find the first zero entry from the beginning */
586             for (; (start < end) && (aservers[start]); start++);
587
588             /* find the last non-zero entry from the end */
589             for (; (end >= 0) && (!aservers[end]); end--);
590
591             /* if there is nothing more to purge, exit from loop */
592             if (start >= end)
593                 break;
594
595             /* move the entry */
596             aservers[start] = aservers[end];
597             aservers[end] = 0;  /* this entry was moved */
598         }
599     }
600
601     /* update all my addresses in ubik_host in such a way 
602      ** that ubik_host[0] has the primary address 
603      */
604     ubik_host[0] = *ame;
605     for (j = 0, i = 1; j < count; j++)
606         if (*ame != myAddr[j])
607             ubik_host[i++] = myAddr[j];
608
609     return 0;                   /* return success */
610 }
611
612
613 /* 
614 * Input Param   : ubik_host is an array containing all my IP addresses.
615 *
616 * Algorithm     : Do an RPC to all remote ubik servers infroming them 
617 *                 about my IP addresses. Get their IP addresses and
618 *                 update my linked list of ubik servers 'ubik_servers'
619 *
620 * Return Values : 0 on success, non-zero on failure
621 */
622 int
623 updateUbikNetworkAddress(ubik_host)
624      afs_uint32 ubik_host[UBIK_MAX_INTERFACE_ADDR];
625 {
626     int j, count, code = 0;
627     UbikInterfaceAddr inAddr, outAddr;
628     struct rx_connection *conns[MAXSERVERS];
629     struct ubik_server *ts, *server[MAXSERVERS];
630     char buffer[32];
631
632     for (count = 0, ts = ubik_servers; ts; count++, ts = ts->next) {
633         conns[count] = ts->disk_rxcid;
634         server[count] = ts;
635     }
636
637
638     /* inform all other servers only if there are more than one
639      * database servers in the cell */
640
641     if (count > 0) {
642
643         for (j = 0; j < UBIK_MAX_INTERFACE_ADDR; j++)
644             inAddr.hostAddr[j] = ntohl(ubik_host[j]);
645
646
647         /* do the multi-RX RPC to all other servers */
648         multi_Rx(conns, count) {
649             multi_DISK_UpdateInterfaceAddr(&inAddr, &outAddr);
650             ts = server[multi_i];       /* reply received from this server */
651             if (!multi_error) {
652                 if (ts->addr[0] != htonl(outAddr.hostAddr[0])) {
653                     code = UBADHOST;
654                     strcpy(buffer, (char *)afs_inet_ntoa(ts->addr[0]));
655                     ubik_print("ubik:Two primary addresses for same server \
656                     %s %s\n", buffer, afs_inet_ntoa(htonl(outAddr.hostAddr[0])));
657                 } else {
658                     for (j = 1; j < UBIK_MAX_INTERFACE_ADDR; j++)
659                         ts->addr[j] = htonl(outAddr.hostAddr[j]);
660                 }
661             } else if (multi_error == RXGEN_OPCODE) {   /* pre 3.5 remote server */
662                 ubik_print
663                     ("ubik server %s does not support UpdateInterfaceAddr RPC\n",
664                      afs_inet_ntoa(ts->addr[0]));
665             } else if (multi_error == UBADHOST) {
666                 code = UBADHOST;        /* remote CellServDB inconsistency */
667                 ubik_print("Inconsistent Cell Info on server: ");
668                 for (j = 0; j < UBIK_MAX_INTERFACE_ADDR && ts->addr[j]; j++)
669                     ubik_print("%s ", afs_inet_ntoa(ts->addr[j]));
670                 ubik_print("\n");
671             } else {
672                 ts->up = 0;     /* mark the remote server as down */
673             }
674         }
675         multi_End;
676     }
677     return code;
678 }