Lines Matching defs:so

196 tcp_sogetpcb(struct socket *so, struct inpcb **rinp, struct tcpcb **rtp)
206 if ((inp = sotoinpcb(so)) == NULL || (tp = intotcpcb(inp)) == NULL) {
209 if ((error = READ_ONCE(so->so_error)))
226 tcp_fill_info(struct tcpcb *tp, struct socket *so, struct mbuf *m)
307 mtx_enter(&so->so_rcv.sb_mtx);
308 ti->tcpi_so_rcv_sb_cc = so->so_rcv.sb_cc;
309 ti->tcpi_so_rcv_sb_hiwat = so->so_rcv.sb_hiwat;
310 ti->tcpi_so_rcv_sb_lowat = so->so_rcv.sb_lowat;
311 ti->tcpi_so_rcv_sb_wat = so->so_rcv.sb_wat;
312 mtx_leave(&so->so_rcv.sb_mtx);
313 mtx_enter(&so->so_snd.sb_mtx);
314 ti->tcpi_so_snd_sb_cc = so->so_snd.sb_cc;
315 ti->tcpi_so_snd_sb_hiwat = so->so_snd.sb_hiwat;
316 ti->tcpi_so_snd_sb_lowat = so->so_snd.sb_lowat;
317 ti->tcpi_so_snd_sb_wat = so->so_snd.sb_wat;
318 mtx_leave(&so->so_snd.sb_mtx);
324 tcp_ctloutput(int op, struct socket *so, int level, int optname,
332 inp = sotoinpcb(so);
338 error = ip6_ctloutput(op, so, level, optname, m);
341 error = ip_ctloutput(op, so, level, optname, m);
450 error = tcp_fill_info(tp, so, m);
473 tcp_attach(struct socket *so, int proto, int wait)
480 if (so->so_pcb)
482 if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0 ||
483 sbcheckreserve(so->so_snd.sb_wat, tcp_sendspace) ||
484 sbcheckreserve(so->so_rcv.sb_wat, tcp_recvspace)) {
485 error = soreserve(so, tcp_sendspace, tcp_recvspace);
492 if (so->so_proto->pr_domain->dom_family == PF_INET6)
497 error = in_pcballoc(so, table, wait);
500 inp = sotoinpcb(so);
503 unsigned int nofd = so->so_state & SS_NOFDREF; /* XXX */
505 so->so_state &= ~SS_NOFDREF; /* don't free the socket yet */
507 so->so_state |= nofd;
517 if ((so->so_options & SO_LINGER) && so->so_linger == 0)
518 so->so_linger = TCP_LINGERTIME;
520 if (so->so_options & SO_DEBUG)
526 tcp_detach(struct socket *so)
533 soassertlocked(so);
535 if ((error = tcp_sogetpcb(so, &inp, &tp)))
538 if (so->so_options & SO_DEBUG) {
561 tcp_bind(struct socket *so, struct mbuf *nam, struct proc *p)
568 soassertlocked(so);
570 if ((error = tcp_sogetpcb(so, &inp, &tp)))
573 if (so->so_options & SO_DEBUG)
578 if (so->so_options & SO_DEBUG)
587 tcp_listen(struct socket *so)
594 soassertlocked(so);
596 if ((error = tcp_sogetpcb(so, &inp, &tp)))
599 if (so->so_options & SO_DEBUG) {
628 tcp_connect(struct socket *so, struct mbuf *nam)
635 soassertlocked(so);
637 if ((error = tcp_sogetpcb(so, &inp, &tp)))
640 if (so->so_options & SO_DEBUG) {
683 so->so_state |= SS_CONNECTOUT;
688 soisconnecting(so);
708 tcp_accept(struct socket *so, struct mbuf *nam)
714 soassertlocked(so);
716 if ((error = tcp_sogetpcb(so, &inp, &tp)))
721 if (so->so_options & SO_DEBUG)
738 tcp_disconnect(struct socket *so)
745 soassertlocked(so);
747 if ((error = tcp_sogetpcb(so, &inp, &tp)))
750 if (so->so_options & SO_DEBUG) {
766 tcp_shutdown(struct socket *so)
773 soassertlocked(so);
775 if ((error = tcp_sogetpcb(so, &inp, &tp)))
778 if (so->so_options & SO_DEBUG) {
783 if (so->so_snd.sb_state & SS_CANTSENDMORE)
786 socantsendmore(so);
801 tcp_rcvd(struct socket *so)
807 soassertlocked(so);
809 if (tcp_sogetpcb(so, &inp, &tp))
812 if (so->so_options & SO_DEBUG)
822 if ((so->so_state & (SS_ISCONNECTED|SS_ISCONNECTING)) != 0)
825 if (so->so_options & SO_DEBUG)
834 tcp_send(struct socket *so, struct mbuf *m, struct mbuf *nam,
842 soassertlocked(so);
849 if ((error = tcp_sogetpcb(so, &inp, &tp)))
852 if (so->so_options & SO_DEBUG)
855 mtx_enter(&so->so_snd.sb_mtx);
856 sbappendstream(so, &so->so_snd, m);
857 mtx_leave(&so->so_snd.sb_mtx);
862 if (so->so_options & SO_DEBUG)
876 tcp_abort(struct socket *so)
882 soassertlocked(so);
884 if (tcp_sogetpcb(so, &inp, &tp))
887 if (so->so_options & SO_DEBUG) {
899 tcp_sense(struct socket *so, struct stat *ub)
905 soassertlocked(so);
907 if ((error = tcp_sogetpcb(so, &inp, &tp)))
910 mtx_enter(&so->so_snd.sb_mtx);
911 ub->st_blksize = so->so_snd.sb_hiwat;
912 mtx_leave(&so->so_snd.sb_mtx);
914 if (so->so_options & SO_DEBUG)
920 tcp_rcvoob(struct socket *so, struct mbuf *m, int flags)
926 soassertlocked(so);
928 if ((error = tcp_sogetpcb(so, &inp, &tp)))
931 if ((so->so_oobmark == 0 &&
932 (so->so_rcv.sb_state & SS_RCVATMARK) == 0) ||
933 so->so_options & SO_OOBINLINE ||
947 if (so->so_options & SO_DEBUG)
953 tcp_sendoob(struct socket *so, struct mbuf *m, struct mbuf *nam,
961 soassertlocked(so);
968 if ((error = tcp_sogetpcb(so, &inp, &tp)))
971 if (so->so_options & SO_DEBUG)
974 if (sbspace(so, &so->so_snd) < -512) {
987 mtx_enter(&so->so_snd.sb_mtx);
988 sbappendstream(so, &so->so_snd, m);
989 mtx_leave(&so->so_snd.sb_mtx);
991 tp->snd_up = tp->snd_una + so->so_snd.sb_cc;
997 if (so->so_options & SO_DEBUG)
1008 tcp_sockaddr(struct socket *so, struct mbuf *nam)
1014 soassertlocked(so);
1016 if ((error = tcp_sogetpcb(so, &inp, &tp)))
1021 if (so->so_options & SO_DEBUG)
1028 tcp_peeraddr(struct socket *so, struct mbuf *nam)
1034 soassertlocked(so);
1036 if ((error = tcp_sogetpcb(so, &inp, &tp)))
1041 if (so->so_options & SO_DEBUG)
1057 struct socket *so = tp->t_inpcb->inp_socket;
1061 else if ((so->so_options & SO_LINGER) && so->so_linger == 0)
1064 soisdisconnecting(so);
1065 mtx_enter(&so->so_rcv.sb_mtx);
1066 sbflush(so, &so->so_rcv);
1067 mtx_leave(&so->so_rcv.sb_mtx);
1136 struct socket *so = NULL;
1218 so = in_pcbsolock_ref(inp);
1219 if (so != NULL)
1222 if (tp != NULL && !ISSET(so->so_options, SO_ACCEPTCONN))
1227 in_pcbsounlock_rele(inp, so);
1250 so = in_pcbsolock_ref(inp);
1252 if (so != NULL && ISSET(so->so_state, SS_CONNECTOUT)) {
1253 tir.ruid = so->so_ruid;
1254 tir.euid = so->so_euid;
1260 in_pcbsounlock_rele(inp, so);
1534 * Scale the send buffer so that inflight data is not accounted against
1544 struct socket *so = tp->t_inpcb->inp_socket;
1547 mtx_enter(&so->so_snd.sb_mtx);
1549 nmax = so->so_snd.sb_hiwat;
1555 } else if (so->so_snd.sb_wat != tcp_sendspace) {
1557 nmax = so->so_snd.sb_wat;
1560 nmax = MIN(sb_max, so->so_snd.sb_wat + tp->snd_max -
1565 if (sbspace_locked(so, &so->so_snd) >= so->so_snd.sb_lowat) {
1566 if (nmax < so->so_snd.sb_cc + so->so_snd.sb_lowat)
1567 nmax = so->so_snd.sb_cc + so->so_snd.sb_lowat;
1569 if (nmax * 8 < so->so_snd.sb_mbcnt + so->so_snd.sb_lowat)
1570 nmax = (so->so_snd.sb_mbcnt+so->so_snd.sb_lowat+7) / 8;
1576 if (nmax != so->so_snd.sb_hiwat)
1577 sbreserve(so, &so->so_snd, nmax);
1579 mtx_leave(&so->so_snd.sb_mtx);
1591 struct socket *so = tp->t_inpcb->inp_socket;
1594 mtx_enter(&so->so_rcv.sb_mtx);
1596 nmax = so->so_rcv.sb_hiwat;
1602 } else if (so->so_rcv.sb_wat != tcp_recvspace) {
1604 nmax = so->so_rcv.sb_wat;
1607 if (tp->rfbuf_cnt > so->so_rcv.sb_hiwat / 8 * 7)
1608 nmax = MIN(sb_max, so->so_rcv.sb_hiwat +
1613 mtx_enter(&so->so_snd.sb_mtx);
1614 if (so->so_rcv.sb_cc >= so->so_rcv.sb_lowat &&
1615 nmax < so->so_snd.sb_lowat)
1616 nmax = so->so_snd.sb_lowat;
1617 mtx_leave(&so->so_snd.sb_mtx);
1619 if (nmax != so->so_rcv.sb_hiwat) {
1622 sbreserve(so, &so->so_rcv, nmax);
1625 mtx_leave(&so->so_rcv.sb_mtx);