Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Jan 2018 22:38:39 +0000 (UTC)
From:      Conrad Meyer <cem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r328418 - in head/sys/fs: nfs nfsserver
Message-ID:  <201801252238.w0PMcd2e028217@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: cem
Date: Thu Jan 25 22:38:39 2018
New Revision: 328418
URL: https://svnweb.freebsd.org/changeset/base/328418

Log:
  nfs: Remove NFSSOCKADDRALLOC, NFSSOCKADDRFREE macros
  
  They were just thin wrappers over malloc(9) w/ M_ZERO and free(9).
  
  Discussed with:	rmacklem, markj
  Sponsored by:	Dell EMC Isilon

Modified:
  head/sys/fs/nfs/nfs_commonsubs.c
  head/sys/fs/nfs/nfsport.h
  head/sys/fs/nfsserver/nfs_nfsdserv.c
  head/sys/fs/nfsserver/nfs_nfsdstate.c

Modified: head/sys/fs/nfs/nfs_commonsubs.c
==============================================================================
--- head/sys/fs/nfs/nfs_commonsubs.c	Thu Jan 25 22:25:13 2018	(r328417)
+++ head/sys/fs/nfs/nfs_commonsubs.c	Thu Jan 25 22:38:39 2018	(r328418)
@@ -3067,7 +3067,7 @@ nfsrv_nfsuserdport(struct sockaddr *sad, u_short port,
 	if (nfsrv_nfsuserd) {
 		NFSUNLOCKNAMEID();
 		error = EPERM;
-		NFSSOCKADDRFREE(sad);
+		free(sad, M_SONAME);
 		goto out;
 	}
 	nfsrv_nfsuserd = 1;
@@ -3088,7 +3088,8 @@ nfsrv_nfsuserdport(struct sockaddr *sad, u_short port,
 		/* Use the port# for a UDP socket (old nfsuserd). */
 		rp->nr_sotype = SOCK_DGRAM;
 		rp->nr_soproto = IPPROTO_UDP;
-		NFSSOCKADDRALLOC(rp->nr_nam);
+		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;
@@ -3099,7 +3100,7 @@ nfsrv_nfsuserdport(struct sockaddr *sad, u_short port,
 	rp->nr_vers = RPCNFSUSERD_VERS;
 	error = newnfs_connect(NULL, rp, NFSPROCCRED(p), p, 0);
 	if (error) {
-		NFSSOCKADDRFREE(rp->nr_nam);
+		free(rp->nr_nam, M_SONAME);
 		nfsrv_nfsuserd = 0;
 	}
 out:
@@ -3122,7 +3123,7 @@ nfsrv_nfsuserddelport(void)
 	nfsrv_nfsuserd = 0;
 	NFSUNLOCKNAMEID();
 	newnfs_disconnect(&nfsrv_nfsuserdsock);
-	NFSSOCKADDRFREE(nfsrv_nfsuserdsock.nr_nam);
+	free(nfsrv_nfsuserdsock.nr_nam, M_SONAME);
 }
 
 /*

Modified: head/sys/fs/nfs/nfsport.h
==============================================================================
--- head/sys/fs/nfs/nfsport.h	Thu Jan 25 22:25:13 2018	(r328417)
+++ head/sys/fs/nfs/nfsport.h	Thu Jan 25 22:38:39 2018	(r328418)
@@ -628,18 +628,7 @@ void nfsrvd_rcv(struct socket *, void *, int);
  * mbufs any more.)
  */
 #define	NFSSOCKADDR(a, t)	((t)(a))
-#define	NFSSOCKADDRALLOC(a) 					\
-    do {							\
-	(a) = malloc(sizeof (struct sockaddr),			\
-	    M_SONAME, M_WAITOK); 				\
-	NFSBZERO((a), sizeof (struct sockaddr)); 		\
-    } while (0)
 #define	NFSSOCKADDRSIZE(a, s)		((a)->sa_len = (s))
-#define	NFSSOCKADDRFREE(a) 					\
-	do { 							\
-		if (a) 						\
-			free((a), M_SONAME); 		\
-	} while (0)
 
 /*
  * These should be defined as a process or thread structure, as required

Modified: head/sys/fs/nfsserver/nfs_nfsdserv.c
==============================================================================
--- head/sys/fs/nfsserver/nfs_nfsdserv.c	Thu Jan 25 22:25:13 2018	(r328417)
+++ head/sys/fs/nfsserver/nfs_nfsdserv.c	Thu Jan 25 22:38:39 2018	(r328418)
@@ -3477,7 +3477,8 @@ nfsrvd_setclientid(struct nfsrv_descript *nd, __unused
 	clp->lc_stateid = malloc(sizeof(struct nfsstatehead) *
 	    nfsrv_statehashsize, M_NFSDCLIENT, M_WAITOK);
 	NFSINITSOCKMUTEX(&clp->lc_req.nr_mtx);
-	NFSSOCKADDRALLOC(clp->lc_req.nr_nam);
+	clp->lc_req.nr_nam = malloc(sizeof(*clp->lc_req.nr_nam), M_SONAME,
+	    M_WAITOK | M_ZERO);
 	NFSSOCKADDRSIZE(clp->lc_req.nr_nam, sizeof (struct sockaddr_in));
 	clp->lc_req.nr_cred = NULL;
 	NFSBCOPY(verf, clp->lc_verf, NFSX_VERF);
@@ -3533,7 +3534,7 @@ nfsrvd_setclientid(struct nfsrv_descript *nd, __unused
 		(void) nfsm_strtom(nd, addrbuf, strlen(addrbuf));
 	}
 	if (clp) {
-		NFSSOCKADDRFREE(clp->lc_req.nr_nam);
+		free(clp->lc_req.nr_nam, M_SONAME);
 		NFSFREEMUTEX(&clp->lc_req.nr_mtx);
 		free(clp->lc_stateid, M_NFSDCLIENT);
 		free(clp, M_NFSDCLIENT);
@@ -3551,7 +3552,7 @@ out:
 	return (0);
 nfsmout:
 	if (clp) {
-		NFSSOCKADDRFREE(clp->lc_req.nr_nam);
+		free(clp->lc_req.nr_nam, M_SONAME);
 		NFSFREEMUTEX(&clp->lc_req.nr_mtx);
 		free(clp->lc_stateid, M_NFSDCLIENT);
 		free(clp, M_NFSDCLIENT);
@@ -3753,7 +3754,8 @@ nfsrvd_exchangeid(struct nfsrv_descript *nd, __unused 
 	clp->lc_stateid = malloc(sizeof(struct nfsstatehead) *
 	    nfsrv_statehashsize, M_NFSDCLIENT, M_WAITOK);
 	NFSINITSOCKMUTEX(&clp->lc_req.nr_mtx);
-	NFSSOCKADDRALLOC(clp->lc_req.nr_nam);
+	clp->lc_req.nr_nam = malloc(sizeof(*clp->lc_req.nr_nam), M_SONAME,
+	    M_WAITOK | M_ZERO);
 	NFSSOCKADDRSIZE(clp->lc_req.nr_nam, sizeof (struct sockaddr_in));
 	sad = NFSSOCKADDR(nd->nd_nam, struct sockaddr_in *);
 	rad = NFSSOCKADDR(clp->lc_req.nr_nam, struct sockaddr_in *);
@@ -3813,7 +3815,7 @@ nfsrvd_exchangeid(struct nfsrv_descript *nd, __unused 
 	 */
 	nd->nd_repstat = nfsrv_setclient(nd, &clp, &clientid, &confirm, p);
 	if (clp != NULL) {
-		NFSSOCKADDRFREE(clp->lc_req.nr_nam);
+		free(clp->lc_req.nr_nam, M_SONAME);
 		NFSFREEMUTEX(&clp->lc_req.nr_mtx);
 		free(clp->lc_stateid, M_NFSDCLIENT);
 		free(clp, M_NFSDCLIENT);
@@ -3846,7 +3848,7 @@ nfsrvd_exchangeid(struct nfsrv_descript *nd, __unused 
 	return (0);
 nfsmout:
 	if (clp != NULL) {
-		NFSSOCKADDRFREE(clp->lc_req.nr_nam);
+		free(clp->lc_req.nr_nam, M_SONAME);
 		NFSFREEMUTEX(&clp->lc_req.nr_mtx);
 		free(clp->lc_stateid, M_NFSDCLIENT);
 		free(clp, M_NFSDCLIENT);

Modified: head/sys/fs/nfsserver/nfs_nfsdstate.c
==============================================================================
--- head/sys/fs/nfsserver/nfs_nfsdstate.c	Thu Jan 25 22:25:13 2018	(r328417)
+++ head/sys/fs/nfsserver/nfs_nfsdstate.c	Thu Jan 25 22:38:39 2018	(r328418)
@@ -1226,7 +1226,7 @@ nfsrv_zapclient(struct nfsclient *clp, NFSPROC_T *p)
 	}
 #endif
 	newnfs_disconnect(&clp->lc_req);
-	NFSSOCKADDRFREE(clp->lc_req.nr_nam);
+	free(clp->lc_req.nr_nam, M_SONAME);
 	NFSFREEMUTEX(&clp->lc_req.nr_mtx);
 	free(clp->lc_stateid, M_NFSDCLIENT);
 	free(clp, M_NFSDCLIENT);



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