Skip to content

Commit a9b2c06

Browse files
nealcardwelldavem330
authored andcommitted
tcp: mitigate ACK loops for connections as tcp_request_sock
In the SYN_RECV state, where the TCP connection is represented by tcp_request_sock, we now rate-limit SYNACKs in response to a client's retransmitted SYNs: we do not send a SYNACK in response to client SYN if it has been less than sysctl_tcp_invalid_ratelimit (default 500ms) since we last sent a SYNACK in response to a client's retransmitted SYN. This allows the vast majority of legitimate client connections to proceed unimpeded, even for the most aggressive platforms, iOS and MacOS, which actually retransmit SYNs 1-second intervals for several times in a row. They use SYN RTO timeouts following the progression: 1,1,1,1,1,2,4,8,16,32. Reported-by: Avery Fay <[email protected]> Signed-off-by: Neal Cardwell <[email protected]> Signed-off-by: Yuchung Cheng <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 032ee42 commit a9b2c06

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

include/linux/tcp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ struct tcp_request_sock {
115115
u32 rcv_isn;
116116
u32 snt_isn;
117117
u32 snt_synack; /* synack sent time */
118+
u32 last_oow_ack_time; /* last SYNACK */
118119
u32 rcv_nxt; /* the ack # by SYNACK. For
119120
* FastOpen it's the seq#
120121
* after data-in-SYN.

include/net/tcp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,7 @@ static inline void tcp_openreq_init(struct request_sock *req,
11451145
tcp_rsk(req)->rcv_isn = TCP_SKB_CB(skb)->seq;
11461146
tcp_rsk(req)->rcv_nxt = TCP_SKB_CB(skb)->seq + 1;
11471147
tcp_rsk(req)->snt_synack = tcp_time_stamp;
1148+
tcp_rsk(req)->last_oow_ack_time = 0;
11481149
req->mss = rx_opt->mss_clamp;
11491150
req->ts_recent = rx_opt->saw_tstamp ? rx_opt->rcv_tsval : 0;
11501151
ireq->tstamp_ok = rx_opt->tstamp_ok;

net/ipv4/tcp_minisocks.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,11 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,
605605
* Reset timer after retransmitting SYNACK, similar to
606606
* the idea of fast retransmit in recovery.
607607
*/
608-
if (!inet_rtx_syn_ack(sk, req))
608+
if (!tcp_oow_rate_limited(sock_net(sk), skb,
609+
LINUX_MIB_TCPACKSKIPPEDSYNRECV,
610+
&tcp_rsk(req)->last_oow_ack_time) &&
611+
612+
!inet_rtx_syn_ack(sk, req))
609613
req->expires = min(TCP_TIMEOUT_INIT << req->num_timeout,
610614
TCP_RTO_MAX) + jiffies;
611615
return NULL;

0 commit comments

Comments
 (0)