feat(client_mss): chunk only the start of the initial server response

With client_mss_bulk the whole authenticated FakeTLS response (ServerHello,
CCS, emulated certificate records, tickets - typically ~4 KiB) was written in
client_mss-sized chunks: about 50 segments at `tspu`. With ~2% loss at least
one segment is lost in ~64% of handshakes, and the burst takes several RTTs
to pass the initial congestion window.

- New server.client_mss_prefix (Linux, requires client_mss_bulk): `full`
  (default, current behavior), `server-hello` (through the end of the first
  TLS record, capped at 2048 bytes, falls back to `full` on unexpected input)
  or a byte count. Only that prefix is written in MSG_EOR chunks; the rest
  goes out in one write at the bulk MSS.
- Chunk payload accounts for TCP timestamps and never exceeds tcpi_snd_mss.
- Removed TcpMaxSegmentGuard: TCP_MAXSEG on an established socket does not
  change the MSS of outgoing segments on Linux, and its getsockopt/setsockopt
  failures no longer abort the handshake. TCP_NODELAY is set once.
- Docs (en/ru/de), API discovery metadata, strict keys, reload diff.
This commit is contained in:
Andrey Osipuk
2026-11-09 15:36:29 +03:00
parent 66708d2866
commit 7e6fc15ef2
25 changed files with 777 additions and 155 deletions
+1
View File
@@ -196,6 +196,7 @@ const SERVER_CONFIG_KEYS: &[&str] = &[
"listen_tcp",
"client_mss",
"client_mss_bulk",
"client_mss_prefix",
"proxy_protocol",
"proxy_protocol_header_timeout_ms",
"proxy_protocol_trusted_cidrs",
+4
View File
@@ -59,6 +59,10 @@ pub(super) fn validate(config: &mut ProxyConfig) -> Result<()> {
.server
.client_mss_bulk_value()
.map_err(|error| ProxyError::Config(format!("server.client_mss_bulk {error}")))?;
config
.server
.client_mss_prefix_value()
.map_err(|error| ProxyError::Config(format!("server.client_mss_prefix {error}")))?;
for (idx, listener) in config.server.listeners.iter().enumerate() {
if listener.client_mss.is_some() {
listener
+9
View File
@@ -124,11 +124,20 @@ pub(super) fn validate_listener_runtime_profiles(config: &ProxyConfig) -> Result
}
}
let prefix = config
.server
.client_mss_prefix_value()
.map_err(|error| ProxyError::Config(format!("server.client_mss_prefix {error}")))?;
let Some(bulk_mss) = config
.server
.client_mss_bulk_value()
.map_err(|error| ProxyError::Config(format!("server.client_mss_bulk {error}")))?
else {
if prefix.is_some() {
return Err(ProxyError::Config(
"server.client_mss_prefix requires server.client_mss_bulk".to_string(),
));
}
return Ok(());
};
if !cfg!(target_os = "linux") {