From: sashiko-bot@kernel.org
To: chia-yu.chang@nokia-bell-labs.com, bpf@vger.kernel.org
Subject: Re: [PATCH net-next v5 3/4] tcp: add TCP_ECN_SEND_ECT_1 flag for congestion control
Date: Tue, 01 Dec 2026 12:57:20 +0000 [thread overview]
Message-ID: <sashiko-outbox-243318@kernel.org> (raw)
In-Reply-To: <20261130125658.20292-4-chia-yu.chang@nokia-bell-labs.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] tcp: premature established ECT in
tcp_init_congestion_control() breaks TFO
- [Medium] tcp: premature tcp_init_congestion_control() in TCP_SYN_SENT
breaks ECT(1)
--
commit 305ea3b4c4a9771dfae11d88a4081cc8b100ab1e
Author: Chia-Yu Chang <chia-yu.chang@nokia-bell-labs.com>
tcp: add TCP_ECN_SEND_ECT_1 flag for congestion control
This commit adds the TCP_ECN_SEND_ECT_1 flag and the
INET_ECN_xmit_established_ect() helper so a congestion control module can
select ECT(1) or ECT(0) for outgoing packets after ECN negotiation.
> diff --git a/net/ipv4/tcp_cong.c b/net/ipv4/tcp_cong.c
> index 3331679c81d70..34617106f5e5e 100644
> --- a/net/ipv4/tcp_cong.c
> +++ b/net/ipv4/tcp_cong.c
> @@ -240,7 +240,14 @@ void tcp_init_congestion_control(struct sock *sk)
> tcp_sk(sk)->prior_ssthresh = 0;
> if (icsk->icsk_ca_ops->init)
> icsk->icsk_ca_ops->init(sk);
> - if (tcp_ca_needs_ecn(sk))
> + /*
> + * Select the initial ECN codepoint based on the congestion
> + * control module flag, while each module is responsible for
> + * handling fallback cases when negotiation did not succeed.
> + */
> + if (tcp_ca_needs_accecn(sk))
> + INET_ECN_xmit_established_ect(sk);
> + else if (tcp_ca_needs_ecn(sk))
> INET_ECN_xmit(sk);
> else
> INET_ECN_dontxmit(sk);
[Severity: Medium]
Does calling INET_ECN_xmit_established_ect(sk) here break AccECN on
passive TCP Fast Open connections?
In tcp_conn_request(), tcp_try_fastopen() -> tcp_fastopen_create_child()
first creates the child socket with tp->syn_ect_snt copied from
treq->syn_ect_snt (0) and then runs tcp_init_transfer() ->
tcp_init_congestion_control(child) before af_ops->send_synack() transmits
the SYN-ACK:
net/ipv4/tcp_input.c:tcp_conn_request() {
...
if (fastopen_sk) {
af_ops->send_synack(fastopen_sk, dst, &fl, req,
&foc, TCP_SYNACK_FASTOPEN, skb);
...
}
Because send_synack() takes its TOS/tclass from fastopen_sk and only
updates tcp_rsk(req)->syn_ect_snt afterwards, the TFO SYN-ACK goes out
with the established ECT(0) or ECT(1) codepoint while tp->syn_ect_snt on
fastopen_sk remains 0. When the client's third ACK arrives reflecting
that ECT in the ACE field, tcp_accecn_third_ack(sk, skb, tp->syn_ect_snt)
checks the reflected ECT against sent_ect == 0, sets
TCP_ACCECN_ACE_FAIL_RECV, and disables ECN marking for the rest of the
connection.
> @@ -251,12 +258,15 @@ static void tcp_reinit_congestion_control(struct sock *sk,
> const struct tcp_congestion_ops *ca)
> {
> struct inet_connection_sock *icsk = inet_csk(sk);
> + struct tcp_sock *tp = tcp_sk(sk);
>
> tcp_cleanup_congestion_control(sk);
> WRITE_ONCE(icsk->icsk_ca_ops, ca);
> icsk->icsk_ca_setsockopt = 1;
> memset(icsk->icsk_ca_priv, 0, sizeof(icsk->icsk_ca_priv));
>
> + /* Reset ECT(1) selection before initializing a new CC */
> + tp->ecn_flags &= ~TCP_ECN_SEND_ECT_1;
> if (ca->flags & TCP_CONG_NEEDS_ECN)
> INET_ECN_xmit_negotiation_ect(sk);
> else
[Severity: Medium]
What happens when tcp_reinit_congestion_control() runs while sk is in
TCP_SYN_SENT before the SYN is sent, such as from
BPF_SOCK_OPS_TCP_CONNECT_CB or setsockopt(TCP_CONGESTION) after a
TCP_FASTOPEN_CONNECT connect()?
Because TCP_SYN_SENT is not in (TCPF_CLOSE | TCPF_LISTEN),
tcp_reinit_congestion_control() immediately calls
tcp_init_congestion_control(sk) before ECN negotiation has happened:
net/ipv4/tcp_cong.c:tcp_reinit_congestion_control() {
...
if (ca->flags & TCP_CONG_NEEDS_ECN)
INET_ECN_xmit_negotiation_ect(sk);
else
INET_ECN_dontxmit(sk);
if (!((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)))
tcp_init_congestion_control(sk);
}
That sets icsk->icsk_ca_initialized = 1, and then tcp_ecn_send_syn() runs
tp->ecn_flags = 0, wiping out any TCP_ECN_SEND_ECT_1 bit that ca->init()
just set. When the handshake finishes, tcp_init_transfer() skips
tcp_init_congestion_control() because icsk_ca_initialized is already 1, so
the established flow falls back to sending ECT(0) instead of ECT(1).
In addition, if tcp_ca_needs_accecn(sk) is true without
TCP_CONG_NEEDS_ECN, tcp_init_congestion_control() overwrites
INET_ECN_dontxmit(sk) with INET_ECN_xmit_established_ect(sk), causing the
outgoing SYN to carry ECT on the wire.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130125658.20292-1-chia-yu.chang@nokia-bell-labs.com?part=3
next prev parent reply other threads:[~2026-12-01 12:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 12:56 [PATCH net-next v5 0/4] TCP Prague preparation series chia-yu.chang
2026-11-30 12:56 ` [PATCH net-next v5 1/4] tcp: export CE count in rate_sample chia-yu.chang
2026-12-01 13:10 ` netdev-bot+sashiko
2026-11-30 12:56 ` [PATCH net-next v5 2/4] tcp: rename ECN transmit helper function chia-yu.chang
2026-11-30 12:56 ` [PATCH net-next v5 3/4] tcp: add TCP_ECN_SEND_ECT_1 flag for congestion control chia-yu.chang
2026-12-01 12:57 ` sashiko-bot [this message]
2026-12-01 13:10 ` netdev-bot+sashiko
2026-11-30 12:56 ` [PATCH net-next v5 4/4] tcp: add MSS ceiling callback " chia-yu.chang
2026-12-01 12:57 ` sashiko-bot
2026-12-01 13:10 ` netdev-bot+sashiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-243318@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=chia-yu.chang@nokia-bell-labs.com \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.