Skip to contentSkip to conversation

tcp: disable Fast Open on timeouts after handshake

PATCH Applied Yuchung Cheng 2 participants 5 messages Nov 19, 2015 – Nov 20, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 tcp: disable Fast Open on timeouts after handshake

Some middle-boxes black-hole the data after the Fast Open handshake
(https://www.ietf.org/proceedings/94/slides/slides-94-tcpm-13.pdf).
The exact reason is unknown. The work-around is to disable Fast Open temporarily after multiple recurring timeouts with few or no data delivered in the established state.

---
 net/ipv4/tcp_timer.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
net/ipv4/tcp_timer.c +12 -0
index c9c716a..448603a 100644
@@ -176,6 +176,18 @@ static int tcp_write_timeout(struct sock *sk)
 		syn_set = true;
 	} else {
 		if (retransmits_timed_out(sk, sysctl_tcp_retries1, 0, 0)) {
+			/* Some middle-boxes may black-hole Fast Open _after_
+			 * the handshake. Therefore we conservatively disable
+			 * Fast Open on this path on recurring timeouts with
+			 * few or zero bytes acked after Fast Open.
+			 */
+			if (tp->syn_data_acked &&
+			    tp->bytes_acked <= tp->rx_opt.mss_clamp) {
+				tcp_fastopen_cache_set(sk, 0, NULL, true, 0);
+				if (icsk->icsk_retransmits == sysctl_tcp_retries1)
+					NET_INC_STATS_BH(sock_net(sk),
+							 LINUX_MIB_TCPFASTOPENACTIVEFAIL);
+			}
 			/* Black hole detection */
 			tcp_mtu_probing(icsk, sk);
 
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
#1 lore raw

PATCH 2/2 tcp: fix Fast Open snmp over-counting bug

Fix incrementing TCPFastOpenActiveFailed snmp stats multiple times when the handshake experiences multiple SYN timeouts.

---
 net/ipv4/tcp_timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/tcp_timer.c +1 -1
index 448603a..193ba1f 100644
@@ -168,7 +168,7 @@ static int tcp_write_timeout(struct sock *sk)
 			dst_negative_advice(sk);
 			if (tp->syn_fastopen || tp->syn_data)
 				tcp_fastopen_cache_set(sk, 0, NULL, true, 0);
-			if (tp->syn_data)
+			if (tp->syn_data && icsk->icsk_retransmits == 1)
 				NET_INC_STATS_BH(sock_net(sk),
 						 LINUX_MIB_TCPFASTOPENACTIVEFAIL);
 		}
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
maintainer
#3 lore raw
In reply to Yuchung Cheng

From: Yuchung Cheng <[email protected]>
Date: Wed, 18 Nov 2015 18:17:30 -0800

Quoted 9 lines

Some middle-boxes black-hole the data after the Fast Open handshake
(https://www.ietf.org/proceedings/94/slides/slides-94-tcpm-13.pdf).
The exact reason is unknown. The work-around is to disable Fast Open temporarily after multiple recurring timeouts with few or no data delivered in the established state.

Applied and queued up for -stable.

Just out of curiosity, why isn't a test for zero data sufficient?

Do these middle-boxes sometimes not black-hole all of the data?

#4 lore raw
Quoted 13 lines · David Miller

From: Yuchung Cheng <[email protected]>
Date: Wed, 18 Nov 2015 18:17:30 -0800

Quoted 9 lines

Some middle-boxes black-hole the data after the Fast Open handshake
(https://www.ietf.org/proceedings/94/slides/slides-94-tcpm-13.pdf).
The exact reason is unknown. The work-around is to disable Fast Open temporarily after multiple recurring timeouts with few or no data delivered in the established state.

Quoted 5 lines

Applied and queued up for -stable.

Just out of curiosity, why isn't a test for zero data sufficient?

Do these middle-boxes sometimes not black-hole all of the data?

Great question. I should be more clear in the commit message. The answer is yes it should be sufficient. The tricky part is tp->bytes_acked includes data acked in the SYN. Since we don't remember data size sent in SYN, hence the heuristic.