Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Jul 2015 06:47:15 +0000 (UTC)
From:      Ed Schouten <ed@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r285350 - head/sys/kern
Message-ID:  <201507100647.t6A6lFFf075326@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ed
Date: Fri Jul 10 06:47:14 2015
New Revision: 285350
URL: https://svnweb.freebsd.org/changeset/base/285350

Log:
  Let listen() return EDESTADDRREQ when not bound.
  
  We currently return EINVAL when calling listen() on a UNIX socket that
  has not been bound to a pathname. If my interpretation of POSIX is
  correct, we should return EDESTADDRREQ: "The socket is not bound to a
  local address, and the protocol does not support listening on an unbound
  socket."
  
  Return EDESTADDRREQ instead when not bound and not connected.
  
  Differential Revision:	https://reviews.freebsd.org/D3038
  Reviewed by:	gnn, network

Modified:
  head/sys/kern/uipc_usrreq.c

Modified: head/sys/kern/uipc_usrreq.c
==============================================================================
--- head/sys/kern/uipc_usrreq.c	Fri Jul 10 05:51:36 2015	(r285349)
+++ head/sys/kern/uipc_usrreq.c	Fri Jul 10 06:47:14 2015	(r285350)
@@ -736,8 +736,10 @@ uipc_listen(struct socket *so, int backl
 
 	UNP_PCB_LOCK(unp);
 	if (unp->unp_vnode == NULL) {
+		/* Already connected or not bound to an address. */
+		error = unp->unp_conn != NULL ? EINVAL : EDESTADDRREQ;
 		UNP_PCB_UNLOCK(unp);
-		return (EINVAL);
+		return (error);
 	}
 
 	SOCK_LOCK(so);



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