Changeset View
Changeset View
Standalone View
Standalone View
head/sys/netinet/tcp_syncache.c
Show All 35 Lines | |||||
#include "opt_inet.h" | #include "opt_inet.h" | ||||
#include "opt_inet6.h" | #include "opt_inet6.h" | ||||
#include "opt_ipsec.h" | #include "opt_ipsec.h" | ||||
#include "opt_pcbgroup.h" | #include "opt_pcbgroup.h" | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/hash.h> | #include <sys/hash.h> | ||||
#include <sys/refcount.h> | |||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <sys/limits.h> | #include <sys/limits.h> | ||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/mutex.h> | #include <sys/mutex.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/mbuf.h> | #include <sys/mbuf.h> | ||||
#include <sys/proc.h> /* for proc0 declaration */ | #include <sys/proc.h> /* for proc0 declaration */ | ||||
▲ Show 20 Lines • Show All 569 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* Build a new TCP socket structure from a syncache entry. | * Build a new TCP socket structure from a syncache entry. | ||||
* | * | ||||
* On success return the newly created socket with its underlying inp locked. | * On success return the newly created socket with its underlying inp locked. | ||||
*/ | */ | ||||
static struct socket * | static struct socket * | ||||
syncache_socket(struct syncache *sc, struct socket *lso, struct mbuf *m) | syncache_socket(struct syncache *sc, struct socket *lso, struct mbuf *m) | ||||
{ | { | ||||
struct tcp_function_block *blk; | |||||
struct inpcb *inp = NULL; | struct inpcb *inp = NULL; | ||||
struct socket *so; | struct socket *so; | ||||
struct tcpcb *tp; | struct tcpcb *tp; | ||||
int error; | int error; | ||||
char *s; | char *s; | ||||
INP_INFO_RLOCK_ASSERT(&V_tcbinfo); | INP_INFO_RLOCK_ASSERT(&V_tcbinfo); | ||||
▲ Show 20 Lines • Show All 175 Lines • ▼ Show 20 Lines | |||||
#endif /* INET */ | #endif /* INET */ | ||||
INP_HASH_WUNLOCK(&V_tcbinfo); | INP_HASH_WUNLOCK(&V_tcbinfo); | ||||
tp = intotcpcb(inp); | tp = intotcpcb(inp); | ||||
tcp_state_change(tp, TCPS_SYN_RECEIVED); | tcp_state_change(tp, TCPS_SYN_RECEIVED); | ||||
tp->iss = sc->sc_iss; | tp->iss = sc->sc_iss; | ||||
tp->irs = sc->sc_irs; | tp->irs = sc->sc_irs; | ||||
tcp_rcvseqinit(tp); | tcp_rcvseqinit(tp); | ||||
tcp_sendseqinit(tp); | tcp_sendseqinit(tp); | ||||
blk = sototcpcb(lso)->t_fb; | |||||
if (blk != tp->t_fb) { | |||||
/* | |||||
* Our parents t_fb was not the default, | |||||
* we need to release our ref on tp->t_fb and | |||||
* pickup one on the new entry. | |||||
*/ | |||||
struct tcp_function_block *rblk; | |||||
rblk = find_and_ref_tcp_fb(blk); | |||||
KASSERT(rblk != NULL, | |||||
("cannot find blk %p out of syncache?", blk)); | |||||
if (tp->t_fb->tfb_tcp_fb_fini) | |||||
(*tp->t_fb->tfb_tcp_fb_fini)(tp); | |||||
refcount_release(&tp->t_fb->tfb_refcnt); | |||||
tp->t_fb = rblk; | |||||
if (tp->t_fb->tfb_tcp_fb_init) { | |||||
(*tp->t_fb->tfb_tcp_fb_init)(tp); | |||||
} | |||||
} | |||||
tp->snd_wl1 = sc->sc_irs; | tp->snd_wl1 = sc->sc_irs; | ||||
tp->snd_max = tp->iss + 1; | tp->snd_max = tp->iss + 1; | ||||
tp->snd_nxt = tp->iss + 1; | tp->snd_nxt = tp->iss + 1; | ||||
tp->rcv_up = sc->sc_irs + 1; | tp->rcv_up = sc->sc_irs + 1; | ||||
tp->rcv_wnd = sc->sc_wnd; | tp->rcv_wnd = sc->sc_wnd; | ||||
tp->rcv_adv += tp->rcv_wnd; | tp->rcv_adv += tp->rcv_wnd; | ||||
tp->last_ack_sent = tp->rcv_nxt; | tp->last_ack_sent = tp->rcv_nxt; | ||||
▲ Show 20 Lines • Show All 1,198 Lines • Show Last 20 Lines |