Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 03 Sep 2019 14:06:21 -0000
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r345895 - head/sys/fs/nfs
Message-ID:  <201904042330.x34NURAA024207@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rmacklem
Date: Thu Apr  4 23:30:27 2019
New Revision: 345895
URL: https://svnweb.freebsd.org/changeset/base/345895

Log:
  Revert r320698, since the related userland changes were reverted by r338192.
  
  r338192 reverted the changes to nfsuserd so that it could use an AF_LOCAL
  socket, since it resulted in a vnode locking panic().
  Post r338192 nfsuserd daemons use the old AF_INET socket for upcalls and
  do not use these kernel changes.
  I left them in for a while, so that nfsuserd daemons built from head sources
  between r320757 (Jul. 6, 2017) and r338192 (Aug. 22, 2018) would need them
  by default.
  This only affects head, since the changes were never MFC'd.
  I will add an UPDATING entry, since an nfsuserd daemon built from head
  sources between r320757 and r338192 will not run unless the "-use-udpsock"
  option is specified. (This command line option is only in the affected
  revisions of the nfsuserd daemon.)
  
  I suspect few will be affected by this, since most who run systems built
  from head sources (not stable or releases) will have rebuilt their nfsuserd
  daemon from sources post r338192 (Aug. 22, 2018)
  
  This is being reverted in preparation for an update to include AF_INET6
  support to the code.

Modified:
  head/sys/fs/nfs/nfs_commonkrpc.c
  head/sys/fs/nfs/nfs_commonport.c
  head/sys/fs/nfs/nfs_commonsubs.c
  head/sys/fs/nfs/nfs_var.h

