Lines Matching refs:so

128 	struct socket *so = fp->f_data;  in soo_read()  local
132 error = mac_socket_check_receive(active_cred, so); in soo_read()
136 error = soreceive(so, 0, uio, 0, 0, 0); in soo_read()
144 struct socket *so = fp->f_data; in soo_write() local
148 error = mac_socket_check_send(active_cred, so); in soo_write()
152 error = sosend(so, 0, uio, 0, 0, 0, uio->uio_td); in soo_write()
153 if (error == EPIPE && (so->so_options & SO_NOSIGPIPE) == 0) { in soo_write()
165 struct socket *so = fp->f_data; in soo_ioctl() local
170 SOCK_LOCK(so); in soo_ioctl()
172 so->so_state |= SS_NBIO; in soo_ioctl()
174 so->so_state &= ~SS_NBIO; in soo_ioctl()
175 SOCK_UNLOCK(so); in soo_ioctl()
180 SOCK_LOCK(so); in soo_ioctl()
181 so->so_state |= SS_ASYNC; in soo_ioctl()
182 if (SOLISTENING(so)) { in soo_ioctl()
183 so->sol_sbrcv_flags |= SB_ASYNC; in soo_ioctl()
184 so->sol_sbsnd_flags |= SB_ASYNC; in soo_ioctl()
186 SOCKBUF_LOCK(&so->so_rcv); in soo_ioctl()
187 so->so_rcv.sb_flags |= SB_ASYNC; in soo_ioctl()
188 SOCKBUF_UNLOCK(&so->so_rcv); in soo_ioctl()
189 SOCKBUF_LOCK(&so->so_snd); in soo_ioctl()
190 so->so_snd.sb_flags |= SB_ASYNC; in soo_ioctl()
191 SOCKBUF_UNLOCK(&so->so_snd); in soo_ioctl()
193 SOCK_UNLOCK(so); in soo_ioctl()
195 SOCK_LOCK(so); in soo_ioctl()
196 so->so_state &= ~SS_ASYNC; in soo_ioctl()
197 if (SOLISTENING(so)) { in soo_ioctl()
198 so->sol_sbrcv_flags &= ~SB_ASYNC; in soo_ioctl()
199 so->sol_sbsnd_flags &= ~SB_ASYNC; in soo_ioctl()
201 SOCKBUF_LOCK(&so->so_rcv); in soo_ioctl()
202 so->so_rcv.sb_flags &= ~SB_ASYNC; in soo_ioctl()
203 SOCKBUF_UNLOCK(&so->so_rcv); in soo_ioctl()
204 SOCKBUF_LOCK(&so->so_snd); in soo_ioctl()
205 so->so_snd.sb_flags &= ~SB_ASYNC; in soo_ioctl()
206 SOCKBUF_UNLOCK(&so->so_snd); in soo_ioctl()
208 SOCK_UNLOCK(so); in soo_ioctl()
214 if (SOLISTENING(so)) { in soo_ioctl()
217 *(int *)data = sbavail(&so->so_rcv); in soo_ioctl()
223 if (SOLISTENING(so)) { in soo_ioctl()
226 *(int *)data = sbavail(&so->so_snd); in soo_ioctl()
232 if (SOLISTENING(so)) { in soo_ioctl()
235 if ((so->so_snd.sb_hiwat < sbused(&so->so_snd)) || in soo_ioctl()
236 (so->so_snd.sb_mbmax < so->so_snd.sb_mbcnt)) { in soo_ioctl()
239 *(int *)data = sbspace(&so->so_snd); in soo_ioctl()
245 error = fsetown(*(int *)data, &so->so_sigio); in soo_ioctl()
249 *(int *)data = fgetown(&so->so_sigio); in soo_ioctl()
253 error = fsetown(-(*(int *)data), &so->so_sigio); in soo_ioctl()
257 *(int *)data = -fgetown(&so->so_sigio); in soo_ioctl()
262 if (SOLISTENING(so)) { in soo_ioctl()
265 *(int *)data = (so->so_rcv.sb_state & SBS_RCVATMARK) != 0; in soo_ioctl()
275 error = ifioctl(so, cmd, data, td); in soo_ioctl()
277 CURVNET_SET(so->so_vnet); in soo_ioctl()
278 error = rtioctl_fib(cmd, data, so->so_fibnum); in soo_ioctl()
281 CURVNET_SET(so->so_vnet); in soo_ioctl()
282 error = ((*so->so_proto->pr_usrreqs->pru_control) in soo_ioctl()
283 (so, cmd, data, 0, td)); in soo_ioctl()
295 struct socket *so = fp->f_data; in soo_poll() local
299 error = mac_socket_check_poll(active_cred, so); in soo_poll()
303 return (sopoll(so, events, fp->f_cred, td)); in soo_poll()
310 struct socket *so = fp->f_data; in soo_stat() local
316 error = mac_socket_check_stat(active_cred, so); in soo_stat()
320 SOCK_LOCK(so); in soo_stat()
321 if (!SOLISTENING(so)) { in soo_stat()
328 sb = &so->so_rcv; in soo_stat()
335 sb = &so->so_snd; in soo_stat()
341 ub->st_uid = so->so_cred->cr_uid; in soo_stat()
342 ub->st_gid = so->so_cred->cr_gid; in soo_stat()
343 error = so->so_proto->pr_usrreqs->pru_sense(so, ub); in soo_stat()
344 SOCK_UNLOCK(so); in soo_stat()
358 struct socket *so; in soo_close() local
360 so = fp->f_data; in soo_close()
364 if (so) in soo_close()
365 error = soclose(so); in soo_close()
376 struct socket *so; in soo_fill_kinfo() local
380 so = fp->f_data; in soo_fill_kinfo()
381 CURVNET_SET(so->so_vnet); in soo_fill_kinfo()
383 so->so_proto->pr_domain->dom_family; in soo_fill_kinfo()
384 kif->kf_un.kf_sock.kf_sock_type0 = so->so_type; in soo_fill_kinfo()
385 kif->kf_un.kf_sock.kf_sock_protocol0 = so->so_proto->pr_protocol; in soo_fill_kinfo()
386 kif->kf_un.kf_sock.kf_sock_pcb = (uintptr_t)so->so_pcb; in soo_fill_kinfo()
391 if (so->so_pcb != NULL) { in soo_fill_kinfo()
392 inpcb = (struct inpcb *)(so->so_pcb); in soo_fill_kinfo()
396 sbused(&so->so_snd); in soo_fill_kinfo()
398 sbused(&so->so_rcv); in soo_fill_kinfo()
403 if (so->so_pcb != NULL) { in soo_fill_kinfo()
404 unpcb = (struct unpcb *)(so->so_pcb); in soo_fill_kinfo()
409 so->so_rcv.sb_state; in soo_fill_kinfo()
411 so->so_snd.sb_state; in soo_fill_kinfo()
413 sbused(&so->so_snd); in soo_fill_kinfo()
415 sbused(&so->so_rcv); in soo_fill_kinfo()
420 error = so->so_proto->pr_usrreqs->pru_sockaddr(so, &sa); in soo_fill_kinfo()
426 error = so->so_proto->pr_usrreqs->pru_peeraddr(so, &sa); in soo_fill_kinfo()
432 strncpy(kif->kf_path, so->so_proto->pr_domain->dom_name, in soo_fill_kinfo()
597 soaio_ready(struct socket *so, struct sockbuf *sb) in soaio_ready() argument
599 return (sb == &so->so_rcv ? soreadable(so) : sowriteable(so)); in soaio_ready()
603 soaio_process_job(struct socket *so, struct sockbuf *sb, struct kaiocb *job) in soaio_process_job() argument
633 if (sb == &so->so_rcv) { in soaio_process_job()
636 error = mac_socket_check_receive(fp->f_cred, so); in soaio_process_job()
640 error = soreceive(so, NULL, job->uiop, NULL, NULL, in soaio_process_job()
649 error = mac_socket_check_send(fp->f_cred, so); in soaio_process_job()
652 error = sosend(so, NULL, job->uiop, NULL, NULL, flags, in soaio_process_job()
656 if (error == EPIPE && (so->so_options & SO_NOSIGPIPE) == 0) { in soaio_process_job()
679 if (done == 0 || !(so->so_state & SS_NBIO)) { in soaio_process_job()
681 if (soaio_ready(so, sb)) { in soaio_process_job()
712 soaio_process_sb(struct socket *so, struct sockbuf *sb) in soaio_process_sb() argument
716 CURVNET_SET(so->so_vnet); in soaio_process_sb()
718 while (!TAILQ_EMPTY(&sb->sb_aiojobq) && soaio_ready(so, sb)) { in soaio_process_sb()
724 soaio_process_job(so, sb, job); in soaio_process_sb()
737 SOCK_LOCK(so); in soaio_process_sb()
738 sorele(so); in soaio_process_sb()
745 struct socket *so; in soaio_rcv() local
747 so = context; in soaio_rcv()
748 soaio_process_sb(so, &so->so_rcv); in soaio_rcv()
754 struct socket *so; in soaio_snd() local
756 so = context; in soaio_snd()
757 soaio_process_sb(so, &so->so_snd); in soaio_snd()
761 sowakeup_aio(struct socket *so, struct sockbuf *sb) in sowakeup_aio() argument
769 soref(so); in sowakeup_aio()
776 struct socket *so; in soo_aio_cancel() local
781 so = job->fd_file->f_data; in soo_aio_cancel()
784 sb = &so->so_rcv; in soo_aio_cancel()
787 sb = &so->so_snd; in soo_aio_cancel()
807 struct socket *so; in soo_aio_queue() local
811 so = fp->f_data; in soo_aio_queue()
812 error = (*so->so_proto->pr_usrreqs->pru_aio_queue)(so, job); in soo_aio_queue()
818 sb = &so->so_rcv; in soo_aio_queue()
821 sb = &so->so_snd; in soo_aio_queue()
832 if (soaio_ready(so, sb)) in soo_aio_queue()
833 sowakeup_aio(so, sb); in soo_aio_queue()