From e96b0f7a73ff5921af89368050a034ed807817e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 1 Jan 2026 23:33:14 +0800 Subject: [PATCH] Netif (Linux): skips local/loopback routes Fixes #2127 --- src/common/netif/netif_linux.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/common/netif/netif_linux.c b/src/common/netif/netif_linux.c index 49976b695..7867d1a1e 100644 --- a/src/common/netif/netif_linux.c +++ b/src/common/netif/netif_linux.c @@ -151,6 +151,12 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) continue; } + // Skip local/loopback routes + if (rtm->rtm_scope == RT_SCOPE_HOST || rtm->rtm_type == RTN_LOCAL) { + FF_DEBUG("Skipping local route #%d (scope=%d, type=%d)", routeCount, rtm->rtm_scope, rtm->rtm_type); + continue; + } + FF_DEBUG("Processing IPv4 default route candidate #%d", routeCount); entry = (__typeof__(entry)) { }; // Default to zero metric (no RTA_PRIORITY found) @@ -360,6 +366,12 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) continue; } + // Skip local/loopback routes + if (rtm->rtm_scope == RT_SCOPE_HOST || rtm->rtm_type == RTN_LOCAL) { + FF_DEBUG("Skipping local route #%d (scope=%d, type=%d)", routeCount, rtm->rtm_scope, rtm->rtm_type); + continue; + } + FF_DEBUG("Processing IPv6 default route candidate #%d", routeCount); entry = (__typeof__(entry)) { }; // Default to zero metric (no RTA_PRIORITY found)