Date: Mon, 11 Mar 2013 17:43:56 +0000 (UTC) From: Michael Tuexen <tuexen@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248172 - head/sys/kern Message-ID: <201303111743.r2BHhuCj029280@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: tuexen Date: Mon Mar 11 17:43:55 2013 New Revision: 248172 URL: http://svnweb.freebsd.org/changeset/base/248172 Log: Return an error if sctp_peeloff() fails because a socket can't be allocated. MFC after: 3 days Modified: head/sys/kern/uipc_socket.c head/sys/kern/uipc_syscalls.c Modified: head/sys/kern/uipc_socket.c ============================================================================== --- head/sys/kern/uipc_socket.c Mon Mar 11 17:36:37 2013 (r248171) +++ head/sys/kern/uipc_socket.c Mon Mar 11 17:43:55 2013 (r248172) @@ -136,6 +136,7 @@ __FBSDID("$FreeBSD$"); #include <sys/uio.h> #include <sys/jail.h> #include <sys/syslog.h> +#include <netinet/in.h> #include <net/vnet.h> @@ -565,8 +566,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: head/sys/kern/uipc_syscalls.c ============================================================================== --- head/sys/kern/uipc_syscalls.c Mon Mar 11 17:36:37 2013 (r248171) +++ head/sys/kern/uipc_syscalls.c Mon Mar 11 17:43:55 2013 (r248172) @@ -2386,8 +2386,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(),
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201303111743.r2BHhuCj029280>