Skip to content

Commit ab42d9e

Browse files
yuchungchengdavem330
authored andcommitted
tcp: refactor CA_Loss state processing
Consolidate all of TCP CA_Loss state processing in tcp_fastretrans_alert() into a new function called tcp_process_loss(). This is to prepare the new F-RTO implementation in the next patch. Signed-off-by: Yuchung Cheng <ycheng@google.com> Acked-by: Neal Cardwell <ncardwell@google.com> Acked-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 9b44190 commit ab42d9e

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

net/ipv4/tcp_input.c

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2664,6 +2664,30 @@ static void tcp_enter_recovery(struct sock *sk, bool ece_ack)
26642664
tcp_set_ca_state(sk, TCP_CA_Recovery);
26652665
}
26662666

2667+
/* Process an ACK in CA_Loss state. Move to CA_Open if lost data are
2668+
* recovered or spurious. Otherwise retransmits more on partial ACKs.
2669+
*/
2670+
static void tcp_process_loss(struct sock *sk, int flag)
2671+
{
2672+
struct inet_connection_sock *icsk = inet_csk(sk);
2673+
struct tcp_sock *tp = tcp_sk(sk);
2674+
2675+
if (!before(tp->snd_una, tp->high_seq)) {
2676+
icsk->icsk_retransmits = 0;
2677+
tcp_try_undo_recovery(sk);
2678+
return;
2679+
}
2680+
2681+
if (flag & FLAG_DATA_ACKED)
2682+
icsk->icsk_retransmits = 0;
2683+
if (tcp_is_reno(tp) && flag & FLAG_SND_UNA_ADVANCED)
2684+
tcp_reset_reno_sack(tp);
2685+
if (tcp_try_undo_loss(sk))
2686+
return;
2687+
tcp_moderate_cwnd(tp);
2688+
tcp_xmit_retransmit_queue(sk);
2689+
}
2690+
26672691
/* Process an event, which can update packets-in-flight not trivially.
26682692
* Main goal of this function is to calculate new estimate for left_out,
26692693
* taking into account both packets sitting in receiver's buffer and
@@ -2710,12 +2734,6 @@ static void tcp_fastretrans_alert(struct sock *sk, int pkts_acked,
27102734
tp->retrans_stamp = 0;
27112735
} else if (!before(tp->snd_una, tp->high_seq)) {
27122736
switch (icsk->icsk_ca_state) {
2713-
case TCP_CA_Loss:
2714-
icsk->icsk_retransmits = 0;
2715-
if (tcp_try_undo_recovery(sk))
2716-
return;
2717-
break;
2718-
27192737
case TCP_CA_CWR:
27202738
/* CWR is to be held something *above* high_seq
27212739
* is ACKed for CWR bit to reach receiver. */
@@ -2746,18 +2764,10 @@ static void tcp_fastretrans_alert(struct sock *sk, int pkts_acked,
27462764
newly_acked_sacked = pkts_acked + tp->sacked_out - prior_sacked;
27472765
break;
27482766
case TCP_CA_Loss:
2749-
if (flag & FLAG_DATA_ACKED)
2750-
icsk->icsk_retransmits = 0;
2751-
if (tcp_is_reno(tp) && flag & FLAG_SND_UNA_ADVANCED)
2752-
tcp_reset_reno_sack(tp);
2753-
if (!tcp_try_undo_loss(sk)) {
2754-
tcp_moderate_cwnd(tp);
2755-
tcp_xmit_retransmit_queue(sk);
2756-
return;
2757-
}
2767+
tcp_process_loss(sk, flag);
27582768
if (icsk->icsk_ca_state != TCP_CA_Open)
27592769
return;
2760-
/* Loss is undone; fall through to processing in Open state. */
2770+
/* Fall through to processing in Open state. */
27612771
default:
27622772
if (tcp_is_reno(tp)) {
27632773
if (flag & FLAG_SND_UNA_ADVANCED)

0 commit comments

Comments
 (0)