Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 May 2020 00:03:39 +0000 (UTC)
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r360997 - in projects/nfs-over-tls/sys: fs/nfsclient rpc xdr
Message-ID:  <202005130003.04D03dQD036326@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rmacklem
Date: Wed May 13 00:03:39 2020
New Revision: 360997
URL: https://svnweb.freebsd.org/changeset/base/360997

Log:
  Get rid of the changes done to the krpc and xdr for dissecting ext_pgs mbufs.
  
  Also do a few code cleanups, such as comments, printfs and whitespace
  while at it.
  
  All of the ext_pgs mbuf dissection code should now be out of this tree.

Modified:
  projects/nfs-over-tls/sys/fs/nfsclient/nfs_clkrpc.c
  projects/nfs-over-tls/sys/rpc/clnt.h
  projects/nfs-over-tls/sys/rpc/clnt_bck.c
  projects/nfs-over-tls/sys/rpc/clnt_vc.c
  projects/nfs-over-tls/sys/rpc/svc.h
  projects/nfs-over-tls/sys/rpc/svc_vc.c
  projects/nfs-over-tls/sys/xdr/xdr_mbuf.c

Modified: projects/nfs-over-tls/sys/fs/nfsclient/nfs_clkrpc.c
==============================================================================
--- projects/nfs-over-tls/sys/fs/nfsclient/nfs_clkrpc.c	Tue May 12 23:51:04 2020	(r360996)
+++ projects/nfs-over-tls/sys/fs/nfsclient/nfs_clkrpc.c	Wed May 13 00:03:39 2020	(r360997)
@@ -94,7 +94,7 @@ printf("cbprogram proc=%d\n", rqst->rq_proc);
 	rqst->rq_args = NULL;
 	newnfs_realign(&nd.nd_mrep, M_WAITOK);
 	nd.nd_md = nd.nd_mrep;
-printf("cbreq nd_md=%p offs=%d\n", nd.nd_md, rqst->rq_xprt->xp_mbufoffs);
+printf("cbreq nd_md=%p\n", nd.nd_md);
 	nd.nd_dpos = mtod(nd.nd_md, char *);
 	nd.nd_nam = svc_getrpccaller(rqst);
 	nd.nd_nam2 = rqst->rq_addr;

Modified: projects/nfs-over-tls/sys/rpc/clnt.h
==============================================================================
--- projects/nfs-over-tls/sys/rpc/clnt.h	Tue May 12 23:51:04 2020	(r360996)
+++ projects/nfs-over-tls/sys/rpc/clnt.h	Wed May 13 00:03:39 2020	(r360997)
@@ -120,7 +120,6 @@ struct rpc_callextra {
 	void		*rc_feedback_arg; /* argument for callback */
 	struct rpc_timers *rc_timers;	  /* optional RTT timers */
 	struct rpc_err	rc_err;		/* detailed call status */
-	u_int		rc_mbufoffs;	/* Offset in resultsp mbuf */
 };
 #endif
 

Modified: projects/nfs-over-tls/sys/rpc/clnt_bck.c
==============================================================================
--- projects/nfs-over-tls/sys/rpc/clnt_bck.c	Tue May 12 23:51:04 2020	(r360996)
+++ projects/nfs-over-tls/sys/rpc/clnt_bck.c	Wed May 13 00:03:39 2020	(r360997)
@@ -89,7 +89,6 @@ __FBSDID("$FreeBSD$");
 #include <rpc/krpc.h>
 #include <rpc/rpcsec_tls.h>
 
