From owner-svn-src-stable@FreeBSD.ORG Sun Jul 7 16:25:39 2013 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id E06B2723; Sun, 7 Jul 2013 16:25:39 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id B83CB1AAD; Sun, 7 Jul 2013 16:25:39 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67GPd5A053306; Sun, 7 Jul 2013 16:25:39 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r67GPdi1053304; Sun, 7 Jul 2013 16:25:39 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201307071625.r67GPdi1053304@svn.freebsd.org> From: Michael Tuexen Date: Sun, 7 Jul 2013 16:25:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252968 - stable/9/sys/kern X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jul 2013 16:25:40 -0000 Author: tuexen Date: Sun Jul 7 16:25:39 2013 New Revision: 252968 URL: http://svnweb.freebsd.org/changeset/base/252968 Log: MFC r248172: Return an error if sctp_peeloff() fails because a socket can't be allocated. sctp_peeloff() uses sonewconn() also in cases where listen() wasn't called. So honor this use case. Modified: stable/9/sys/kern/uipc_socket.c stable/9/sys/kern/uipc_syscalls.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/kern/uipc_socket.c ============================================================================== --- stable/9/sys/kern/uipc_socket.c Sun Jul 7 16:16:32 2013 (r252967) +++ stable/9/sys/kern/uipc_socket.c Sun Jul 7 16:25:39 2013 (r252968) @@ -136,6 +136,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include @@ -505,8 +506,12 @@ sonewconn(struct socket *head, int conns /* * The accept socket may be tearing down but we just * won a race on the ACCEPT_LOCK. + * However, if sctp_peeloff() is called on a 1-to-many + * style socket, the SO_ACCEPTCONN doesn't need to be set. */ - if (!(head->so_options & SO_ACCEPTCONN)) { + if (!(head->so_options & SO_ACCEPTCONN) && + ((head->so_proto->pr_protocol != IPPROTO_SCTP) || + (head->so_type != SOCK_SEQPACKET))) { SOCK_LOCK(so); so->so_head = NULL; sofree(so); /* NB: returns ACCEPT_UNLOCK'ed. */ Modified: stable/9/sys/kern/uipc_syscalls.c ============================================================================== --- stable/9/sys/kern/uipc_syscalls.c Sun Jul 7 16:16:32 2013 (r252967) +++ stable/9/sys/kern/uipc_syscalls.c Sun Jul 7 16:25:39 2013 (r252968) @@ -2372,8 +2372,10 @@ sys_sctp_peeloff(td, uap) CURVNET_SET(head->so_vnet); so = sonewconn(head, SS_ISCONNECTED); - if (so == NULL) + if (so == NULL) { + error = ENOMEM; goto noconnection; + } /* * Before changing the flags on the socket, we have to bump the * reference count. Otherwise, if the protocol calls sofree(),