Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
runner = ["qemu-aarch64-static"] # use qemu user emulation for cargo run and test
runner = ["qemu-aarch64-static"] # use qemu user emulation for cargo run and test
52 changes: 52 additions & 0 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion lightway-app-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ readme = "README.md"

[features]
default = [ "tokio" ]
io-uring = [ "dep:io-uring", "dep:tokio", "dep:tokio-eventfd" ]
io-uring = [ "dep:io-uring", "dep:tokio", "dep:tokio-eventfd", "dep:parking_lot" ]
tokio = [ "dep:tokio", "dep:tokio-stream" ]

[lints]
Expand All @@ -28,6 +28,7 @@ ipnet.workspace = true
libc.workspace = true
lightway-core.workspace = true
metrics.workspace = true
parking_lot = { version = "0.12.3", optional = true }
serde.workspace = true
serde_with = "3.4.0"
serde_yaml = "0.9.34"
Expand Down
16 changes: 13 additions & 3 deletions lightway-app-utils/examples/udprelay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,18 @@ struct TunIOUring {

impl TunIOUring {
async fn new(tun: Tun, ring_size: usize, channel_size: usize) -> Result<Self> {
let tun_iouring = IOUring::new(
let tun_iouring = match IOUring::new(
Arc::new(WrappedTun(tun)),
ring_size,
channel_size,
TUN_MTU,
Duration::from_millis(100),
)
.await?;
.await
{
Ok(it) => it,
Err(err) => return Err(err),
};

Ok(Self { tun_iouring })
}
Expand All @@ -231,7 +235,13 @@ impl TunAdapter for TunIOUring {
}

async fn recv_from_tun(&self) -> Result<BytesMut> {
self.tun_iouring.recv().await.map_err(anyhow::Error::msg)
match self.tun_iouring.recv().await {
IOCallbackResult::Ok(pkt) => Ok(pkt),
IOCallbackResult::WouldBlock => {
Err(std::io::Error::from(std::io::ErrorKind::WouldBlock).into())
}
IOCallbackResult::Err(err) => Err(err.into()),
}
}
}

Expand Down
Loading
Loading