aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp_input.c
diff options
context:
space:
mode:
authorYuchung Cheng <ycheng@google.com>2013-03-20 09:32:59 -0400
committerDavid S. Miller <davem@davemloft.net>2013-03-21 11:47:51 -0400
commitab42d9ee3d215ab74a49818ffc53771a88ce7ddf (patch)
treedb72c31294c11da6fcb53581dcb47340bc02f2cb /net/ipv4/tcp_input.c
parent9b44190dc114c1720b34975b5bfc65aece112ced (diff)
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>
Diffstat (limited to 'net/ipv4/tcp_input.c')
-rw-r--r--net/ipv4/tcp_input.c42
1 files changed, 26 insertions, 16 deletions
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 231c79fe91f3..8d821e45b917 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -2664,6 +2664,30 @@ static void tcp_enter_recovery(struct sock *sk, bool ece_ack)
2664 tcp_set_ca_state(sk, TCP_CA_Recovery); 2664 tcp_set_ca_state(sk, TCP_CA_Recovery);
2665} 2665}
2666 2666
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 */
2670static 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
2667/* Process an event, which can update packets-in-flight not trivially. 2691/* Process an event, which can update packets-in-flight not trivially.
2668 * Main goal of this function is to calculate new estimate for left_out, 2692 * Main goal of this function is to calculate new estimate for left_out,
2669 * taking into account both packets sitting in receiver's buffer and 2693 * 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,
2710 tp->retrans_stamp = 0; 2734 tp->retrans_stamp = 0;
2711 } else if (!before(tp->snd_una, tp->high_seq)) { 2735 } else if (!before(tp->snd_una, tp->high_seq)) {
2712 switch (icsk->icsk_ca_state) { 2736 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
2719 case TCP_CA_CWR: 2737 case TCP_CA_CWR:
2720 /* CWR is to be held something *above* high_seq 2738 /* CWR is to be held something *above* high_seq
2721 * is ACKed for CWR bit to reach receiver. */ 2739 * is ACKed for CWR bit to reach receiver. */
@@ -2746,18 +2764,10 @@ static void tcp_fastretrans_alert(struct sock *sk, int pkts_acked,
2746 newly_acked_sacked = pkts_acked + tp->sacked_out - prior_sacked; 2764 newly_acked_sacked = pkts_acked + tp->sacked_out - prior_sacked;
2747 break; 2765 break;
2748 case TCP_CA_Loss: 2766 case TCP_CA_Loss:
2749 if (flag & FLAG_DATA_ACKED) 2767 tcp_process_loss(sk, flag);
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 }
2758 if (icsk->icsk_ca_state != TCP_CA_Open) 2768 if (icsk->icsk_ca_state != TCP_CA_Open)
2759 return; 2769 return;
2760 /* Loss is undone; fall through to processing in Open state. */ 2770 /* Fall through to processing in Open state. */
2761 default: 2771 default:
2762 if (tcp_is_reno(tp)) { 2772 if (tcp_is_reno(tp)) {
2763 if (flag & FLAG_SND_UNA_ADVANCED) 2773 if (flag & FLAG_SND_UNA_ADVANCED)