From 508f5c3ae00783e046483825bef7e47c239a46cc Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Thu, 29 Oct 2020 14:38:59 -0700 Subject: [PATCH] wgengine/router: fix bug where getInterfaceRoutes always returned an empty list Regression from https://github.com/tailscale/tailscale/commit/f2ce64f0c6c688aebbd4b273faf86f28c428a0cf#r43710860 Fixes #870 --- wgengine/router/ifconfig_windows.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/wgengine/router/ifconfig_windows.go b/wgengine/router/ifconfig_windows.go index e1169e9b6..fc7cf0d65 100644 --- a/wgengine/router/ifconfig_windows.go +++ b/wgengine/router/ifconfig_windows.go @@ -625,20 +625,17 @@ func deltaRouteData(a, b []*winipcfg.RouteData) (add, del []*winipcfg.RouteData) // getInterfaceRoutes returns all the interface's routes. // Corresponds to GetIpForwardTable2 function, but filtered by interface. -func getInterfaceRoutes(ifc *winipcfg.IPAdapterAddresses, family winipcfg.AddressFamily) ([]*winipcfg.MibIPforwardRow2, error) { +func getInterfaceRoutes(ifc *winipcfg.IPAdapterAddresses, family winipcfg.AddressFamily) (matches []*winipcfg.MibIPforwardRow2, err error) { routes, err := winipcfg.GetIPForwardTable2(family) if err != nil { return nil, err } - matches := make([]*winipcfg.MibIPforwardRow2, len(routes)) - i := 0 for i := range routes { if routes[i].InterfaceLUID == ifc.LUID { - matches[i] = &routes[i] - i++ + matches = append(matches, &routes[i]) } } - return matches[:i], nil + return } // syncRoutes incrementally sets multiples routes on an interface.