diff --git a/konduit-platform/src/routes/linux.rs b/konduit-platform/src/routes/linux.rs index 6e2429d..51eab52 100644 --- a/konduit-platform/src/routes/linux.rs +++ b/konduit-platform/src/routes/linux.rs @@ -90,6 +90,14 @@ impl RouteManager { // Collect all default-route gateways with their metrics. // VPN default routes have low metric (50); physical/DHCP routes have high metric (600+). // We want the physical gateway, so take the one with the highest metric. + // + // The metric comparison alone is not reliable: the kernel does not always + // round-trip the Priority attribute on route dumps (see the Oif-based match + // in suspend_default_route() below, which exists for the same reason), and a + // leftover default route on a reused tun ifindex from an imperfectly torn + // down previous session can win the metric comparison by accident. Since we + // already know our own tun interface's index at this point, exclude it + // outright rather than trusting metric alone to steer around it. let mut candidates: Vec<(u32, Ipv4Addr, u32)> = Vec::new(); while let Some(route) = routes.try_next().await? { @@ -110,6 +118,9 @@ impl RouteManager { } } if let (Some(gw), Some(idx)) = (gateway, oif) { + if Some(idx) == self.tun_index { + continue; + } candidates.push((metric, gw, idx)); } }