tailscale/net/interfaces
Brad Fitzpatrick 2a67beaacf net/interfaces: bound Linux /proc/net/route parsing
tailscaled was using 100% CPU on a machine with ~1M lines, 100MB+
of /proc/net/route data.

Two problems: in likelyHomeRouterIPLinux, we didn't stop reading the
file once we found the default route (which is on the first non-header
line when present). Which meant it was finding the answer and then
parsing 100MB over 1M lines unnecessarily. Second was that if the
default route isn't present, it'd read to the end of the file looking
for it. If it's not in the first 1,000 lines, it ain't coming, or at
least isn't worth having. (it's only used for discovering a potential
UPnP/PMP/PCP server, which is very unlikely to be present in the
environment of a machine with a ton of routes)

Change-Id: I2c4a291ab7f26aedc13885d79237b8f05c2fd8e4
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-02-03 09:31:25 -08:00
..
interfaces_darwin_test.go net/{dnscache,interfaces}: use netaddr.IP.IsPrivate, delete copied code 2021-07-26 20:30:28 -07:00
interfaces_darwin.go net/interfaces: define DefaultRouteInterface and State.DefaultRouteInterface 2021-12-29 12:13:15 -08:00
interfaces_default_route_test.go all: gofmt with Go 1.17 2021-08-05 15:54:00 -07:00
interfaces_defaultrouteif_todo.go net/interfaces: define DefaultRouteInterface and State.DefaultRouteInterface 2021-12-29 12:13:15 -08:00
interfaces_linux_test.go net/interfaces: bound Linux /proc/net/route parsing 2022-02-03 09:31:25 -08:00
interfaces_linux.go net/interfaces: bound Linux /proc/net/route parsing 2022-02-03 09:31:25 -08:00
interfaces_test.go net/interfaces: define DefaultRouteInterface and State.DefaultRouteInterface 2021-12-29 12:13:15 -08:00
interfaces_windows_test.go net/interfaces: quiet PAC detection logging in no-PAC case, add benchmark 2020-10-01 22:02:39 -07:00
interfaces_windows.go net/interfaces: define DefaultRouteInterface and State.DefaultRouteInterface 2021-12-29 12:13:15 -08:00
interfaces.go net/interfaces: define DefaultRouteInterface and State.DefaultRouteInterface 2021-12-29 12:13:15 -08:00