From a4920eded77d6f9e0765f455530548a5a88988fa Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Thu, 2 Nov 2023 20:01:21 +0700 Subject: [PATCH] (feat) quic: Add path MTU discovery configuration. # Conflicts: # transports/quic/src/config.rs --- transports/quic/src/config.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/transports/quic/src/config.rs b/transports/quic/src/config.rs index 201594e247c..646fbb17620 100644 --- a/transports/quic/src/config.rs +++ b/transports/quic/src/config.rs @@ -18,7 +18,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -use quinn::VarInt; +use quinn::{MtuDiscoveryConfig, VarInt}; use std::{sync::Arc, time::Duration}; /// Config for the transport. @@ -61,6 +61,9 @@ pub struct Config { client_tls_config: Arc, /// TLS server config for the inner [`quinn::ServerConfig`]. server_tls_config: Arc, + + /// Parameters governing MTU discovery. See [`MtuDiscoveryConfig`] for details. + path_mtu_discovery_config: Option, } impl Config { @@ -80,8 +83,17 @@ impl Config { // Ensure that one stream is not consuming the whole connection. max_stream_data: 10_000_000, + path_mtu_discovery_config: Some(Default::default()), } } + + pub fn path_mtu_discovery_config( + mut self, + path_mtu_discovery_config: Option, + ) -> Self { + self.path_mtu_discovery_config = path_mtu_discovery_config; + self + } } /// Represents the inner configuration for [`quinn`]. @@ -104,6 +116,7 @@ impl From for QuinnConfig { max_stream_data, support_draft_29, handshake_timeout: _, + path_mtu_discovery_config, } = config; let mut transport = quinn::TransportConfig::default(); // Disable uni-directional streams. @@ -116,6 +129,7 @@ impl From for QuinnConfig { transport.allow_spin(false); transport.stream_receive_window(max_stream_data.into()); transport.receive_window(max_connection_data.into()); + transport.mtu_discovery_config(path_mtu_discovery_config); let transport = Arc::new(transport); let mut server_config = quinn::ServerConfig::with_crypto(server_tls_config);