Skip to content

Commit

Permalink
fix(smoltcp): use the patched upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
XOR-op committed Sep 22, 2024
1 parent 5430820 commit 90264cf
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 13 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 @@ -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"}
3 changes: 2 additions & 1 deletion boltconn/src/common/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ impl IdGenerator {
}
}

#[allow(unused)]
pub struct TputMeasurement {
inner: std::sync::Mutex<TputMeasurementInner>,
}
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions boltconn/src/transport/smol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -786,7 +786,7 @@ pub struct VirtualRxToken {
}

impl RxToken for VirtualRxToken {
fn consume<R, F: FnOnce(&mut [u8]) -> R>(mut self, f: F) -> R {
fn consume<R, F: FnOnce(&[u8]) -> R>(mut self, f: F) -> R {
f(&mut self.buf)
}
}
Expand Down
7 changes: 0 additions & 7 deletions boltconn/src/transport/wireguard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ struct WireguardTunnelInner {
smol_notify: Arc<Notify>,
inbound_buf_pool: Arc<Pool<Vec<u8>>>,
reserved: Option<[u8; 3]>,
metric: crate::common::utils::TputMeasurement,
}

impl WireguardTunnel {
Expand Down Expand Up @@ -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,
)),
},
})
}
Expand All @@ -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()
Expand Down

0 comments on commit 90264cf

Please sign in to comment.