diff options
author | Yuchung Cheng <ycheng@google.com> | 2012-05-02 09:30:02 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-05-02 20:56:09 -0400 |
commit | 1fbc340514fc3003514bd681b372e1f47ae6183f (patch) | |
tree | ee4217005d896c2be29279956dfe5dcf64c3c51e /net/ipv4/tcp_input.c | |
parent | 5c6239c8f89f301c47e96bf9d2931c446b934be0 (diff) |
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 <ycheng@google.com>
Acked-by: Neal Cardwell <ncardwell@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.c | 61 |
1 files changed, 34 insertions, 27 deletions
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 96a631deb4e6..be8e09d2c6b1 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
@@ -3022,6 +3022,38 @@ static void tcp_update_cwnd_in_recovery(struct sock *sk, int newly_acked_sacked, | |||
3022 | tp->snd_cwnd = tcp_packets_in_flight(tp) + sndcnt; | 3022 | tp->snd_cwnd = tcp_packets_in_flight(tp) + sndcnt; |
3023 | } | 3023 | } |
3024 | 3024 | ||
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 | |||
3025 | /* Process an event, which can update packets-in-flight not trivially. | 3057 | /* Process an event, which can update packets-in-flight not trivially. |
3026 | * Main goal of this function is to calculate new estimate for left_out, | 3058 | * Main goal of this function is to calculate new estimate for left_out, |
3027 | * taking into account both packets sitting in receiver's buffer and | 3059 | * 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, | |||
3041 | struct tcp_sock *tp = tcp_sk(sk); | 3073 | struct tcp_sock *tp = tcp_sk(sk); |
3042 | int do_lost = is_dupack || ((flag & FLAG_DATA_SACKED) && | 3074 | int do_lost = is_dupack || ((flag & FLAG_DATA_SACKED) && |
3043 | (tcp_fackets_out(tp) > tp->reordering)); | 3075 | (tcp_fackets_out(tp) > tp->reordering)); |
3044 | int fast_rexmit = 0, mib_idx; | 3076 | int fast_rexmit = 0; |
3045 | 3077 | ||
3046 | if (WARN_ON(!tp->packets_out && tp->sacked_out)) | 3078 | if (WARN_ON(!tp->packets_out && tp->sacked_out)) |
3047 | tp->sacked_out = 0; | 3079 | tp->sacked_out = 0; |
@@ -3142,32 +3174,7 @@ static void tcp_fastretrans_alert(struct sock *sk, int pkts_acked, | |||
3142 | } | 3174 | } |
3143 | 3175 | ||
3144 | /* Otherwise enter Recovery state */ | 3176 | /* Otherwise enter Recovery state */ |
3145 | 3177 | tcp_enter_recovery(sk, (flag & FLAG_ECE)); | |
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); | ||
3171 | fast_rexmit = 1; | 3178 | fast_rexmit = 1; |
3172 | } | 3179 | } |
3173 | 3180 | ||