Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/tcp_output.c
Show First 20 Lines • Show All 258 Lines • ▼ Show 20 Lines | #endif | ||||
tp->t_flags &= ~TF_LASTIDLE; | tp->t_flags &= ~TF_LASTIDLE; | ||||
if (idle) { | if (idle) { | ||||
if (tp->t_flags & TF_MORETOCOME) { | if (tp->t_flags & TF_MORETOCOME) { | ||||
tp->t_flags |= TF_LASTIDLE; | tp->t_flags |= TF_LASTIDLE; | ||||
idle = 0; | idle = 0; | ||||
} | } | ||||
} | } | ||||
again: | again: | ||||
sendwin = 0; | |||||
/* | /* | ||||
* If we've recently taken a timeout, snd_max will be greater than | * If we've recently taken a timeout, snd_max will be greater than | ||||
* snd_nxt. There may be SACK information that allows us to avoid | * snd_nxt. There may be SACK information that allows us to avoid | ||||
* resending already delivered data. Adjust snd_nxt accordingly. | * resending already delivered data. Adjust snd_nxt accordingly. | ||||
*/ | */ | ||||
if ((tp->t_flags & TF_SACK_PERMIT) && | if ((tp->t_flags & TF_SACK_PERMIT) && | ||||
SEQ_LT(tp->snd_nxt, tp->snd_max)) | SEQ_LT(tp->snd_nxt, tp->snd_max)) | ||||
tcp_sack_adjust(tp); | sendwin = tcp_sack_adjust(tp); | ||||
sendalot = 0; | sendalot = 0; | ||||
tso = 0; | tso = 0; | ||||
mtu = 0; | mtu = 0; | ||||
off = tp->snd_nxt - tp->snd_una; | off = tp->snd_nxt - tp->snd_una; | ||||
sendwin = min(tp->snd_wnd, tp->snd_cwnd); | sendwin = min(tp->snd_wnd, tp->snd_cwnd + sendwin); | ||||
flags = tcp_outflags[tp->t_state]; | flags = tcp_outflags[tp->t_state]; | ||||
/* | /* | ||||
* Send any SACK-generated retransmissions. If we're explicitly trying | * Send any SACK-generated retransmissions. If we're explicitly trying | ||||
* to send out new data (when sendalot is 1), bypass this function. | * to send out new data (when sendalot is 1), bypass this function. | ||||
* If we retransmit in fast recovery mode, decrement snd_cwnd, since | * If we retransmit in fast recovery mode, decrement snd_cwnd, since | ||||
* we're replacing a (future) new transmission with a retransmission | * we're replacing a (future) new transmission with a retransmission | ||||
* now, and we previously incremented snd_cwnd in tcp_input(). | * now, and we previously incremented snd_cwnd in tcp_input(). | ||||
*/ | */ | ||||
/* | /* | ||||
* Still in sack recovery , reset rxmit flag to zero. | * Still in sack recovery , reset rxmit flag to zero. | ||||
*/ | */ | ||||
sack_rxmit = 0; | sack_rxmit = 0; | ||||
sack_bytes_rxmt = 0; | sack_bytes_rxmt = 0; | ||||
len = 0; | len = 0; | ||||
p = NULL; | p = NULL; | ||||
if ((tp->t_flags & TF_SACK_PERMIT) && IN_FASTRECOVERY(tp->t_flags) && | if ((tp->t_flags & TF_SACK_PERMIT) && | ||||
(IN_FASTRECOVERY(tp->t_flags) || SEQ_LT(tp->snd_nxt, tp->snd_max)) && | |||||
(p = tcp_sack_output(tp, &sack_bytes_rxmt))) { | (p = tcp_sack_output(tp, &sack_bytes_rxmt))) { | ||||
uint32_t cwin; | uint32_t cwin; | ||||
cwin = | cwin = | ||||
imax(min(tp->snd_wnd, tp->snd_cwnd) - sack_bytes_rxmt, 0); | imax(min(tp->snd_wnd, tp->snd_cwnd) - sack_bytes_rxmt, 0); | ||||
/* Do not retransmit SACK segments beyond snd_recover */ | /* Do not retransmit SACK segments beyond snd_recover */ | ||||
if (SEQ_GT(p->end, tp->snd_recover)) { | if (SEQ_GT(p->end, tp->snd_recover)) { | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | after_sack_rexmit: | ||||
* In the normal retransmit-FIN-only case, however, snd_nxt will | * In the normal retransmit-FIN-only case, however, snd_nxt will | ||||
* be set to snd_una, the offset will be 0, and the length may | * be set to snd_una, the offset will be 0, and the length may | ||||
* wind up 0. | * wind up 0. | ||||
* | * | ||||
* If sack_rxmit is true we are retransmitting from the scoreboard | * If sack_rxmit is true we are retransmitting from the scoreboard | ||||
* in which case len is already set. | * in which case len is already set. | ||||
*/ | */ | ||||
if (sack_rxmit == 0) { | if (sack_rxmit == 0) { | ||||
if (sack_bytes_rxmt == 0) | if (sack_bytes_rxmt == 0) | ||||
cc: Same here for readability, it's better to remove () between relational operators:
```
if… | |||||
len = ((int32_t)min(sbavail(&so->so_snd), sendwin) - | len = ((int32_t)min(sbavail(&so->so_snd), sendwin) - | ||||
off); | off); | ||||
else { | else { | ||||
int32_t cwin; | int32_t cwin; | ||||
/* | /* | ||||
* We are inside of a SACK recovery episode and are | * We are inside of a SACK recovery episode and are | ||||
* sending new data, having retransmitted all the | * sending new data, having retransmitted all the | ||||
▲ Show 20 Lines • Show All 150 Lines • ▼ Show 20 Lines | #endif | ||||
if ((tp->t_flags & TF_TSO) && V_tcp_do_tso && len > tp->t_maxseg && | if ((tp->t_flags & TF_TSO) && V_tcp_do_tso && len > tp->t_maxseg && | ||||
(tp->t_port == 0) && | (tp->t_port == 0) && | ||||
((tp->t_flags & TF_SIGNATURE) == 0) && | ((tp->t_flags & TF_SIGNATURE) == 0) && | ||||
tp->rcv_numsacks == 0 && sack_rxmit == 0 && | tp->rcv_numsacks == 0 && sack_rxmit == 0 && | ||||
ipoptlen == 0 && !(flags & TH_SYN)) | ipoptlen == 0 && !(flags & TH_SYN)) | ||||
tso = 1; | tso = 1; | ||||
if (sack_rxmit) { | if (sack_rxmit) { | ||||
if (SEQ_LT(p->rxmit + len, tp->snd_una + sbused(&so->so_snd))) | if (SEQ_LT(p->rxmit + len, | ||||
tp->snd_una + sbused(&so->so_snd))) | |||||
flags &= ~TH_FIN; | flags &= ~TH_FIN; | ||||
} else { | } else { | ||||
if (SEQ_LT(tp->snd_nxt + len, tp->snd_una + | if (SEQ_LT(tp->snd_nxt + len, | ||||
sbused(&so->so_snd))) | tp->snd_una + sbused(&so->so_snd))) | ||||
flags &= ~TH_FIN; | flags &= ~TH_FIN; | ||||
} | } | ||||
recwin = lmin(lmax(sbspace(&so->so_rcv), 0), | recwin = lmin(lmax(sbspace(&so->so_rcv), 0), | ||||
(long)TCP_MAXWIN << tp->rcv_scale); | (long)TCP_MAXWIN << tp->rcv_scale); | ||||
/* | /* | ||||
* Sender silly window avoidance. We transmit under the following | * Sender silly window avoidance. We transmit under the following | ||||
▲ Show 20 Lines • Show All 1,042 Lines • ▼ Show 20 Lines | timer: | ||||
if (flags & TH_SYN) | if (flags & TH_SYN) | ||||
++xlen; | ++xlen; | ||||
if (flags & TH_FIN) { | if (flags & TH_FIN) { | ||||
++xlen; | ++xlen; | ||||
tp->t_flags |= TF_SENTFIN; | tp->t_flags |= TF_SENTFIN; | ||||
} | } | ||||
if (SEQ_GT(tp->snd_nxt + xlen, tp->snd_max)) | if (SEQ_GT(tp->snd_nxt + xlen, tp->snd_max)) | ||||
tp->snd_max = tp->snd_nxt + xlen; | tp->snd_max = tp->snd_nxt + xlen; | ||||
} | } | ||||
if ((error == 0) && | if ((tp->rcv_numsacks > 0) && | ||||
(TCPS_HAVEESTABLISHED(tp->t_state) && | (error == 0) && | ||||
(tp->t_flags & TF_SACK_PERMIT) && | TCPS_HAVEESTABLISHED(tp->t_state) && | ||||
tp->rcv_numsacks > 0)) { | (tp->t_flags & TF_SACK_PERMIT)) { | ||||
/* Clean up any DSACK's sent */ | /* Clean up any DSACK's sent */ | ||||
tcp_clean_dsack_blocks(tp); | tcp_clean_dsack_blocks(tp); | ||||
} | |||||
if (sack_rxmit && | |||||
(error == 0) && | |||||
SEQ_LT(tp->snd_nxt, SEQ_MIN(p->rxmit, p->end))) { | |||||
Not Done Inline ActionsSame here for readability, it's better to remove () between relational operators and re-align: if (error == 0 && sack_rxmit && SEQ_LT(tp->snd_nxt, SEQ_MIN(p->rxmit, p->end))) { cc: Same here for readability, it's better to remove () between relational operators and re-align… | |||||
tp->snd_nxt = SEQ_MIN(p->rxmit, p->end); | |||||
} | } | ||||
Not Done Inline ActionsSame here for readability, it's better to remove () between relational operators and re-align: if (error == 0 && tp->rcv_numsacks > 0 && TCPS_HAVEESTABLISHED(tp->t_state) && tp->t_flags & TF_SACK_PERMIT) { cc: Same here for readability, it's better to remove () between relational operators and re-align… | |||||
if (error) { | if (error) { | ||||
/* | /* | ||||
* We know that the packet was lost, so back out the | * We know that the packet was lost, so back out the | ||||
* sequence number advance, if any. | * sequence number advance, if any. | ||||
* | * | ||||
* If the error is EPERM the packet got blocked by the | * If the error is EPERM the packet got blocked by the | ||||
* local firewall. Normally we should terminate the | * local firewall. Normally we should terminate the | ||||
* connection but the blocking may have been spurious | * connection but the blocking may have been spurious | ||||
▲ Show 20 Lines • Show All 531 Lines • Show Last 20 Lines |
Same here for readability, it's better to remove () between relational operators: