Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/tcp_input.c
Show First 20 Lines • Show All 1,463 Lines • ▼ Show 20 Lines | tcp_autorcvbuf(struct mbuf *m, struct tcphdr *th, struct socket *so, | ||||
} | } | ||||
return (newsize); | return (newsize); | ||||
} | } | ||||
void | void | ||||
tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, | tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, | ||||
struct tcpcb *tp, int drop_hdrlen, int tlen, uint8_t iptos) | struct tcpcb *tp, int drop_hdrlen, int tlen, uint8_t iptos) | ||||
{ | { | ||||
int thflags, acked, ourfinisacked, needoutput = 0, sack_changed; | int thflags, acked = 0, ourfinisacked, needoutput = 0, sack_changed; | ||||
int rstreason, todrop, win; | int rstreason, todrop, win; | ||||
uint32_t tiwin; | uint32_t tiwin; | ||||
uint16_t nsegs; | uint16_t nsegs; | ||||
char *s; | char *s; | ||||
struct in_conninfo *inc; | struct in_conninfo *inc; | ||||
struct mbuf *mfree; | struct mbuf *mfree; | ||||
struct tcpopt to; | struct tcpopt to; | ||||
int tfo_syn; | int tfo_syn; | ||||
▲ Show 20 Lines • Show All 888 Lines • ▼ Show 20 Lines | case TCPS_SYN_RECEIVED: | ||||
* Make transitions: | * Make transitions: | ||||
* SYN-RECEIVED -> ESTABLISHED | * SYN-RECEIVED -> ESTABLISHED | ||||
* SYN-RECEIVED* -> FIN-WAIT-1 | * SYN-RECEIVED* -> FIN-WAIT-1 | ||||
*/ | */ | ||||
tp->t_starttime = ticks; | tp->t_starttime = ticks; | ||||
if (IS_FASTOPEN(tp->t_flags) && tp->t_tfo_pending) { | if (IS_FASTOPEN(tp->t_flags) && tp->t_tfo_pending) { | ||||
tcp_fastopen_decrement_counter(tp->t_tfo_pending); | tcp_fastopen_decrement_counter(tp->t_tfo_pending); | ||||
tp->t_tfo_pending = NULL; | tp->t_tfo_pending = NULL; | ||||
/* | |||||
* Account for the ACK of our SYN prior to | |||||
* regular ACK processing below. | |||||
*/ | |||||
tp->snd_una++; | |||||
} | } | ||||
if (tp->t_flags & TF_NEEDFIN) { | if (tp->t_flags & TF_NEEDFIN) { | ||||
tcp_state_change(tp, TCPS_FIN_WAIT_1); | tcp_state_change(tp, TCPS_FIN_WAIT_1); | ||||
tp->t_flags &= ~TF_NEEDFIN; | tp->t_flags &= ~TF_NEEDFIN; | ||||
} else { | } else { | ||||
tcp_state_change(tp, TCPS_ESTABLISHED); | tcp_state_change(tp, TCPS_ESTABLISHED); | ||||
TCP_PROBE5(accept__established, NULL, tp, | TCP_PROBE5(accept__established, NULL, tp, | ||||
m, tp, th); | m, tp, th); | ||||
/* | /* | ||||
* TFO connections call cc_conn_init() during SYN | * TFO connections call cc_conn_init() during SYN | ||||
* processing. Calling it again here for such | * processing. Calling it again here for such | ||||
* connections is not harmless as it would undo the | * connections is not harmless as it would undo the | ||||
* snd_cwnd reduction that occurs when a TFO SYN|ACK | * snd_cwnd reduction that occurs when a TFO SYN|ACK | ||||
* is retransmitted. | * is retransmitted. | ||||
*/ | */ | ||||
if (!IS_FASTOPEN(tp->t_flags)) | if (!IS_FASTOPEN(tp->t_flags)) | ||||
cc_conn_init(tp); | cc_conn_init(tp); | ||||
tcp_timer_activate(tp, TT_KEEP, TP_KEEPIDLE(tp)); | tcp_timer_activate(tp, TT_KEEP, TP_KEEPIDLE(tp)); | ||||
} | } | ||||
/* | /* | ||||
* Account for the ACK of our SYN prior to | |||||
* regular ACK processing below, except for | |||||
* simultaneous SYN, which is handled later. | |||||
*/ | |||||
if (SEQ_GT(th->th_ack, tp->snd_una) && !(tp->t_flags & TF_NEEDSYN)) | |||||
acked = -1; | |||||
rscheff: Alternatively, TF_NEEDSYN could be set here, relying on the snd_una adjustment in the block at… | |||||
/* | |||||
* If segment contains data or ACK, will call tcp_reass() | * If segment contains data or ACK, will call tcp_reass() | ||||
* later; if not, do so now to pass queued data to user. | * later; if not, do so now to pass queued data to user. | ||||
*/ | */ | ||||
if (tlen == 0 && (thflags & TH_FIN) == 0) | if (tlen == 0 && (thflags & TH_FIN) == 0) | ||||
(void) tcp_reass(tp, (struct tcphdr *)0, NULL, 0, | (void) tcp_reass(tp, (struct tcphdr *)0, NULL, 0, | ||||
(struct mbuf *)0); | (struct mbuf *)0); | ||||
tp->snd_wl1 = th->th_seq - 1; | tp->snd_wl1 = th->th_seq - 1; | ||||
/* FALLTHROUGH */ | /* FALLTHROUGH */ | ||||
▲ Show 20 Lines • Show All 277 Lines • ▼ Show 20 Lines | if (tp->t_flags & TF_NEEDSYN) { | ||||
tp->rcv_scale = tp->request_r_scale; | tp->rcv_scale = tp->request_r_scale; | ||||
/* Send window already scaled. */ | /* Send window already scaled. */ | ||||
} | } | ||||
} | } | ||||
process_ACK: | process_ACK: | ||||
INP_WLOCK_ASSERT(tp->t_inpcb); | INP_WLOCK_ASSERT(tp->t_inpcb); | ||||
/* | |||||
* Adjust for the SYN bit in sequence space, | |||||
Not Done Inline ActionsCan I get a block comment above this that explains what is being accounted for here? In all the cases you removed they had such block comments, so we have lost some code documentation by adding this here without comment. I believe this is accounting for several possibilities. rgrimes: Can I get a block comment above this that explains what is being accounted for here? In all… | |||||
* but don't account it for cwnd calculations. | |||||
rgrimesUnsubmitted Not Done Inline Actionss/it for/for it in/ rgrimes: s/it for/for it in/ | |||||
* This is for the SYN_RECEIVED, non-simultaneous | |||||
* SYN case. SYN_SENT and simultaneous SYN are | |||||
* treated elsewhere. | |||||
*/ | |||||
if (acked != 0) | |||||
tp->snd_una++; | |||||
acked = BYTES_THIS_ACK(tp, th); | acked = BYTES_THIS_ACK(tp, th); | ||||
tuexenUnsubmitted Not Done Inline ActionsAm I reading this correctly:
If that is correct, then you are using it as a flag first and as a counter (for the bytes) later. Wouldn't it make sense to use a separate boolean variable for the first steps? tuexen: Am I reading this correctly:
* You initialize acked to 0;
* Under some condition you set it to… | |||||
KASSERT(acked >= 0, ("%s: acked unexepectedly negative " | KASSERT(acked >= 0, ("%s: acked unexepectedly negative " | ||||
"(tp->snd_una=%u, th->th_ack=%u, tp=%p, m=%p)", __func__, | "(tp->snd_una=%u, th->th_ack=%u, tp=%p, m=%p)", __func__, | ||||
tp->snd_una, th->th_ack, tp, m)); | tp->snd_una, th->th_ack, tp, m)); | ||||
TCPSTAT_ADD(tcps_rcvackpack, nsegs); | TCPSTAT_ADD(tcps_rcvackpack, nsegs); | ||||
TCPSTAT_ADD(tcps_rcvackbyte, acked); | TCPSTAT_ADD(tcps_rcvackbyte, acked); | ||||
/* | /* | ||||
* If we just performed our first retransmit, and the ACK | * If we just performed our first retransmit, and the ACK | ||||
▲ Show 20 Lines • Show All 1,137 Lines • Show Last 20 Lines |
Alternatively, TF_NEEDSYN could be set here, relying on the snd_una adjustment in the block at line 2676. However, tracking it separately without any other side effects than the intended one (proper accounting for the initial window) is easier to understand.