From ad6b3a0654675c94a31822789ee3b74d3a78dd3f Mon Sep 17 00:00:00 2001 From: Jerome Gravel-Niquet Date: Sun, 20 Aug 2023 19:28:23 -0400 Subject: [PATCH] allow disabling GSO for problematic setups --- Cargo.lock | 8 ++++---- crates/corro-agent/src/agent.rs | 8 ++++---- crates/corro-agent/src/api/peer.rs | 5 +++++ crates/corro-types/src/config.rs | 3 +++ examples/fly/config.toml | 1 + 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6da6d3c4..10b8c429 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2499,9 +2499,9 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.10.2" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8c8bb234e70c863204303507d841e7fa2295e95c822b2bb4ca8ebf57f17b1cb" +checksum = "b83c2a964b8b68e6c9c616f09b735b436a78843704fa6979a076073e622f69dc" dependencies = [ "bytes", "rand", @@ -2517,9 +2517,9 @@ dependencies = [ [[package]] name = "quinn-udp" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6df19e284d93757a9fb91d63672f7741b129246a669db09d1c0063071debc0c0" +checksum = "055b4e778e8feb9f93c4e439f71dc2156ef13360b432b799e179a8c4cdf0b1d7" dependencies = [ "bytes", "libc", diff --git a/crates/corro-agent/src/agent.rs b/crates/corro-agent/src/agent.rs index 3a6ef53b..2eb7d059 100644 --- a/crates/corro-agent/src/agent.rs +++ b/crates/corro-agent/src/agent.rs @@ -326,13 +326,13 @@ pub async fn run(agent: Agent, opts: AgentOptions) -> eyre::Result<()> { let tripwire = tripwire.clone(); tokio::spawn(async move { let remote_addr = connecting.remote_address(); - let local_ip = connecting.local_ip().unwrap(); + // let local_ip = connecting.local_ip().unwrap(); debug!("got a connection from {remote_addr}"); let conn = match connecting.await { Ok(conn) => conn, Err(e) => { - error!("could not connection from {remote_addr} to {local_ip}: {e}"); + error!("could not connection from {remote_addr}: {e}"); return; } }; @@ -793,7 +793,7 @@ pub async fn run(agent: Agent, opts: AgentOptions) -> eyre::Result<()> { )); let gossip_chunker = - ReceiverStream::new(bcast_rx).chunks_timeout(512, Duration::from_millis(500)); + ReceiverStream::new(bcast_rx).chunks_timeout(10, Duration::from_millis(500)); tokio::pin!(gossip_chunker); loop { @@ -1100,7 +1100,7 @@ async fn generate_bootstrap( // fallback to in-db nodes let conn = pool.read().await?; addrs = block_in_place(|| { - let mut prepped = conn.prepare("select address from __corro_members limit 5")?; + let mut prepped = conn.prepare("SELECT address FROM __corro_members LIMIT 5")?; let node_addrs = prepped.query_map([], |row| row.get::<_, String>(0))?; Ok::<_, rusqlite::Error>( node_addrs diff --git a/crates/corro-agent/src/api/peer.rs b/crates/corro-agent/src/api/peer.rs index ce1029a8..85f9e535 100644 --- a/crates/corro-agent/src/api/peer.rs +++ b/crates/corro-agent/src/api/peer.rs @@ -88,6 +88,10 @@ fn build_quinn_transport_config(config: &GossipConfig) -> quinn::TransportConfig transport_config.mtu_discovery_config(Some(mtu_discovery)); } + if config.disable_gso { + transport_config.enable_segmentation_offload(false); + } + transport_config } @@ -694,6 +698,7 @@ mod tests { }), plaintext: false, max_mtu: None, + disable_gso: false, }; let server = gossip_server_endpoint(&gossip_config).await?; diff --git a/crates/corro-types/src/config.rs b/crates/corro-types/src/config.rs index c168ed8f..08ceb01b 100644 --- a/crates/corro-types/src/config.rs +++ b/crates/corro-types/src/config.rs @@ -80,6 +80,8 @@ pub struct GossipConfig { pub plaintext: bool, #[serde(default)] pub max_mtu: Option, + #[serde(default)] + pub disable_gso: bool, } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -233,6 +235,7 @@ impl ConfigBuilder { plaintext: self.tls.is_none(), tls: self.tls, max_mtu: None, // TODO: add a builder function for it + disable_gso: false, }, admin: AdminConfig { uds_path: self.admin_path.unwrap_or_else(default_admin_path), diff --git a/examples/fly/config.toml b/examples/fly/config.toml index d328243d..5bfac59d 100644 --- a/examples/fly/config.toml +++ b/examples/fly/config.toml @@ -7,6 +7,7 @@ addr = "fly-local-6pn:8787" bootstrap = ["corrosion2.internal:8787"] plaintext = true max_mtu = 1372 +disable_gso = true [api] addr = "[::]:8080"