From 268e801ec565e1dd3d4002f725bd5c6b5fc765d6 Mon Sep 17 00:00:00 2001 From: Maycon Santos Date: Mon, 22 Jul 2024 19:44:15 +0200 Subject: [PATCH] Ignore network monitor checks for software interfaces (#2302) ignore checks for Teredo and ISATAP interfaces --- client/internal/networkmonitor/monitor_windows.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/client/internal/networkmonitor/monitor_windows.go b/client/internal/networkmonitor/monitor_windows.go index f58802e4e..308b2aa45 100644 --- a/client/internal/networkmonitor/monitor_windows.go +++ b/client/internal/networkmonitor/monitor_windows.go @@ -99,6 +99,11 @@ func routeChanged(nexthop systemops.Nexthop, intf *net.Interface, routes []syste return false } + if isSoftInterface(nexthop.Intf.Name) { + log.Tracef("network monitor: ignoring default route change for soft interface %s", nexthop.Intf.Name) + return false + } + unspec := getUnspecifiedPrefix(nexthop.IP) defaultRoutes, foundMatchingRoute := processRoutes(nexthop, intf, routes, unspec) @@ -119,7 +124,7 @@ func getUnspecifiedPrefix(ip netip.Addr) netip.Prefix { return netip.PrefixFrom(netip.IPv4Unspecified(), 0) } -func processRoutes(nexthop systemops.Nexthop, intf *net.Interface, routes []systemops.Route, unspec netip.Prefix) ([]string, bool) { +func processRoutes(nexthop systemops.Nexthop, nexthopIntf *net.Interface, routes []systemops.Route, unspec netip.Prefix) ([]string, bool) { var defaultRoutes []string foundMatchingRoute := false @@ -128,7 +133,7 @@ func processRoutes(nexthop systemops.Nexthop, intf *net.Interface, routes []syst routeInfo := formatRouteInfo(r) defaultRoutes = append(defaultRoutes, routeInfo) - if r.Nexthop == nexthop.IP && compareIntf(r.Interface, intf) == 0 { + if r.Nexthop == nexthop.IP && compareIntf(r.Interface, nexthopIntf) == 0 { foundMatchingRoute = true log.Debugf("network monitor: found matching default route: %s", routeInfo) } @@ -239,13 +244,11 @@ func compareIntf(a, b *net.Interface) int { return -1 case b == nil: return 1 - case isIsatapInterface(a.Name) && isIsatapInterface(b.Name): - return 0 default: return a.Index - b.Index } } -func isIsatapInterface(name string) bool { - return strings.HasPrefix(strings.ToLower(name), "isatap") +func isSoftInterface(name string) bool { + return strings.Contains(strings.ToLower(name), "isatap") || strings.Contains(strings.ToLower(name), "teredo") }