Deleted Added
full compact
sys_socket.c (183661) sys_socket.c (191816)
1/*-
2 * Copyright (c) 1982, 1986, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 16 unchanged lines hidden (view full) ---

25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)sys_socket.c 8.1 (Berkeley) 6/10/93
30 */
31
32#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1982, 1986, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 16 unchanged lines hidden (view full) ---

25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)sys_socket.c 8.1 (Berkeley) 6/10/93
30 */
31
32#include <sys/cdefs.h>
33__FBSDID("$FreeBSD: head/sys/kern/sys_socket.c 183661 2008-10-07 07:10:28Z rwatson $");
33__FBSDID("$FreeBSD: head/sys/kern/sys_socket.c 191816 2009-05-05 10:56:12Z zec $");
34
35#include "opt_mac.h"
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/file.h>
40#include <sys/filedesc.h>
41#include <sys/proc.h>
42#include <sys/protosw.h>
43#include <sys/sigio.h>
44#include <sys/signal.h>
45#include <sys/signalvar.h>
46#include <sys/socket.h>
47#include <sys/socketvar.h>
48#include <sys/filio.h> /* XXX */
49#include <sys/sockio.h>
50#include <sys/stat.h>
51#include <sys/uio.h>
52#include <sys/ucred.h>
34
35#include "opt_mac.h"
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/file.h>
40#include <sys/filedesc.h>
41#include <sys/proc.h>
42#include <sys/protosw.h>
43#include <sys/sigio.h>
44#include <sys/signal.h>
45#include <sys/signalvar.h>
46#include <sys/socket.h>
47#include <sys/socketvar.h>
48#include <sys/filio.h> /* XXX */
49#include <sys/sockio.h>
50#include <sys/stat.h>
51#include <sys/uio.h>
52#include <sys/ucred.h>
53#include <sys/vimage.h>
53
54#include <net/if.h>
55#include <net/route.h>
56
57#include <security/mac/mac_framework.h>
58
59struct fileops socketops = {
60 .fo_read = soo_read,

--- 8 unchanged lines hidden (view full) ---

69};
70
71/* ARGSUSED */
72int
73soo_read(struct file *fp, struct uio *uio, struct ucred *active_cred,
74 int flags, struct thread *td)
75{
76 struct socket *so = fp->f_data;
54
55#include <net/if.h>
56#include <net/route.h>
57
58#include <security/mac/mac_framework.h>
59
60struct fileops socketops = {
61 .fo_read = soo_read,

--- 8 unchanged lines hidden (view full) ---

70};
71
72/* ARGSUSED */
73int
74soo_read(struct file *fp, struct uio *uio, struct ucred *active_cred,
75 int flags, struct thread *td)
76{
77 struct socket *so = fp->f_data;
77#ifdef MAC
78 int error;
79
78 int error;
79
80#ifdef MAC
80 SOCK_LOCK(so);
81 error = mac_socket_check_receive(active_cred, so);
82 SOCK_UNLOCK(so);
83 if (error)
84 return (error);
85#endif
81 SOCK_LOCK(so);
82 error = mac_socket_check_receive(active_cred, so);
83 SOCK_UNLOCK(so);
84 if (error)
85 return (error);
86#endif
86 return (soreceive(so, 0, uio, 0, 0, 0));
87 CURVNET_SET(so->so_vnet);
88 error = soreceive(so, 0, uio, 0, 0, 0);
89 CURVNET_RESTORE();
90 return (error);
87}
88
89/* ARGSUSED */
90int
91soo_write(struct file *fp, struct uio *uio, struct ucred *active_cred,
92 int flags, struct thread *td)
93{
94 struct socket *so = fp->f_data;

--- 25 unchanged lines hidden (view full) ---

120
121int
122soo_ioctl(struct file *fp, u_long cmd, void *data, struct ucred *active_cred,
123 struct thread *td)
124{
125 struct socket *so = fp->f_data;
126 int error = 0;
127
91}
92
93/* ARGSUSED */
94int
95soo_write(struct file *fp, struct uio *uio, struct ucred *active_cred,
96 int flags, struct thread *td)
97{
98 struct socket *so = fp->f_data;

--- 25 unchanged lines hidden (view full) ---

124
125int
126soo_ioctl(struct file *fp, u_long cmd, void *data, struct ucred *active_cred,
127 struct thread *td)
128{
129 struct socket *so = fp->f_data;
130 int error = 0;
131
132 CURVNET_SET(so->so_vnet);
128 switch (cmd) {
129 case FIONBIO:
130 SOCK_LOCK(so);
131 if (*(int *)data)
132 so->so_state |= SS_NBIO;
133 else
134 so->so_state &= ~SS_NBIO;
135 SOCK_UNLOCK(so);

--- 64 unchanged lines hidden (view full) ---

200 error = ifioctl(so, cmd, data, td);
201 else if (IOCGROUP(cmd) == 'r')
202 error = rtioctl_fib(cmd, data, so->so_fibnum);
203 else
204 error = ((*so->so_proto->pr_usrreqs->pru_control)
205 (so, cmd, data, 0, td));
206 break;
207 }
133 switch (cmd) {
134 case FIONBIO:
135 SOCK_LOCK(so);
136 if (*(int *)data)
137 so->so_state |= SS_NBIO;
138 else
139 so->so_state &= ~SS_NBIO;
140 SOCK_UNLOCK(so);

--- 64 unchanged lines hidden (view full) ---

205 error = ifioctl(so, cmd, data, td);
206 else if (IOCGROUP(cmd) == 'r')
207 error = rtioctl_fib(cmd, data, so->so_fibnum);
208 else
209 error = ((*so->so_proto->pr_usrreqs->pru_control)
210 (so, cmd, data, 0, td));
211 break;
212 }
213 CURVNET_RESTORE();
208 return (error);
209}
210
211int
212soo_poll(struct file *fp, int events, struct ucred *active_cred,
213 struct thread *td)
214{
215 struct socket *so = fp->f_data;

--- 69 unchanged lines hidden ---
214 return (error);
215}
216
217int
218soo_poll(struct file *fp, int events, struct ucred *active_cred,
219 struct thread *td)
220{
221 struct socket *so = fp->f_data;

--- 69 unchanged lines hidden ---