summaryrefslogtreecommitdiffstats
path: root/sys/kern/sys_socket.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2007-08-06 14:26:03 +0000
committerrwatson <rwatson@FreeBSD.org>2007-08-06 14:26:03 +0000
commit23574c86734ab5cb088584d30345e698cbbeaef2 (patch)
tree63e9e0c42ec5669b83e25b5f9cbdcbee7e1be6dc /sys/kern/sys_socket.c
parent5f4b9d20fc4bf36bf86f78bb1622ee474a93dc56 (diff)
downloadFreeBSD-src-23574c86734ab5cb088584d30345e698cbbeaef2.zip
FreeBSD-src-23574c86734ab5cb088584d30345e698cbbeaef2.tar.gz
Remove the now-unused NET_{LOCK,UNLOCK,ASSERT}_GIANT() macros, which
previously conditionally acquired Giant based on debug.mpsafenet. As that has now been removed, they are no longer required. Removing them significantly simplifies error-handling in the socket layer, eliminated quite a bit of unwinding of locking in error cases. While here clean up the now unneeded opt_net.h, which previously was used for the NET_WITH_GIANT kernel option. Clean up some related gotos for consistency. Reviewed by: bz, csjp Tested by: kris Approved by: re (kensmith)
Diffstat (limited to 'sys/kern/sys_socket.c')
-rw-r--r--sys/kern/sys_socket.c47
1 files changed, 12 insertions, 35 deletions
diff --git a/sys/kern/sys_socket.c b/sys/kern/sys_socket.c
index be230cb..9229658 100644
--- a/sys/kern/sys_socket.c
+++ b/sys/kern/sys_socket.c
@@ -73,21 +73,16 @@ soo_read(struct file *fp, struct uio *uio, struct ucred *active_cred,
int flags, struct thread *td)
{
struct socket *so = fp->f_data;
+#ifdef MAC
int error;
- NET_LOCK_GIANT();
-#ifdef MAC
SOCK_LOCK(so);
error = mac_check_socket_receive(active_cred, so);
SOCK_UNLOCK(so);
- if (error) {
- NET_UNLOCK_GIANT();
+ if (error)
return (error);
- }
#endif
- error = soreceive(so, 0, uio, 0, 0, 0);
- NET_UNLOCK_GIANT();
- return (error);
+ return (soreceive(so, 0, uio, 0, 0, 0));
}
/* ARGSUSED */
@@ -98,15 +93,12 @@ soo_write(struct file *fp, struct uio *uio, struct ucred *active_cred,
struct socket *so = fp->f_data;
int error;
- NET_LOCK_GIANT();
#ifdef MAC
SOCK_LOCK(so);
error = mac_check_socket_send(active_cred, so);
SOCK_UNLOCK(so);
- if (error) {
- NET_UNLOCK_GIANT();
+ if (error)
return (error);
- }
#endif
error = sosend(so, 0, uio, 0, 0, 0, uio->uio_td);
if (error == EPIPE && (so->so_options & SO_NOSIGPIPE) == 0) {
@@ -114,7 +106,6 @@ soo_write(struct file *fp, struct uio *uio, struct ucred *active_cred,
psignal(uio->uio_td->td_proc, SIGPIPE);
PROC_UNLOCK(uio->uio_td->td_proc);
}
- NET_UNLOCK_GIANT();
return (error);
}
@@ -125,9 +116,7 @@ soo_ioctl(struct file *fp, u_long cmd, void *data, struct ucred *active_cred,
struct socket *so = fp->f_data;
int error = 0;
- NET_LOCK_GIANT();
switch (cmd) {
-
case FIONBIO:
SOCK_LOCK(so);
if (*(int *)data)
@@ -207,8 +196,7 @@ soo_ioctl(struct file *fp, u_long cmd, void *data, struct ucred *active_cred,
(so, cmd, data, 0, td));
break;
}
- NET_UNLOCK_GIANT();
- return(error);
+ return (error);
}
int
@@ -216,22 +204,16 @@ soo_poll(struct file *fp, int events, struct ucred *active_cred,
struct thread *td)
{
struct socket *so = fp->f_data;
+#ifdef MAC
int error;
- NET_LOCK_GIANT();
-#ifdef MAC
SOCK_LOCK(so);
error = mac_check_socket_poll(active_cred, so);
SOCK_UNLOCK(so);
- if (error) {
- NET_UNLOCK_GIANT();
+ if (error)
return (error);
- }
#endif
- error = sopoll(so, events, fp->f_cred, td);
- NET_UNLOCK_GIANT();
-
- return (error);
+ return (sopoll(so, events, fp->f_cred, td));
}
int
@@ -239,19 +221,18 @@ soo_stat(struct file *fp, struct stat *ub, struct ucred *active_cred,
struct thread *td)
{
struct socket *so = fp->f_data;
+#ifdef MAC
int error;
+#endif
bzero((caddr_t)ub, sizeof (*ub));
ub->st_mode = S_IFSOCK;
- NET_LOCK_GIANT();
#ifdef MAC
SOCK_LOCK(so);
error = mac_check_socket_stat(active_cred, so);
SOCK_UNLOCK(so);
- if (error) {
- NET_UNLOCK_GIANT();
+ if (error)
return (error);
- }
#endif
/*
* If SBS_CANTRCVMORE is set, but there's still data left in the
@@ -269,9 +250,7 @@ soo_stat(struct file *fp, struct stat *ub, struct ucred *active_cred,
ub->st_size = so->so_rcv.sb_cc - so->so_rcv.sb_ctl;
ub->st_uid = so->so_cred->cr_uid;
ub->st_gid = so->so_cred->cr_gid;
- error = (*so->so_proto->pr_usrreqs->pru_sense)(so, ub);
- NET_UNLOCK_GIANT();
- return (error);
+ return (*so->so_proto->pr_usrreqs->pru_sense)(so, ub);
}
/*
@@ -287,13 +266,11 @@ soo_close(struct file *fp, struct thread *td)
int error = 0;
struct socket *so;
- NET_LOCK_GIANT();
so = fp->f_data;
fp->f_ops = &badfileops;
fp->f_data = NULL;
if (so)
error = soclose(so);
- NET_UNLOCK_GIANT();
return (error);
}
OpenPOWER on IntegriCloud