Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/tcp_usrreq.c
Show First 20 Lines • Show All 1,230 Lines • ▼ Show 20 Lines | tcp_connect(struct tcpcb *tp, struct sockaddr *nam, struct thread *td) | ||||
struct in_addr laddr; | struct in_addr laddr; | ||||
u_short lport; | u_short lport; | ||||
int error; | int error; | ||||
INP_WLOCK_ASSERT(inp); | INP_WLOCK_ASSERT(inp); | ||||
INP_HASH_WLOCK(&V_tcbinfo); | INP_HASH_WLOCK(&V_tcbinfo); | ||||
if (inp->inp_lport == 0) { | if (inp->inp_lport == 0) { | ||||
error = in_pcbbind(inp, (struct sockaddr *)0, td->td_ucred); | inp->inp_flags |= INP_ANONPORT; | ||||
if (error) | error = in_pcbbind(inp, nam, td->td_ucred); | ||||
if (error) { | |||||
inp->inp_flags &= ~INP_ANONPORT; | |||||
goto out; | goto out; | ||||
} | } | ||||
} | |||||
/* | /* | ||||
* Cannot simply call in_pcbconnect, because there might be an | * Cannot simply call in_pcbconnect, because there might be an | ||||
* earlier incarnation of this same connection still in | * earlier incarnation of this same connection still in | ||||
* TIME_WAIT state, creating an ADDRINUSE error. | * TIME_WAIT state, creating an ADDRINUSE error. | ||||
*/ | */ | ||||
laddr = inp->inp_laddr; | laddr = inp->inp_laddr; | ||||
lport = inp->inp_lport; | lport = inp->inp_lport; | ||||
Show All 38 Lines | |||||
{ | { | ||||
struct inpcb *inp = tp->t_inpcb; | struct inpcb *inp = tp->t_inpcb; | ||||
int error; | int error; | ||||
INP_WLOCK_ASSERT(inp); | INP_WLOCK_ASSERT(inp); | ||||
INP_HASH_WLOCK(&V_tcbinfo); | INP_HASH_WLOCK(&V_tcbinfo); | ||||
if (inp->inp_lport == 0) { | if (inp->inp_lport == 0) { | ||||
error = in6_pcbbind(inp, (struct sockaddr *)0, td->td_ucred); | inp->inp_flags |= INP_ANONPORT; | ||||
if (error) | error = in6_pcbbind(inp, nam, td->td_ucred); | ||||
if (error) { | |||||
inp->inp_flags &= ~INP_ANONPORT; | |||||
goto out; | goto out; | ||||
} | |||||
} | } | ||||
error = in6_pcbconnect(inp, nam, td->td_ucred); | error = in6_pcbconnect(inp, nam, td->td_ucred); | ||||
if (error != 0) | if (error != 0) | ||||
goto out; | goto out; | ||||
INP_HASH_WUNLOCK(&V_tcbinfo); | INP_HASH_WUNLOCK(&V_tcbinfo); | ||||
/* Compute window scaling to request. */ | /* Compute window scaling to request. */ | ||||
while (tp->request_r_scale < TCP_MAX_WINSHIFT && | while (tp->request_r_scale < TCP_MAX_WINSHIFT && | ||||
▲ Show 20 Lines • Show All 1,036 Lines • Show Last 20 Lines |