Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/tcp_syncache.c
Show First 20 Lines • Show All 828 Lines • ▼ Show 20 Lines | #if defined(IPSEC) || defined(IPSEC_SUPPORT) | ||||
if (ipsec_copy_pcbpolicy(sotoinpcb(lso), inp) != 0) | if (ipsec_copy_pcbpolicy(sotoinpcb(lso), inp) != 0) | ||||
printf("syncache_socket: could not copy policy\n"); | printf("syncache_socket: could not copy policy\n"); | ||||
#endif | #endif | ||||
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; | ||||
tp->t_lasttsval = sc->sc_ts; | |||||
tcp_rcvseqinit(tp); | tcp_rcvseqinit(tp); | ||||
tcp_sendseqinit(tp); | tcp_sendseqinit(tp); | ||||
blk = sototcpcb(lso)->t_fb; | blk = sototcpcb(lso)->t_fb; | ||||
if (V_functions_inherit_listen_socket_stack && blk != tp->t_fb) { | if (V_functions_inherit_listen_socket_stack && blk != tp->t_fb) { | ||||
/* | /* | ||||
* Our parents t_fb was not the default, | * Our parents t_fb was not the default, | ||||
* we need to release our ref on tp->t_fb and | * we need to release our ref on tp->t_fb and | ||||
* pickup one on the new entry. | * pickup one on the new entry. | ||||
Show All 32 Lines | else { | ||||
if (sc->sc_flags & SCF_WINSCALE) { | if (sc->sc_flags & SCF_WINSCALE) { | ||||
tp->t_flags |= TF_REQ_SCALE|TF_RCVD_SCALE; | tp->t_flags |= TF_REQ_SCALE|TF_RCVD_SCALE; | ||||
tp->snd_scale = sc->sc_requested_s_scale; | tp->snd_scale = sc->sc_requested_s_scale; | ||||
tp->request_r_scale = sc->sc_requested_r_scale; | tp->request_r_scale = sc->sc_requested_r_scale; | ||||
} | } | ||||
if (sc->sc_flags & SCF_TIMESTAMP) { | if (sc->sc_flags & SCF_TIMESTAMP) { | ||||
tp->t_flags |= TF_REQ_TSTMP|TF_RCVD_TSTMP; | tp->t_flags |= TF_REQ_TSTMP|TF_RCVD_TSTMP; | ||||
tp->ts_recent = sc->sc_tsreflect; | tp->ts_recent = sc->sc_tsreflect; | ||||
tp->ts_recent_age = tcp_ts_getticks(); | tp->ts_recent_age = tcp_ts_getsbintime(); | ||||
tp->ts_offset = sc->sc_tsoff; | |||||
} | } | ||||
#if defined(IPSEC_SUPPORT) || defined(TCP_SIGNATURE) | #if defined(IPSEC_SUPPORT) || defined(TCP_SIGNATURE) | ||||
if (sc->sc_flags & SCF_SIGNATURE) | if (sc->sc_flags & SCF_SIGNATURE) | ||||
tp->t_flags |= TF_SIGNATURE; | tp->t_flags |= TF_SIGNATURE; | ||||
#endif | #endif | ||||
if (sc->sc_flags & SCF_SACK) | if (sc->sc_flags & SCF_SACK) | ||||
tp->t_flags |= TF_SACK_PERMIT; | tp->t_flags |= TF_SACK_PERMIT; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 588 Lines • ▼ Show 20 Lines | #endif | ||||
if (V_tcp_do_rfc1323) { | if (V_tcp_do_rfc1323) { | ||||
/* | /* | ||||
* A timestamp received in a SYN makes | * A timestamp received in a SYN makes | ||||
* it ok to send timestamp requests and replies. | * it ok to send timestamp requests and replies. | ||||
*/ | */ | ||||
if (to->to_flags & TOF_TS) { | if (to->to_flags & TOF_TS) { | ||||
sc->sc_tsreflect = to->to_tsval; | sc->sc_tsreflect = to->to_tsval; | ||||
sc->sc_ts = tcp_ts_getticks(); | sc->sc_ts = TCP_SBT_TO_TS(tcp_ts_getsbintime()); | ||||
sc->sc_flags |= SCF_TIMESTAMP; | sc->sc_flags |= SCF_TIMESTAMP; | ||||
} | } | ||||
if (to->to_flags & TOF_SCALE) { | if (to->to_flags & TOF_SCALE) { | ||||
int wscale = 0; | int wscale = 0; | ||||
/* | /* | ||||
* Pick the smallest possible scaling factor that | * Pick the smallest possible scaling factor that | ||||
* will still allow us to scale up to sb_max, aka | * will still allow us to scale up to sb_max, aka | ||||
▲ Show 20 Lines • Show All 520 Lines • ▼ Show 20 Lines | syncookie_generate(struct syncache_head *sch, struct syncache *sc) | ||||
* done to prevent the 8 cookie bits from showing up directly on the | * done to prevent the 8 cookie bits from showing up directly on the | ||||
* wire. | * wire. | ||||
*/ | */ | ||||
iss = hash & ~0xff; | iss = hash & ~0xff; | ||||
iss |= cookie.cookie ^ (hash >> 24); | iss |= cookie.cookie ^ (hash >> 24); | ||||
/* Randomize the timestamp. */ | /* Randomize the timestamp. */ | ||||
if (sc->sc_flags & SCF_TIMESTAMP) { | if (sc->sc_flags & SCF_TIMESTAMP) { | ||||
sc->sc_ts = arc4random(); | sc->sc_ts = TCP_SBT_TO_TS(tcp_ts_getsbintime()); | ||||
sc->sc_tsoff = sc->sc_ts - tcp_ts_getticks(); | |||||
} | } | ||||
TCPSTAT_INC(tcps_sc_sendcookie); | TCPSTAT_INC(tcps_sc_sendcookie); | ||||
return (iss); | return (iss); | ||||
} | } | ||||
static struct syncache * | static struct syncache * | ||||
syncookie_lookup(struct in_conninfo *inc, struct syncache_head *sch, | syncookie_lookup(struct in_conninfo *inc, struct syncache_head *sch, | ||||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | #endif | ||||
if (cookie.flags.sack_ok) | if (cookie.flags.sack_ok) | ||||
sc->sc_flags |= SCF_SACK; | sc->sc_flags |= SCF_SACK; | ||||
if (to->to_flags & TOF_TS) { | if (to->to_flags & TOF_TS) { | ||||
sc->sc_flags |= SCF_TIMESTAMP; | sc->sc_flags |= SCF_TIMESTAMP; | ||||
sc->sc_tsreflect = to->to_tsval; | sc->sc_tsreflect = to->to_tsval; | ||||
sc->sc_ts = to->to_tsecr; | sc->sc_ts = to->to_tsecr; | ||||
sc->sc_tsoff = to->to_tsecr - tcp_ts_getticks(); | sc->sc_tsoff = to->to_tsecr - TCP_SBT_TO_TS(tcp_ts_getsbintime()); | ||||
} | } | ||||
if (to->to_flags & TOF_SIGNATURE) | if (to->to_flags & TOF_SIGNATURE) | ||||
sc->sc_flags |= SCF_SIGNATURE; | sc->sc_flags |= SCF_SIGNATURE; | ||||
sc->sc_rxmits = 0; | sc->sc_rxmits = 0; | ||||
TCPSTAT_INC(tcps_sc_recvcookie); | TCPSTAT_INC(tcps_sc_recvcookie); | ||||
▲ Show 20 Lines • Show All 118 Lines • Show Last 20 Lines |