svn commit: r252968 - stable/9/sys/kern
Michael Tuexen
tuexen at FreeBSD.org
Sun Jul 7 16:25:40 UTC 2013
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 <sys/uio.h>
#include <sys/jail.h>
#include <sys/syslog.h>
+#include <netinet/in.h>
#include <net/vnet.h>
@@ -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(),
More information about the svn-src-stable-9
mailing list