From 302f15f9e8ab2d8b614b27e4655e4383f99055ad Mon Sep 17 00:00:00 2001 From: "Matthew N. Dodd" Date: Tue, 25 Mar 2003 01:25:30 +0000 Subject: [PATCH] Add mount options 'noinet4' and 'noinet6' which prevent using those address families. This is useful for preventing NFS mounts from using IPv6 on hosts that have both A and AAAA records for the same name. --- sbin/mount_nfs/mount_nfs.8 | 4 ++++ sbin/mount_nfs/mount_nfs.c | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/sbin/mount_nfs/mount_nfs.8 b/sbin/mount_nfs/mount_nfs.8 index 56a2ba616c40..3fe82e5cdd6a 100644 --- a/sbin/mount_nfs/mount_nfs.8 +++ b/sbin/mount_nfs/mount_nfs.8 @@ -227,6 +227,10 @@ upper and lower bounds of the timeouts for ``directory'' attributes and for regular files, and 30 -> 60 seconds for directories. The algorithm to calculate the timeout is based on the age of the file. The older the file, the longer the cache is considered valid, subject to the limits above. +.It noinet4 +.It noinet6 +Disables AF_INET or AF_INET6 connections. Useful for hosts that have +both an A record and an AAAA record for the same name. .El .Pp .Bl -tag -width "dumbtimerXX" diff --git a/sbin/mount_nfs/mount_nfs.c b/sbin/mount_nfs/mount_nfs.c index 7bbfa7edb6ad..fd2e5f967031 100644 --- a/sbin/mount_nfs/mount_nfs.c +++ b/sbin/mount_nfs/mount_nfs.c @@ -98,6 +98,8 @@ static const char rcsid[] = #define ALTF_ACDIRMIN 0x20000 #define ALTF_ACDIRMAX 0x40000 #define ALTF_NOLOCKD 0x80000 +#define ALTF_NOINET4 0x100000 +#define ALTF_NOINET6 0x200000 struct mntopt mopts[] = { MOPT_STDOPTS, @@ -121,6 +123,8 @@ struct mntopt mopts[] = { { "acdirmin=", 0, ALTF_ACDIRMIN, 1 }, { "acdirmax=", 0, ALTF_ACDIRMAX, 1 }, { "lockd", 1, ALTF_NOLOCKD, 1 }, + { "inet4", 1, ALTF_NOINET4, 1 }, + { "inet6", 1, ALTF_NOINET6, 1 }, { NULL } }; @@ -172,6 +176,8 @@ struct nfhret { }; #define BGRND 1 #define ISBGRND 2 +#define OF_NOINET4 4 +#define OF_NOINET6 8 int retrycnt = -1; int opflags = 0; int nfsproto = IPPROTO_UDP; @@ -333,6 +339,10 @@ main(argc, argv) */ if (altflags & ALTF_BG) opflags |= BGRND; + if (altflags & ALTF_NOINET4) + opflags |= OF_NOINET4; + if (altflags & ALTF_NOINET6) + opflags |= OF_NOINET6; if (altflags & ALTF_MNTUDP) mnttcp_ok = 0; if (altflags & ALTF_TCP) { @@ -529,6 +539,12 @@ getnfsargs(spec, nfsargsp) */ remoteerr = 0; for (ai = ai_nfs; ai != NULL; ai = ai->ai_next) { + if ((ai->ai_family == AF_INET6) && + (opflags & OF_NOINET6)) + continue; + if ((ai->ai_family == AF_INET) && + (opflags & OF_NOINET4)) + continue; ret = nfs_tryproto(nfsargsp, ai, hostp, spec, &errstr); if (ret == TRYRET_SUCCESS) break;