Skip to content

Commit

Permalink
feat(quic): allow disabling of path MTU discovery
Browse files Browse the repository at this point in the history
Path MTU discovery seems to be broken in QUIC right now on Windows and we had to disable it in Subspace.

Related: autonomys/subspace#2195.

Pull-Request: #4823.

Co-authored-by: Shamil Gadelshin <[email protected]>
  • Loading branch information
nazar-pc and shamil-gadelshin authored Nov 12, 2023
1 parent 441c242 commit 3ec575a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
5 changes: 5 additions & 0 deletions transports/quic/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion transports/quic/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "libp2p-quic"
version = "0.10.0"
version = "0.10.1"
authors = ["Parity Technologies <[email protected]>"]
edition = "2021"
rust-version = { workspace = true }
Expand Down
14 changes: 13 additions & 1 deletion transports/quic/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -63,6 +63,9 @@ pub struct Config {
server_tls_config: Arc<rustls::ServerConfig>,
/// Libp2p identity of the node.
keypair: libp2p_identity::Keypair,

/// Parameters governing MTU discovery. See [`MtuDiscoveryConfig`] for details.
mtu_discovery_config: Option<MtuDiscoveryConfig>,
}

impl Config {
Expand All @@ -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`].
Expand All @@ -108,6 +118,7 @@ impl From<Config> for QuinnConfig {
support_draft_29,
handshake_timeout: _,
keypair,
mtu_discovery_config,
} = config;
let mut transport = quinn::TransportConfig::default();
// Disable uni-directional streams.
Expand All @@ -120,6 +131,7 @@ impl From<Config> 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);
Expand Down

0 comments on commit 3ec575a

Please sign in to comment.