* [PATCH net-next v5 1/4] tcp: export CE count in rate_sample
2026-11-30 12:56 [PATCH net-next v5 0/4] TCP Prague preparation series chia-yu.chang
@ 2026-11-30 12:56 ` 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
` (2 subsequent siblings)
3 siblings, 1 reply; 10+ messages in thread
From: chia-yu.chang @ 2026-11-30 12:56 UTC (permalink / raw)
To: emil, martin.lau, ast, kafai.wan, bpf, willemb, horms,
linux-kernel, kuba, netdev, pabeni, davem, edumazet, kuniyu, ij,
ncardwell, koen0607, g.white, ingemar.s.johansson,
mirja.kuehlewind, cheshire, rs.ietf, Jason_Livingood, vidhi_goel,
Mike_Rudolph, Jeff_Howe, srichard
Cc: Olivier Tilmans, Chia-Yu Chang
From: Ilpo Järvinen <ij@kernel.org>
Store the number of newly ACKed/SACKed CE-marked packets in rate_sample.
This will be used by upcoming congestion control algorithms, e.g.,
TCP Prague, that need access to AccECN-derived congestion info.
For RFC3168 ECN mode, acked_sacked_ce equals delivered when FLAG_ECE
is present. For AccECN mode, it carries the derived CE-marked packets
from AccECN options or ACE field based on RFC9768.
Signed-off-by: Ilpo Järvinen <ij@kernel.org>
Co-developed-by: Olivier Tilmans <olivier.tilmans@nokia.com>
Signed-off-by: Olivier Tilmans <olivier.tilmans@nokia.com>
Co-developed-by: Chia-Yu Chang <chia-yu.chang@nokia-bell-labs.com>
Signed-off-by: Chia-Yu Chang <chia-yu.chang@nokia-bell-labs.com>
---
v5:
- Rebase to the latest net-next tree
- Clarify acked_sacked_ce comment to document that it carries
the exact CE-marked packet count under AccECN, while under RFC3168
ECN it equals acked_sacked when the ECE flag is present.
v3:
- Improve commit message
- Rename ece_delta to acked_sacked_ce
- Remove redundant rate_sample initializer
---
include/net/tcp.h | 7 +++++++
net/ipv4/tcp_input.c | 36 ++++++++++++++++--------------------
2 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 68a60268d19d..12129ae8b06b 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -1369,6 +1369,13 @@ struct rate_sample {
long rtt_us; /* RTT of last (S)ACKed packet (or -1) */
int losses; /* number of packets marked lost upon ACK */
u32 acked_sacked; /* number of packets newly (S)ACKed upon ACK */
+ /*
+ * Number of packets newly (S)ACked associated with congestion
+ * signalling upon ACK.
+ * For AccECN, this is the number of newly CE-marked packets.
+ * For RFC3168, this equals acked_sacked when the ECE flag is present.
+ */
+ u32 acked_sacked_ce;
u32 prior_in_flight; /* in flight before this ACK */
u32 last_end_seq; /* end_seq of most recently ACKed packet */
bool is_app_limited; /* is sample from packet with bubble in pipe? */
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 801c76744ed8..a37660275e35 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -606,9 +606,9 @@ static u32 __tcp_accecn_process(struct sock *sk, const struct sk_buff *skb,
return safe_delta;
}
-static u32 tcp_accecn_process(struct sock *sk, const struct sk_buff *skb,
- u32 delivered_pkts, u32 delivered_bytes,
- int *flag)
+static void tcp_accecn_process(struct sock *sk, struct rate_sample *rs,
+ const struct sk_buff *skb, u32 delivered_pkts,
+ u32 delivered_bytes, int *flag)
{
struct tcp_sock *tp = tcp_sk(sk);
u32 delta;
@@ -618,11 +618,11 @@ static u32 tcp_accecn_process(struct sock *sk, const struct sk_buff *skb,
if (delta > 0) {
tcp_count_delivered_ce(tp, delta);
*flag |= FLAG_ECE;
+ rs->acked_sacked_ce = delta;
/* Recalculate header predictor */
if (tp->pred_flags)
tcp_fast_path_on(tp);
}
- return delta;
}
/* Buffer size and advertised window tuning.
@@ -4249,8 +4249,8 @@ static void tcp_xmit_recovery(struct sock *sk, int rexmit)
}
/* Returns the number of packets newly acked or sacked by the current ACK */
-static u32 tcp_newly_delivered(struct sock *sk, u32 prior_delivered,
- u32 ecn_count, int flag)
+static u32 tcp_newly_delivered(struct sock *sk, struct rate_sample *rs,
+ u32 prior_delivered, int flag)
{
const struct net *net = sock_net(sk);
struct tcp_sock *tp = tcp_sk(sk);
@@ -4261,8 +4261,9 @@ static u32 tcp_newly_delivered(struct sock *sk, u32 prior_delivered,
if (flag & FLAG_ECE) {
if (tcp_ecn_mode_rfc3168(tp))
- ecn_count = delivered;
- NET_ADD_STATS(net, LINUX_MIB_TCPDELIVEREDCE, ecn_count);
+ rs->acked_sacked_ce = delivered;
+ NET_ADD_STATS(net, LINUX_MIB_TCPDELIVEREDCE,
+ rs->acked_sacked_ce);
}
return delivered;
@@ -4327,7 +4328,6 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
u32 delivered = tp->delivered;
u32 lost = tp->lost;
int rexmit = REXMIT_NONE; /* Flag to (re)transmit to recover losses */
- u32 ecn_count = 0; /* Did we receive ECE/an AccECN ACE update? */
u32 prior_fack;
sack_state.first_sackt = 0;
@@ -4445,10 +4445,8 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
tcp_rack_update_reo_wnd(sk, &rs);
if (tcp_ecn_mode_accecn(tp))
- ecn_count = tcp_accecn_process(sk, skb,
- tp->delivered - delivered,
- sack_state.delivered_bytes,
- &flag);
+ tcp_accecn_process(sk, &rs, skb, tp->delivered - delivered,
+ sack_state.delivered_bytes, &flag);
tcp_in_ack_event(sk, flag);
@@ -4474,7 +4472,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
if ((flag & FLAG_FORWARD_PROGRESS) || !(flag & FLAG_NOT_DUP))
sk_dst_confirm(sk);
- delivered = tcp_newly_delivered(sk, delivered, ecn_count, flag);
+ delivered = tcp_newly_delivered(sk, &rs, delivered, flag);
lost = tp->lost - lost; /* freshly marked lost */
rs.is_ack_delayed = !!(flag & FLAG_ACK_MAYBE_DELAYED);
@@ -4485,16 +4483,14 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
no_queue:
if (tcp_ecn_mode_accecn(tp))
- ecn_count = tcp_accecn_process(sk, skb,
- tp->delivered - delivered,
- sack_state.delivered_bytes,
- &flag);
+ tcp_accecn_process(sk, &rs, skb, tp->delivered - delivered,
+ sack_state.delivered_bytes, &flag);
tcp_in_ack_event(sk, flag);
/* If data was DSACKed, see if we can undo a cwnd reduction. */
if (flag & FLAG_DSACKING_ACK) {
tcp_fastretrans_alert(sk, prior_snd_una, num_dupack, &flag,
&rexmit);
- tcp_newly_delivered(sk, delivered, ecn_count, flag);
+ tcp_newly_delivered(sk, &rs, delivered, flag);
}
/* If this ack opens up a zero window, clear backoff. It was
* being used to time the probes, and is probably far higher than
@@ -4521,7 +4517,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
&sack_state);
tcp_fastretrans_alert(sk, prior_snd_una, num_dupack, &flag,
&rexmit);
- tcp_newly_delivered(sk, delivered, ecn_count, flag);
+ tcp_newly_delivered(sk, &rs, delivered, flag);
tcp_xmit_recovery(sk, rexmit);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH net-next v5 1/4] tcp: export CE count in rate_sample
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
0 siblings, 0 replies; 10+ messages in thread
From: netdev-bot+sashiko @ 2026-12-01 13:10 UTC (permalink / raw)
To: chia-yu.chang
Cc: emil, martin.lau, ast, kafai.wan, bpf, willemb, horms,
linux-kernel, kuba, netdev, pabeni, davem, edumazet, kuniyu, ij,
ncardwell, koen0607, g.white, ingemar.s.johansson,
mirja.kuehlewind, cheshire, rs.ietf, Jason_Livingood, vidhi_goel,
Mike_Rudolph, Jeff_Howe, srichard
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The new comment on struct rate_sample::acked_sacked_ce
(include/net/tcp.h:1372-1378) calls the field the "Number of packets…
--
tcp: export CE count in rate_sample
This commit adds an acked_sacked_ce field to struct rate_sample. The field
holds the number of newly ACKed/SACKed CE-marked packets, for use by
upcoming congestion control modules such as TCP Prague. In RFC3168 mode it
is set to the delivered count when FLAG_ECE is present. In AccECN mode it
holds the delta derived from the ACE field or the AccECN options.
> diff --git a/include/net/tcp.h b/include/net/tcp.h
> index 68a60268d19da..12129ae8b06b5 100644
> --- a/include/net/tcp.h
> +++ b/include/net/tcp.h
> @@ -1369,6 +1369,13 @@ struct rate_sample {
> long rtt_us; /* RTT of last (S)ACKed packet (or -1) */
> int losses; /* number of packets marked lost upon ACK */
> u32 acked_sacked; /* number of packets newly (S)ACKed upon ACK */
> + /*
> + * Number of packets newly (S)ACked associated with congestion
> + * signalling upon ACK.
> + * For AccECN, this is the number of newly CE-marked packets.
> + * For RFC3168, this equals acked_sacked when the ECE flag is present.
> + */
> + u32 acked_sacked_ce;
[Severity: Low]
Does this comment hold for the AccECN case? It describes the field as a
subset of the newly (S)ACKed packets, which implies acked_sacked_ce never
exceeds acked_sacked. The AccECN path doesn't seem to guarantee that.
__tcp_accecn_process() keeps going on timestamp progress alone, so
delivered_pkts can be 0:
net/ipv4/tcp_input.c:__tcp_accecn_process() {
...
if (!(flag & (FLAG_FORWARD_PROGRESS | FLAG_TS_PROGRESS)))
return 0;
...
corrected_ace = tcp_accecn_ace(th) - TCP_ACCECN_CEP_INIT_OFFSET;
delta = (corrected_ace - tp->delivered_ce) & TCP_ACCECN_CEP_ACE_MASK;
if (delivered_pkts <= TCP_ACCECN_CEP_ACE_MASK)
return delta;
...
}
Take an ACK on the slowpath that doesn't ack the SYN. Here delta can be
1..7, taken from the peer's ACE field, even when delivered_pkts is 0 or
smaller than delta. tcp_accecn_process() then stores it without any clamp:
rs->acked_sacked_ce = delta;
Later, tcp_rate_gen() sets rs->acked_sacked = delivered without checking
it against acked_sacked_ce.
The ACE bits are set by the peer. A peer can therefore make
acked_sacked_ce larger than acked_sacked, including when acked_sacked is 0.
This can happen maliciously, or simply because the peer counts CE-marked
pure ACKs or retransmits, which RFC 9768 allows.
The value is also visible right away to BPF struct_ops cong_control
programs. A consumer that trusts this comment and computes acked_sacked_ce
/ acked_sacked could get a ratio above 1, or a non-zero numerator over a
zero denominator.
Nothing in the tree reads acked_sacked_ce yet, and the stored value has the
same meaning as the old ecn_count. So this is mostly a mismatch between the
comment and the code.
Could the comment say that under AccECN this is the ACE/option-derived CE
count, which is not bounded by acked_sacked? Or should the value be clamped
to the delivered count?
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130125658.20292-1-chia-yu.chang%40nokia-bell-labs.com
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH net-next v5 2/4] tcp: rename ECN transmit helper function
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-11-30 12:56 ` 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-11-30 12:56 ` [PATCH net-next v5 4/4] tcp: add MSS ceiling callback " chia-yu.chang
3 siblings, 0 replies; 10+ messages in thread
From: chia-yu.chang @ 2026-11-30 12:56 UTC (permalink / raw)
To: emil, martin.lau, ast, kafai.wan, bpf, willemb, horms,
linux-kernel, kuba, netdev, pabeni, davem, edumazet, kuniyu, ij,
ncardwell, koen0607, g.white, ingemar.s.johansson,
mirja.kuehlewind, cheshire, rs.ietf, Jason_Livingood, vidhi_goel,
Mike_Rudolph, Jeff_Howe, srichard
Cc: Chia-Yu Chang
From: Chia-Yu Chang <chia-yu.chang@nokia-bell-labs.com>
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@nokia-bell-labs.com>
---
v5:
- Document detailed comments for INET_ECN_xmit_negotiation_ect()
v3:
- Rename helper to better reflect its behavior
---
include/net/tcp_ecn.h | 25 +++++++++++++++++++++----
net/ipv4/tcp_cong.c | 4 ++--
2 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/include/net/tcp_ecn.h b/include/net/tcp_ecn.h
index 865d5c5a7718..3bb0b2f692f4 100644
--- a/include/net/tcp_ecn.h
+++ b/include/net/tcp_ecn.h
@@ -32,8 +32,25 @@ enum tcp_accecn_option {
TCP_ACCECN_OPTION_PERSIST = 3,
};
-/* Apply either ECT(0) or ECT(1) based on TCP_CONG_ECT_1_NEGOTIATION flag */
-static inline void INET_ECN_xmit_ect_1_negotiation(struct sock *sk)
+/**
+ * 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 TCP_CONG_ECT_1_NEGOTIATION is set, otherwise ECT(0).
+ *
+ * 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.
+ */
+static inline void INET_ECN_xmit_negotiation_ect(struct sock *sk)
{
__INET_ECN_xmit(sk, tcp_ca_ect_1_negotiation(sk));
}
@@ -583,7 +600,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 +635,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
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH net-next v5 3/4] tcp: add TCP_ECN_SEND_ECT_1 flag for congestion control
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-11-30 12:56 ` [PATCH net-next v5 2/4] tcp: rename ECN transmit helper function chia-yu.chang
@ 2026-11-30 12:56 ` chia-yu.chang
2026-12-01 12:57 ` sashiko-bot
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
3 siblings, 2 replies; 10+ messages in thread
From: chia-yu.chang @ 2026-11-30 12:56 UTC (permalink / raw)
To: emil, martin.lau, ast, kafai.wan, bpf, willemb, horms,
linux-kernel, kuba, netdev, pabeni, davem, edumazet, kuniyu, ij,
ncardwell, koen0607, g.white, ingemar.s.johansson,
mirja.kuehlewind, cheshire, rs.ietf, Jason_Livingood, vidhi_goel,
Mike_Rudolph, Jeff_Howe, srichard
Cc: Chia-Yu Chang
From: Chia-Yu Chang <chia-yu.chang@nokia-bell-labs.com>
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@nokia-bell-labs.com>
---
v5:
- Document detailed comments for INET_ECN_xmit_established_ect()
- Clear ECT(1) selection from prior CC in tcp_reinit_congestion_control()
v3:
- Update commit message
- Update flag name and helper function name to eliminate confusion
---
include/net/tcp.h | 1 +
include/net/tcp_ecn.h | 22 ++++++++++++++++++++++
net/ipv4/tcp_cong.c | 12 +++++++++++-
net/ipv4/tcp_output.c | 2 +-
4 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 12129ae8b06b..1cc3f60da8d6 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -435,6 +435,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)
#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 3bb0b2f692f4..a8a64be25c1e 100644
--- a/include/net/tcp_ecn.h
+++ b/include/net/tcp_ecn.h
@@ -55,6 +55,28 @@ static inline void INET_ECN_xmit_negotiation_ect(struct sock *sk)
__INET_ECN_xmit(sk, tcp_ca_ect_1_negotiation(sk));
}
+/**
+ * INET_ECN_xmit_established_ect - set the ECT codepoint after CA init
+ * @sk: TCP socket
+ *
+ * Unlike INET_ECN_xmit_negotiation_ect(), which selects the codepoint
+ * used during ECN negotiation (SYN/SYN-ACK), this helper selects the
+ * ECN codepoint used by the established flow.
+ *
+ * The codepoint is chosen according to TCP_ECN_SEND_ECT_1:
+ * ECT(1) when the bit is set, ECT(0) otherwise.
+ *
+ * This helper does not determine whether ECN should be enabled.
+ * Callers invoke it only after congestion control initialization,
+ * with the congestion control module selecting the codepoint to use.
+ *
+ * This changes the socket TOS/tclass rather than a single packet.
+ */
+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..34617106f5e5 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);
@@ -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
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 08d0d4a639fe..7b694479095e 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -350,7 +350,7 @@ static void tcp_ecn_send(struct sock *sk, struct sk_buff *skb,
if (tcp_ecn_mode_accecn(tp)) {
if (!tcp_accecn_ace_fail_recv(tp) &&
!tcp_accecn_ace_fail_send(tp))
- INET_ECN_xmit(sk);
+ INET_ECN_xmit_established_ect(sk);
else
INET_ECN_dontxmit(sk);
tcp_accecn_set_ace(tp, skb, th);
--
2.34.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH net-next v5 3/4] tcp: add TCP_ECN_SEND_ECT_1 flag for congestion control
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
2026-12-01 13:10 ` netdev-bot+sashiko
1 sibling, 0 replies; 10+ messages in thread
From: sashiko-bot @ 2026-12-01 12:57 UTC (permalink / raw)
To: chia-yu.chang, bpf
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
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH net-next v5 3/4] tcp: add TCP_ECN_SEND_ECT_1 flag for congestion control
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
@ 2026-12-01 13:10 ` netdev-bot+sashiko
1 sibling, 0 replies; 10+ messages in thread
From: netdev-bot+sashiko @ 2026-12-01 13:10 UTC (permalink / raw)
To: chia-yu.chang
Cc: emil, martin.lau, ast, kafai.wan, bpf, willemb, horms,
linux-kernel, kuba, netdev, pabeni, davem, edumazet, kuniyu, ij,
ncardwell, koen0607, g.white, ingemar.s.johansson,
mirja.kuehlewind, cheshire, rs.ietf, Jason_Livingood, vidhi_goel,
Mike_Rudolph, Jeff_Howe, srichard
Thank you for your contribution! Sashiko AI review found 5 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 3 · Low: 2
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] Undisclosed behaviour change in tcp_init_congestion_control()
(net/ipv4/tcp_cong.c:248-253).
- [Medium] TCP_ECN_SEND_ECT_1 is cleared only in
tcp_reinit_congestion_control() (net/ipv4/tcp_cong.c:269), which is…
- [Medium] tcp: premature established ECT in
tcp_init_congestion_control() breaks TFO
- [Low] The commit message says TCP_ECN_SEND_ECT_1 lets a CC choose
ECT(1) or ECT(0) 'when congestion control is initialized after ECN…
- [Low] If a BPF sock_ops program switches the CC from
BPF_SOCK_OPS_TCP_CONNECT_CB, any TCP_ECN_SEND_ECT_1 the CC sets in its…
--
tcp: add TCP_ECN_SEND_ECT_1 flag for congestion control
This commit adds a TCP_ECN_SEND_ECT_1 bit to tp->ecn_flags. A congestion
control module can set it to choose ECT(1) instead of ECT(0) for the
established flow. tcp_init_congestion_control() and the AccECN branch of
tcp_ecn_send() now use a new INET_ECN_xmit_established_ect() helper that
reads the bit, and tcp_reinit_congestion_control() clears the bit before
switching CCs.
> 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 setting the established codepoint here break AccECN on passive
TCP Fast Open connections?
For a TFO SYN, tcp_conn_request() creates the child socket before the
SYN-ACK is sent:
tcp_conn_request()
tcp_try_fastopen()
tcp_fastopen_create_child()
syn_recv_sock()
tcp_create_openreq_child()
tcp_ecn_openreq_child() /* tp->syn_ect_snt = 0 */
tcp_init_transfer()
tcp_init_congestion_control()
INET_ECN_xmit_established_ect() /* child tos = ECT */
af_ops->send_synack(fastopen_sk, ..., TCP_SYNACK_FASTOPEN, skb)
tcp_v4_send_synack() and tcp_v6_send_synack() then build the SYN-ACK
from the child's tos/tclass. With this patch, that now carries ECT(0)
or ECT(1) for any CC with TCP_CONG_NEEDS_ACCECN, even one without
TCP_CONG_NEEDS_ECN. The codepoint is recorded in
tcp_rsk(req)->syn_ect_snt. However, the child's tp->syn_ect_snt was
copied from treq->syn_ect_snt earlier, while it was still 0
(Not-ECT).
When the client's third ACK reflects the SYN-ACK codepoint in ACE,
tcp_rcv_state_process() in TCP_SYN_RECV calls tcp_accecn_third_ack()
with tp->syn_ect_snt == 0. The transition check then fails and sets
TCP_ACCECN_ACE_FAIL_RECV. From then on, tcp_ecn_send() takes the
INET_ECN_dontxmit() branch.
If that is right, an AccECN CC would lose ECN for the rest of the
connection on every passive TFO connection. With the default
sysctl_tcp_ecn_fallback this is deterministic, not a corner case.
Should the child's tp->syn_ect_snt follow what the SYN-ACK actually
carried? Or should the established codepoint only be applied once the
SYN-ACK has gone out? It may also be worth checking whether NEEDS_ECN
CCs, which already reach INET_ECN_xmit() here, see the same mismatch.
[Severity: Medium]
Does this change behaviour for a CC that has TCP_CONG_NEEDS_ACCECN but not
TCP_CONG_NEEDS_ECN?
Before this patch, such a CC got INET_ECN_dontxmit() here. Now its socket
TOS/tclass always gets ECT(0) or ECT(1), whatever ECN mode was actually
negotiated.
tcp_ecn_send_syn() sets use_ecn whenever use_accecn is true, so this CC
does try to negotiate. With a non-ECN peer the mode ends up as
TCP_ECN_DISABLED. tcp_init_transfer()->tcp_init_congestion_control() then
takes this new branch, and tcp_ecn_send() never clears the result:
net/ipv4/tcp_output.c:tcp_ecn_send() {
...
if (!tcp_ecn_mode_any(tp))
return;
...
}
Wouldn't every packet of this non-ECN connection then go out ECT-marked?
An AQM would CE-mark those packets instead of dropping them, and no CE
feedback would ever come back.
The ECT write happens after ->init(), so the module can't undo it by
calling INET_ECN_dontxmit() in init. Its only option seems to be swapping
icsk_ca_ops to an ops without NEEDS_ACCECN, as DCTCP does with dctcp_reno.
BPF struct_ops CCs can register with this flag, because
TCP_CONG_NEEDS_ACCECN is part of TCP_CONG_MASK.
The flag's definition says:
/* Require successfully negotiated AccECN capability */
#define TCP_CONG_NEEDS_ACCECN BIT(2)
The commit message doesn't mention this change, and only the new comment
here hints at the "module handles fallback" contract.
Should this branch check the negotiated mode? If not, could the commit
message describe the new contract?
> @@ -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;
[Severity: Medium]
This is the only place TCP_ECN_SEND_ECT_1 is cleared, and it only covers
the setsockopt(TCP_CONGESTION) path. Can a stale bit survive the other
paths that tear down or replace the CC?
tcp_disconnect() releases the CC and wipes icsk_ca_priv, but leaves
tp->ecn_flags as it is:
net/ipv4/tcp.c:tcp_disconnect() {
...
if (icsk->icsk_ca_initialized && icsk->icsk_ca_ops->release)
icsk->icsk_ca_ops->release(sk);
memset(icsk->icsk_ca_priv, 0, sizeof(icsk->icsk_ca_priv));
icsk->icsk_ca_initialized = 0;
...
}
For passive children, tcp_create_openreq_child() clones the listener's
ecn_flags. tcp_ecn_openreq_child() then only calls tcp_ecn_mode_set(),
which clears just the mode bits:
tp->ecn_flags &= ~TCP_ECN_MODE_ANY;
tp->ecn_flags |= mode;
So bit 5 survives. tcp_ca_openreq_child() can then give the child a
different CC, either through RTAX_CC_ALGO or
tcp_assign_congestion_control(), without clearing it.
For example:
1. A socket connects with a BPF CC that sets TCP_ECN_SEND_ECT_1.
2. It is disconnected with connect(AF_UNSPEC).
3. It calls listen().
Every accepted child inherits the bit, even if its CC is CUBIC. With
AccECN negotiated, tcp_ecn_send()->INET_ECN_xmit_established_ect() would
then send ECT(1) on every segment for a classic CC.
Would clearing the bit in tcp_init_congestion_control() before ->init(),
or in tcp_cleanup_congestion_control(), cover these paths?
> if (ca->flags & TCP_CONG_NEEDS_ECN)
> INET_ECN_xmit_negotiation_ect(sk);
> else
[Severity: Low]
Is the CC's ECT(1) request lost when a BPF sock_ops program switches the
CC from BPF_SOCK_OPS_TCP_CONNECT_CB?
tcp_connect()
tcp_call_bpf(sk, BPF_SOCK_OPS_TCP_CONNECT_CB)
bpf_setsockopt(TCP_CONGESTION)
tcp_reinit_congestion_control()
tcp_init_congestion_control() /* sk is in SYN_SENT */
ca->init() /* sets TCP_ECN_SEND_ECT_1 */
icsk->icsk_ca_initialized = 1;
...
tcp_ecn_send_syn()
tp->ecn_flags = 0; /* bit is wiped */
After the handshake, tcp_init_transfer() skips the re-init:
if (!icsk->icsk_ca_initialized)
tcp_init_congestion_control(sk);
So the bit is never set again. In AccECN mode, tcp_ecn_send() sends ECT(0)
for a CC that asked for ECT(1).
This hazard is new, because before this patch the CC's codepoint choice
wasn't stored in ecn_flags. The fallback is the conservative ECT(0). A CC
that checks tcp_ecn_mode_accecn() in init would fall back on this path
anyway, as DCTCP does.
Is losing the bit here intended?
> diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
> index 08d0d4a639fec..7b694479095e0 100644
> --- a/net/ipv4/tcp_output.c
> +++ b/net/ipv4/tcp_output.c
> @@ -350,7 +350,7 @@ static void tcp_ecn_send(struct sock *sk, struct sk_buff *skb,
> if (tcp_ecn_mode_accecn(tp)) {
> if (!tcp_accecn_ace_fail_recv(tp) &&
> !tcp_accecn_ace_fail_send(tp))
> - INET_ECN_xmit(sk);
> + INET_ECN_xmit_established_ect(sk);
[Severity: Low]
The commit message says the new bit:
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.
Does this match what the code does?
At init, tcp_init_congestion_control() only uses the bit for CCs with
TCP_CONG_NEEDS_ACCECN. Here in tcp_ecn_send(), it is used on every
segment in AccECN mode, for every CC. The commit message doesn't mention
this per-segment change.
In RFC3168 fallback mode, new data always gets ECT(0). Pure ACKs and
retransmits of a NEEDS_ECN CC keep the current TOS:
} else {
/* Not-retransmitted data segment: set ECT and inject CWR. */
if (skb->len != tcp_header_len &&
!before(TCP_SKB_CB(skb)->seq, tp->snd_nxt)) {
INET_ECN_xmit(sk);
...
} else if (!tcp_ca_needs_ecn(sk)) {
/* ACK or retransmitted segment: clear ECT|CE */
INET_ECN_dontxmit(sk);
}
Take a NEEDS_ECN|NEEDS_ACCECN CC that set the bit and then fell back to
RFC3168. Its pure ACKs and retransmits would keep the ECT(1) set at init
until the first new data segment switches the socket to ECT(0). The flow
would then send a mix of codepoints, not the single one the commit message
describes.
Could the commit message describe the actual scope of the bit?
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130125658.20292-1-chia-yu.chang%40nokia-bell-labs.com
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH net-next v5 4/4] tcp: add MSS ceiling callback for congestion control
2026-11-30 12:56 [PATCH net-next v5 0/4] TCP Prague preparation series chia-yu.chang
` (2 preceding siblings ...)
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-11-30 12:56 ` chia-yu.chang
2026-12-01 12:57 ` sashiko-bot
2026-12-01 13:10 ` netdev-bot+sashiko
3 siblings, 2 replies; 10+ messages in thread
From: chia-yu.chang @ 2026-11-30 12:56 UTC (permalink / raw)
To: emil, martin.lau, ast, kafai.wan, bpf, willemb, horms,
linux-kernel, kuba, netdev, pabeni, davem, edumazet, kuniyu, ij,
ncardwell, koen0607, g.white, ingemar.s.johansson,
mirja.kuehlewind, cheshire, rs.ietf, Jason_Livingood, vidhi_goel,
Mike_Rudolph, Jeff_Howe, srichard
Cc: Chia-Yu Chang
From: Chia-Yu Chang <chia-yu.chang@nokia-bell-labs.com>
Allow congestion control modules to provide an optional MSS ceiling
through the new mss_ceiling() callback. The callback returns an upper
bound for tp->mss_cache and therefore uses the same units and semantics
as mss_cache.
The TCP stack derives MSS from PMTU discovery and other existing
constraints, while congestion control may further reduce the effective
MSS when needed. The ceiling is applied during MSS calculation and
remains subject to existing PMTU updates and other TCP MSS constraints.
Add tcp_update_mss_ceiling() to allow congestion control modules to
request immediate recomputation of mss_cache after changing their MSS
ceiling. This will be used by upcoming congestion controls, e.g., TCP
Prague, that perform fine-grained rate control at very low rates
(e.g., sub-Mbps) to improve latency characteristics.
The motivation for this facility and its performance impact on low-rate
Prague traffic are in: https://dl.acm.org/doi/10.1145/3822163.3827934
Signed-off-by: Chia-Yu Chang <chia-yu.chang@nokia-bell-labs.com>
---
v5:
- Apply mss_ceiling() in tcp_sync_mss() instead of __tcp_mtu_to_mss()
- Only invoke mss_ceiling() after congestion control initialization
- Document mss_ceiling() callback semantics and update commit message
- Add tcp_update_mss_ceiling() helper to recompute mss_cache after
congestion-control MSS ceiling updates
- Clamp excessively small MSS ceilings to the effective minimum send MSS
- Add BPF struct_ops support for mss_ceiling()
v3:
- Replace mss_cache_set_by_cca with mss_ceiling() callback
- Add tcp_update_mss() helper for immediate MSS recomputation
---
include/net/tcp.h | 7 +++++++
net/ipv4/bpf_tcp_ca.c | 7 +++++++
net/ipv4/tcp_output.c | 27 +++++++++++++++++++++++++++
3 files changed, 41 insertions(+)
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 1cc3f60da8d6..01402ccad477 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -865,6 +865,7 @@ static inline void tcp_clear_xmit_timers(struct sock *sk)
unsigned int tcp_sync_mss(struct sock *sk, u32 pmtu);
unsigned int tcp_current_mss(struct sock *sk);
+unsigned int tcp_update_mss_ceiling(struct sock *sk);
u32 tcp_clamp_probe0_to_user_timeout(const struct sock *sk, u32 when);
u32 tcp_tso_autosize(const struct sock *sk, unsigned int mss_now,
@@ -1439,6 +1440,12 @@ struct tcp_congestion_ops {
/* returns the multiplier used in tcp_sndbuf_expand (optional) */
u32 (*sndbuf_expand)(struct sock *sk);
+ /*
+ * Return the maximum value allowed for tp->mss_cache (optional)
+ * The returned value uses the same units and semantics as mss_cache.
+ */
+ u32 (*mss_ceiling)(struct sock *sk);
+
/* control/slow paths put last */
/* get info for inet_diag (optional) */
size_t (*get_info)(struct sock *sk, u32 ext, int *attr,
diff --git a/net/ipv4/bpf_tcp_ca.c b/net/ipv4/bpf_tcp_ca.c
index 2a71dc81562f..b03cc9e9c064 100644
--- a/net/ipv4/bpf_tcp_ca.c
+++ b/net/ipv4/bpf_tcp_ca.c
@@ -195,6 +195,7 @@ BTF_ID_FLAGS(func, tcp_reno_undo_cwnd)
BTF_ID_FLAGS(func, tcp_slow_start)
BTF_ID_FLAGS(func, tcp_cong_avoid_ai)
BTF_ID_FLAGS(func, tcp_tso_autosize)
+BTF_ID_FLAGS(func, tcp_update_mss_ceiling)
BTF_KFUNCS_END(bpf_tcp_ca_check_kfunc_ids)
static const struct btf_kfunc_id_set bpf_tcp_ca_kfunc_set = {
@@ -290,6 +291,11 @@ static u32 bpf_tcp_ca_tso_segs(struct sock *sk, u32 mss_now)
return 0;
}
+static u32 bpf_tcp_ca_mss_ceiling(struct sock *sk)
+{
+ return 0;
+}
+
static void bpf_tcp_ca_cong_control(struct sock *sk, u32 ack, int flag,
const struct rate_sample *rs)
{
@@ -322,6 +328,7 @@ static struct tcp_congestion_ops __bpf_ops_tcp_congestion_ops = {
.in_ack_event = bpf_tcp_ca_in_ack_event,
.pkts_acked = bpf_tcp_ca_pkts_acked,
.tso_segs = bpf_tcp_ca_tso_segs,
+ .mss_ceiling = bpf_tcp_ca_mss_ceiling,
.cong_control = bpf_tcp_ca_cong_control,
.undo_cwnd = bpf_tcp_ca_undo_cwnd,
.sndbuf_expand = bpf_tcp_ca_sndbuf_expand,
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 7b694479095e..96ed9ba7abe6 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2147,6 +2147,21 @@ unsigned int tcp_sync_mss(struct sock *sk, u32 pmtu)
mss_now = tcp_mtu_to_mss(sk, pmtu);
mss_now = tcp_bound_to_half_wnd(tp, mss_now);
+ /*
+ * Apply an optional MSS ceiling requested by the congestion control
+ * module. Values below the effective minimum send MSS are clamped.
+ */
+ if (icsk->icsk_ca_initialized && icsk->icsk_ca_ops->mss_ceiling) {
+ u32 mss_ceiling = icsk->icsk_ca_ops->mss_ceiling(sk);
+
+ if (mss_ceiling && mss_ceiling < mss_now) {
+ u32 min_snd_mss = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_min_snd_mss) -
+ (tcp_sk(sk)->tcp_header_len - sizeof(struct tcphdr));
+
+ mss_now = max(mss_ceiling, min_snd_mss);
+ }
+ }
+
/* And store cached results */
icsk->icsk_pmtu_cookie = pmtu;
if (icsk->icsk_mtup.enabled)
@@ -2190,6 +2205,18 @@ unsigned int tcp_current_mss(struct sock *sk)
return mss_now;
}
+__bpf_kfunc unsigned int tcp_update_mss_ceiling(struct sock *sk)
+{
+ struct inet_connection_sock *icsk = inet_csk(sk);
+
+ if (icsk->icsk_ca_initialized &&
+ icsk->icsk_ca_ops->mss_ceiling &&
+ icsk->icsk_pmtu_cookie)
+ return tcp_sync_mss(sk, icsk->icsk_pmtu_cookie);
+ return tcp_sk(sk)->mss_cache;
+}
+EXPORT_SYMBOL_GPL(tcp_update_mss_ceiling);
+
/* RFC2861, slow part. Adjust cwnd, after it was not full during one rto.
* As additional protections, we do not touch cwnd in retransmission phases,
* and if application hit its sndbuf limit recently.
--
2.34.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH net-next v5 4/4] tcp: add MSS ceiling callback for congestion control
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
1 sibling, 0 replies; 10+ messages in thread
From: sashiko-bot @ 2026-12-01 12:57 UTC (permalink / raw)
To: chia-yu.chang, bpf
Thank you for your contribution! Sashiko AI review found 5 potential
issues to consider:
- [High] tcp: mss_ceiling() skipped at conn init, in ca->init(), and on
CC switch
- [High] bpf: unbounded recursion when struct_ops mss_ceiling() calls
tcp_update_mss_ceiling()
- [Medium] tcp: max(mss_ceiling, min_snd_mss) in tcp_sync_mss()
overrides half-window bound
- [Medium] tcp: tcp_v6_mtu_reduced() drops valid IPv6 PMTU reductions
above mss_ceiling
- [Medium] tcp: mss_ceiling in tp->mss_cache corrupts MTU probing
search_low and snd_cwnd
--
commit 6a2835052973696e33d5f9fcd760f0e3858c0186
Author: Chia-Yu Chang <chia-yu.chang@nokia-bell-labs.com>
tcp: add MSS ceiling callback for congestion control
This commit adds an optional mss_ceiling() callback to struct
tcp_congestion_ops and a tcp_update_mss_ceiling() helper and BPF kfunc to
recompute tp->mss_cache when the congestion control module changes its MSS
ceiling.
> diff --git a/net/ipv4/bpf_tcp_ca.c b/net/ipv4/bpf_tcp_ca.c
> index 2a71dc81562f4..b03cc9e9c0641 100644
> --- a/net/ipv4/bpf_tcp_ca.c
> +++ b/net/ipv4/bpf_tcp_ca.c
> @@ -195,6 +195,7 @@ BTF_ID_FLAGS(func, tcp_reno_undo_cwnd)
> BTF_ID_FLAGS(func, tcp_slow_start)
> BTF_ID_FLAGS(func, tcp_cong_avoid_ai)
> BTF_ID_FLAGS(func, tcp_tso_autosize)
> +BTF_ID_FLAGS(func, tcp_update_mss_ceiling)
> BTF_KFUNCS_END(bpf_tcp_ca_check_kfunc_ids)
[Severity: High]
Can a BPF struct_ops congestion control program overflow the kernel stack
by calling tcp_update_mss_ceiling() from inside its mss_ceiling()
callback?
tcp_update_mss_ceiling() is exposed to all BPF_PROG_TYPE_STRUCT_OPS
callbacks without filtering out tcp_congestion_ops.mss_ceiling, and
bpf_prog_check_recur() does not enable runtime recursion checks on the
trampoline when jits_use_priv_stack is false:
tcp_sync_mss(sk, pmtu)
icsk->icsk_ca_ops->mss_ceiling(sk)
tcp_update_mss_ceiling(sk)
tcp_sync_mss(sk, icsk->icsk_pmtu_cookie)
icsk->icsk_ca_ops->mss_ceiling(sk) <-- unbounded recursion
[ ... ]
> diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
> index 7b694479095e0..96ed9ba7abe6d 100644
> --- a/net/ipv4/tcp_output.c
> +++ b/net/ipv4/tcp_output.c
> @@ -2147,6 +2147,21 @@ unsigned int tcp_sync_mss(struct sock *sk, u32 pmtu)
> mss_now = tcp_mtu_to_mss(sk, pmtu);
> mss_now = tcp_bound_to_half_wnd(tp, mss_now);
>
> + /*
> + * Apply an optional MSS ceiling requested by the congestion control
> + * module. Values below the effective minimum send MSS are clamped.
> + */
> + if (icsk->icsk_ca_initialized && icsk->icsk_ca_ops->mss_ceiling) {
> + u32 mss_ceiling = icsk->icsk_ca_ops->mss_ceiling(sk);
> +
> + if (mss_ceiling && mss_ceiling < mss_now) {
> + u32 min_snd_mss = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_min_snd_mss) -
> + (tcp_sk(sk)->tcp_header_len - sizeof(struct tcphdr));
> +
> + mss_now = max(mss_ceiling, min_snd_mss);
> + }
> + }
[Severity: Medium]
Can max(mss_ceiling, min_snd_mss) raise mss_now above the peer's
half-window bound from tcp_bound_to_half_wnd()?
tcp_mtu_to_mss() already enforces sysctl_tcp_min_snd_mss, after which
tcp_bound_to_half_wnd() can reduce mss_now below min_snd_mss when the peer
advertises a small receive window and sysctl_tcp_min_snd_mss is raised. If
mss_ceiling is smaller still, assigning max(mss_ceiling, min_snd_mss) after
tcp_bound_to_half_wnd() increases mss_now back up to min_snd_mss instead of
capping it.
> +
> /* And store cached results */
> icsk->icsk_pmtu_cookie = pmtu;
> if (icsk->icsk_mtup.enabled)
[Severity: Medium]
As reported by Eric Dumazet on v4 [1], does storing the ceiling-clamped
value in tp->mss_cache cause tcp_v6_mtu_reduced() to drop valid IPv6 PMTU
reductions above the ceiling?
net/ipv6/tcp_ipv6.c:tcp_v6_mtu_reduced() {
...
if (tcp_mtu_to_mss(sk, mtu) >= tcp_sk(sk)->mss_cache)
return;
...
}
When a Packet Too Big arrives with an MTU below icsk->icsk_pmtu_cookie
whose unclamped MSS is still at or above the ceiling-clamped tp->mss_cache,
tcp_v6_mtu_reduced() returns early without updating the route PMTU or
icsk_pmtu_cookie. Once the congestion control later raises its ceiling and
calls tcp_update_mss_ceiling(), tp->mss_cache is recomputed from the stale
icsk_pmtu_cookie and oversized packets are sent.
[Severity: Medium]
Does clamping tp->mss_cache to mss_ceiling also corrupt MTU probing
(icsk_mtup) state when probing is enabled?
When the reprobe timer fires in tcp_mtu_check_reprobe(), it sets
icsk->icsk_mtup.search_low = tcp_mss_to_mtu(sk, tcp_current_mss(sk)) from
the ceiling-clamped tp->mss_cache, so tcp_sync_mss() then clamps mss_now to
that search_low and prevents tp->mss_cache from rising when the congestion
control later increases its ceiling. In addition, when a probe succeeds,
tcp_mtup_probe_success() scales tp->snd_cwnd down by
tcp_mss_to_mtu(sk, tp->mss_cache) / icsk->icsk_mtup.probe_size assuming
tp->mss_cache will grow to probe_size, but tcp_sync_mss() re-clamps
tp->mss_cache to mss_ceiling and leaves snd_cwnd reduced.
> @@ -2190,6 +2205,18 @@ unsigned int tcp_current_mss(struct sock *sk)
> return mss_now;
> }
>
> +__bpf_kfunc unsigned int tcp_update_mss_ceiling(struct sock *sk)
> +{
> + struct inet_connection_sock *icsk = inet_csk(sk);
> +
> + if (icsk->icsk_ca_initialized &&
> + icsk->icsk_ca_ops->mss_ceiling &&
> + icsk->icsk_pmtu_cookie)
> + return tcp_sync_mss(sk, icsk->icsk_pmtu_cookie);
> + return tcp_sk(sk)->mss_cache;
> +}
> +EXPORT_SYMBOL_GPL(tcp_update_mss_ceiling);
[Severity: High]
Does gating on icsk->icsk_ca_initialized and icsk->icsk_ca_ops->mss_ceiling
skip applying the ceiling at connection establishment, inside ca_ops->init(),
and when switching congestion controls?
During connection setup, tcp_sync_mss() runs before tcp_init_transfer()
initializes congestion control, while icsk_ca_initialized is 0, and records
icsk_pmtu_cookie = pmtu without calling mss_ceiling(). When
tcp_init_congestion_control() then runs:
net/ipv4/tcp_cong.c:tcp_init_congestion_control() {
...
if (icsk->icsk_ca_ops->init)
icsk->icsk_ca_ops->init(sk);
...
icsk->icsk_ca_initialized = 1;
}
icsk_ca_initialized is set only after init() returns, so calling
tcp_update_mss_ceiling() from ca_ops->init() is a no-op, and nothing calls
tcp_sync_mss() once icsk_ca_initialized becomes 1 because dst_mtu(dst)
already matches icsk_pmtu_cookie. Conversely, switching via
setsockopt(TCP_CONGESTION) from a module with mss_ceiling() to one without
it (such as CUBIC) in tcp_reinit_congestion_control() never recomputes
tp->mss_cache, leaving the socket stuck at the previous module's ceiling
because tcp_update_mss_ceiling() requires icsk_ca_ops->mss_ceiling to be
non-NULL.
[1] https://lore.kernel.org/r/CAL4Wiip6JFsVH_WAn4HmrXCiuKEJCoZR9nUv9X7RZU73_YJyzw@mail.gmail.com
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130125658.20292-1-chia-yu.chang@nokia-bell-labs.com?part=4
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH net-next v5 4/4] tcp: add MSS ceiling callback for congestion control
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
1 sibling, 0 replies; 10+ messages in thread
From: netdev-bot+sashiko @ 2026-12-01 13:10 UTC (permalink / raw)
To: chia-yu.chang
Cc: emil, martin.lau, ast, kafai.wan, bpf, willemb, horms,
linux-kernel, kuba, netdev, pabeni, davem, edumazet, kuniyu, ij,
ncardwell, koen0607, g.white, ingemar.s.johansson,
mirja.kuehlewind, cheshire, rs.ietf, Jason_Livingood, vidhi_goel,
Mike_Rudolph, Jeff_Howe, srichard
Thank you for your contribution! Sashiko AI review found 5 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 2 · Low: 2
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] Unbounded recursion that can overflow the kernel stack.
- [Medium] The MSS ceiling only takes effect inside tcp_sync_mss(), and
nothing re-syncs mss_cache when the congestion control is initialised…
- [Medium] tcp: mss_ceiling in tp->mss_cache corrupts MTU probing
search_low and snd_cwnd
- [Low] The mss_ceiling() callback is documented in include/net/tcp.h as
returning 'the maximum value allowed for tp->mss_cache', but in…
- [Low] The patch adds a new tcp_congestion_ops member (mss_ceiling), a
matching BPF struct_ops CFI stub slot, and a new EXPORT_SYMBOL_GPL…
--
tcp: add MSS ceiling callback for congestion control
This adds an optional mss_ceiling() callback to tcp_congestion_ops.
tcp_sync_mss() uses it to cap tp->mss_cache. The patch also adds
tcp_update_mss_ceiling(), which is exported and registered as a tcp_ca
kfunc, so a congestion control can force mss_cache to be recomputed after
it changes its ceiling.
> diff --git a/net/ipv4/bpf_tcp_ca.c b/net/ipv4/bpf_tcp_ca.c
> index 2a71dc81562f4..b03cc9e9c0641 100644
> --- a/net/ipv4/bpf_tcp_ca.c
> +++ b/net/ipv4/bpf_tcp_ca.c
> @@ -195,6 +195,7 @@ BTF_ID_FLAGS(func, tcp_reno_undo_cwnd)
> BTF_ID_FLAGS(func, tcp_slow_start)
> BTF_ID_FLAGS(func, tcp_cong_avoid_ai)
> BTF_ID_FLAGS(func, tcp_tso_autosize)
> +BTF_ID_FLAGS(func, tcp_update_mss_ceiling)
[Severity: High]
Can a BPF mss_ceiling() implementation recurse without bound through this
kfunc?
bpf_tcp_ca_kfunc_set has only .owner and .set and no .filter, and it is
registered for BPF_PROG_TYPE_STRUCT_OPS. Every tcp_congestion_ops member
program can therefore call tcp_update_mss_ceiling(), including the program
that implements the new .mss_ceiling member.
On an established socket, icsk_ca_initialized, icsk_ca_ops->mss_ceiling and
icsk_pmtu_cookie are all set. The gate in tcp_update_mss_ceiling() passes,
so the calls go:
bpf mss_ceiling()
tcp_update_mss_ceiling()
tcp_sync_mss()
icsk->icsk_ca_ops->mss_ceiling()
tcp_update_mss_ceiling()
tcp_sync_mss()
...
The trampoline does not seem to stop this either. For STRUCT_OPS,
bpf_prog_check_recur() returns prog->aux->jits_use_priv_stack. That is
false for tcp_ca programs, so __bpf_prog_enter() runs without the
prog->active recursion check.
Each level adds a trampoline frame, up to 512 bytes of BPF stack, and the
tcp_update_mss_ceiling() and tcp_sync_mss() frames. Any tcp_sync_mss() on
such a socket can start the loop, for example:
- tcp_current_mss() on a PMTU change
- tcp_v4_mtu_reduced()
- tcp_ack_update_window() when the peer window grows
net/core/filter.c uses bpf_chg_cc_inprogress to guard a similar struct_ops
self-recursion in bpf_setsockopt(TCP_CONGESTION). Does this path need a
re-entrancy guard, or a kfunc filter that keeps the mss_ceiling member from
calling this kfunc?
> BTF_KFUNCS_END(bpf_tcp_ca_check_kfunc_ids)
>
> static const struct btf_kfunc_id_set bpf_tcp_ca_kfunc_set = {
[ ... ]
> diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
> index 7b694479095e0..96ed9ba7abe6d 100644
> --- a/net/ipv4/tcp_output.c
> +++ b/net/ipv4/tcp_output.c
> @@ -2147,6 +2147,21 @@ unsigned int tcp_sync_mss(struct sock *sk, u32 pmtu)
> mss_now = tcp_mtu_to_mss(sk, pmtu);
> mss_now = tcp_bound_to_half_wnd(tp, mss_now);
>
> + /*
> + * Apply an optional MSS ceiling requested by the congestion control
> + * module. Values below the effective minimum send MSS are clamped.
> + */
> + if (icsk->icsk_ca_initialized && icsk->icsk_ca_ops->mss_ceiling) {
> + u32 mss_ceiling = icsk->icsk_ca_ops->mss_ceiling(sk);
> +
> + if (mss_ceiling && mss_ceiling < mss_now) {
> + u32 min_snd_mss = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_min_snd_mss) -
> + (tcp_sk(sk)->tcp_header_len - sizeof(struct tcphdr));
> +
> + mss_now = max(mss_ceiling, min_snd_mss);
[Severity: Medium]
Does folding the CC ceiling into tp->mss_cache confuse MTU probing?
When icsk_mtup.enabled is set (tcp_mtu_probing=2, or 1 after a
blackhole is detected), the probing code treats tp->mss_cache as the
MSS the path is currently known to carry. With this change it can be
the much smaller CC ceiling instead. That value then leaks into the
search state in two places.
First, tcp_mtu_check_reprobe() rebuilds the search range from the
cached value once tcp_probe_interval has elapsed:
net/ipv4/tcp_output.c:tcp_mtu_check_reprobe() {
...
int mss = tcp_current_mss(sk);
...
icsk->icsk_mtup.search_low = tcp_mss_to_mtu(sk, mss);
...
}
If the ceiling is in effect at that point, search_low drops to the MTU
that matches the ceiling. Later the CC may raise or drop its ceiling
and call tcp_update_mss_ceiling(). tcp_sync_mss() still applies
min(mss_now, tcp_mtu_to_mss(sk, search_low)), so mss_cache stays at
the old ceiling. It only recovers as new probes succeed and walk
search_low back up.
Second, tcp_mtu_probe() picks probe_size from search_low and
search_high without looking at the ceiling. The probe segment is
therefore larger than what the CC asked for. When it is ACKed,
tcp_mtup_probe_success() rescales cwnd on the assumption that
mss_cache is about to grow to the probe size:
net/ipv4/tcp_input.c:tcp_mtup_probe_success() {
...
val = (u64)tcp_snd_cwnd(tp) * tcp_mss_to_mtu(sk, tp->mss_cache);
do_div(val, icsk->icsk_mtup.probe_size);
...
icsk->icsk_mtup.search_low = icsk->icsk_mtup.probe_size;
icsk->icsk_mtup.probe_size = 0;
tcp_sync_mss(sk, icsk->icsk_pmtu_cookie);
...
}
The final tcp_sync_mss() re-applies the ceiling, so mss_cache does not
grow. By then snd_cwnd has already been scaled by the ratio of the
mss_cache MTU to probe_size. With a 500 byte ceiling and a 1500 byte
probe, cwnd is cut to roughly a third, and no larger segments make up
for it. Every further successful probe in the same search cuts it
again.
Should the ceiling be kept apart from the path MSS that MTU probing
works with? For example, tcp_mtu_check_reprobe() and
tcp_mtup_probe_success() could use the uncapped value, or the ceiling
could be applied somewhere other than tp->mss_cache. Or is the intent
that a CC using mss_ceiling() is never combined with icsk_mtup?
[Severity: Low]
Can this raise mss_cache instead of capping it?
include/net/tcp.h documents the callback as returning "the maximum value
allowed for tp->mss_cache". At this point, though, mss_now has already been
through tcp_bound_to_half_wnd(). That function can lower it below
sysctl_tcp_min_snd_mss, down to max(cutoff, 68 - tcp_header_len). The max()
here can then push it back above that bound.
For example, take tcp_min_snd_mss = 1000, timestamps enabled, and a peer
max_window of 1200. Then cutoff is 600 and mss_now is 600. If mss_ceiling()
returns 300, mss_now becomes max(300, 988) = 988, which is above the
half-window bound computed just before.
Would min(mss_now, max(mss_ceiling, min_snd_mss)) keep the documented
semantics?
Also, the comment in include/net/tcp.h does not say that a return value of
0 means no ceiling. This code and the BPF CFI stub both rely on that.
> + }
> + }
> +
> /* And store cached results */
> icsk->icsk_pmtu_cookie = pmtu;
> if (icsk->icsk_mtup.enabled)
> @@ -2190,6 +2205,18 @@ unsigned int tcp_current_mss(struct sock *sk)
> return mss_now;
> }
>
> +__bpf_kfunc unsigned int tcp_update_mss_ceiling(struct sock *sk)
> +{
> + struct inet_connection_sock *icsk = inet_csk(sk);
> +
> + if (icsk->icsk_ca_initialized &&
> + icsk->icsk_ca_ops->mss_ceiling &&
> + icsk->icsk_pmtu_cookie)
[Severity: Medium]
Does this gate turn the helper into a no-op in the two places a congestion
control is most likely to need it?
First, tcp_init_congestion_control() calls ->init() before it sets
icsk_ca_initialized:
net/ipv4/tcp_cong.c:tcp_init_congestion_control() {
...
if (icsk->icsk_ca_ops->init)
icsk->icsk_ca_ops->init(sk);
...
icsk->icsk_ca_initialized = 1;
}
So if a CC calls tcp_update_mss_ceiling() from init(), nothing happens. The
connection-setup tcp_sync_mss() calls also all run before CA init:
- tcp_connect_init()
- tcp_rcv_synsent_state_process(), before tcp_finish_connect()
- tcp_v4_syn_recv_sock() and tcp_v6_syn_recv_sock()
As a result the ceiling is not in effect when the connection becomes
established. It stays off until some unrelated tcp_sync_mss() trigger.
Second, tcp_reinit_congestion_control() swaps icsk_ca_ops and calls
tcp_init_congestion_control(), but it never calls tcp_sync_mss(). Suppose a
socket switches with setsockopt(TCP_CONGESTION) from a CC that set a
ceiling to one without mss_ceiling, such as cubic. tp->mss_cache keeps the
reduced value. This helper cannot fix that, because it returns early when
the new ops have no mss_ceiling.
After that, mss_cache is only recomputed on a PMTU change, a successful MTU
probe, peer window growth in tcp_ack_update_window(), or a mss_clamp
change. On a stable path with tcp_mtu_probing=0 and a steady peer window,
would the old CC's ceiling stay in effect for the rest of the connection?
> + return tcp_sync_mss(sk, icsk->icsk_pmtu_cookie);
> + return tcp_sk(sk)->mss_cache;
> +}
> +EXPORT_SYMBOL_GPL(tcp_update_mss_ceiling);
[Severity: Low]
This isn't a bug, but nothing in the tree uses the new mss_ceiling member
or the tcp_update_mss_ceiling() export and kfunc. There is also no BPF
selftest under tools/testing/selftests/bpf for the new struct_ops member or
the kfunc. The only stated user is the upcoming TCP Prague.
Could an in-tree user or a selftest be added with this series? No existing
test would catch the issues above.
> +
> /* RFC2861, slow part. Adjust cwnd, after it was not full during one rto.
> * As additional protections, we do not touch cwnd in retransmission phases,
> * and if application hit its sndbuf limit recently.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130125658.20292-1-chia-yu.chang%40nokia-bell-labs.com
^ permalink raw reply [flat|nested] 10+ messages in thread