summaryrefslogtreecommitdiffstats
path: root/usr.sbin/amd
diff options
context:
space:
mode:
authordfr <dfr@FreeBSD.org>1998-04-13 12:11:24 +0000
committerdfr <dfr@FreeBSD.org>1998-04-13 12:11:24 +0000
commit72618c7990b921fdec9b65204302a5e9346e62ac (patch)
tree970f24971c446f2d6122b1a1940ecc79dcad987d /usr.sbin/amd
parent0996fc2e055d7cdc5c4fe1bab2f7f73b73062659 (diff)
downloadFreeBSD-src-72618c7990b921fdec9b65204302a5e9346e62ac.zip
FreeBSD-src-72618c7990b921fdec9b65204302a5e9346e62ac.tar.gz
Fixes for using amd with non-NFSv3 servers and for choosing the right address
for a multihomed server. PR: bin/6231, bin/4678 Submitted by: Mika Nystrom <mika@cs.caltech.edu
Diffstat (limited to 'usr.sbin/amd')
-rw-r--r--usr.sbin/amd/amd/amd.c7
-rw-r--r--usr.sbin/amd/amd/nfs_ops.c11
-rw-r--r--usr.sbin/amd/amd/srvr_nfs.c37
-rw-r--r--usr.sbin/amd/amd/wire.c11
4 files changed, 58 insertions, 8 deletions
diff --git a/usr.sbin/amd/amd/amd.c b/usr.sbin/amd/amd/amd.c
index 1d3a1e4..c8c513e 100644
--- a/usr.sbin/amd/amd/amd.c
+++ b/usr.sbin/amd/amd/amd.c
@@ -37,7 +37,7 @@
*
* @(#)amd.c 8.1 (Berkeley) 6/6/93
*
- * $Id: amd.c,v 1.5 1997/02/22 16:01:26 peter Exp $
+ * $Id: amd.c,v 1.6 1997/09/02 06:35:01 charnier Exp $
*
*/
@@ -72,6 +72,9 @@ char *op_sys = OS_REP; /* Name of current op_sys */
char *arch = ARCH_REP; /* Name of current architecture */
char *endian = ARCH_ENDIAN; /* Big or Little endian */
char *wire;
+unsigned long mysubnet; /* subnet address for my machine
+ corresponding to "wire"
+ */
int foreground = 1; /* This is the top-level server */
int mypid; /* Current process id */
int immediate_abort; /* Should close-down unmounts be retried */
@@ -271,7 +274,7 @@ char *argv[];
orig_umask = umask(0);
/*
- * Figure out primary network name
+ * Figure out primary network name; side-effect: sets "mysubnet"
*/
wire = getwire();
diff --git a/usr.sbin/amd/amd/nfs_ops.c b/usr.sbin/amd/amd/nfs_ops.c
index 1d94943..fa8ac03 100644
--- a/usr.sbin/amd/amd/nfs_ops.c
+++ b/usr.sbin/amd/amd/nfs_ops.c
@@ -35,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: nfs_ops.c,v 1.6 1997/02/22 16:01:37 peter Exp $
+ * $Id: nfs_ops.c,v 1.8 1997/04/22 10:24:26 dfr Exp $
*/
#ifndef lint
@@ -178,6 +178,15 @@ int done;
#ifdef DEBUG
dlog("mount version 3 refused, retrying with version 1");
#endif
+ /*
+ * At this point, fp->fh_error is meaningless
+ * since we are already fixing the problem
+ * We don't want it to get back to the caller!
+ * Mount is now still "in progress"
+ *
+ */
+
+ fp->fh_error = -1;
fp->fh_id = FHID_ALLOC();
fp->fh_mountres.mr_version = MOUNTVERS;
call_mountd(fp, MOUNTPROC_MNT, MOUNTVERS, got_nfs_fh, fp->fh_wchan);
diff --git a/usr.sbin/amd/amd/srvr_nfs.c b/usr.sbin/amd/amd/srvr_nfs.c
index 22e99fc..0672c8e 100644
--- a/usr.sbin/amd/amd/srvr_nfs.c
+++ b/usr.sbin/amd/amd/srvr_nfs.c
@@ -37,7 +37,7 @@
*
* @(#)srvr_nfs.c 8.1 (Berkeley) 6/6/93
*
- * $Id$
+ * $Id: srvr_nfs.c,v 1.4 1997/02/22 16:01:44 peter Exp $
*
*/
@@ -591,6 +591,9 @@ int pingval;
}
}
+
+extern unsigned long mysubnet;
+
/*
* Find an nfs server for a host.
*/
@@ -653,13 +656,41 @@ mntfs *mf;
* Get here if we can't find an entry
*/
if (hp) {
+ int i, j;
+ unsigned long tmpaddr;
+
switch (hp->h_addrtype) {
case AF_INET:
ip = ALLOC(sockaddr_in);
bzero((voidp) ip, sizeof(*ip));
ip->sin_family = AF_INET;
- bcopy((voidp) hp->h_addr, (voidp) &ip->sin_addr, sizeof(ip->sin_addr));
-
+ /*
+ * pick host address that is on the same subnet
+ * as mysubnet if possible; otherwise, pick the first
+ * one.
+ */
+ for (i=0; hp->h_addr_list[i]; i++) {
+ bcopy ((voidp)hp->h_addr_list[i], (voidp)&tmpaddr,
+ sizeof(tmpaddr));
+ for (j=0; j < 4; j++) {
+ if ((0xff & (mysubnet >> 8*j)) == 0) continue;
+ if ((0xff & (mysubnet >> 8*j)) !=
+ (0xff & (tmpaddr >> 8*j))) break;
+ }
+ if (j == 4) {
+
+ /* we found a matching subnet address */
+ break;
+ }
+ }
+ if (!hp->h_addr_list[i]) {
+ /* no interface matching current subnet; pick one */
+ bcopy((voidp) hp->h_addr, (voidp) &ip->sin_addr, sizeof(ip->sin_addr));
+ }
+ else {
+ /* we found a matching subnet interface */
+ bcopy((voidp) hp->h_addr_list[i], (voidp) &ip->sin_addr, sizeof(ip->sin_addr));
+ }
ip->sin_port = htons(NFS_PORT);
break;
diff --git a/usr.sbin/amd/amd/wire.c b/usr.sbin/amd/amd/wire.c
index 340a284..a31e0f6 100644
--- a/usr.sbin/amd/amd/wire.c
+++ b/usr.sbin/amd/amd/wire.c
@@ -37,7 +37,7 @@
*
* @(#)wire.c 8.1 (Berkeley) 6/6/93
*
- * $Id$
+ * $Id: wire.c,v 1.4 1997/02/22 16:01:46 peter Exp $
*
*/
@@ -85,6 +85,8 @@ static addrlist *localnets = 0;
#define clist (ifc.ifc_ifcu.ifcu_req)
#define count (ifc.ifc_len/sizeof(struct ifreq))
+extern unsigned long mysubnet;
+
char *getwire P((void));
char *getwire()
{
@@ -136,6 +138,8 @@ char *getwire()
/*
* Scan the list looking for a suitable interface
*/
+ mysubnet = 0;
+
for (cp = buf; cp < cplim; cp += size(ifr)) {
addrlist *al;
ifr = (struct ifreq *) cp;
@@ -227,10 +231,13 @@ char *getwire()
/* This is probably very wrong. */
np = getnetbyaddr(subnet, AF_INET);
#endif /* IN_CLASSA */
- if (np)
+ if (np) {
s = np->n_name;
+ mysubnet = np->n_net;
+ }
else {
subnet = address & netmask;
+ mysubnet = subnet;
hp = gethostbyaddr((char *) &subnet, 4, AF_INET);
if (hp)
s = hp->h_name;
OpenPOWER on IntegriCloud