RE: [PATCH net-next v4 3/4] tcp: add TCP_ECN_SEND_ECT_1 flag for congestion control

From: Chia-Yu Chang (Nokia)

Date: Sun Nov 29 2026 - 11:50:53 EST


> -----Original Message-----
> From: Eric Dumazet <edumazet@xxxxxxxxxx>
> Sent: Thursday, November 19, 2026 7:48 PM
> To: Chia-Yu Chang (Nokia) <chia-yu.chang@xxxxxxxxxxxxxxxxxxx>
> Cc: linux-kernel@xxxxxxxxxxxxxxx; kuba@xxxxxxxxxx; netdev@xxxxxxxxxxxxxxx; pabeni@xxxxxxxxxx; davem@xxxxxxxxxxxxx; kuniyu@xxxxxxxxxx; ij@xxxxxxxxxx; ncardwell@xxxxxxxxxx; koen0607@xxxxxxxxx; g.white@xxxxxxxxxxxxx; ingemar.s.johansson@xxxxxxxxxxxx; mirja.kuehlewind@xxxxxxxxxxxx; cheshire@xxxxxxxxx; rs.ietf@xxxxxx; Jason_Livingood@xxxxxxxxxxx; vidhi_goel@xxxxxxxxx; Mike_Rudolph@xxxxxxxxxxx; Jeff_Howe@xxxxxxxxxxx; srichard@xxxxxxxxxx
> Subject: Re: [PATCH net-next v4 3/4] tcp: add TCP_ECN_SEND_ECT_1 flag for congestion control
>
>
> CAUTION: This is an external email. Please be very careful when clicking links or opening attachments. See the URL nok.it/ext for additional information.
>
>
>
> Le jeu. 19 nov. 2026 à 19:01, <chia-yu.chang@xxxxxxxxxxxxxxxxxxx> a écrit :
> >
> > From: Chia-Yu Chang <chia-yu.chang@xxxxxxxxxxxxxxxxxxx>
> >
> > This patch introduces the new TCP_ECN_SEND_ECT_1 bit, which enables a
> > congestion control module to control whether the connection transmits
> > using ECT(1) (if the bit is set) or ECT(0) (otherwise), when
> > congestion control is initialized after ECN negotiation.
> >
> > A congestion control module, such as the upcoming TCP Prague using L4S
> > ECN, can set this new TCP_ECN_SEND_ECT_1 bit if it wants to send the
> > ECT(1) code point in outgoing IP headers.
> >
> > Signed-off-by: Chia-Yu Chang <chia-yu.chang@xxxxxxxxxxxxxxxxxxx>
> >
> > --
> > v3:
> > - Update commit message
> > - Update flag name and helper function name to eliminate confusion
> > ---
> > include/net/tcp.h | 1 +
> > include/net/tcp_ecn.h | 6 ++++++
> > net/ipv4/tcp_cong.c | 4 +++-
> > net/ipv4/tcp_output.c | 2 +-
> > 4 files changed, 11 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/net/tcp.h b/include/net/tcp.h index
> > 4b1159e6c125..0242fd6bbb07 100644
> > --- a/include/net/tcp.h
> > +++ b/include/net/tcp.h
> > @@ -428,6 +428,7 @@ static inline void tcp_dec_quickack_mode(struct sock *sk)
> > #define TCP_ECN_DEMAND_CWR BIT(2)
> > #define TCP_ECN_SEEN BIT(3)
> > #define TCP_ECN_MODE_ACCECN BIT(4)
> > +#define TCP_ECN_SEND_ECT_1 BIT(5)
>
> Who clears this bit ?
>
> The only place where tp->ecn_flags is reset is tcp_ecn_send_syn().
>
> If a module sets the bit, and the user later switches to another congestion control with setsockopt(TCP_CONGESTION) on an AccECN flow, tcp_ecn_send() will keep sending ECT(1) on every packet, with a classic congestion response.
>
> I do not think we should rely on each module ->release() to clear it. tcp_reinit_congestion_control() should do it.

Hi Eric,

You are right, I will add the corresponding reset and comments in tcp_reinit_congestion_control().
>
> >
> > #define TCP_ECN_DISABLED 0
> > #define TCP_ECN_MODE_PENDING (TCP_ECN_MODE_RFC3168 | TCP_ECN_MODE_ACCECN)
> > diff --git a/include/net/tcp_ecn.h b/include/net/tcp_ecn.h index
> > 9ca016d98972..ff402cdb988d 100644
> > --- a/include/net/tcp_ecn.h
> > +++ b/include/net/tcp_ecn.h
> > @@ -38,6 +38,12 @@ static inline void INET_ECN_xmit_negotiation_ect(struct sock *sk)
> > __INET_ECN_xmit(sk, tcp_ca_ect_1_negotiation(sk)); }
> >
> > +/* Apply either ECT(0) or ECT(1) based on TCP_ECN_SEND_ECT_1 flag */
> > +static inline void INET_ECN_xmit_established_ect(struct sock *sk) {
> > + __INET_ECN_xmit(sk, tcp_sk(sk)->ecn_flags &
> > +TCP_ECN_SEND_ECT_1); }
> > +
> > static inline void tcp_ecn_queue_cwr(struct tcp_sock *tp) {
> > /* Do not set CWR if in AccECN mode! */ diff --git
> > a/net/ipv4/tcp_cong.c b/net/ipv4/tcp_cong.c index
> > 3331679c81d7..43b0634f7673 100644
> > --- a/net/ipv4/tcp_cong.c
> > +++ b/net/ipv4/tcp_cong.c
> > @@ -240,7 +240,9 @@ 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))
> > + if (tcp_ca_needs_accecn(sk))
> > + INET_ECN_xmit_established_ect(sk);
> > + else if (tcp_ca_needs_ecn(sk))
> > INET_ECN_xmit(sk);
>
> This only looks at the module flag, not at what was negotiated.
>
> If AccECN negotiation failed (RFC 3168 fallback, or no ECN at all), we still set ECT(0)/ECT(1) here. Is the module expected to handle all the fallbacks from its ->init(), like DCTCP does ? If so, please add a comment, and say it in the changelog.
>

Yes, I add new comments above the code to explain that "each module is responsible for handling fallback cases when negotiation did not succeed."

Thanks.
Chia-Yu