tcp: make inflight data (pipe) calculation consistent

Reviewed by: glebius, rrs, tuexen
Differential Revision: https://reviews.freebsd.org/D49047
This commit is contained in:
Cheng Cui 2025-02-21 15:53:06 -05:00
parent 518cdd344e
commit 67787d2004
No known key found for this signature in database
GPG key ID: F9BE886D1486EF98
6 changed files with 16 additions and 50 deletions

View file

@ -500,13 +500,7 @@ newreno_cc_cong_signal(struct cc_var *ccv, ccsignal_t type)
break;
case CC_RTO:
if (CCV(ccv, t_rxtshift) == 1) {
if (V_tcp_do_newsack) {
pipe = tcp_compute_pipe(ccv->tp);
} else {
pipe = CCV(ccv, snd_max) -
CCV(ccv, snd_fack) +
CCV(ccv, sackhint.sack_bytes_rexmit);
}
pipe = tcp_compute_pipe(ccv->tp);
CCV(ccv, snd_ssthresh) = max(2,
min(CCV(ccv, snd_wnd), pipe) / 2 / mss) * mss;
}

View file

@ -470,13 +470,7 @@ cubic_cong_signal(struct cc_var *ccv, ccsignal_t type)
cubic_data->undo_cwnd_epoch = cubic_data->cwnd_epoch;
cubic_data->undo_W_max = cubic_data->W_max;
cubic_data->undo_K = cubic_data->K;
if (V_tcp_do_newsack) {
pipe = tcp_compute_pipe(ccv->tp);
} else {
pipe = CCV(ccv, snd_max) -
CCV(ccv, snd_fack) +
CCV(ccv, sackhint.sack_bytes_rexmit);
}
pipe = tcp_compute_pipe(ccv->tp);
CCV(ccv, snd_ssthresh) = max(2,
(((uint64_t)min(CCV(ccv, snd_wnd), pipe) *
CUBIC_BETA) >> CUBIC_SHIFT) / mss) * mss;

View file

@ -294,13 +294,7 @@ dctcp_cong_signal(struct cc_var *ccv, ccsignal_t type)
break;
case CC_RTO:
if (CCV(ccv, t_rxtshift) == 1) {
if (V_tcp_do_newsack) {
pipe = tcp_compute_pipe(ccv->tp);
} else {
pipe = CCV(ccv, snd_max) -
CCV(ccv, snd_fack) +
CCV(ccv, sackhint.sack_bytes_rexmit);
}
pipe = tcp_compute_pipe(ccv->tp);
CCV(ccv, snd_ssthresh) = max(2,
min(CCV(ccv, snd_wnd), pipe) / 2 / mss) * mss;
}

View file

@ -325,13 +325,7 @@ htcp_cong_signal(struct cc_var *ccv, ccsignal_t type)
case CC_RTO:
if (CCV(ccv, t_rxtshift) == 1) {
if (V_tcp_do_newsack) {
pipe = tcp_compute_pipe(ccv->tp);
} else {
pipe = CCV(ccv, snd_max) -
CCV(ccv, snd_fack) +
CCV(ccv, sackhint.sack_bytes_rexmit);
}
pipe = tcp_compute_pipe(ccv->tp);
CCV(ccv, snd_ssthresh) = max(2,
min(CCV(ccv, snd_wnd), pipe) / 2 / mss) * mss;
}

View file

@ -428,13 +428,7 @@ newreno_cong_signal(struct cc_var *ccv, ccsignal_t type)
break;
case CC_RTO:
if (CCV(ccv, t_rxtshift) == 1) {
if (V_tcp_do_newsack) {
pipe = tcp_compute_pipe(ccv->tp);
} else {
pipe = CCV(ccv, snd_max) -
CCV(ccv, snd_fack) +
CCV(ccv, sackhint.sack_bytes_rexmit);
}
pipe = tcp_compute_pipe(ccv->tp);
CCV(ccv, snd_ssthresh) = max(2,
((uint64_t)min(CCV(ccv, snd_wnd), pipe) *
(uint64_t)factor) /

View file

@ -2660,12 +2660,7 @@ tcp_do_segment(struct tcpcb *tp, struct mbuf *m, struct tcphdr *th,
* we have less than ssthresh
* worth of data in flight.
*/
if (V_tcp_do_newsack) {
awnd = tcp_compute_pipe(tp);
} else {
awnd = (tp->snd_nxt - tp->snd_fack) +
tp->sackhint.sack_bytes_rexmit;
}
awnd = tcp_compute_pipe(tp);
if (awnd < tp->snd_ssthresh) {
tp->snd_cwnd += imax(maxseg,
imin(2 * maxseg,
@ -4098,11 +4093,7 @@ tcp_do_prr_ack(struct tcpcb *tp, struct tcphdr *th, struct tcpopt *to,
(IN_CONGRECOVERY(tp->t_flags) &&
!IN_FASTRECOVERY(tp->t_flags))) {
del_data = tp->sackhint.delivered_data;
if (V_tcp_do_newsack)
pipe = tcp_compute_pipe(tp);
else
pipe = (tp->snd_nxt - tp->snd_fack) +
tp->sackhint.sack_bytes_rexmit;
pipe = tcp_compute_pipe(tp);
} else {
if (tp->sackhint.prr_delivered < (tcprexmtthresh * maxseg +
tp->snd_recover - tp->snd_una)) {
@ -4206,14 +4197,19 @@ tcp_newreno_partial_ack(struct tcpcb *tp, struct tcphdr *th)
int
tcp_compute_pipe(struct tcpcb *tp)
{
if (tp->t_fb->tfb_compute_pipe == NULL) {
return (tp->snd_max - tp->snd_una +
int pipe;
if (tp->t_fb->tfb_compute_pipe != NULL) {
pipe = (*tp->t_fb->tfb_compute_pipe)(tp);
} else if (V_tcp_do_newsack) {
pipe = tp->snd_max - tp->snd_una +
tp->sackhint.sack_bytes_rexmit -
tp->sackhint.sacked_bytes -
tp->sackhint.lost_bytes);
tp->sackhint.lost_bytes;
} else {
return((*tp->t_fb->tfb_compute_pipe)(tp));
pipe = tp->snd_nxt - tp->snd_fack + tp->sackhint.sack_bytes_rexmit;
}
return (imax(pipe, 0));
}
uint32_t