summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorrmacklem <rmacklem@FreeBSD.org>2016-12-03 21:56:46 +0000
committerrmacklem <rmacklem@FreeBSD.org>2016-12-03 21:56:46 +0000
commit2cf7ac1cb82bf50e2d65da5345d07a51900953b4 (patch)
tree03050755991d18096718c2dc961c1f5b67cd42a8 /sbin
parent364520e9c44df40168a3962fa08744c3379b3453 (diff)
downloadFreeBSD-src-2cf7ac1cb82bf50e2d65da5345d07a51900953b4.zip
FreeBSD-src-2cf7ac1cb82bf50e2d65da5345d07a51900953b4.tar.gz
MFC: r308871
Modify umount so that it does not do an Unmount RPC for NFSv4 mounts and uses TCP for the Unmount RPC if the mount is over TCP. Without this patch, umount does an Unmount RPC over UDP for all NFS mounts.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/umount/umount.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/sbin/umount/umount.c b/sbin/umount/umount.c
index 521bbc8..ccd15f5 100644
--- a/sbin/umount/umount.c
+++ b/sbin/umount/umount.c
@@ -49,6 +49,7 @@ static const char rcsid[] =
#include <netdb.h>
#include <rpc/rpc.h>
#include <rpcsvc/mount.h>
+#include <nfs/nfssvc.h>
#include <ctype.h>
#include <err.h>
@@ -317,6 +318,9 @@ umountfs(struct statfs *sfs)
CLIENT *clp;
char *nfsdirname, *orignfsdirname;
char *hostp, *delimp;
+ char buf[1024];
+ struct nfscl_dumpmntopts dumpmntopts;
+ const char *proto_ptr = NULL;
ai = NULL;
do_rpc = 0;
@@ -355,8 +359,24 @@ umountfs(struct statfs *sfs)
* mount from mntfromname that is still mounted.
*/
if (getmntentry(sfs->f_mntfromname, NULL, NULL,
- CHECKUNIQUE) != NULL)
+ CHECKUNIQUE) != NULL) {
do_rpc = 1;
+ proto_ptr = "udp";
+ /*
+ * Try and find out whether this NFS mount is NFSv4 and
+ * what protocol is being used. If this fails, the
+ * default is NFSv2,3 and use UDP for the Unmount RPC.
+ */
+ dumpmntopts.ndmnt_fname = sfs->f_mntonname;
+ dumpmntopts.ndmnt_buf = buf;
+ dumpmntopts.ndmnt_blen = sizeof(buf);
+ if (nfssvc(NFSSVC_DUMPMNTOPTS, &dumpmntopts) >= 0) {
+ if (strstr(buf, "nfsv4,") != NULL)
+ do_rpc = 0;
+ else if (strstr(buf, ",tcp,") != NULL)
+ proto_ptr = "tcp";
+ }
+ }
}
if (!namematch(ai)) {
@@ -394,7 +414,7 @@ umountfs(struct statfs *sfs)
* has been unmounted.
*/
if (ai != NULL && !(fflag & MNT_FORCE) && do_rpc) {
- clp = clnt_create(hostp, MOUNTPROG, MOUNTVERS3, "udp");
+ clp = clnt_create(hostp, MOUNTPROG, MOUNTVERS3, proto_ptr);
if (clp == NULL) {
warnx("%s: %s", hostp,
clnt_spcreateerror("MOUNTPROG"));
OpenPOWER on IntegriCloud