Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/tcp_input.c
| Show First 20 Lines • Show All 1,629 Lines • ▼ Show 20 Lines | #endif | ||||
| * fall back to non RFC1323 RTT calculation. Normalize | * fall back to non RFC1323 RTT calculation. Normalize | ||||
| * timestamp if syncookies were used when this connection | * timestamp if syncookies were used when this connection | ||||
| * was established. | * was established. | ||||
| */ | */ | ||||
| if ((to.to_flags & TOF_TS) && (to.to_tsecr != 0)) { | if ((to.to_flags & TOF_TS) && (to.to_tsecr != 0)) { | ||||
| to.to_tsecr -= tp->ts_offset; | to.to_tsecr -= tp->ts_offset; | ||||
| if (TSTMP_GT(to.to_tsecr, tcp_ts_getticks())) { | if (TSTMP_GT(to.to_tsecr, tcp_ts_getticks())) { | ||||
| to.to_tsecr = 0; | to.to_tsecr = 0; | ||||
| } else if (tp->t_rxtshift == 1 && | |||||
| tp->t_flags & TF_PREVVALID && | |||||
| tp->t_badrxtwin != 0 && | |||||
| TSTMP_LT(to.to_tsecr, tp->t_badrxtwin)) { | |||||
| cc_cong_signal(tp, th, CC_RTO_ERR); | |||||
| } | } | ||||
| } | } | ||||
| /* | /* | ||||
| * Process options only when we get SYN/ACK back. The SYN case | * Process options only when we get SYN/ACK back. The SYN case | ||||
| * for incoming connections is handled in tcp_syncache. | * for incoming connections is handled in tcp_syncache. | ||||
| * According to RFC1323 the window field in a SYN (i.e., a <SYN> | * According to RFC1323 the window field in a SYN (i.e., a <SYN> | ||||
| * or <SYN,ACK>) segment itself is never scaled. | * or <SYN,ACK>) segment itself is never scaled. | ||||
| * XXX this is traditional behavior, may need to be cleaned up. | * XXX this is traditional behavior, may need to be cleaned up. | ||||
| ▲ Show 20 Lines • Show All 136 Lines • ▼ Show 20 Lines | if (tlen == 0) { | ||||
| (to.to_flags & TOF_SACK) == 0 && | (to.to_flags & TOF_SACK) == 0 && | ||||
| TAILQ_EMPTY(&tp->snd_holes)) { | TAILQ_EMPTY(&tp->snd_holes)) { | ||||
| /* | /* | ||||
| * This is a pure ack for outstanding data. | * This is a pure ack for outstanding data. | ||||
| */ | */ | ||||
| TCPSTAT_INC(tcps_predack); | TCPSTAT_INC(tcps_predack); | ||||
| /* | /* | ||||
| * "bad retransmit" recovery without timestamps. | * "bad retransmit" recovery. | ||||
| */ | */ | ||||
| if ((to.to_flags & TOF_TS) == 0 && | if (tp->t_rxtshift == 1 && | ||||
| tp->t_rxtshift == 1 && | |||||
| tp->t_flags & TF_PREVVALID && | tp->t_flags & TF_PREVVALID && | ||||
| tp->t_badrxtwin != 0 && | tp->t_badrxtwin != 0 && | ||||
| TSTMP_LT(ticks, tp->t_badrxtwin)) { | (((to.to_flags & TOF_TS) != 0 && | ||||
| to.to_tsecr != 0 && | |||||
| TSTMP_LT(to.to_tsecr, tp->t_badrxtwin)) || | |||||
| ((to.to_flags & TOF_TS) == 0 && | |||||
| TSTMP_LT(ticks, tp->t_badrxtwin)))) | |||||
| cc_cong_signal(tp, th, CC_RTO_ERR); | cc_cong_signal(tp, th, CC_RTO_ERR); | ||||
| } | |||||
| /* | /* | ||||
| * Recalculate the transmit timer / rtt. | * Recalculate the transmit timer / rtt. | ||||
| * | * | ||||
| * Some boxes send broken timestamp replies | * Some boxes send broken timestamp replies | ||||
rscheff: Any specific reason to write the or statement as two separate if clauses?
I believe in other… | |||||
Done Inline ActionsI agree with Richard, better one complex if clause. The two clauses are mutually exclusive as one wants TOF_TS and other !TOF_TS, so cc_cong_signal() can be executed only once. My first reading was that it is intentionally written this way cause we may want two calls into cc_cong_singal(), so it was a misleading reading. Oh, the upper level embracing if can also be merged into one big clause: if ((tp->t_rxtshift == 1 &&
tp->t_flags & TF_PREVVALID &&
tp->t_badrxtwin != 0) &&
(((to.to_flags & TOF_TS) != 0 &&
(to.to_tsecr != 0) &&
TSTMP_LT(to.to_tsecr, tp->t_badrxtwin)) ||
((to.to_flags & TOF_TS) == 0 &&
TSTMP_LT(ticks, tp->t_badrxtwin))))
cc_cong_signal(tp, th, CC_RTO_ERR);This will also fix lines longer than 79 chars. IMHO, we may slightly violate style(9) and add single space indentation to highlight our three main large blocks (a && (b || c)). glebius: I agree with Richard, better one complex if clause. The two clauses are mutually exclusive as… | |||||
Done Inline ActionsNow using one and two spaces of indentation to make the expression more readable. tuexen: Now using one and two spaces of indentation to make the expression more readable. | |||||
Done Inline ActionsIt was a try to break things up for improved readability by humans. tuexen: It was a try to break things up for improved readability by humans. | |||||
| * during the SYN+ACK phase, ignore | * during the SYN+ACK phase, ignore | ||||
| * timestamps of 0 or we could calculate a | * timestamps of 0 or we could calculate a | ||||
| * huge RTT and blow up the retransmit timer. | * huge RTT and blow up the retransmit timer. | ||||
| */ | */ | ||||
| if ((to.to_flags & TOF_TS) != 0 && | if ((to.to_flags & TOF_TS) != 0 && | ||||
| to.to_tsecr) { | to.to_tsecr) { | ||||
| uint32_t t; | uint32_t t; | ||||
| ▲ Show 20 Lines • Show All 2,424 Lines • Show Last 20 Lines | |||||
Any specific reason to write the or statement as two separate if clauses?
I believe in other parts we do it ((true & x & y & z) | (false & a & b &c )) - as multiline checks;
I don't like them both get executed "always", so at the very least, an "else" just before the 2nd if would be good.
The logic looks ok to me.