Re: [PATCH net-next v4 2/4] tcp: rename ECN transmit helper function
From: Eric Dumazet
Date: Thu Nov 19 2026 - 14:00:25 EST
Le jeu. 19 nov. 2026 à 19:01, <chia-yu.chang@xxxxxxxxxxxxxxxxxxx> a écrit :
>
> From: Chia-Yu Chang <chia-yu.chang@xxxxxxxxxxxxxxxxxxx>
>
> Rename INET_ECN_xmit_ect_1_negotiation() to
> INET_ECN_xmit_negotiation_ect(). The previous name suggests that the
> helper always uses ECT(1), while it actually chooses the ECT codepoint
> to be used during the ECN negotiation.
>
> This renaming also prepares for the introduction of a similarly named
> helper function for established connections in the followup patch.
>
> Signed-off-by: Chia-Yu Chang <chia-yu.chang@xxxxxxxxxxxxxxxxxxx>
>
> --
> v3:
> - Rename helper to better reflect its behavior
> ---
> include/net/tcp_ecn.h | 6 +++---
> net/ipv4/tcp_cong.c | 4 ++--
> 2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/include/net/tcp_ecn.h b/include/net/tcp_ecn.h
> index 865d5c5a7718..9ca016d98972 100644
> --- a/include/net/tcp_ecn.h
> +++ b/include/net/tcp_ecn.h
> @@ -33,7 +33,7 @@ enum tcp_accecn_option {
> };
>
> /* Apply either ECT(0) or ECT(1) based on TCP_CONG_ECT_1_NEGOTIATION flag */
While you are renaming it, please expand this comment, it is rather
cryptic. Something like :
/**
* INET_ECN_xmit_negotiation_ect - set the ECT codepoint used before CA init
* @sk: TCP socket
*
* Mark the socket ECN-capable for the packets sent while ECN is still being
* negotiated (SYN, SYN-ACK), i.e. before tcp_init_congestion_control() runs.
*
* The codepoint is chosen by the congestion control module:
* ECT(1) if it sets TCP_CONG_ECT_1_NEGOTIATION, ECT(0) otherwise.
*
* This does not decide whether ECT should be sent at all: callers only use
* it when the module (TCP_CONG_NEEDS_ECN) or a BPF program asked for ECT
* on these packets.
*
* This changes the socket TOS/tclass, not a single packet, so the codepoint
* stays in effect until tcp_init_congestion_control() or tcp_ecn_send()
* selects the one used for the established flow.
*/
The helper added in patch 3 (INET_ECN_xmit_established_ect()) would
deserve the same treatment, so that the split between the two is clear.
> -static inline void INET_ECN_xmit_ect_1_negotiation(struct sock *sk)
> +static inline void INET_ECN_xmit_negotiation_ect(struct sock *sk)
> {
> __INET_ECN_xmit(sk, tcp_ca_ect_1_negotiation(sk));
> }
> @@ -583,7 +583,7 @@ static inline void tcp_ecn_send_synack(struct sock *sk, struct sk_buff *skb)
> TCP_SKB_CB(skb)->tcp_flags &= ~TCPHDR_ECE;
> else if (tcp_ca_needs_ecn(sk) ||
> tcp_bpf_ca_needs_ecn(sk))
> - INET_ECN_xmit_ect_1_negotiation(sk);
> + INET_ECN_xmit_negotiation_ect(sk);
>
> if (tp->ecn_flags & TCP_ECN_MODE_ACCECN) {
> TCP_SKB_CB(skb)->tcp_flags &= ~TCPHDR_ACE;
> @@ -618,7 +618,7 @@ static inline void tcp_ecn_send_syn(struct sock *sk, struct sk_buff *skb)
>
> if (use_ecn) {
> if (tcp_ca_needs_ecn(sk) || bpf_needs_ecn)
> - INET_ECN_xmit_ect_1_negotiation(sk);
> + INET_ECN_xmit_negotiation_ect(sk);
>
> TCP_SKB_CB(skb)->tcp_flags |= TCPHDR_ECE | TCPHDR_CWR;
> if (use_accecn) {
> diff --git a/net/ipv4/tcp_cong.c b/net/ipv4/tcp_cong.c
> index e3f462f161dd..3331679c81d7 100644
> --- a/net/ipv4/tcp_cong.c
> +++ b/net/ipv4/tcp_cong.c
> @@ -228,7 +228,7 @@ void tcp_assign_congestion_control(struct sock *sk)
>
> memset(icsk->icsk_ca_priv, 0, sizeof(icsk->icsk_ca_priv));
> if (ca->flags & TCP_CONG_NEEDS_ECN)
> - INET_ECN_xmit_ect_1_negotiation(sk);
> + INET_ECN_xmit_negotiation_ect(sk);
> else
> INET_ECN_dontxmit(sk);
> }
> @@ -258,7 +258,7 @@ static void tcp_reinit_congestion_control(struct sock *sk,
> memset(icsk->icsk_ca_priv, 0, sizeof(icsk->icsk_ca_priv));
>
> if (ca->flags & TCP_CONG_NEEDS_ECN)
> - INET_ECN_xmit_ect_1_negotiation(sk);
> + INET_ECN_xmit_negotiation_ect(sk);
> else
> INET_ECN_dontxmit(sk);
>
> --
> 2.34.1
>