]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
tcp: accecn: retransmit SYN/ACK without AccECN option or non-AccECN SYN/ACK
authorChia-Yu Chang <chia-yu.chang@nokia-bell-labs.com>
Sat, 31 Jan 2026 22:25:09 +0000 (23:25 +0100)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 3 Feb 2026 14:13:24 +0000 (15:13 +0100)
For Accurate ECN, the first SYN/ACK sent by the TCP server shall set
the ACE flag (Table 1 of RFC9768) and the AccECN option to complete the
capability negotiation. However, if the TCP server needs to retransmit
such a SYN/ACK (for example, because it did not receive an ACK
acknowledging its SYN/ACK, or received a second SYN requesting AccECN
support), the TCP server retransmits the SYN/ACK without the AccECN
option. This is because the SYN/ACK may be lost due to congestion, or a
middlebox may block the AccECN option. Furthermore, if this retransmission
also times out, to expedite connection establishment, the TCP server
should retransmit the SYN/ACK with (AE,CWR,ECE) = (0,0,0) and without the
AccECN option, while maintaining AccECN feedback mode.

This complies with Section 3.2.3.2.2 of the AccECN spec RFC9768.

Signed-off-by: Chia-Yu Chang <chia-yu.chang@nokia-bell-labs.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20260131222515.8485-10-chia-yu.chang@nokia-bell-labs.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
include/net/tcp_ecn.h
net/ipv4/tcp_output.c

index a709fb1756eb758e77bc4bfab4258ecaca1c4527..796c613b5ef31242c639c03789af37c8c1dfc2f7 100644 (file)
@@ -649,12 +649,22 @@ static inline void tcp_ecn_clear_syn(struct sock *sk, struct sk_buff *skb)
 }
 
 static inline void
-tcp_ecn_make_synack(const struct request_sock *req, struct tcphdr *th)
+tcp_ecn_make_synack(const struct request_sock *req, struct tcphdr *th,
+                   enum tcp_synack_type synack_type)
 {
-       if (tcp_rsk(req)->accecn_ok)
-               tcp_accecn_echo_syn_ect(th, tcp_rsk(req)->syn_ect_rcv);
-       else if (inet_rsk(req)->ecn_ok)
-               th->ece = 1;
+       /* Accurate ECN shall retransmit SYN/ACK with ACE=0 if the
+        * previously retransmitted SYN/ACK also times out.
+        */
+       if (!req->num_timeout || synack_type != TCP_SYNACK_RETRANS) {
+               if (tcp_rsk(req)->accecn_ok)
+                       tcp_accecn_echo_syn_ect(th, tcp_rsk(req)->syn_ect_rcv);
+               else if (inet_rsk(req)->ecn_ok)
+                       th->ece = 1;
+       } else if (tcp_rsk(req)->accecn_ok) {
+               th->ae  = 0;
+               th->cwr = 0;
+               th->ece = 0;
+       }
 }
 
 static inline bool tcp_accecn_option_beacon_check(const struct sock *sk)
index a1596fe8dd9f32839dbb1340995fc741cf9acd6b..22728daed436a55af250000d7bc019d9599d14ed 100644 (file)
@@ -1106,7 +1106,7 @@ static unsigned int tcp_synack_options(const struct sock *sk,
 
        if (treq->accecn_ok &&
            READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_ecn_option) &&
-           req->num_timeout < 1 && remaining >= TCPOLEN_ACCECN_BASE) {
+           synack_type != TCP_SYNACK_RETRANS && remaining >= TCPOLEN_ACCECN_BASE) {
                opts->use_synack_ecn_bytes = 1;
                remaining -= tcp_options_fit_accecn(opts, 0, remaining);
        }
@@ -4012,7 +4012,7 @@ struct sk_buff *tcp_make_synack(const struct sock *sk, struct dst_entry *dst,
        memset(th, 0, sizeof(struct tcphdr));
        th->syn = 1;
        th->ack = 1;
-       tcp_ecn_make_synack(req, th);
+       tcp_ecn_make_synack(req, th, synack_type);
        th->source = htons(ireq->ir_num);
        th->dest = ireq->ir_rmt_port;
        skb->mark = ireq->ir_mark;