Lines Matching refs:so

124 	struct socket *so = fp->f_data;  in soo_read()  local
128 error = mac_socket_check_receive(active_cred, so); in soo_read()
132 error = soreceive(so, 0, uio, 0, 0, 0); in soo_read()
140 struct socket *so = fp->f_data; in soo_write() local
144 error = mac_socket_check_send(active_cred, so); in soo_write()
148 error = sosend(so, 0, uio, 0, 0, 0, uio->uio_td); in soo_write()
149 if (error == EPIPE && (so->so_options & SO_NOSIGPIPE) == 0) { in soo_write()
161 struct socket *so = fp->f_data; in soo_ioctl() local
166 SOCK_LOCK(so); in soo_ioctl()
168 so->so_state |= SS_NBIO; in soo_ioctl()
170 so->so_state &= ~SS_NBIO; in soo_ioctl()
171 SOCK_UNLOCK(so); in soo_ioctl()
176 SOCK_LOCK(so); in soo_ioctl()
177 so->so_state |= SS_ASYNC; in soo_ioctl()
178 if (SOLISTENING(so)) { in soo_ioctl()
179 so->sol_sbrcv_flags |= SB_ASYNC; in soo_ioctl()
180 so->sol_sbsnd_flags |= SB_ASYNC; in soo_ioctl()
182 SOCKBUF_LOCK(&so->so_rcv); in soo_ioctl()
183 so->so_rcv.sb_flags |= SB_ASYNC; in soo_ioctl()
184 SOCKBUF_UNLOCK(&so->so_rcv); in soo_ioctl()
185 SOCKBUF_LOCK(&so->so_snd); in soo_ioctl()
186 so->so_snd.sb_flags |= SB_ASYNC; in soo_ioctl()
187 SOCKBUF_UNLOCK(&so->so_snd); in soo_ioctl()
189 SOCK_UNLOCK(so); in soo_ioctl()
191 SOCK_LOCK(so); in soo_ioctl()
192 so->so_state &= ~SS_ASYNC; in soo_ioctl()
193 if (SOLISTENING(so)) { in soo_ioctl()
194 so->sol_sbrcv_flags &= ~SB_ASYNC; in soo_ioctl()
195 so->sol_sbsnd_flags &= ~SB_ASYNC; in soo_ioctl()
197 SOCKBUF_LOCK(&so->so_rcv); in soo_ioctl()
198 so->so_rcv.sb_flags &= ~SB_ASYNC; in soo_ioctl()
199 SOCKBUF_UNLOCK(&so->so_rcv); in soo_ioctl()
200 SOCKBUF_LOCK(&so->so_snd); in soo_ioctl()
201 so->so_snd.sb_flags &= ~SB_ASYNC; in soo_ioctl()
202 SOCKBUF_UNLOCK(&so->so_snd); in soo_ioctl()
204 SOCK_UNLOCK(so); in soo_ioctl()
210 if (SOLISTENING(so)) { in soo_ioctl()
213 *(int *)data = sbavail(&so->so_rcv); in soo_ioctl()
219 if (SOLISTENING(so)) { in soo_ioctl()
222 *(int *)data = sbavail(&so->so_snd); in soo_ioctl()
228 if (SOLISTENING(so)) { in soo_ioctl()
231 if ((so->so_snd.sb_hiwat < sbused(&so->so_snd)) || in soo_ioctl()
232 (so->so_snd.sb_mbmax < so->so_snd.sb_mbcnt)) { in soo_ioctl()
235 *(int *)data = sbspace(&so->so_snd); in soo_ioctl()
241 error = fsetown(*(int *)data, &so->so_sigio); in soo_ioctl()
245 *(int *)data = fgetown(&so->so_sigio); in soo_ioctl()
249 error = fsetown(-(*(int *)data), &so->so_sigio); in soo_ioctl()
253 *(int *)data = -fgetown(&so->so_sigio); in soo_ioctl()
258 if (SOLISTENING(so)) { in soo_ioctl()
261 *(int *)data = (so->so_rcv.sb_state & SBS_RCVATMARK) != 0; in soo_ioctl()
271 error = ifioctl(so, cmd, data, td); in soo_ioctl()
273 CURVNET_SET(so->so_vnet); in soo_ioctl()
274 error = rtioctl_fib(cmd, data, so->so_fibnum); in soo_ioctl()
277 CURVNET_SET(so->so_vnet); in soo_ioctl()
278 error = ((*so->so_proto->pr_usrreqs->pru_control) in soo_ioctl()
279 (so, cmd, data, 0, td)); in soo_ioctl()
291 struct socket *so = fp->f_data; in soo_poll() local
295 error = mac_socket_check_poll(active_cred, so); in soo_poll()
299 return (sopoll(so, events, fp->f_cred, td)); in soo_poll()
306 struct socket *so = fp->f_data; in soo_stat() local
312 error = mac_socket_check_stat(active_cred, so); in soo_stat()
316 SOCK_LOCK(so); in soo_stat()
317 if (!SOLISTENING(so)) { in soo_stat()
324 sb = &so->so_rcv; in soo_stat()
331 sb = &so->so_snd; in soo_stat()
337 ub->st_uid = so->so_cred->cr_uid; in soo_stat()
338 ub->st_gid = so->so_cred->cr_gid; in soo_stat()
339 error = so->so_proto->pr_usrreqs->pru_sense(so, ub); in soo_stat()
340 SOCK_UNLOCK(so); in soo_stat()
354 struct socket *so; in soo_close() local
356 so = fp->f_data; in soo_close()
360 if (so) in soo_close()
361 error = soclose(so); in soo_close()
371 struct socket *so; in soo_fill_kinfo() local
375 so = fp->f_data; in soo_fill_kinfo()
376 CURVNET_SET(so->so_vnet); in soo_fill_kinfo()
378 so->so_proto->pr_domain->dom_family; in soo_fill_kinfo()
379 kif->kf_un.kf_sock.kf_sock_type0 = so->so_type; in soo_fill_kinfo()
380 kif->kf_un.kf_sock.kf_sock_protocol0 = so->so_proto->pr_protocol; in soo_fill_kinfo()
381 kif->kf_un.kf_sock.kf_sock_pcb = (uintptr_t)so->so_pcb; in soo_fill_kinfo()
386 if (so->so_pcb != NULL) { in soo_fill_kinfo()
387 inpcb = (struct inpcb *)(so->so_pcb); in soo_fill_kinfo()
391 sbused(&so->so_snd); in soo_fill_kinfo()
393 sbused(&so->so_rcv); in soo_fill_kinfo()
398 if (so->so_pcb != NULL) { in soo_fill_kinfo()
399 unpcb = (struct unpcb *)(so->so_pcb); in soo_fill_kinfo()
404 so->so_rcv.sb_state; in soo_fill_kinfo()
406 so->so_snd.sb_state; in soo_fill_kinfo()
408 sbused(&so->so_snd); in soo_fill_kinfo()
410 sbused(&so->so_rcv); in soo_fill_kinfo()
415 error = so->so_proto->pr_usrreqs->pru_sockaddr(so, &sa); in soo_fill_kinfo()
421 error = so->so_proto->pr_usrreqs->pru_peeraddr(so, &sa); in soo_fill_kinfo()
427 strncpy(kif->kf_path, so->so_proto->pr_domain->dom_name, in soo_fill_kinfo()
590 soaio_ready(struct socket *so, struct sockbuf *sb) in soaio_ready() argument
592 return (sb == &so->so_rcv ? soreadable(so) : sowriteable(so)); in soaio_ready()
596 soaio_process_job(struct socket *so, struct sockbuf *sb, struct kaiocb *job) in soaio_process_job() argument
626 if (sb == &so->so_rcv) { in soaio_process_job()
629 error = mac_socket_check_receive(fp->f_cred, so); in soaio_process_job()
633 error = soreceive(so, NULL, job->uiop, NULL, NULL, in soaio_process_job()
642 error = mac_socket_check_send(fp->f_cred, so); in soaio_process_job()
645 error = sosend(so, NULL, job->uiop, NULL, NULL, flags, in soaio_process_job()
649 if (error == EPIPE && (so->so_options & SO_NOSIGPIPE) == 0) { in soaio_process_job()
672 if (done == 0 || !(so->so_state & SS_NBIO)) { in soaio_process_job()
674 if (soaio_ready(so, sb)) { in soaio_process_job()
705 soaio_process_sb(struct socket *so, struct sockbuf *sb) in soaio_process_sb() argument
709 CURVNET_SET(so->so_vnet); in soaio_process_sb()
711 while (!TAILQ_EMPTY(&sb->sb_aiojobq) && soaio_ready(so, sb)) { in soaio_process_sb()
717 soaio_process_job(so, sb, job); in soaio_process_sb()
730 SOCK_LOCK(so); in soaio_process_sb()
731 sorele(so); in soaio_process_sb()
738 struct socket *so; in soaio_rcv() local
740 so = context; in soaio_rcv()
741 soaio_process_sb(so, &so->so_rcv); in soaio_rcv()
747 struct socket *so; in soaio_snd() local
749 so = context; in soaio_snd()
750 soaio_process_sb(so, &so->so_snd); in soaio_snd()
754 sowakeup_aio(struct socket *so, struct sockbuf *sb) in sowakeup_aio() argument
762 soref(so); in sowakeup_aio()
769 struct socket *so; in soo_aio_cancel() local
774 so = job->fd_file->f_data; in soo_aio_cancel()
777 sb = &so->so_rcv; in soo_aio_cancel()
780 sb = &so->so_snd; in soo_aio_cancel()
800 struct socket *so; in soo_aio_queue() local
804 so = fp->f_data; in soo_aio_queue()
805 error = (*so->so_proto->pr_usrreqs->pru_aio_queue)(so, job); in soo_aio_queue()
811 sb = &so->so_rcv; in soo_aio_queue()
814 sb = &so->so_snd; in soo_aio_queue()
825 if (soaio_ready(so, sb)) in soo_aio_queue()
826 sowakeup_aio(so, sb); in soo_aio_queue()