-
 struct cmessage {
         struct cmsghdr cmsg;
         struct cmsgcred cmcred;
@@ -209,7 +208,6 @@ clnt_bck_call(
 	struct mbuf *mreq = NULL, *results;
 	struct ct_request *cr;
 	int error, maxextsiz;
-	uint32_t junk;
 #ifdef KERN_TLS
 	u_int maxlen;
 #endif
@@ -425,9 +423,7 @@ got_reply:
 		ext->rc_feedback(FEEDBACK_OK, proc, ext->rc_feedback_arg);
 
 	xdrmbuf_create(&xdrs, cr->cr_mrep, XDR_DECODE);
-	ok = xdr_uint32_t(&xdrs, &junk);
-	if (ok)
-		ok = xdr_replymsg(&xdrs, &reply_msg);
+	ok = xdr_replymsg(&xdrs, &reply_msg);
 	cr->cr_mrep = NULL;
 
 	if (ok) {
@@ -446,14 +442,6 @@ got_reply:
 			} else {
 				KASSERT(results,
 				    ("auth validated but no result"));
-				if (ext) {
-					if ((results->m_flags & M_NOMAP) !=
-					    0)
-						ext->rc_mbufoffs =
-						    xdrs.x_handy;
-					else
-						ext->rc_mbufoffs = 0;
-				}
 				*resultsp = results;
 			}
 		}		/* end successful completion */

Modified: projects/nfs-over-tls/sys/rpc/clnt_vc.c
==============================================================================
--- projects/nfs-over-tls/sys/rpc/clnt_vc.c	Tue May 12 23:51:04 2020	(r360996)
+++ projects/nfs-over-tls/sys/rpc/clnt_vc.c	Wed May 13 00:03:39 2020	(r360997)
@@ -86,7 +86,6 @@ __FBSDID("$FreeBSD$");
 #include <rpc/krpc.h>
 #include <rpc/rpcsec_tls.h>
 
-
 struct cmessage {
         struct cmsghdr cmsg;
         struct cmsgcred cmcred;
@@ -535,19 +534,6 @@ got_reply:
 	if (ext && ext->rc_feedback)
 		ext->rc_feedback(FEEDBACK_OK, proc, ext->rc_feedback_arg);
 
-#ifdef notnow
-{ struct mbuf *m, *m2;
-int txxxx;
-if (cr->cr_mrep != NULL) {
-txxxx = m_length(cr->cr_mrep, NULL);
-if (txxxx > 0) {
-m = mb_copym_ext_pgs(cr->cr_mrep, txxxx, 16384, M_WAITOK,
-    mb_free_mext_pgs, &m2);
-m2 = cr->cr_mrep;
-cr->cr_mrep = m;
-m_freem(m2);
-} } }
-#endif
 	xdrmbuf_create(&xdrs, cr->cr_mrep, XDR_DECODE);
 	ok = xdr_replymsg(&xdrs, &reply_msg);
 	cr->cr_mrep = NULL;
@@ -569,14 +555,6 @@ m_freem(m2);
 			} else {
 				KASSERT(results,
 				    ("auth validated but no result"));
-				if (ext) {
-					if ((results->m_flags & M_NOMAP) !=
-					    0)
-						ext->rc_mbufoffs =
-						    xdrs.x_handy;
-					else
-						ext->rc_mbufoffs = 0;
-				}
 				*resultsp = results;
 			}
 		}		/* end successful completion */
