Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Jun 2017 20:11:30 +0000 (UTC)
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r319988 - head/sys/kern
Message-ID:  <201706152011.v5FKBUUL045834@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: glebius
Date: Thu Jun 15 20:11:29 2017
New Revision: 319988
URL: https://svnweb.freebsd.org/changeset/base/319988

Log:
  Plug read(2) and write(2) on listening sockets.

Modified:
  head/sys/kern/uipc_socket.c

Modified: head/sys/kern/uipc_socket.c
==============================================================================
--- head/sys/kern/uipc_socket.c	Thu Jun 15 20:06:41 2017	(r319987)
+++ head/sys/kern/uipc_socket.c	Thu Jun 15 20:11:29 2017	(r319988)
@@ -1613,8 +1613,14 @@ sosend(struct socket *so, struct sockaddr *addr, struc
 	int error;
 
 	CURVNET_SET(so->so_vnet);
-	error = so->so_proto->pr_usrreqs->pru_sosend(so, addr, uio, top,
-	    control, flags, td);
+	if (!SOLISTENING(so))
+		error = so->so_proto->pr_usrreqs->pru_sosend(so, addr, uio,
+		    top, control, flags, td);
+	else {
+		m_freem(top);
+		m_freem(control);
+		error = ENOTCONN;
+	}
 	CURVNET_RESTORE();
 	return (error);
 }
@@ -2544,8 +2550,11 @@ soreceive(struct socket *so, struct sockaddr **psa, st
 	int error;
 
 	CURVNET_SET(so->so_vnet);
-	error = (so->so_proto->pr_usrreqs->pru_soreceive(so, psa, uio, mp0,
-	    controlp, flagsp));
+	if (!SOLISTENING(so))
+		error = (so->so_proto->pr_usrreqs->pru_soreceive(so, psa, uio,
+		    mp0, controlp, flagsp));
+	else
+		error = ENOTCONN;
 	CURVNET_RESTORE();
 	return (error);
 }



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