diff --git a/netwatch/src/interfaces/linux.rs b/netwatch/src/interfaces/linux.rs index 2cf55c7..0dce28a 100644 --- a/netwatch/src/interfaces/linux.rs +++ b/netwatch/src/interfaces/linux.rs @@ -41,9 +41,11 @@ pub enum Error { } pub async fn default_route() -> Option { - let route = default_route_proc().await; - if let Ok(route) = route { - return route; + // /proc/net/route only contains IPv4 routes. If it finds one, return it. + // If it returns Ok(None) (no IPv4 default route) or Err (file unreadable), + // fall through to netlink which checks both IPv4 and IPv6. + if let Ok(Some(route)) = default_route_proc().await { + return Some(route); } #[cfg(target_os = "android")] diff --git a/netwatch/tests/patchbay.rs b/netwatch/tests/patchbay.rs index 139a46b..0f11130 100644 --- a/netwatch/tests/patchbay.rs +++ b/netwatch/tests/patchbay.rs @@ -51,7 +51,6 @@ async fn default_route_v4_only() -> TestResult { /// Netwatch detects a default route on a v6-only network. #[tokio::test] -#[ignore = "default_route() does not fall through to netlink when /proc/net/route has no IPv4 default"] async fn default_route_v6_only() -> TestResult { let state = state_for_routed_device(IpSupport::V6Only).await?; @@ -75,7 +74,6 @@ async fn default_route_dual_stack() -> TestResult { /// After replugging from a v4 router to a v6 router, netwatch detects the new /// default route. #[tokio::test] -#[ignore = "default_route() does not fall through to netlink when /proc/net/route has no IPv4 default"] async fn default_route_after_replug_v4_to_v6() -> TestResult { let lab = Lab::new().await?; let v4_router = lab