From owner-dev-commits-src-all@freebsd.org Tue Sep 14 18:18:10 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 44CBB66E11F; Tue, 14 Sep 2021 18:18:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4H8BRQ1Qq2z3s8n; Tue, 14 Sep 2021 18:18:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 115381EDE8; Tue, 14 Sep 2021 18:18:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 18EII94C044014; Tue, 14 Sep 2021 18:18:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 18EII9NB044013; Tue, 14 Sep 2021 18:18:09 GMT (envelope-from git) Date: Tue, 14 Sep 2021 18:18:09 GMT Message-Id: <202109141818.18EII9NB044013@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alexander Motin Subject: git: 272c4a4dc5fb - main - Allow setting NFS server scope and owner. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 272c4a4dc5fbe3d82d735c5b9a3b6faab052808b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Sep 2021 18:18:10 -0000 The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=272c4a4dc5fbe3d82d735c5b9a3b6faab052808b commit 272c4a4dc5fbe3d82d735c5b9a3b6faab052808b Author: Alexander Motin AuthorDate: 2021-09-14 18:14:30 +0000 Commit: Alexander Motin CommitDate: 2021-09-14 18:18:03 +0000 Allow setting NFS server scope and owner. By default NFS server reports as scope and owner major the host UUID value and zero for owner minor. It works good in case of standalone server. But in case of CARP-based HA cluster failover the values should remain persistent, otherwise some clients like VMware ESXi get confused by the change and fail to reconnect automatically. The patch makes server scope, major owner and minor owner values configurable via sysctls. If not set (by default) the host UUID value is still used. Reviewed by: rmacklem MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D31952 --- sys/fs/nfsserver/nfs_nfsdserv.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/sys/fs/nfsserver/nfs_nfsdserv.c b/sys/fs/nfsserver/nfs_nfsdserv.c index 85834f7796f7..4394d3033fce 100644 --- a/sys/fs/nfsserver/nfs_nfsdserv.c +++ b/sys/fs/nfsserver/nfs_nfsdserv.c @@ -82,6 +82,15 @@ static bool nfsrv_openaccess = true; SYSCTL_BOOL(_vfs_nfsd, OID_AUTO, v4openaccess, CTLFLAG_RW, &nfsrv_openaccess, 0, "Enable Linux style NFSv4 Open access check"); +static char nfsrv_scope[NFSV4_OPAQUELIMIT]; +SYSCTL_STRING(_vfs_nfsd, OID_AUTO, scope, CTLFLAG_RWTUN, + &nfsrv_scope, NFSV4_OPAQUELIMIT, "Server scope"); +static char nfsrv_owner_major[NFSV4_OPAQUELIMIT]; +SYSCTL_STRING(_vfs_nfsd, OID_AUTO, owner_major, CTLFLAG_RWTUN, + &nfsrv_owner_major, NFSV4_OPAQUELIMIT, "Server owner major"); +static uint64_t nfsrv_owner_minor; +SYSCTL_U64(_vfs_nfsd, OID_AUTO, owner_minor, CTLFLAG_RWTUN, + &nfsrv_owner_minor, 0, "Server owner minor"); /* * This list defines the GSS mechanisms supported. @@ -4253,7 +4262,6 @@ nfsrvd_exchangeid(struct nfsrv_descript *nd, __unused int isdgram, nfsquad_t clientid, confirm; uint8_t *verf; uint32_t sp4type, v41flags; - uint64_t owner_minor; struct timespec verstime; #ifdef INET struct sockaddr_in *sin, *rin; @@ -4262,6 +4270,7 @@ nfsrvd_exchangeid(struct nfsrv_descript *nd, __unused int isdgram, struct sockaddr_in6 *sin6, *rin6; #endif struct thread *p = curthread; + char *s; if ((nd->nd_repstat = nfsd_checkrootexp(nd)) != 0) goto nfsmout; @@ -4376,12 +4385,17 @@ nfsrvd_exchangeid(struct nfsrv_descript *nd, __unused int isdgram, *tl++ = txdr_unsigned(confirm.lval[0]); /* SequenceID */ *tl++ = txdr_unsigned(v41flags); /* Exch flags */ *tl++ = txdr_unsigned(NFSV4EXCH_SP4NONE); /* No SSV */ - owner_minor = 0; /* Owner */ - txdr_hyper(owner_minor, tl); /* Minor */ - (void)nfsm_strtom(nd, nd->nd_cred->cr_prison->pr_hostuuid, - strlen(nd->nd_cred->cr_prison->pr_hostuuid)); /* Major */ - (void)nfsm_strtom(nd, nd->nd_cred->cr_prison->pr_hostuuid, - strlen(nd->nd_cred->cr_prison->pr_hostuuid)); /* Scope */ + txdr_hyper(nfsrv_owner_minor, tl); /* Owner Minor */ + if (nfsrv_owner_major[0] != 0) + s = nfsrv_owner_major; + else + s = nd->nd_cred->cr_prison->pr_hostuuid; + nfsm_strtom(nd, s, strlen(s)); /* Owner Major */ + if (nfsrv_scope[0] != 0) + s = nfsrv_scope; + else + s = nd->nd_cred->cr_prison->pr_hostuuid; + nfsm_strtom(nd, s, strlen(s) ); /* Scope */ NFSM_BUILD(tl, uint32_t *, NFSX_UNSIGNED); *tl = txdr_unsigned(1); (void)nfsm_strtom(nd, "freebsd.org", strlen("freebsd.org"));