svn commit: r337975 - in stable/11/sys: kern sys

Mark Johnston markj at FreeBSD.org
Fri Aug 17 16:04:21 UTC 2018


Author: markj
Date: Fri Aug 17 16:04:20 2018
New Revision: 337975
URL: https://svnweb.freebsd.org/changeset/base/337975

Log:
  MFC r337328:
  Don't check rcv sockbuf limits when sending on a unix stream socket.
  
  PR:	181741, 212812

Modified:
  stable/11/sys/kern/uipc_sockbuf.c
  stable/11/sys/kern/uipc_usrreq.c
  stable/11/sys/sys/sockbuf.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/kern/uipc_sockbuf.c
==============================================================================
--- stable/11/sys/kern/uipc_sockbuf.c	Fri Aug 17 15:41:01 2018	(r337974)
+++ stable/11/sys/kern/uipc_sockbuf.c	Fri Aug 17 16:04:20 2018	(r337975)
@@ -888,21 +888,14 @@ sbappendaddr(struct sockbuf *sb, const struct sockaddr
 	return (retval);
 }
 
-int
+void
 sbappendcontrol_locked(struct sockbuf *sb, struct mbuf *m0,
     struct mbuf *control)
 {
-	struct mbuf *m, *n, *mlast;
-	int space;
+	struct mbuf *m, *mlast;
 
-	SOCKBUF_LOCK_ASSERT(sb);
-
-	space = m_length(control, &n) + m_length(m0, NULL);
-
-	if (space > sbspace(sb))
-		return (0);
 	m_clrprotoflags(m0);
-	n->m_next = m0;			/* concatenate data to control */
+	m_last(control)->m_next = m0;
 
 	SBLASTRECORDCHK(sb);
 
@@ -916,18 +909,15 @@ sbappendcontrol_locked(struct sockbuf *sb, struct mbuf
 	SBLASTMBUFCHK(sb);
 
 	SBLASTRECORDCHK(sb);
-	return (1);
 }
 
-int
+void
 sbappendcontrol(struct sockbuf *sb, struct mbuf *m0, struct mbuf *control)
 {
-	int retval;
 
 	SOCKBUF_LOCK(sb);
-	retval = sbappendcontrol_locked(sb, m0, control);
+	sbappendcontrol_locked(sb, m0, control);
 	SOCKBUF_UNLOCK(sb);
-	return (retval);
 }
 
 /*

Modified: stable/11/sys/kern/uipc_usrreq.c
==============================================================================
--- stable/11/sys/kern/uipc_usrreq.c	Fri Aug 17 15:41:01 2018	(r337974)
+++ stable/11/sys/kern/uipc_usrreq.c	Fri Aug 17 16:04:20 2018	(r337975)
@@ -981,16 +981,22 @@ uipc_send(struct socket *so, int flags, struct mbuf *m
 			unp2->unp_flags &= ~UNP_WANTCRED;
 			control = unp_addsockcred(td, control);
 		}
+
 		/*
-		 * Send to paired receive port, and then reduce send buffer
-		 * hiwater marks to maintain backpressure.  Wake up readers.
+		 * Send to paired receive port and wake up readers.  Don't
+		 * check for space available in the receive buffer if we're
+		 * attaching ancillary data; Unix domain sockets only check
+		 * for space in the sending sockbuf, and that check is
+		 * performed one level up the stack.  At that level we cannot
+		 * precisely account for the amount of buffer space used
+		 * (e.g., because control messages are not yet internalized).
 		 */
 		switch (so->so_type) {
 		case SOCK_STREAM:
 			if (control != NULL) {
-				if (sbappendcontrol_locked(&so2->so_rcv, m,
-				    control))
-					control = NULL;
+				sbappendcontrol_locked(&so2->so_rcv, m,
+				    control);
+				control = NULL;
 			} else
 				sbappend_locked(&so2->so_rcv, m, flags);
 			break;
@@ -999,14 +1005,8 @@ uipc_send(struct socket *so, int flags, struct mbuf *m
 			const struct sockaddr *from;
 
 			from = &sun_noname;
-			/*
-			 * Don't check for space available in so2->so_rcv.
-			 * Unix domain sockets only check for space in the
-			 * sending sockbuf, and that check is performed one
-			 * level up the stack.
-			 */
 			if (sbappendaddr_nospacecheck_locked(&so2->so_rcv,
-				from, m, control))
+			    from, m, control))
 				control = NULL;
 			break;
 			}

Modified: stable/11/sys/sys/sockbuf.h
==============================================================================
--- stable/11/sys/sys/sockbuf.h	Fri Aug 17 15:41:01 2018	(r337974)
+++ stable/11/sys/sys/sockbuf.h	Fri Aug 17 16:04:20 2018	(r337975)
@@ -146,9 +146,9 @@ int	sbappendaddr_locked(struct sockbuf *sb, const stru
 	    struct mbuf *m0, struct mbuf *control);
 int	sbappendaddr_nospacecheck_locked(struct sockbuf *sb,
 	    const struct sockaddr *asa, struct mbuf *m0, struct mbuf *control);
-int	sbappendcontrol(struct sockbuf *sb, struct mbuf *m0,
+void	sbappendcontrol(struct sockbuf *sb, struct mbuf *m0,
 	    struct mbuf *control);
-int	sbappendcontrol_locked(struct sockbuf *sb, struct mbuf *m0,
+void	sbappendcontrol_locked(struct sockbuf *sb, struct mbuf *m0,
 	    struct mbuf *control);
 void	sbappendrecord(struct sockbuf *sb, struct mbuf *m0);
 void	sbappendrecord_locked(struct sockbuf *sb, struct mbuf *m0);


More information about the svn-src-stable-11 mailing list