Skip to content

Commit 93b174a

Browse files
yuchungchengdavem330
authored andcommitted
tcp: bug fix Fast Open client retransmission
If SYN-ACK partially acks SYN-data, the client retransmits the remaining data by tcp_retransmit_skb(). This increments lost recovery state variables like tp->retrans_out in Open state. If loss recovery happens before the retransmission is acked, it triggers the WARN_ON check in tcp_fastretrans_alert(). For example: the client sends SYN-data, gets SYN-ACK acking only ISN, retransmits data, sends another 4 data packets and get 3 dupacks. Since the retransmission is not caused by network drop it should not update the recovery state variables. Further the server may return a smaller MSS than the cached MSS used for SYN-data, so the retranmission needs a loop. Otherwise some data will not be retransmitted until timeout or other loss recovery events. Signed-off-by: Yuchung Cheng <ycheng@google.com> Acked-by: Neal Cardwell <ncardwell@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 1afa471 commit 93b174a

3 files changed

Lines changed: 16 additions & 6 deletions

File tree

‎include/net/tcp.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ static inline __u32 cookie_v6_init_sequence(struct sock *sk,
525525
extern void __tcp_push_pending_frames(struct sock *sk, unsigned int cur_mss,
526526
int nonagle);
527527
extern bool tcp_may_send_now(struct sock *sk);
528+
extern int __tcp_retransmit_skb(struct sock *, struct sk_buff *);
528529
extern int tcp_retransmit_skb(struct sock *, struct sk_buff *);
529530
extern void tcp_retransmit_timer(struct sock *sk);
530531
extern void tcp_xmit_retransmit_queue(struct sock *);

‎net/ipv4/tcp_input.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5645,7 +5645,11 @@ static bool tcp_rcv_fastopen_synack(struct sock *sk, struct sk_buff *synack,
56455645
tcp_fastopen_cache_set(sk, mss, cookie, syn_drop);
56465646

56475647
if (data) { /* Retransmit unacked data in SYN */
5648-
tcp_retransmit_skb(sk, data);
5648+
tcp_for_write_queue_from(data, sk) {
5649+
if (data == tcp_send_head(sk) ||
5650+
__tcp_retransmit_skb(sk, data))
5651+
break;
5652+
}
56495653
tcp_rearm_rto(sk);
56505654
return true;
56515655
}

‎net/ipv4/tcp_output.c‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2309,12 +2309,11 @@ static void tcp_retrans_try_collapse(struct sock *sk, struct sk_buff *to,
23092309
* state updates are done by the caller. Returns non-zero if an
23102310
* error occurred which prevented the send.
23112311
*/
2312-
int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
2312+
int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
23132313
{
23142314
struct tcp_sock *tp = tcp_sk(sk);
23152315
struct inet_connection_sock *icsk = inet_csk(sk);
23162316
unsigned int cur_mss;
2317-
int err;
23182317

23192318
/* Inconslusive MTU probe */
23202319
if (icsk->icsk_mtup.probe_size) {
@@ -2387,11 +2386,17 @@ int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
23872386
if (unlikely(NET_IP_ALIGN && ((unsigned long)skb->data & 3))) {
23882387
struct sk_buff *nskb = __pskb_copy(skb, MAX_TCP_HEADER,
23892388
GFP_ATOMIC);
2390-
err = nskb ? tcp_transmit_skb(sk, nskb, 0, GFP_ATOMIC) :
2391-
-ENOBUFS;
2389+
return nskb ? tcp_transmit_skb(sk, nskb, 0, GFP_ATOMIC) :
2390+
-ENOBUFS;
23922391
} else {
2393-
err = tcp_transmit_skb(sk, skb, 1, GFP_ATOMIC);
2392+
return tcp_transmit_skb(sk, skb, 1, GFP_ATOMIC);
23942393
}
2394+
}
2395+
2396+
int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
2397+
{
2398+
struct tcp_sock *tp = tcp_sk(sk);
2399+
int err = __tcp_retransmit_skb(sk, skb);
23952400

23962401
if (err == 0) {
23972402
/* Update global TCP statistics. */

0 commit comments

Comments
 (0)