Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/tcp_input.c
Show First 20 Lines • Show All 997 Lines • ▼ Show 20 Lines | if (isipv6) { | ||||
goto dropunlock; | goto dropunlock; | ||||
} else | } else | ||||
#endif | #endif | ||||
if (inp->inp_ip_minttl > ip->ip_ttl) | if (inp->inp_ip_minttl > ip->ip_ttl) | ||||
goto dropunlock; | goto dropunlock; | ||||
} | } | ||||
tp = intotcpcb(inp); | tp = intotcpcb(inp); | ||||
to.to_ae = &tp->t_ae; | |||||
switch (tp->t_state) { | switch (tp->t_state) { | ||||
case TCPS_TIME_WAIT: | case TCPS_TIME_WAIT: | ||||
/* | /* | ||||
* A previous connection in TIMEWAIT state is supposed to catch | * A previous connection in TIMEWAIT state is supposed to catch | ||||
* stray or duplicate segments arriving late. If this segment | * stray or duplicate segments arriving late. If this segment | ||||
* was a legitimate new connection attempt, the old INPCB gets | * was a legitimate new connection attempt, the old INPCB gets | ||||
* removed and we can try again to find a listening socket. | * removed and we can try again to find a listening socket. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 523 Lines • ▼ Show 20 Lines | tcp_do_segment(struct tcpcb *tp, struct mbuf *m, struct tcphdr *th, | ||||
struct mbuf *mfree; | struct mbuf *mfree; | ||||
struct tcpopt to; | struct tcpopt to; | ||||
int tfo_syn; | int tfo_syn; | ||||
u_int maxseg; | u_int maxseg; | ||||
thflags = tcp_get_flags(th); | thflags = tcp_get_flags(th); | ||||
tp->sackhint.last_sack_ack = 0; | tp->sackhint.last_sack_ack = 0; | ||||
sack_changed = 0; | sack_changed = 0; | ||||
to.to_ae = &tp->t_ae; | |||||
nsegs = max(1, m->m_pkthdr.lro_nsegs); | nsegs = max(1, m->m_pkthdr.lro_nsegs); | ||||
NET_EPOCH_ASSERT(); | NET_EPOCH_ASSERT(); | ||||
INP_WLOCK_ASSERT(inp); | INP_WLOCK_ASSERT(inp); | ||||
KASSERT(tp->t_state > TCPS_LISTEN, ("%s: TCPS_LISTEN", | KASSERT(tp->t_state > TCPS_LISTEN, ("%s: TCPS_LISTEN", | ||||
__func__)); | __func__)); | ||||
KASSERT(tp->t_state != TCPS_TIME_WAIT, ("%s: TCPS_TIME_WAIT", | KASSERT(tp->t_state != TCPS_TIME_WAIT, ("%s: TCPS_TIME_WAIT", | ||||
__func__)); | __func__)); | ||||
▲ Show 20 Lines • Show All 1,871 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
/* | /* | ||||
* Parse TCP options and place in tcpopt. | * Parse TCP options and place in tcpopt. | ||||
*/ | */ | ||||
void | void | ||||
tcp_dooptions(struct tcpopt *to, u_char *cp, int cnt, int flags) | tcp_dooptions(struct tcpopt *to, u_char *cp, int cnt, int flags) | ||||
{ | { | ||||
int opt, optlen; | int opt, optlen, tmp; | ||||
to->to_flags = 0; | to->to_flags = 0; | ||||
for (; cnt > 0; cnt -= optlen, cp += optlen) { | for (; cnt > 0; cnt -= optlen, cp += optlen) { | ||||
opt = cp[0]; | opt = cp[0]; | ||||
if (opt == TCPOPT_EOL) | if (opt == TCPOPT_EOL) | ||||
break; | break; | ||||
if (opt == TCPOPT_NOP) | if (opt == TCPOPT_NOP) | ||||
optlen = 1; | optlen = 1; | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | case TCPOPT_FAST_OPEN: | ||||
if (!(flags & TO_SYN)) | if (!(flags & TO_SYN)) | ||||
continue; | continue; | ||||
if (!V_tcp_fastopen_client_enable && | if (!V_tcp_fastopen_client_enable && | ||||
!V_tcp_fastopen_server_enable) | !V_tcp_fastopen_server_enable) | ||||
continue; | continue; | ||||
to->to_flags |= TOF_FASTOPEN; | to->to_flags |= TOF_FASTOPEN; | ||||
to->to_tfo_len = optlen - 2; | to->to_tfo_len = optlen - 2; | ||||
to->to_tfo_cookie = to->to_tfo_len ? cp + 2 : NULL; | to->to_tfo_cookie = to->to_tfo_len ? cp + 2 : NULL; | ||||
break; | |||||
case TCPOPT_ACCECN0: | |||||
case TCPOPT_ACCECN1: | |||||
if (optlen >= (TCPOLEN_ACCECN_EMPTY + | |||||
1 * TCPOLEN_ACCECN_COUNTER)) { | |||||
tmp = ntoh24(cp + TCPOLEN_ACCECN_EMPTY + 0); | |||||
if (opt == TCPOPT_ACCECN0) { | |||||
tmp -= (to->to_ae->se0b & 0xFFFFFF); | |||||
if (tmp > 0) | |||||
to->to_ae->se0b += tmp; | |||||
} else { | |||||
tmp -= (to->to_ae->se1b & 0xFFFFFF); | |||||
if (tmp > 0) | |||||
to->to_ae->se1b += tmp; | |||||
} | |||||
} | |||||
if (optlen >= (TCPOLEN_ACCECN_EMPTY + | |||||
2 * TCPOLEN_ACCECN_COUNTER)) { | |||||
tmp = ntoh24(cp + TCPOLEN_ACCECN_EMPTY + 3); | |||||
tmp -= (to->to_ae->sceb & 0xFFFFFF); | |||||
if (tmp > 0) | |||||
to->to_ae->sceb += tmp; | |||||
} | |||||
if (optlen >= (TCPOLEN_ACCECN_EMPTY + | |||||
3 * TCPOLEN_ACCECN_COUNTER)) { | |||||
tmp = ntoh24(cp + TCPOLEN_ACCECN_EMPTY + 6); | |||||
if (opt == TCPOPT_ACCECN0) { | |||||
tmp -= (to->to_ae->se1b & 0xFFFFFF); | |||||
if (tmp > 0) | |||||
to->to_ae->se1b += tmp; | |||||
} else { | |||||
tmp -= (to->to_ae->se0b & 0xFFFFFF); | |||||
if (tmp > 0) | |||||
to->to_ae->se0b += tmp; | |||||
} | |||||
} | |||||
break; | break; | ||||
default: | default: | ||||
continue; | continue; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 549 Lines • Show Last 20 Lines |