From owner-svn-src-all@freebsd.org Sat Dec 3 21:49:27 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 72868C6582D; Sat, 3 Dec 2016 21:49:27 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2923A84; Sat, 3 Dec 2016 21:49:27 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uB3LnQDB034689; Sat, 3 Dec 2016 21:49:26 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uB3LnQTE034688; Sat, 3 Dec 2016 21:49:26 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201612032149.uB3LnQTE034688@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Sat, 3 Dec 2016 21:49:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r309517 - stable/11/sbin/umount X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Dec 2016 21:49:27 -0000 Author: rmacklem Date: Sat Dec 3 21:49:26 2016 New Revision: 309517 URL: https://svnweb.freebsd.org/changeset/base/309517 Log: 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. Modified: stable/11/sbin/umount/umount.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/umount/umount.c ============================================================================== --- stable/11/sbin/umount/umount.c Sat Dec 3 21:27:19 2016 (r309516) +++ stable/11/sbin/umount/umount.c Sat Dec 3 21:49:26 2016 (r309517) @@ -49,6 +49,7 @@ static const char rcsid[] = #include #include #include +#include #include #include @@ -323,6 +324,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; @@ -361,8 +365,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)) { @@ -400,7 +420,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"));