[8371] in Athena Bugs
AFS subnet biasing
daemon@ATHENA.MIT.EDU (Richard Basch)
Wed Oct 9 21:33:28 1991
Date: Wed, 9 Oct 91 21:34:13 -0400
To: afsbugs+@transarc.com
Cc: bugs@MIT.EDU
From: "Richard Basch" <basch@MIT.EDU>
The following patches are things that we did at MIT; one of them was to
introduce the concept of subnet biasing. This code works on the
following machine types:
vax_bsd43
rt_aos4
rs_aix31
Even though I have not built another version of the binaries, it should
also work on:
vax_ul4
pmax_ul4
To compile it on the rs_aix31 system, you will need to extend your .exp
files to include some of the other externals, such as "ifnet".
I expect this code will work on almost every system; I have a high
degree of confidence that this will work with Sun systems, since they
are very similar to BSD in networking code. When I complete my MAC A/UX
port, I will submit lots of patches, one of which may be to this code to
work with that system. Since IFS is asking about the MAC A/UX port, I
will give them the pieces that do not contain your code, and give them
pointers as to how I did the rest (at least until you give the ok to
pass it on).
-R
*** /tmp/,RCSt1PCkBwj Wed Oct 9 21:27:23 1991
--- afs/afs_resource.c Mon Oct 7 00:58:34 1991
***************
*** 11,22 ****
#include "../afs/afsincludes.h" /* Afs-based standard headers */
#include "../afs/afs_stats.h" /* afs statistics */
/* shouldn't do it this way, but for now will do */
#ifndef ERROR_TABLE_BASE_u
#define ERROR_TABLE_BASE_u (5376L)
#endif /* ubik error base define */
! RCSID ("$Header: /afs/athena.mit.edu/astaff/project/afsdev/src/3.1.patch/src/afs/RCS/afs_resource.c,v 1.1 91/08/10 17:08:45 probe Exp $")
/* This file contains routines used for dealing with users, volumes, cells
* and connections. They are related, unfortunately, as follows:
--- 11,27 ----
#include "../afs/afsincludes.h" /* Afs-based standard headers */
#include "../afs/afs_stats.h" /* afs statistics */
+ #ifdef AFS_PREFER_LOCAL
+ #include "../net/if.h"
+ #include "../netinet/in_var.h"
+ #endif
+
/* shouldn't do it this way, but for now will do */
#ifndef ERROR_TABLE_BASE_u
#define ERROR_TABLE_BASE_u (5376L)
#endif /* ubik error base define */
! RCSID ("$Header: /afs/athena.mit.edu/astaff/project/afsdev/src/3.1.patch/src/afs/RCS/afs_resource.c,v 1.2 91/10/04 15:11:49 probe Exp Locker: probe $")
/* This file contains routines used for dealing with users, volumes, cells
* and connections. They are related, unfortunately, as follows:
***************
*** 212,219 ****
if (tu->ct.EndTimestamp < now) {
/* this token has expired, warn users and reset access cache */
tcell = afs_GetCell(tu->cell);
! printf("afs: Tokens for user of AFS id %d for cell %s expired now\n",
! tu->vid, tcell->cellName);
tu->states |= (UTokensBad | UNeedsReset);
}
}
--- 217,230 ----
if (tu->ct.EndTimestamp < now) {
/* this token has expired, warn users and reset access cache */
tcell = afs_GetCell(tu->cell);
! #ifndef AFS_ATHENA_ENV
! /* This shouldn't be broadcast to the console or to
! * other people, and it won't necessarily get to the
! * person for whom the tokens have expired.
! */
! printf("afs: Tokens for user %d (AFS id %d) for cell %s expired now\n",
! tu->uid, tu->vid, tcell->cellName);
! #endif
tu->states |= (UTokensBad | UNeedsReset);
}
}
***************
*** 348,354 ****
struct volume *afs_GetVolSlot()
{
extern int cacheDiskType;
! struct volume *afs_UFSGetVolSlot(), *afs_MemGetVolSlot();
AFS_STATCNT(afs_GetVolSlot);
switch(cacheDiskType) {
--- 359,368 ----
struct volume *afs_GetVolSlot()
{
extern int cacheDiskType;
! struct volume *afs_UFSGetVolSlot();
! #ifndef AFS_NOMEMCACHE
! struct volume *afs_MemGetVolSlot();
! #endif
AFS_STATCNT(afs_GetVolSlot);
switch(cacheDiskType) {
***************
*** 356,362 ****
--- 370,380 ----
return afs_UFSGetVolSlot();
break;
case AFS_FCACHE_TYPE_MEM:
+ #ifdef AFS_NOMEMCACHE
+ panic("afs_CFileOpen: Memory cache file type not supported");
+ #else
return afs_MemGetVolSlot();
+ #endif
break;
case AFS_FCACHE_TYPE_NFS:
panic("afs_CFileOpen: NFS cache file type not supported");
***************
*** 427,432 ****
--- 445,451 ----
return tv;
}
+ #ifndef AFS_NOMEMCACHE
struct volume *afs_MemGetVolSlot() {
register struct volume *tv, **lv;
register long i;
***************
*** 446,451 ****
--- 465,471 ----
afs_freeVolList = tv->next;
return tv;
}
+ #endif /* !AFS_NOMEMCACHE */
/* reset volume name to volume id mapping cache */
afs_CheckVolumeNames() {
***************
*** 1336,1341 ****
--- 1356,1366 ----
register long aserver; {
register struct server *ts;
register int i;
+ #ifdef AFS_PREFER_LOCAL
+ register u_long as = ntohl(aserver);
+ register struct ifnet *in;
+ #endif
+
AFS_STATCNT(afs_GetServer);
i = SHash(aserver);
ObtainSharedLock(&afs_xserver);
***************
*** 1355,1360 ****
--- 1380,1412 ----
/* compute random value for funny sorting */
afs_servers[i] = ts;
ts->random = afs_random();
+ #ifdef AFS_PREFER_LOCAL
+ /*
+ * Bias the order so that servers on the local subnets are preferred.
+ *
+ * Written by Richard Basch/MIT
+ * Copyright (c) 1991 by the Massachusetts Institute of Technology.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of M.I.T. not be used in
+ * advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. M.I.T. makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ */
+ ts->random |= 0x4000; /* Set the high bit */
+ for (in = ifnet; in; in=in->if_next) {
+ register struct in_ifaddr *ia = (struct in_ifaddr *)in->if_addrlist;
+ if ((in->if_flags & IFF_UP) &&
+ (as & ia->ia_subnetmask) == ia->ia_subnet) {
+ ts->random &= 0x3fff; /* Local: clear high bits */
+ break; /* No need to check more */
+ }
+ }
+ #endif
ReleaseWriteLock(&afs_xserver);
return ts;
}
***************
*** 1553,1559 ****
tu = afs_FindUser(areq->uid, tsp->cell->cell);
#ifndef AFS_NEXT_ENV
if (tu) {
! uprintf("afs: Tokens for user of AFS id %d for cell %s have expired\n", tu->vid, aconn->server->cell->cellName);
}
else /* The else case shouldn't be possible and should probably be replaced by a panic? */
uprintf("afs: Tokens for user %d for cell %s have expired\n", areq->uid, aconn->server->cell->cellName);
--- 1605,1612 ----
tu = afs_FindUser(areq->uid, tsp->cell->cell);
#ifndef AFS_NEXT_ENV
if (tu) {
! uprintf("afs: Tokens for user %d (AFS id %d) for cell %s have expired\n",
! areq->uid, tu->vid, aconn->server->cell->cellName);
}
else /* The else case shouldn't be possible and should probably be replaced by a panic? */
uprintf("afs: Tokens for user %d for cell %s have expired\n", areq->uid, aconn->server->cell->cellName);