[client] Treat missing default route per protocol in next-hop check

A failed GetNextHop lookup is now treated as an absent route (zero
Nexthop) and compared per protocol, instead of forcing a restart. In a
single-stack network the missing IPv6 default route no longer counts as
a change on every debounce, which previously defeated the unchanged-route
check.
This commit is contained in:
Zoltán Papp
2026-06-23 01:20:46 +02:00
parent 3a6d0c3f0b
commit 0fb531e4bc

View File

@@ -141,14 +141,12 @@ func (nw *NetworkMonitor) checkChanges(ctx context.Context, event chan struct{},
}
// nexthopChanged reports whether the current default next hop differs from the
// given baseline. A lookup error is treated as a change so we fail safe and
// restart rather than miss a real network change.
// given baseline, per protocol. A failed lookup is treated as an absent route
// (zero Nexthop), so a protocol that had no default route to begin with (e.g.
// IPv6 in a single-stack network) does not by itself count as a change.
func nexthopChanged(oldv4, oldv6 systemops.Nexthop) bool {
newv4, errv4 := systemops.GetNextHop(netip.IPv4Unspecified())
newv6, errv6 := systemops.GetNextHop(netip.IPv6Unspecified())
if errv4 != nil || errv6 != nil {
return true
}
newv4, _ := systemops.GetNextHop(netip.IPv4Unspecified())
newv6, _ := systemops.GetNextHop(netip.IPv6Unspecified())
return !sameNexthop(oldv4, newv4) || !sameNexthop(oldv6, newv6)
}