From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796129841; b=3i2gak1LHKAyfDAn8rMFuPK9oETVhlEJ5o/W+2ynykWr12wykHIbGXvaWTqTSFG0mUuc FD66XWi698Vxtt+SIqNgGwkGT8TZm7T0KBym0+s53Y6mX55f6IVLXuA9fvIc36ayrHMLr JG7qaTSDGaca/DADoGnL1pTChcBIAPaB6ELIBxrtYdk4+OwL58XSWUA6dtVVcErkvpfJl esOmcch0cwXvAyfw7OSdOnqy1umcm7fv9aiHS5NEHK75miB7NJx6CgpGQtRluoUfqvfdD KWdnaMFmryHSZyiiams74xHhldgl75ovTIsd0UA3BL5zFpNfwwpRpMU+yzRBrRdfh3w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796129841; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=KAAh+ugAw8vcNBuknHEHKz7ehF8Go2KIySXcuqMCI5w=; b=TS+2ncPSc25KPKxtn/49C24WLIWbAyZngVYoVFflO2maHbfHHjpUUfUEU307BZrndCf7 bbaBrLXVtjz29kBy+impIVyLcP2COQOM55vwEZ4oTHANB9IliafkcENxp8XjEYdf1tM0z 0gu3r4bbu9WWQkSxcOZt7S5XwJfroKr5Xt2cf4s0aTKfic9BBTulCQp0os5Ey5gWNR40j w/5Z0Q7c47WbqzFw5ykcTWN9ufki6f/qHR2mRjukYsmIA4FB7prNeLpg1U/tFyIwLS3ut 81v7M/Zv9m8ZMsHZXrdK0q/jhGctJNrEulbLksEfFTHrg8FRzitcmKUMZfaNfIXJHQA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SYFrVd0d; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D2F6606A31A for ; Tue, 1 Dec 2026 12:57:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SYFrVd0d Received: by smtp.kernel.org (Postfix) with ESMTPSA id E15E81F000C1; Tue, 1 Dec 2026 12:57:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796129841; bh=KAAh+ugAw8vcNBuknHEHKz7ehF8Go2KIySXcuqMCI5w=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=SYFrVd0dNeM0CJlYzgnK8s3ivgr5Eewby0lvtV1W1fa4gHkLnvYV+DkaExf+uwXeG sRycNpZUj4e2XvLNnMmAX045XNPMniu7VxmTqKp/yeAtxCWcszIKUmU+EXeEDafuyl uu5I6CYDFSibG8mdqQJgGAZy1b77cFwpKxi7WTjWMxF5tofXCWOOJbBQhKxxTMGqjH 3Rv/knklP4aFF1AQ9Aoyg9Uww53zOG79J1vs6xjy4LOW3UXHGPi8ynus1qAVfVsIEJ x2oB9wYcER5Hw20Uqj8wQTo16CgCFMBANcbCKlaDzw3MNj8S9IT4SXOyPRAMpW4fSc K3j0uucaw3roQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH net-next v5 3/4] tcp: add TCP_ECN_SEND_ECT_1 flag for congestion control Reply-To: sashiko-reviews@lists.linux.dev To: chia-yu.chang@nokia-bell-labs.com, bpf@vger.kernel.org In-Reply-To: <20261130125658.20292-4-chia-yu.chang@nokia-bell-labs.com> References: <20261130125658.20292-1-chia-yu.chang@nokia-bell-labs.com> <20261130125658.20292-4-chia-yu.chang@nokia-bell-labs.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 12:57:20 +0000 X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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 =3D 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 =3D=3D 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 so= ck *sk, > const struct tcp_congestion_ops *ca) > { > struct inet_connection_sock *icsk =3D inet_csk(sk); > + struct tcp_sock *tp =3D tcp_sk(sk); > =20 > tcp_cleanup_congestion_control(sk); > WRITE_ONCE(icsk->icsk_ca_ops, ca); > icsk->icsk_ca_setsockopt =3D 1; > memset(icsk->icsk_ca_priv, 0, sizeof(icsk->icsk_ca_priv)); > =20 > + /* Reset ECT(1) selection before initializing a new CC */ > + tp->ecn_flags &=3D ~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 =3D 1, and then tcp_ecn_send_syn() runs tp->ecn_flags =3D 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. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130125658.2029= 2-1-chia-yu.chang@nokia-bell-labs.com?part=3D3