Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/tcp_usrreq.c
Show First 20 Lines • Show All 150 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* TCP attaches to socket via pru_attach(), reserving space, | * TCP attaches to socket via pru_attach(), reserving space, | ||||
* and an internet control block. | * and an internet control block. | ||||
*/ | */ | ||||
static int | static int | ||||
tcp_usr_attach(struct socket *so, int proto, struct thread *td) | tcp_usr_attach(struct socket *so, int proto, struct thread *td) | ||||
{ | { | ||||
struct inpcb *inp; | struct inpcb *inp; | ||||
struct tcp_function_block *tfb; | |||||
struct tcpcb *tp = NULL; | struct tcpcb *tp = NULL; | ||||
int error; | int error; | ||||
inp = sotoinpcb(so); | inp = sotoinpcb(so); | ||||
KASSERT(inp == NULL, ("tcp_usr_attach: inp != NULL")); | KASSERT(inp == NULL, ("tcp_usr_attach: inp != NULL")); | ||||
error = soreserve(so, V_tcp_sendspace, V_tcp_recvspace); | error = soreserve(so, V_tcp_sendspace, V_tcp_recvspace); | ||||
if (error) | if (error) | ||||
goto out; | goto out; | ||||
so->so_rcv.sb_flags |= SB_AUTOSIZE; | so->so_rcv.sb_flags |= SB_AUTOSIZE; | ||||
so->so_snd.sb_flags |= SB_AUTOSIZE; | so->so_snd.sb_flags |= SB_AUTOSIZE; | ||||
error = in_pcballoc(so, &V_tcbinfo); | error = in_pcballoc(so, &V_tcbinfo); | ||||
if (error) | if (error) | ||||
goto out; | goto out; | ||||
inp = sotoinpcb(so); | inp = sotoinpcb(so); | ||||
tp = tcp_newtcpcb(inp); | tfb = tcp_find_and_ref_default_fb(); | ||||
tp = tcp_newtcpcb(inp, tfb); | |||||
if (tp == NULL) { | if (tp == NULL) { | ||||
error = ENOBUFS; | error = ENOBUFS; | ||||
refcount_release(&tfb->tfb_refcnt); | |||||
in_pcbfree(inp); | in_pcbfree(inp); | ||||
goto out; | goto out; | ||||
} | } | ||||
tp->t_state = TCPS_CLOSED; | tp->t_state = TCPS_CLOSED; | ||||
/* Can we inherit anything from the listener? */ | /* Can we inherit anything from the listener? */ | ||||
if ((so->so_listen != NULL) && | if ((so->so_listen != NULL) && | ||||
(so->so_listen->so_pcb != NULL) && | (so->so_listen->so_pcb != NULL) && | ||||
(tp->t_fb->tfb_inherit != NULL)) { | (tp->t_fb->tfb_inherit != NULL)) { | ||||
▲ Show 20 Lines • Show All 2,954 Lines • Show Last 20 Lines |