@@ -932,7 +910,11 @@ clnt_vc_soupcall(struct socket *so, void *arg, int wai
 
 	CTASSERT(sizeof(xid_plus_direction) == 2 * sizeof(uint32_t));
 
-	/* RPC-over-TLS needs to block reception during handshake upcall. */
+	/*
+	 * RPC-over-TLS needs to block reception during
+	 * upcalls since the upcall will be doing I/O on
+	 * the socket via openssl library calls.
+	 */
 	mtx_lock(&ct->ct_lock);
 	if (ct->ct_dontrcv) {
 		mtx_unlock(&ct->ct_lock);
@@ -942,15 +924,13 @@ clnt_vc_soupcall(struct socket *so, void *arg, int wai
 
 	/*
 	 * If another thread is already here, it must be in
-	 * soreceive(), so just return.
+	 * soreceive(), so just return to avoid races with it.
 	 * ct_upcallrefs is protected by the SOCKBUF_LOCK(),
 	 * which is held in this function, except when
 	 * soreceive() is called.
 	 */
 	if (ct->ct_upcallrefs > 0)
-{ printf("soup another\n");
 		return (SU_OK);
-}
 	ct->ct_upcallrefs++;
 
 	/*
@@ -987,6 +967,7 @@ clnt_vc_soupcall(struct socket *so, void *arg, int wai
 		}
 		if (error != 0) {
 		wakeup_all:
+printf("wakeup_all err=%d\n", error);
 			mtx_lock(&ct->ct_lock);
 			ct->ct_error.re_status = RPC_CANTRECV;
 			ct->ct_error.re_errno = error;

Modified: projects/nfs-over-tls/sys/rpc/svc.h
==============================================================================
--- projects/nfs-over-tls/sys/rpc/svc.h	Tue May 12 23:51:04 2020	(r360996)
+++ projects/nfs-over-tls/sys/rpc/svc.h	Wed May 13 00:03:39 2020	(r360997)
@@ -175,7 +175,6 @@ typedef struct __rpc_svcxprt {
 	int		xp_upcallset;	/* socket upcall is set up */
 	uint32_t	xp_snd_cnt;	/* # of bytes to send to socket */
 	uint32_t	xp_snt_cnt;	/* # of bytes sent to socket */
-	u_int		xp_mbufoffs;	/* Offset into ext_pgs mbuf */
 	bool_t		xp_dontrcv;	/* Do not receive on the socket */
 	uint32_t	xp_tls;		/* RPC-over-TLS on socket */
 	uint64_t	xp_sslsec;	/* Userland SSL * */

Modified: projects/nfs-over-tls/sys/rpc/svc_vc.c
==============================================================================
--- projects/nfs-over-tls/sys/rpc/svc_vc.c	Tue May 12 23:51:04 2020	(r360996)
+++ projects/nfs-over-tls/sys/rpc/svc_vc.c	Wed May 13 00:03:39 2020	(r360997)
@@ -76,7 +76,6 @@ __FBSDID("$FreeBSD$");
 
 #include <security/mac/mac_framework.h>
 
-
 static bool_t svc_vc_rendezvous_recv(SVCXPRT *, struct rpc_msg *,
     struct sockaddr **, struct mbuf **);
 static enum xprt_stat svc_vc_rendezvous_stat(SVCXPRT *);
@@ -593,32 +592,6 @@ svc_vc_process_pending(SVCXPRT *xprt)
 	struct socket *so = xprt->xp_socket;
 	struct mbuf *m;
 
-#ifdef notnow
-{ struct mbuf *m1, *m2, *m3, *m4;
-	int txxxx;
-	m3 = cd->mpending;
-	m4 = NULL;
-	while (m3 != NULL && (m3->m_flags & M_NOMAP) != 0) {
-		m4 = m3;
-		m3 = m3->m_next;
-	}
-	if (m3 != NULL) {
-		txxxx = m_length(m3, NULL);
-		if (txxxx > 0) {
-			m1 = mb_copym_ext_pgs(m3, txxxx, 16384, M_WAITOK,
-			    mb_free_mext_pgs, &m2);
-			if (m4 != NULL) {
-				m4->m_next = m1;
-				m_freem(m3);
-			} else {
-				m2 = cd->mpending;
-				cd->mpending = m1;
-				m_freem(m2);
-			}
-		}
-	}
-}
-#endif
 	/*
 	 * If cd->resid is non-zero, we have part of the
 	 * record already, otherwise we are expecting a record
@@ -648,7 +621,7 @@ svc_vc_process_pending(SVCXPRT *xprt)
 		header = ntohl(header);
 		cd->eor = (header & 0x80000000) != 0;
 		cd->resid = header & 0x7fffffff;
-		cd->resid += sizeof(uint32_t);
+		m_adj(cd->mpending, sizeof(uint32_t));
 	}
 
 	/*
@@ -661,14 +634,10 @@ svc_vc_process_pending(SVCXPRT *xprt)
 	while (cd->mpending && cd->resid) {
 		m = cd->mpending;
 		if (cd->mpending->m_next
-		    || cd->mpending->m_len > cd->resid) {
-			if ((cd->mpending->m_flags & M_NOMAP) != 0)
-				cd->mpending = mb_splitatpos_ext(
-				    cd->mpending, cd->resid, M_WAITOK);
-			else
-				cd->mpending = m_split(cd->mpending,
-				    cd->resid, M_WAITOK);
-		} else
+		    || cd->mpending->m_len > cd->resid)
+			cd->mpending = m_split(cd->mpending,
+			    cd->resid, M_WAITOK);
+		else
 			cd->mpending = NULL;
 		if (cd->mreq)
 			m_last(cd->mreq)->m_next = m;
@@ -702,7 +671,7 @@ svc_vc_recv(SVCXPRT *xprt, struct rpc_msg *msg,
 	struct socket* so = xprt->xp_socket;
 	XDR xdrs;
 	int error, rcvflag;
-	uint32_t xid_plus_direction[3], junk;
+	uint32_t xid_plus_direction[2];
 	struct cmsghdr *cmsg;
 	struct tls_get_record tgr;
 
@@ -735,15 +704,15 @@ svc_vc_recv(SVCXPRT *xprt, struct rpc_msg *msg,
 				m_copydata(cd->mreq, 0,
 				    sizeof(xid_plus_direction),
 				    (char *)xid_plus_direction);
+				xid_plus_direction[0] =
+				    ntohl(xid_plus_direction[0]);
 				xid_plus_direction[1] =
 				    ntohl(xid_plus_direction[1]);
-				xid_plus_direction[2] =
-				    ntohl(xid_plus_direction[2]);
 				/* Check message direction. */
-				if (xid_plus_direction[2] == REPLY) {
+				if (xid_plus_direction[1] == REPLY) {
 					clnt_bck_svccall(xprt->xp_p2,
 					    cd->mreq,
-					    xid_plus_direction[1]);
+					    xid_plus_direction[0]);
 					cd->mreq = NULL;
 					continue;
 				}
@@ -763,18 +732,13 @@ svc_vc_recv(SVCXPRT *xprt, struct rpc_msg *msg,
 
 			sx_xunlock(&xprt->xp_lock);
 
-			if (! xdr_uint32_t(&xdrs, &junk) ||
-			    ! xdr_callmsg(&xdrs, msg)) {
+			if (! xdr_callmsg(&xdrs, msg)) {
 				XDR_DESTROY(&xdrs);
 				return (FALSE);
 			}
 
 			*addrp = NULL;
 			*mp = xdrmbuf_getall(&xdrs);
-			if (((*mp)->m_flags & M_NOMAP) != 0)
-				xprt->xp_mbufoffs = xdrs.x_handy;
-			else
-				xprt->xp_mbufoffs = 0;
 			XDR_DESTROY(&xdrs);
 
 			return (TRUE);
@@ -901,19 +865,6 @@ svc_vc_backchannel_recv(SVCXPRT *xprt, struct rpc_msg 
 	sx_xunlock(&xprt->xp_lock);
 
 printf("recv backch m=%p\n", m);
-#ifdef notnow
-{ struct mbuf *m1, *m2;
-int txxxx;
-if (m != NULL) {
-txxxx = m_length(m, NULL);
-if (txxxx > 0) {
-m1 = mb_copym_ext_pgs(m, txxxx, 16384, M_WAITOK,
-    mb_free_mext_pgs, &m2);
-m2 = m;
-m = m1;
-m_freem(m2);
-} } }
-#endif
 	xdrmbuf_create(&xdrs, m, XDR_DECODE);
 	if (! xdr_callmsg(&xdrs, msg)) {
 printf("recv backch callmsg failed\n");
@@ -922,11 +873,6 @@ printf("recv backch callmsg failed\n");
 	}
 	*addrp = NULL;
 	*mp = xdrmbuf_getall(&xdrs);
-	if (((*mp)->m_flags & M_NOMAP) != 0)
-		xprt->xp_mbufoffs = xdrs.x_handy;
-	else
-		xprt->xp_mbufoffs = 0;
-printf("backch offs=%d\n", xprt->xp_mbufoffs);
 	XDR_DESTROY(&xdrs);
 	return (TRUE);
 }

Modified: projects/nfs-over-tls/sys/xdr/xdr_mbuf.c
==============================================================================
--- projects/nfs-over-tls/sys/xdr/xdr_mbuf.c	Tue May 12 23:51:04 2020	(r360996)
+++ projects/nfs-over-tls/sys/xdr/xdr_mbuf.c	Wed May 13 00:03:39 2020	(r360997)
@@ -122,10 +122,9 @@ xdrmbuf_getall(XDR *xdrs)
 		xdrs->x_private = NULL;
 	}
 
-	if (m) {
-		if ((m->m_flags & M_NOMAP) == 0)
-			m_adj(m, xdrs->x_handy);
-	} else
+	if (m)
+		m_adj(m, xdrs->x_handy);
+	else
 		m = m_get(M_WAITOK, MT_DATA);
 	return (m);
 }
@@ -195,10 +194,7 @@ xdrmbuf_getbytes(XDR *xdrs, char *addr, u_int len)
 		sz = m->m_len - xdrs->x_handy;
 		if (sz > len)
 			sz = len;
-		if ((m->m_flags & M_NOMAP) != 0)
-			m_copydata(m, xdrs->x_handy, sz, addr);
-		else
-			bcopy(mtod(m, const char *) + xdrs->x_handy, addr, sz);
+		bcopy(mtod(m, const char *) + xdrs->x_handy, addr, sz);
 
 		addr += sz;
 		xdrs->x_handy += sz;
@@ -290,8 +286,6 @@ xdrmbuf_inline(XDR *xdrs, u_int len)
 	char *p;
 
 	if (!m)
-		return (0);
-	if ((m->m_flags & M_NOMAP) != 0)
 		return (0);
 	if (xdrs->x_op == XDR_ENCODE) {
 		available = M_TRAILINGSPACE(m) + (m->m_len - xdrs->x_handy);



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