Skip to contentSkip to conversation

tcp: Added check of destination specific CC before sending syn/ack

PATCH In review [email protected] 2 participants 2 messages Jul 9, 2018

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

PATCH 1/1 tcp: Added check of destination specific CC before sending syn/ack

From: Joakim Misund <[email protected]>

Issue:
Currently TCP stack does not check for a destination specific CC before responding to a syn with a syn/ack. The system wide default CC is used. If the default CC does not need ECN, but the destination specific does, the syn/ack will not carry ECT(0) which makes it eligible to drop instead of being marked at routers. In an ECN-based network ECN marks are frequent (likely) and packet not carrying ECT(0) are likely to be dropped. This leads to slow connection establishment, and in worst case the establishment can fail.

---
 include/net/tcp.h     | 1 +
 net/ipv4/tcp_input.c  | 2 ++
 net/ipv4/tcp_output.c | 2 +-
 3 files changed, 4 insertions(+), 1 deletion(-)
include/net/tcp.h +1 -0
index af3ec72d5d41..347c59ac0a72 100644
@@ -545,6 +545,7 @@ void tcp_send_loss_probe(struct sock *sk);
 bool tcp_schedule_loss_probe(struct sock *sk, bool advancing_rto);
 void tcp_skb_collapse_tstamp(struct sk_buff *skb,
 			     const struct sk_buff *next_skb);
+void tcp_ca_dst_init(struct sock *sk, const struct dst_entry *dst);
 
 /* tcp_input.c */
 void tcp_rearm_rto(struct sock *sk);
net/ipv4/tcp_input.c +2 -0
index 8e5522c6833a..973e3b5b0516 100644
@@ -6401,6 +6401,8 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops,
 		isn = af_ops->init_seq(skb);
 	}
 
+	tcp_ca_dst_init(sk, dst);
+
 	tcp_ecn_create_request(req, skb, sk, dst);
 
 	if (want_cookie) {
net/ipv4/tcp_output.c +1 -1
index 8e08b409c71e..550597acd48c 100644
@@ -3256,7 +3256,7 @@ struct sk_buff *tcp_make_synack(const struct sock *sk, struct dst_entry *dst,
 }
 EXPORT_SYMBOL(tcp_make_synack);
 
-static void tcp_ca_dst_init(struct sock *sk, const struct dst_entry *dst)
+void tcp_ca_dst_init(struct sock *sk, const struct dst_entry *dst)
 {
 	struct inet_connection_sock *icsk = inet_csk(sk);
 	const struct tcp_congestion_ops *ca;
Signature · 1 line
2.17.1
#1 lore raw
Quoted 33 lines · On 07/09/2018 04:25 AM, [email protected] wrote:

From: Joakim Misund <[email protected]>

Issue:
Currently TCP stack does not check for a destination specific CC before responding to a syn with a syn/ack. The system wide default CC is used. If the default CC does not need ECN, but the destination specific does, the syn/ack will not carry ECT(0) which makes it eligible to drop instead of being marked at routers. In an ECN-based network ECN marks are frequent (likely) and packet not carrying ECT(0) are likely to be dropped. This leads to slow connection establishment, and in worst case the establishment can fail.

---
 include/net/tcp.h     | 1 +
 net/ipv4/tcp_input.c  | 2 ++
 net/ipv4/tcp_output.c | 2 +-
 3 files changed, 4 insertions(+), 1 deletion(-)
include/net/tcp.h +1 -0
index af3ec72d5d41..347c59ac0a72 100644
@@ -545,6 +545,7 @@ void tcp_send_loss_probe(struct sock *sk);
 bool tcp_schedule_loss_probe(struct sock *sk, bool advancing_rto);
 void tcp_skb_collapse_tstamp(struct sk_buff *skb,
 			     const struct sk_buff *next_skb);
+void tcp_ca_dst_init(struct sock *sk, const struct dst_entry *dst);
 
 /* tcp_input.c */
 void tcp_rearm_rto(struct sock *sk);
net/ipv4/tcp_input.c +0 -0
index 8e5522c6833a..973e3b5b0516 100644

net/ipv4/tcp_input.c int tcp_conn_request(struct request_sock_ops *rsk_ops, · line 6404

Quoted 4 lines
net/ipv4/tcp_input.c +1 -0
@@ -6401,6 +6401,8 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops,
 		isn = af_ops->init_seq(skb);
 	}
 
+	tcp_ca_dst_init(sk, dst);

At this point sk is not locked (and will not be)

Multiple cpus can handle SYN packets in // so this would be racy.

You need to solve this problem in another way.

Thanks.