summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_socket.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2002-10-05 21:23:47 +0000
committerrwatson <rwatson@FreeBSD.org>2002-10-05 21:23:47 +0000
commit74ec128a1cc11d5f9f7620636ba845fe578a57fc (patch)
treec761fa053a4d22f10903c9ddd53565b138238188 /sys/kern/uipc_socket.c
parent6fbe1ed04632e261e3e7c04a4047222500fd0078 (diff)
downloadFreeBSD-src-74ec128a1cc11d5f9f7620636ba845fe578a57fc.zip
FreeBSD-src-74ec128a1cc11d5f9f7620636ba845fe578a57fc.tar.gz
Modify label allocation semantics for sockets: pass in soalloc's malloc
flags so that we can call malloc with M_NOWAIT if necessary, avoiding potential sleeps while holding mutexes in the TCP syncache code. Similar to the existing support for mbuf label allocation: if we can't allocate all the necessary label store in each policy, we back out the label allocation and fail the socket creation. Sync from MAC tree. Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories
Diffstat (limited to 'sys/kern/uipc_socket.c')
-rw-r--r--sys/kern/uipc_socket.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 7b71f00..4084cb1 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -131,6 +131,9 @@ soalloc(waitok)
int waitok;
{
struct socket *so;
+#ifdef MAC
+ int error;
+#endif
int flag;
if (waitok == 1)
@@ -140,14 +143,19 @@ soalloc(waitok)
flag |= M_ZERO;
so = uma_zalloc(socket_zone, flag);
if (so) {
+#ifdef MAC
+ error = mac_init_socket(so, flag);
+ if (error != 0) {
+ uma_zfree(socket_zone, so);
+ so = NULL;
+ return so;
+ }
+#endif
/* XXX race condition for reentrant kernel */
so->so_gencnt = ++so_gencnt;
/* sx_init(&so->so_sxlock, "socket sxlock"); */
TAILQ_INIT(&so->so_aiojobq);
++numopensockets;
-#ifdef MAC
- mac_init_socket(so);
-#endif
}
return so;
}
OpenPOWER on IntegriCloud