| 1709 | |
| 1710 | #ifdef INET6 |
| 1711 | static int |
| 1712 | tcp6_connect(struct tcpcb *tp, struct sockaddr *nam, struct thread *td) |
| 1713 | { |
| 1714 | struct inpcb *inp = tp->t_inpcb; |
| 1715 | int error; |
| 1716 | |
| 1717 | INP_WLOCK_ASSERT(inp); |
| 1718 | INP_HASH_WLOCK(&V_tcbinfo); |
| 1719 | |
| 1720 | if (V_tcp_require_unique_port && inp->inp_lport == 0) { |
| 1721 | error = in6_pcbbind(inp, (struct sockaddr *)0, td->td_ucred); |
| 1722 | if (error) |
| 1723 | goto out; |
| 1724 | } |
| 1725 | error = in6_pcbconnect(inp, nam, td->td_ucred); |
| 1726 | if (error != 0) |
| 1727 | goto out; |
| 1728 | INP_HASH_WUNLOCK(&V_tcbinfo); |
| 1729 | |
| 1730 | /* Compute window scaling to request. */ |
| 1731 | while (tp->request_r_scale < TCP_MAX_WINSHIFT && |
| 1732 | (TCP_MAXWIN << tp->request_r_scale) < sb_max) |
| 1733 | tp->request_r_scale++; |
| 1734 | |
| 1735 | soisconnecting(inp->inp_socket); |
| 1736 | TCPSTAT_INC(tcps_connattempt); |
| 1737 | tcp_state_change(tp, TCPS_SYN_SENT); |
| 1738 | tp->iss = tcp_new_isn(&inp->inp_inc); |
| 1739 | if (tp->t_flags & TF_REQ_TSTMP) |
| 1740 | tp->ts_offset = tcp_new_ts_offset(&inp->inp_inc); |
| 1741 | tcp_sendseqinit(tp); |
| 1742 | |
| 1743 | return 0; |
| 1744 | |
| 1745 | out: |
| 1746 | INP_HASH_WUNLOCK(&V_tcbinfo); |
| 1747 | return error; |
| 1748 | } |
| 1749 | #endif /* INET6 */ |
| 1750 | |
| 1751 | /* |
no test coverage detected