aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/sys_socket.c
diff options
context:
space:
mode:
authorRobert Watson <rwatson@FreeBSD.org>2009-06-02 18:26:17 +0000
committerRobert Watson <rwatson@FreeBSD.org>2009-06-02 18:26:17 +0000
commitf93bfb23dcb5b1d8a3aa13da522369974fcda39b (patch)
tree9f93a531fd61b5932ab6fcc38f6915b3f1a0ab60 /sys/kern/sys_socket.c
parentfd02a3b5c966582744a3fbdcfab9d8c3fd5f7436 (diff)
downloadsrc-f93bfb23dcb5b1d8a3aa13da522369974fcda39b.tar.gz
src-f93bfb23dcb5b1d8a3aa13da522369974fcda39b.zip
Add internal 'mac_policy_count' counter to the MAC Framework, which is a
count of the number of registered policies. Rather than unconditionally locking sockets before passing them into MAC, lock them in the MAC entry points only if mac_policy_count is non-zero. This avoids locking overhead for a number of socket system calls when no policies are registered, eliminating measurable overhead for the MAC Framework for the socket subsystem when there are no active policies. Possibly socket locks should be acquired by policies if they are required for socket labels, which would further avoid locking overhead when there are policies but they don't require labeling of sockets, or possibly don't even implement socket controls. Obtained from: TrustedBSD Project
Notes
Notes: svn path=/head/; revision=193332
Diffstat (limited to 'sys/kern/sys_socket.c')
-rw-r--r--sys/kern/sys_socket.c8
1 files changed, 0 insertions, 8 deletions
diff --git a/sys/kern/sys_socket.c b/sys/kern/sys_socket.c
index 61b036168523..5e5695c3f507 100644
--- a/sys/kern/sys_socket.c
+++ b/sys/kern/sys_socket.c
@@ -78,9 +78,7 @@ soo_read(struct file *fp, struct uio *uio, struct ucred *active_cred,
int error;
#ifdef MAC
- SOCK_LOCK(so);
error = mac_socket_check_receive(active_cred, so);
- SOCK_UNLOCK(so);
if (error)
return (error);
#endif
@@ -99,9 +97,7 @@ soo_write(struct file *fp, struct uio *uio, struct ucred *active_cred,
int error;
#ifdef MAC
- SOCK_LOCK(so);
error = mac_socket_check_send(active_cred, so);
- SOCK_UNLOCK(so);
if (error)
return (error);
#endif
@@ -222,9 +218,7 @@ soo_poll(struct file *fp, int events, struct ucred *active_cred,
#ifdef MAC
int error;
- SOCK_LOCK(so);
error = mac_socket_check_poll(active_cred, so);
- SOCK_UNLOCK(so);
if (error)
return (error);
#endif
@@ -243,9 +237,7 @@ soo_stat(struct file *fp, struct stat *ub, struct ucred *active_cred,
bzero((caddr_t)ub, sizeof (*ub));
ub->st_mode = S_IFSOCK;
#ifdef MAC
- SOCK_LOCK(so);
error = mac_socket_check_stat(active_cred, so);
- SOCK_UNLOCK(so);
if (error)
return (error);
#endif