mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-25 22:09:08 +01:00
[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:
@@ -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
|
// 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
|
// given baseline, per protocol. A failed lookup is treated as an absent route
|
||||||
// restart rather than miss a real network change.
|
// (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 {
|
func nexthopChanged(oldv4, oldv6 systemops.Nexthop) bool {
|
||||||
newv4, errv4 := systemops.GetNextHop(netip.IPv4Unspecified())
|
newv4, _ := systemops.GetNextHop(netip.IPv4Unspecified())
|
||||||
newv6, errv6 := systemops.GetNextHop(netip.IPv6Unspecified())
|
newv6, _ := systemops.GetNextHop(netip.IPv6Unspecified())
|
||||||
if errv4 != nil || errv6 != nil {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return !sameNexthop(oldv4, newv4) || !sameNexthop(oldv6, newv6)
|
return !sameNexthop(oldv4, newv4) || !sameNexthop(oldv6, newv6)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user