Skip to content

Commit

Permalink
Ignore network monitor checks for software interfaces (#2302)
Browse files Browse the repository at this point in the history
ignore checks for Teredo and ISATAP interfaces
  • Loading branch information
mlsmaycon authored Jul 22, 2024
1 parent 788f130 commit 268e801
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions client/internal/networkmonitor/monitor_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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

Expand All @@ -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)
}
Expand Down Expand Up @@ -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")
}

0 comments on commit 268e801

Please sign in to comment.