diff --git a/Cargo.lock b/Cargo.lock index 4622790ff63..3f54623dca5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2973,7 +2973,7 @@ dependencies = [ [[package]] name = "libp2p-quic" -version = "0.10.0" +version = "0.10.1" dependencies = [ "async-std", "bytes", diff --git a/Cargo.toml b/Cargo.toml index dda224934c2..27a8214ed6f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -93,7 +93,7 @@ libp2p-perf = { version = "0.3.0", path = "protocols/perf" } libp2p-ping = { version = "0.44.0", path = "protocols/ping" } libp2p-plaintext = { version = "0.41.0", path = "transports/plaintext" } libp2p-pnet = { version = "0.24.0", path = "transports/pnet" } -libp2p-quic = { version = "0.10.0", path = "transports/quic" } +libp2p-quic = { version = "0.10.1", path = "transports/quic" } libp2p-relay = { version = "0.17.0", path = "protocols/relay" } libp2p-rendezvous = { version = "0.14.0", path = "protocols/rendezvous" } libp2p-request-response = { version = "0.26.0", path = "protocols/request-response" } diff --git a/transports/quic/CHANGELOG.md b/transports/quic/CHANGELOG.md index 49438fa7ebb..8da8f1634a3 100644 --- a/transports/quic/CHANGELOG.md +++ b/transports/quic/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.10.1 - unreleased + +- Allow disabling path MTU discovery. + See [PR 4823](https://github.com/libp2p/rust-libp2p/pull/4823). + ## 0.10.0 - Improve hole-punch timing. diff --git a/transports/quic/Cargo.toml b/transports/quic/Cargo.toml index 4ce23bf1207..013d2269980 100644 --- a/transports/quic/Cargo.toml +++ b/transports/quic/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libp2p-quic" -version = "0.10.0" +version = "0.10.1" authors = ["Parity Technologies "] edition = "2021" rust-version = { workspace = true } diff --git a/transports/quic/src/config.rs b/transports/quic/src/config.rs index 5351a537c76..4e4bb94cd7a 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. @@ -63,6 +63,9 @@ pub struct Config { server_tls_config: Arc, /// Libp2p identity of the node. keypair: libp2p_identity::Keypair, + + /// Parameters governing MTU discovery. See [`MtuDiscoveryConfig`] for details. + mtu_discovery_config: Option, } impl Config { @@ -83,8 +86,15 @@ impl Config { // Ensure that one stream is not consuming the whole connection. max_stream_data: 10_000_000, keypair: keypair.clone(), + mtu_discovery_config: Some(Default::default()), } } + + /// Disable MTU path discovery (it is enabled by default). + pub fn disable_path_mtu_discovery(mut self) -> Self { + self.mtu_discovery_config = None; + self + } } /// Represents the inner configuration for [`quinn`]. @@ -108,6 +118,7 @@ impl From for QuinnConfig { support_draft_29, handshake_timeout: _, keypair, + mtu_discovery_config, } = config; let mut transport = quinn::TransportConfig::default(); // Disable uni-directional streams. @@ -120,6 +131,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(mtu_discovery_config); let transport = Arc::new(transport); let mut server_config = quinn::ServerConfig::with_crypto(server_tls_config);