diff --git a/Cargo.lock b/Cargo.lock index 6bece6d..bdbafae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4069,7 +4069,7 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "smoltcp" version = "0.11.0" -source = "git+https://github.com/XOR-op/smoltcp.git?branch=resize-recv-buffer#1555b5e0c1145df92bfbbb4221d550d73efb3b34" +source = "git+https://github.com/XOR-op/smoltcp.git?branch=rcv-buf-pinned#60ede1b4ef49426c794b1b25c5c7e39ac3a0f97f" dependencies = [ "bitflags 1.3.2", "byteorder", diff --git a/Cargo.toml b/Cargo.toml index c039c21..4fe1698 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,6 @@ debug = true [patch.crates-io] rustls = { git = "https://github.com/XOR-op/rustls.delta.git", branch = "unofficial-rel-0.23" } -smoltcp = { git = "https://github.com/XOR-op/smoltcp.git", branch = "resize-recv-buffer" } +smoltcp = { git = "https://github.com/XOR-op/smoltcp.git", branch = "rcv-buf-pinned" } # Only used to bump x25519-dalek; will be removed once 0.6.1 is released boringtun = { git = "https://github.com/XOR-op/boringtun", branch = "master"} diff --git a/boltconn/src/common/utils.rs b/boltconn/src/common/utils.rs index 2722eef..4d51e8b 100644 --- a/boltconn/src/common/utils.rs +++ b/boltconn/src/common/utils.rs @@ -10,6 +10,7 @@ impl IdGenerator { } } +#[allow(unused)] pub struct TputMeasurement { inner: std::sync::Mutex, } @@ -36,7 +37,7 @@ impl TputMeasurement { inner.accum_bytes += bytes as u64; let now = Instant::now(); let elapsed = now - inner.last_time; - if elapsed >= inner.interval || inner.accum_bytes > 1024 * 1024 { + if elapsed >= inner.interval { let tput = inner.accum_bytes as f64 / elapsed.as_secs_f64(); inner.accum_bytes = 0; inner.last_time = now; diff --git a/boltconn/src/transport/smol.rs b/boltconn/src/transport/smol.rs index dd88f96..f1e9cdd 100644 --- a/boltconn/src/transport/smol.rs +++ b/boltconn/src/transport/smol.rs @@ -15,7 +15,7 @@ use hickory_proto::TokioTime; use hickory_resolver::name_server::RuntimeProvider; use hickory_resolver::TokioHandle; use rand::Rng; -use smoltcp::iface::{Interface, SocketHandle, SocketSet}; +use smoltcp::iface::{Interface, PollResult, SocketHandle, SocketSet}; use smoltcp::phy::{Device, DeviceCapabilities, Medium, RxToken, TxToken}; use smoltcp::socket::{ tcp::Socket as SmolTcpSocket, udp::PacketBuffer as UdpSocketBuffer, @@ -427,7 +427,7 @@ impl SmolStack { } } - pub fn drive_iface(&mut self) -> bool { + pub fn drive_iface(&mut self) -> PollResult { self.iface.poll( SmolInstant::now(), &mut self.ip_device, @@ -786,7 +786,7 @@ pub struct VirtualRxToken { } impl RxToken for VirtualRxToken { - fn consume R>(mut self, f: F) -> R { + fn consume R>(mut self, f: F) -> R { f(&mut self.buf) } } diff --git a/boltconn/src/transport/wireguard.rs b/boltconn/src/transport/wireguard.rs index 3d291d6..316204a 100644 --- a/boltconn/src/transport/wireguard.rs +++ b/boltconn/src/transport/wireguard.rs @@ -92,7 +92,6 @@ struct WireguardTunnelInner { smol_notify: Arc, inbound_buf_pool: Arc>>, reserved: Option<[u8; 3]>, - metric: crate::common::utils::TputMeasurement, } impl WireguardTunnel { @@ -194,9 +193,6 @@ impl WireguardTunnel { smol_notify, inbound_buf_pool: buf_pool, reserved: config.reserved, - metric: crate::common::utils::TputMeasurement::new(std::time::Duration::from_secs( - 1, - )), }, }) } @@ -211,9 +207,6 @@ impl WireguardTunnel { let len = self.inner.outbound_recv(buf).await?; // Indeed we can achieve zero-copy with the implementation of ring, // but there is no hard guarantee for that, so we just manually copy buffer. - if let Some(tput) = self.inner.metric.update_to_mbps(len) { - // tracing::debug!("WireGuard inbound throughput: {:.2} Mbps", tput); - } let result = self .tunnel .lock()