diff options
| author | David Lönnhager <david.l@mullvad.net> | 2024-01-29 13:19:42 +0100 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2024-01-31 11:02:49 +0100 |
| commit | 19e28d9e1c0dd0b160c6083db61760d07ee00432 (patch) | |
| tree | dec8e01d682fd9a5acc1fecf8d8223257fcdd2f5 | |
| parent | c09307718470851d0f2ec1a3194f2e7a699e2248 (diff) | |
| download | mullvadvpn-19e28d9e1c0dd0b160c6083db61760d07ee00432.tar.xz mullvadvpn-19e28d9e1c0dd0b160c6083db61760d07ee00432.zip | |
Coalesce tunnel device errors on Windows
| -rw-r--r-- | talpid-core/src/tunnel_state_machine/connecting_state.rs | 14 | ||||
| -rw-r--r-- | talpid-wireguard/src/lib.rs | 5 | ||||
| -rw-r--r-- | talpid-wireguard/src/wireguard_nt.rs | 2 |
3 files changed, 11 insertions, 10 deletions
diff --git a/talpid-core/src/tunnel_state_machine/connecting_state.rs b/talpid-core/src/tunnel_state_machine/connecting_state.rs index 75f3d8eebf..ec8ddc5f2c 100644 --- a/talpid-core/src/tunnel_state_machine/connecting_state.rs +++ b/talpid-core/src/tunnel_state_machine/connecting_state.rs @@ -37,7 +37,7 @@ pub(crate) type TunnelCloseEvent = Fuse<oneshot::Receiver<Option<ErrorStateCause const MAX_ATTEMPTS_WITH_SAME_TUN: u32 = 5; const MIN_TUNNEL_ALIVE_TIME: Duration = Duration::from_millis(1000); #[cfg(target_os = "windows")] -const MAX_RECOVERABLE_FAIL_RETRIES: u32 = 4; +const MAX_ATTEMPT_CREATE_TUN: u32 = 4; const INITIAL_ALLOWED_TUNNEL_TRAFFIC: AllowedTunnelTraffic = AllowedTunnelTraffic::None; @@ -589,7 +589,6 @@ fn should_retry(error: &tunnel::Error, retry_attempt: u32) -> bool { tunnel::Error::WireguardTunnelMonitoringError(Error::PskNegotiationError(_)) => true, - #[cfg(not(windows))] tunnel::Error::WireguardTunnelMonitoringError(Error::TunnelError( TunnelError::RecoverableStartWireguardError, )) => true, @@ -606,14 +605,11 @@ fn should_retry(error: &tunnel::Error, retry_attempt: u32) -> bool { #[cfg(windows)] tunnel::Error::WireguardTunnelMonitoringError(Error::TunnelError( - // This usually occurs when the tunnel interface cannot be created. - TunnelError::RecoverableStartWireguardError, - )) if retry_attempt < MAX_RECOVERABLE_FAIL_RETRIES => true, - - #[cfg(windows)] - tunnel::Error::OpenVpnTunnelMonitoringError( + TunnelError::SetupTunnelDevice(_), + )) + | tunnel::Error::OpenVpnTunnelMonitoringError( talpid_openvpn::Error::WintunCreateAdapterError(_), - ) if retry_attempt < MAX_RECOVERABLE_FAIL_RETRIES => true, + ) if retry_attempt < MAX_ATTEMPT_CREATE_TUN => true, _ => false, } diff --git a/talpid-wireguard/src/lib.rs b/talpid-wireguard/src/lib.rs index f1ddc827e5..82c3483e22 100644 --- a/talpid-wireguard/src/lib.rs +++ b/talpid-wireguard/src/lib.rs @@ -985,6 +985,11 @@ pub enum TunnelError { #[error(display = "Failed to create tunnel device")] SetupTunnelDeviceError(#[error(source)] tun_provider::Error), + /// Failed to set up a tunnel device + #[cfg(windows)] + #[error(display = "Failed to create tunnel device")] + SetupTunnelDevice(#[error(source)] io::Error), + /// Failed to setup a tunnel device. #[cfg(windows)] #[error(display = "Failed to config IP interfaces on tunnel device")] diff --git a/talpid-wireguard/src/wireguard_nt.rs b/talpid-wireguard/src/wireguard_nt.rs index 0a9cc15219..1c7c9d0c71 100644 --- a/talpid-wireguard/src/wireguard_nt.rs +++ b/talpid-wireguard/src/wireguard_nt.rs @@ -417,7 +417,7 @@ impl WgNtTunnel { ); match error { - Error::CreateTunnelDevice(_) => super::TunnelError::RecoverableStartWireguardError, + Error::CreateTunnelDevice(error) => super::TunnelError::SetupTunnelDevice(error), _ => super::TunnelError::FatalStartWireguardError, } }) |
