Skip to content

Commit 1fbc340

Browse files
yuchungchengdavem330
authored andcommitted
tcp: early retransmit: tcp_enter_recovery()
This a prepartion patch that refactors the code to enter recovery into a new function tcp_enter_recovery(). It's needed to implement the delayed fast retransmit in ER. Signed-off-by: Yuchung Cheng <[email protected]> Acked-by: Neal Cardwell <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5c6239c commit 1fbc340

File tree

1 file changed

+34
-27
lines changed

1 file changed

+34
-27
lines changed

net/ipv4/tcp_input.c

+34-27
Original file line numberDiff line numberDiff line change
@@ -3022,6 +3022,38 @@ static void tcp_update_cwnd_in_recovery(struct sock *sk, int newly_acked_sacked,
30223022
tp->snd_cwnd = tcp_packets_in_flight(tp) + sndcnt;
30233023
}
30243024

3025+
static void tcp_enter_recovery(struct sock *sk, bool ece_ack)
3026+
{
3027+
struct tcp_sock *tp = tcp_sk(sk);
3028+
int mib_idx;
3029+
3030+
if (tcp_is_reno(tp))
3031+
mib_idx = LINUX_MIB_TCPRENORECOVERY;
3032+
else
3033+
mib_idx = LINUX_MIB_TCPSACKRECOVERY;
3034+
3035+
NET_INC_STATS_BH(sock_net(sk), mib_idx);
3036+
3037+
tp->high_seq = tp->snd_nxt;
3038+
tp->prior_ssthresh = 0;
3039+
tp->undo_marker = tp->snd_una;
3040+
tp->undo_retrans = tp->retrans_out;
3041+
3042+
if (inet_csk(sk)->icsk_ca_state < TCP_CA_CWR) {
3043+
if (!ece_ack)
3044+
tp->prior_ssthresh = tcp_current_ssthresh(sk);
3045+
tp->snd_ssthresh = inet_csk(sk)->icsk_ca_ops->ssthresh(sk);
3046+
TCP_ECN_queue_cwr(tp);
3047+
}
3048+
3049+
tp->bytes_acked = 0;
3050+
tp->snd_cwnd_cnt = 0;
3051+
tp->prior_cwnd = tp->snd_cwnd;
3052+
tp->prr_delivered = 0;
3053+
tp->prr_out = 0;
3054+
tcp_set_ca_state(sk, TCP_CA_Recovery);
3055+
}
3056+
30253057
/* Process an event, which can update packets-in-flight not trivially.
30263058
* Main goal of this function is to calculate new estimate for left_out,
30273059
* taking into account both packets sitting in receiver's buffer and
@@ -3041,7 +3073,7 @@ static void tcp_fastretrans_alert(struct sock *sk, int pkts_acked,
30413073
struct tcp_sock *tp = tcp_sk(sk);
30423074
int do_lost = is_dupack || ((flag & FLAG_DATA_SACKED) &&
30433075
(tcp_fackets_out(tp) > tp->reordering));
3044-
int fast_rexmit = 0, mib_idx;
3076+
int fast_rexmit = 0;
30453077

30463078
if (WARN_ON(!tp->packets_out && tp->sacked_out))
30473079
tp->sacked_out = 0;
@@ -3142,32 +3174,7 @@ static void tcp_fastretrans_alert(struct sock *sk, int pkts_acked,
31423174
}
31433175

31443176
/* Otherwise enter Recovery state */
3145-
3146-
if (tcp_is_reno(tp))
3147-
mib_idx = LINUX_MIB_TCPRENORECOVERY;
3148-
else
3149-
mib_idx = LINUX_MIB_TCPSACKRECOVERY;
3150-
3151-
NET_INC_STATS_BH(sock_net(sk), mib_idx);
3152-
3153-
tp->high_seq = tp->snd_nxt;
3154-
tp->prior_ssthresh = 0;
3155-
tp->undo_marker = tp->snd_una;
3156-
tp->undo_retrans = tp->retrans_out;
3157-
3158-
if (icsk->icsk_ca_state < TCP_CA_CWR) {
3159-
if (!(flag & FLAG_ECE))
3160-
tp->prior_ssthresh = tcp_current_ssthresh(sk);
3161-
tp->snd_ssthresh = icsk->icsk_ca_ops->ssthresh(sk);
3162-
TCP_ECN_queue_cwr(tp);
3163-
}
3164-
3165-
tp->bytes_acked = 0;
3166-
tp->snd_cwnd_cnt = 0;
3167-
tp->prior_cwnd = tp->snd_cwnd;
3168-
tp->prr_delivered = 0;
3169-
tp->prr_out = 0;
3170-
tcp_set_ca_state(sk, TCP_CA_Recovery);
3177+
tcp_enter_recovery(sk, (flag & FLAG_ECE));
31713178
fast_rexmit = 1;
31723179
}
31733180

0 commit comments

Comments
 (0)