Files
firezone/rust/bin-shared/Cargo.toml
Thomas Eizinger 33c707dbf6 feat(windows): introduce dedicated "TUN send" thread (#8159)
Same as done for unix-based operation systems in #8117, we introduce a
dedicated "TUN send" thread for Windows in this PR. Not only does this
move the syscalls and copying of sending packets away from `connlib`'s
main thread but it also establishes backpressure between those threads
properly.

WinTUN does not have any ability to signal that it has space in its send
buffer. If it fails to allocate a packet for sending, it will return
`ERROR_BUFFER_OVERFLOW` [0]. We now handle this case gracefully by
suspending the send thread for 10ms and then try again. This isn't a
great way of establishing back-pressure but at least we don't have any
packet loss.

To test this, I temporarily lowered the ring buffer size and ran a speed
test. In that, I could confirm that `ERROR_BUFFER_OVERFLOW` is indeed
emitted and handled as intended.

[0]: https://git.zx2c4.com/wintun/tree/api/session.c#n267
2025-02-17 20:33:45 +00:00

75 lines
2.3 KiB
TOML

[package]
name = "firezone-bin-shared"
version = "0.1.0"
edition = { workspace = true }
description = "Firezone-specific modules shared between binaries."
license = { workspace = true }
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
anyhow = { workspace = true }
axum = { workspace = true, features = ["http1", "tokio"] }
clap = { workspace = true, features = ["derive", "env"] }
firezone-logging = { workspace = true }
futures = { workspace = true, features = ["std", "async-await"] }
hex-literal = { workspace = true }
ip-packet = { workspace = true }
ip_network = { workspace = true, features = ["serde"] }
socket-factory = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true, features = ["io-util", "net", "rt", "sync"] }
tracing = { workspace = true }
tun = { workspace = true }
[dev-dependencies]
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
[target.'cfg(target_os = "linux")'.dependencies]
flume = { workspace = true }
libc = { workspace = true }
netlink-packet-core = { version = "0.7" }
netlink-packet-route = { version = "0.19" }
nix = { workspace = true, features = ["socket"] }
rtnetlink = { workspace = true }
zbus = "4.4" # Can't use `zbus`'s `tokio` feature here, or it will break toast popups all the way over in `gui-client`.
[target.'cfg(windows)'.dependencies]
known-folders = { workspace = true }
ring = "0.17"
uuid = { workspace = true, features = ["v4"] }
windows-core = "0.58.0"
windows-implement = "0.58.0"
wintun = "0.5.1"
winreg = { workspace = true }
tokio-util = { workspace = true }
[target.'cfg(windows)'.dependencies.windows]
workspace = true
features = [
# For implementing COM interfaces
"implement",
"Win32_Foundation",
# For listening for network change events
"Win32_Networking_NetworkListManager",
"Win32_NetworkManagement_IpHelper",
"Win32_NetworkManagement_Ndis",
"Win32_Networking_WinSock",
"Win32_Security",
# COM is needed to listen for network change events
"Win32_System_Com",
# Needed to listen for system DNS changes
"Win32_System_Registry",
"Win32_System_Threading",
]
[target.'cfg(windows)'.dev-dependencies]
ip-packet = { workspace = true }
tokio = { workspace = true, features = ["net", "time"] }
[lints]
workspace = true
[[bench]]
name = "tunnel"
harness = false