aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/linux/linux_socket.c
diff options
context:
space:
mode:
authorMatt Macy <mmacy@FreeBSD.org>2018-05-09 18:47:24 +0000
committerMatt Macy <mmacy@FreeBSD.org>2018-05-09 18:47:24 +0000
commitcbd92ce62e92bd17871c9668c2c2bebac3e2ac2e (patch)
tree40c405d5c0a6545e7dfd7beb64dc7e5076f7b644 /sys/compat/linux/linux_socket.c
parent0272270a8d6fe4e6edb92de3e1711442e5d15766 (diff)
downloadsrc-cbd92ce62e92bd17871c9668c2c2bebac3e2ac2e.tar.gz
src-cbd92ce62e92bd17871c9668c2c2bebac3e2ac2e.zip
Eliminate the overhead of gratuitous repeated reinitialization of cap_rights
- Add macros to allow preinitialization of cap_rights_t. - Convert most commonly used code paths to use preinitialized cap_rights_t. A 3.6% speedup in fstat was measured with this change. Reported by: mjg Reviewed by: oshogbo Approved by: sbruno MFC after: 1 month
Notes
Notes: svn path=/head/; revision=333425
Diffstat (limited to 'sys/compat/linux/linux_socket.c')
-rw-r--r--sys/compat/linux/linux_socket.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c
index 0887374f4e70..604627048ed0 100644
--- a/sys/compat/linux/linux_socket.c
+++ b/sys/compat/linux/linux_socket.c
@@ -766,7 +766,6 @@ linux_bind(struct thread *td, struct linux_bind_args *args)
int
linux_connect(struct thread *td, struct linux_connect_args *args)
{
- cap_rights_t rights;
struct socket *so;
struct sockaddr *sa;
struct file *fp;
@@ -788,7 +787,7 @@ linux_connect(struct thread *td, struct linux_connect_args *args)
* when on a non-blocking socket. Instead it returns the
* error getsockopt(SOL_SOCKET, SO_ERROR) would return on BSD.
*/
- error = getsock_cap(td, args->s, cap_rights_init(&rights, CAP_CONNECT),
+ error = getsock_cap(td, args->s, &cap_connect_rights,
&fp, &fflag, NULL);
if (error != 0)
return (error);
@@ -824,7 +823,6 @@ linux_accept_common(struct thread *td, int s, l_uintptr_t addr,
socklen_t * __restrict anamelen;
int flags;
} */ bsd_args;
- cap_rights_t rights;
struct socket *so;
struct file *fp;
int error, error1;
@@ -842,8 +840,7 @@ linux_accept_common(struct thread *td, int s, l_uintptr_t addr,
if (error == EFAULT && namelen != sizeof(struct sockaddr_in))
return (EINVAL);
if (error == EINVAL) {
- error1 = getsock_cap(td, s,
- cap_rights_init(&rights, CAP_ACCEPT), &fp, NULL, NULL);
+ error1 = getsock_cap(td, s, &cap_accept_rights, &fp, NULL, NULL);
if (error1 != 0)
return (error1);
so = fp->f_data;