diff options
| author | Sebastian Holmin <sebastian.holmin@mullvad.net> | 2025-08-13 11:44:58 +0200 |
|---|---|---|
| committer | Sebastian Holmin <sebastian.holmin@mullvad.net> | 2025-08-26 15:31:57 +0200 |
| commit | 6b52ebea312baf888ee23595b6bed5d0e450d3c8 (patch) | |
| tree | 7e330c9693ff5357ed9924dd8449246f02c12093 | |
| parent | 50922353838e936ed6f05a3f92df72ba6e93d322 (diff) | |
| download | mullvadvpn-6b52ebea312baf888ee23595b6bed5d0e450d3c8.tar.xz mullvadvpn-6b52ebea312baf888ee23595b6bed5d0e450d3c8.zip | |
Update boringtun, adding multihop fixes and GRO
Adds:
- Userspace multihop de-fragmentation
- PcapSniffer
- UDP GRO on Linux
Also updates setup of userspace multihop on the deamon side, as
`PacketChannel` has been replaced with specifc channel types that
implement the `IpSend`, `IpRecv`, `UdpSend` and `UdpRecv` traits.
| -rw-r--r-- | Cargo.lock | 2 | ||||
| -rw-r--r-- | talpid-wireguard/Cargo.toml | 2 | ||||
| -rw-r--r-- | talpid-wireguard/src/boringtun/mod.rs | 54 |
3 files changed, 34 insertions, 24 deletions
diff --git a/Cargo.lock b/Cargo.lock index 10bb02092d..2918fa1434 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -455,7 +455,7 @@ dependencies = [ [[package]] name = "boringtun" version = "0.6.0" -source = "git+https://github.com/mullvad/boringtun?rev=82166463940bb76ac9917ded1fdf663ed6ece40e#82166463940bb76ac9917ded1fdf663ed6ece40e" +source = "git+https://github.com/mullvad/boringtun?rev=83b3b5bb1bf3ec8b9849cc0d250d96d623b6181f#83b3b5bb1bf3ec8b9849cc0d250d96d623b6181f" dependencies = [ "aead", "async-trait", diff --git a/talpid-wireguard/Cargo.toml b/talpid-wireguard/Cargo.toml index 1122494716..2bfea215a7 100644 --- a/talpid-wireguard/Cargo.toml +++ b/talpid-wireguard/Cargo.toml @@ -46,7 +46,7 @@ tokio-stream = { version = "0.1", features = ["io-util"] } optional = true features = ["device", "tun"] git = "https://github.com/mullvad/boringtun" -rev = "82166463940bb76ac9917ded1fdf663ed6ece40e" +rev = "83b3b5bb1bf3ec8b9849cc0d250d96d623b6181f" [target.'cfg(unix)'.dependencies] nix = { workspace = true, features = ["fs"] } diff --git a/talpid-wireguard/src/boringtun/mod.rs b/talpid-wireguard/src/boringtun/mod.rs index e790ef70f9..f4ba01f089 100644 --- a/talpid-wireguard/src/boringtun/mod.rs +++ b/talpid-wireguard/src/boringtun/mod.rs @@ -11,7 +11,10 @@ use boringtun::{ api::{ApiClient, ApiServer, command::*}, peer::AllowedIP, }, - udp::{UdpSocketFactory, channel::PacketChannel}, + udp::{ + UdpSocketFactory, + channel::{PacketChannelUdp, TunChannelRx, TunChannelTx, get_packet_channels}, + }, }; #[cfg(not(target_os = "android"))] use ipnetwork::IpNetwork; @@ -34,8 +37,8 @@ type UdpFactory = AndroidUdpSocketFactory; type UdpFactory = UdpSocketFactory; type SinglehopDevice = DeviceHandle<(UdpFactory, Arc<tun07::AsyncDevice>, Arc<tun07::AsyncDevice>)>; -type EntryDevice = DeviceHandle<(UdpFactory, PacketChannel, PacketChannel)>; -type ExitDevice = DeviceHandle<(PacketChannel, Arc<AsyncDevice>, Arc<AsyncDevice>)>; +type EntryDevice = DeviceHandle<(UdpFactory, TunChannelTx, TunChannelRx)>; +type ExitDevice = DeviceHandle<(PacketChannelUdp, Arc<AsyncDevice>, Arc<AsyncDevice>)>; const PACKET_CHANNEL_CAPACITY: usize = 100; @@ -104,12 +107,13 @@ struct AndroidUdpSocketFactory { #[cfg(target_os = "android")] impl UdpTransportFactory for AndroidUdpSocketFactory { type Send = <UdpSocketFactory as UdpTransportFactory>::Send; - type Recv = <UdpSocketFactory as UdpTransportFactory>::Recv; + type RecvV4 = <UdpSocketFactory as UdpTransportFactory>::RecvV4; + type RecvV6 = <UdpSocketFactory as UdpTransportFactory>::RecvV6; async fn bind( &mut self, params: &boringtun::udp::UdpTransportFactoryParams, - ) -> std::io::Result<((Self::Send, Self::Recv), (Self::Send, Self::Recv))> { + ) -> std::io::Result<((Self::Send, Self::RecvV4), (Self::Send, Self::RecvV6))> { let ((udp_v4_tx, udp_v4_rx), (udp_v6_tx, udp_v6_rx)) = UdpSocketFactory.bind(params).await?; @@ -216,25 +220,32 @@ async fn create_devices( if let Some(exit_peer) = &config.exit_peer { // multihop - let source_v4 = config.tunnel.addresses.iter().find_map(|ip| match ip { - &IpAddr::V4(ipv4_addr) => Some(ipv4_addr), - IpAddr::V6(..) => None, - }); + let source_v4 = config + .tunnel + .addresses + .iter() + .find_map(|ip| match ip { + &IpAddr::V4(ipv4_addr) => Some(ipv4_addr), + IpAddr::V6(..) => None, + }) + .unwrap_or(Ipv4Addr::UNSPECIFIED); - let source_v6 = config.tunnel.addresses.iter().find_map(|ip| match ip { - &IpAddr::V6(ipv6_addr) => Some(ipv6_addr), - IpAddr::V4(..) => None, - }); + let source_v6 = config + .tunnel + .addresses + .iter() + .find_map(|ip| match ip { + &IpAddr::V6(ipv6_addr) => Some(ipv6_addr), + IpAddr::V4(..) => None, + }) + .unwrap_or(Ipv6Addr::UNSPECIFIED); - let channel = PacketChannel::new( - PACKET_CHANNEL_CAPACITY, - source_v4.unwrap_or(Ipv4Addr::UNSPECIFIED), // HACK: unwrap_or - source_v6.unwrap_or(Ipv6Addr::UNSPECIFIED), // HACK: unwrap_or - ); + let (tun_tx, tun_rx, udp_channels) = + get_packet_channels(PACKET_CHANNEL_CAPACITY, source_v4, source_v6); let (exit_api, exit_api_server) = ApiServer::new(); - let exit_device = DeviceHandle::<(PacketChannel, Arc<AsyncDevice>, Arc<AsyncDevice>)>::new( - channel.clone(), + let exit_device = ExitDevice::new( + udp_channels, async_tun.clone(), async_tun, DeviceConfig { @@ -249,8 +260,7 @@ async fn create_devices( #[cfg(not(target_os = "android"))] let factory = UdpSocketFactory; - let entry_device = - EntryDevice::new(factory, channel.clone(), channel, boringtun_entry_config).await; + let entry_device = EntryDevice::new(factory, tun_tx, tun_rx, boringtun_entry_config).await; let private_key = &config.tunnel.private_key; let peer = &config.entry_peer; |
