svn commit: r359780 - head/sys/fs/nfsserver

Rick Macklem rmacklem at FreeBSD.org
Fri Apr 10 21:25:36 UTC 2020


Author: rmacklem
Date: Fri Apr 10 21:25:35 2020
New Revision: 359780
URL: https://svnweb.freebsd.org/changeset/base/359780

Log:
  Replace mbuf macros with the code they would generate in the NFS code.
  
  When the code was ported to Mac OS/X, mbuf handling functions were
  converted to using the Mac OS/X accessor functions. For FreeBSD, they
  are a simple set of macros in sys/fs/nfs/nfskpiport.h.
  Since porting to Mac OS/X is no longer a consideration, replacement of
  these macros with the code generated by them makes the code more
  readable.
  When support for external page mbufs is added as needed by the KERN_TLS,
  the patch becomes simpler if done without the macros.
  
  This patch should not result in any semantic change.
  This conversion will be committed one file at a time.

Modified:
  head/sys/fs/nfsserver/nfs_nfsdsubs.c

Modified: head/sys/fs/nfsserver/nfs_nfsdsubs.c
==============================================================================
--- head/sys/fs/nfsserver/nfs_nfsdsubs.c	Fri Apr 10 20:42:11 2020	(r359779)
+++ head/sys/fs/nfsserver/nfs_nfsdsubs.c	Fri Apr 10 21:25:35 2020	(r359780)
@@ -1290,15 +1290,15 @@ nfsrv_adj(mbuf_t mp, int len, int nul)
 	count = 0;
 	m = mp;
 	for (;;) {
-		count += mbuf_len(m);
-		if (mbuf_next(m) == NULL)
+		count += m->m_len;
+		if (m->m_next == NULL)
 			break;
-		m = mbuf_next(m);
+		m = m->m_next;
 	}
-	if (mbuf_len(m) > len) {
-		mbuf_setlen(m, mbuf_len(m) - len);
+	if (m->m_len > len) {
+		m->m_len -= len;
 		if (nul > 0) {
-			cp = NFSMTOD(m, caddr_t) + mbuf_len(m) - nul;
+			cp = mtod(m, caddr_t) + m->m_len - nul;
 			for (i = 0; i < nul; i++)
 				*cp++ = '\0';
 		}
@@ -1312,20 +1312,20 @@ nfsrv_adj(mbuf_t mp, int len, int nul)
 	 * Find the mbuf with last data, adjust its length,
 	 * and toss data from remaining mbufs on chain.
 	 */
-	for (m = mp; m; m = mbuf_next(m)) {
-		if (mbuf_len(m) >= count) {
-			mbuf_setlen(m, count);
+	for (m = mp; m; m = m->m_next) {
+		if (m->m_len >= count) {
+			m->m_len = count;
 			if (nul > 0) {
-				cp = NFSMTOD(m, caddr_t) + mbuf_len(m) - nul;
+				cp = mtod(m, caddr_t) + m->m_len - nul;
 				for (i = 0; i < nul; i++)
 					*cp++ = '\0';
 			}
 			break;
 		}
-		count -= mbuf_len(m);
+		count -= m->m_len;
 	}
-	for (m = mbuf_next(m); m; m = mbuf_next(m))
-		mbuf_setlen(m, 0);
+	for (m = m->m_next; m; m = m->m_next)
+		m->m_len = 0;
 }
 
 /*
@@ -1879,16 +1879,16 @@ nfsrv_parsename(struct nfsrv_descript *nd, char *bufp,
 	     */
 	    fromcp = nd->nd_dpos;
 	    md = nd->nd_md;
-	    rem = NFSMTOD(md, caddr_t) + mbuf_len(md) - fromcp;
+	    rem = mtod(md, caddr_t) + md->m_len - fromcp;
 	    for (i = 0; i < len; i++) {
 		while (rem == 0) {
-			md = mbuf_next(md);
+			md = md->m_next;
 			if (md == NULL) {
 				error = EBADRPC;
 				goto nfsmout;
 			}
-			fromcp = NFSMTOD(md, caddr_t);
-			rem = mbuf_len(md);
+			fromcp = mtod(md, caddr_t);
+			rem = md->m_len;
 		}
 		if (*fromcp == '\0') {
 			nd->nd_repstat = EACCES;


More information about the svn-src-all mailing list