[PATCH net-next v3 4/4] tcp: add MSS ceiling callback for congestion control

From: chia-yu . chang

Date: Fri Nov 13 2026 - 15:36:30 EST


From: Chia-Yu Chang <chia-yu.chang@xxxxxxxxxxxxxxxxxxx>

Allow congestion control modules to provide an optional MSS ceiling
through the new mss_ceiling() callback. The TCP stack derives MSS
from PMTU discovery and existing MSS constraints, while the congestion
control may further reduce the effective MSS when needed. The ceiling
is applied during MSS calculation and remains subject to existing PMTU
updates.

Also, tcp_update_mss() is added to allow congestion control modules to
request immediate MSS recomputation 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., below 1Mbps,
and benefit from reducing the effective MSS while still preserving normal
PMTU handling.

Signed-off-by: Chia-Yu Chang <chia-yu.chang@xxxxxxxxxxxxxxxxxxx>

--
v3:
- Replace mss_cache_set_by_cca with mss_ceiling() callback
- Add tcp_update_mss() helper for immediate MSS recomputation
---
include/net/tcp.h | 4 ++++
net/ipv4/tcp_output.c | 16 ++++++++++++++++
2 files changed, 20 insertions(+)

diff --git a/include/net/tcp.h b/include/net/tcp.h
index 0242fd6bbb07..9d398ae09015 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -858,6 +858,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(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,
@@ -1417,6 +1418,9 @@ struct tcp_congestion_ops {
/* returns the multiplier used in tcp_sndbuf_expand (optional) */
u32 (*sndbuf_expand)(struct sock *sk);

+ /* returns the MSS upper bound (optional) */
+ 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/tcp_output.c b/net/ipv4/tcp_output.c
index 7b694479095e..f70dddd7283b 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2062,6 +2062,10 @@ static inline int __tcp_mtu_to_mss(struct sock *sk, int pmtu)

mss_now -= psp_sk_overhead(sk);

+ /* Apply MSS ceiling from congestion control module, if any */
+ if (icsk->icsk_ca_ops->mss_ceiling)
+ mss_now = min_t(u32, mss_now, icsk->icsk_ca_ops->mss_ceiling(sk));
+
/* Clamp it (mss_clamp does not include tcp options) */
if (mss_now > tp->rx_opt.mss_clamp)
mss_now = tp->rx_opt.mss_clamp;
@@ -2082,6 +2086,7 @@ int tcp_mtu_to_mss(struct sock *sk, int pmtu)
return __tcp_mtu_to_mss(sk, pmtu) -
(tcp_sk(sk)->tcp_header_len - sizeof(struct tcphdr));
}
+EXPORT_SYMBOL(tcp_mtu_to_mss);

/* Inverse of above */
int tcp_mss_to_mtu(struct sock *sk, int mss)
@@ -2190,6 +2195,17 @@ unsigned int tcp_current_mss(struct sock *sk)
return mss_now;
}

+unsigned int tcp_update_mss(struct sock *sk)
+{
+ struct dst_entry *dst = __sk_dst_get(sk);
+ struct tcp_sock *tp = tcp_sk(sk);
+
+ if (!dst)
+ return tp->mss_cache;
+ return tcp_sync_mss(sk, dst_mtu(dst));
+}
+EXPORT_SYMBOL_GPL(tcp_update_mss);
+
/* 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