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