Modified: head/sys/fs/nfs/nfs_commonkrpc.c
==============================================================================
--- head/sys/fs/nfs/nfs_commonkrpc.c	Thu Apr  4 23:16:36 2019	(r345894)
+++ head/sys/fs/nfs/nfs_commonkrpc.c	Thu Apr  4 23:30:27 2019	(r345895)
@@ -208,8 +208,6 @@ newnfs_connect(struct nfsmount *nmp, struct nfssockreq
 			nconf = getnetconfigent("udp");
 		else
 			nconf = getnetconfigent("tcp");
-	else if (saddr->sa_family == AF_LOCAL)
-		nconf = getnetconfigent("local");
 	else
 		if (nrp->nr_sotype == SOCK_DGRAM)
 			nconf = getnetconfigent("udp6");

Modified: head/sys/fs/nfs/nfs_commonport.c
==============================================================================
--- head/sys/fs/nfs/nfs_commonport.c	Thu Apr  4 23:16:36 2019	(r345894)
+++ head/sys/fs/nfs/nfs_commonport.c	Thu Apr  4 23:30:27 2019	(r345895)
@@ -631,30 +631,14 @@ nfssvc_call(struct thread *p, struct nfssvc_args *uap,
 		goto out;
 	} else if (uap->flag & NFSSVC_NFSUSERDPORT) {
 		u_short sockport;
-		struct sockaddr *sad;
-		struct sockaddr_un *sun;
 
-		if ((uap->flag & NFSSVC_NEWSTRUCT) != 0) {
-			/* New nfsuserd using an AF_LOCAL socket. */
-			sun = malloc(sizeof(struct sockaddr_un), M_SONAME,
-			    M_WAITOK | M_ZERO);
-			error = copyinstr(uap->argp, sun->sun_path,
-			    sizeof(sun->sun_path), NULL);
-			if (error != 0) {
-				free(sun, M_SONAME);
-				return (error);
-			}
-		        sun->sun_family = AF_LOCAL;
-		        sun->sun_len = SUN_LEN(sun);
-			sockport = 0;
-			sad = (struct sockaddr *)sun;
-		} else {
+		if ((uap->flag & NFSSVC_NEWSTRUCT) == 0)
 			error = copyin(uap->argp, (caddr_t)&sockport,
 			    sizeof (u_short));
-			sad = NULL;
-		}
-		if (error == 0)
-			error = nfsrv_nfsuserdport(sad, sockport, p);
+		else
+			error = ENXIO;
+		if (!error)
+			error = nfsrv_nfsuserdport(sockport, p);
 	} else if (uap->flag & NFSSVC_NFSUSERDDELPORT) {
 		nfsrv_nfsuserddelport();
 		error = 0;

Modified: head/sys/fs/nfs/nfs_commonsubs.c
==============================================================================
--- head/sys/fs/nfs/nfs_commonsubs.c	Thu Apr  4 23:16:36 2019	(r345894)
+++ head/sys/fs/nfs/nfs_commonsubs.c	Thu Apr  4 23:30:27 2019	(r345895)
@@ -3504,7 +3504,7 @@ nfsrv_cmpmixedcase(u_char *cp, u_char *cp2, int len)
  * Set the port for the nfsuserd.
  */
 APPLESTATIC int
-nfsrv_nfsuserdport(struct sockaddr *sad, u_short port, NFSPROC_T *p)
+nfsrv_nfsuserdport(u_short port, NFSPROC_T *p)
 {
 	struct nfssockreq *rp;
 	struct sockaddr_in *ad;
@@ -3514,7 +3514,6 @@ nfsrv_nfsuserdport(struct sockaddr *sad, u_short port,
 	if (nfsrv_nfsuserd) {
 		NFSUNLOCKNAMEID();
 		error = EPERM;
-		free(sad, M_SONAME);
 		goto out;
 	}
 	nfsrv_nfsuserd = 1;
@@ -3524,25 +3523,16 @@ nfsrv_nfsuserdport(struct sockaddr *sad, u_short port,
 	 */
 	rp = &nfsrv_nfsuserdsock;
 	rp->nr_client = NULL;
-	rp->nr_cred = NULL;
+	rp->nr_sotype = SOCK_DGRAM;
+	rp->nr_soproto = IPPROTO_UDP;
 	rp->nr_lock = (NFSR_RESERVEDPORT | NFSR_LOCALHOST);
-	if (sad != NULL) {
-		/* Use the AF_LOCAL socket address passed in. */
-		rp->nr_sotype = SOCK_STREAM;
-		rp->nr_soproto = 0;
-		rp->nr_nam = sad;
-	} else {
-		/* Use the port# for a UDP socket (old nfsuserd). */
-		rp->nr_sotype = SOCK_DGRAM;
-		rp->nr_soproto = IPPROTO_UDP;
-		rp->nr_nam = malloc(sizeof(*rp->nr_nam), M_SONAME, M_WAITOK |
-		    M_ZERO);
-		NFSSOCKADDRSIZE(rp->nr_nam, sizeof (struct sockaddr_in));
-		ad = NFSSOCKADDR(rp->nr_nam, struct sockaddr_in *);
-		ad->sin_family = AF_INET;
-		ad->sin_addr.s_addr = htonl((u_int32_t)0x7f000001);
-		ad->sin_port = port;
-	}
+	rp->nr_cred = NULL;
+	rp->nr_nam = malloc(sizeof(*rp->nr_nam), M_SONAME, M_WAITOK | M_ZERO);
+	NFSSOCKADDRSIZE(rp->nr_nam, sizeof (struct sockaddr_in));
+	ad = NFSSOCKADDR(rp->nr_nam, struct sockaddr_in *);
+	ad->sin_family = AF_INET;
+	ad->sin_addr.s_addr = htonl((u_int32_t)0x7f000001);	/* 127.0.0.1 */
+	ad->sin_port = port;
 	rp->nr_prog = RPCPROG_NFSUSERD;
 	rp->nr_vers = RPCNFSUSERD_VERS;
 	error = newnfs_connect(NULL, rp, NFSPROCCRED(p), p, 0);

Modified: head/sys/fs/nfs/nfs_var.h
==============================================================================
--- head/sys/fs/nfs/nfs_var.h	Thu Apr  4 23:16:36 2019	(r345894)
+++ head/sys/fs/nfs/nfs_var.h	Thu Apr  4 23:30:27 2019	(r345895)
@@ -136,7 +136,7 @@ int nfsrv_checksetattr(vnode_t, struct nfsrv_descript 
     NFSPROC_T *);
 int nfsrv_checkgetattr(struct nfsrv_descript *, vnode_t,
     struct nfsvattr *, nfsattrbit_t *, NFSPROC_T *);
-int nfsrv_nfsuserdport(struct sockaddr *, u_short, NFSPROC_T *);
+int nfsrv_nfsuserdport(u_short, NFSPROC_T *);
 void nfsrv_nfsuserddelport(void);
 void nfsrv_throwawayallstate(NFSPROC_T *);
 int nfsrv_checksequence(struct nfsrv_descript *, uint32_t, uint32_t *,





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201904042330.x34NURAA024207>