summaryrefslogtreecommitdiffhomepage
path: root/net/interfaces
AgeCommit message (Collapse)AuthorFilesLines
2021-05-16all: adapt to opaque netaddr typesJosh Bleecher Snyder1-9/+9
This commit is a mishmash of automated edits using gofmt: gofmt -r 'netaddr.IPPort{IP: a, Port: b} -> netaddr.IPPortFrom(a, b)' -w . gofmt -r 'netaddr.IPPrefix{IP: a, Port: b} -> netaddr.IPPrefixFrom(a, b)' -w . gofmt -r 'a.IP.Is4 -> a.IP().Is4' -w . gofmt -r 'a.IP.As16 -> a.IP().As16' -w . gofmt -r 'a.IP.Is6 -> a.IP().Is6' -w . gofmt -r 'a.IP.As4 -> a.IP().As4' -w . gofmt -r 'a.IP.String -> a.IP().String' -w . And regexps: \w*(.*)\.Port = (.*) -> $1 = $1.WithPort($2) \w*(.*)\.IP = (.*) -> $1 = $1.WithIP($2) And lots of manual fixups. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-05-10net/interface: remove darwin fetchRoutingTable workaroundBrad Fitzpatrick1-26/+2
Fixed upstream. Bump dep. Updates #1345 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-04-29net/interfaces: return all Tailscale addresses from Tailscale().David Anderson1-2/+6
Signed-off-by: David Anderson <danderson@tailscale.com>
2021-04-23net/interfaces: work around race fetching routing tableBrad Fitzpatrick2-2/+41
Fixes #1345 Updates golang/go#45736 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-03-31interfaces: check correct error /proc/net/routeDenton Gentry1-4/+6
wrap io.EOF if we hit https://github.com/google/gvisor/issues/5732 Check for the correct err. Signed-off-by: Denton Gentry <dgentry@tailscale.com>
2021-03-30interfaces: try larger read from /proc/net/routeDenton Gentry2-5/+94
Work around https://github.com/google/gvisor/issues/5732 by trying to read /proc/net/route with a larger bufsize if it fails the first time. Signed-off-by: Denton Gentry <dgentry@tailscale.com>
2021-03-30interfaces: allow IPv6 ULA as a valid address.Denton Gentry2-1/+25
IPv6 Unique Local Addresses are sometimes used with Network Prefix Translation to reach the Internet. In that respect their use is similar to the private IPv4 address ranges 10/8, 172.16/12, and 192.168/16. Treat them as sufficient for AnyInterfaceUp(), but specifically exclude Tailscale's own IPv6 ULA prefix to avoid mistakenly trying to bootstrap Tailscale using Tailscale. This helps in supporting Google Cloud Run, where the addresses are 169.254.8.1/32 and fddf:3978:feb1:d745::c001/128 on eth1. Signed-off-by: Denton Gentry <dgentry@tailscale.com>
2021-03-26net/interfaces: remove mutating methods, add EqualFiltered insteadBrad Fitzpatrick2-41/+74
Now callers (wgengine/monitor) don't need to mutate the state to remove boring interfaces before calling State.Equal. Instead, the methods to remove boring interfaces from the State are removed, as is the reflect-using Equal method itself, and in their place is a new EqualFiltered method that takes a func predicate to match interfaces to compare. And then the FilterInteresting predicate is added for use with EqualFiltered to do the job that that wgengine/monitor previously wanted. Now wgengine/monitor can keep the full interface state around, including the "boring" interfaces, which we'll need for peerapi on macOS/iOS to bind to the interface index of the utunN device. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-03-26net/interfaces: track more interface metadata in StateBrad Fitzpatrick1-10/+10
We have it already but threw it away. But macOS/iOS code will be needing the interface index, so hang on to it. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-03-19net/interfaces: use windows API to get the default route instead of parsing ↵Aleksandar Pesic1-44/+64
`route print` output Fixes: #1470 Signed-off-by: Aleksandar Pesic <peske.nis@gmail.com>
2021-03-16net/interfaces: skip IPv6 link-local interfaces like we do for IPv4Brad Fitzpatrick1-7/+6
We strip them control-side anyway, and we already strip IPv4 link local, so there's no point uploading them. And iOS has a ton of them, which results in somewhat silly amount of traffic in the MapRequest. We'll be doing same-LAN-inter-tailscaled link-local traffic a different way, with same-LAN discovery. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-03-15net/interfaces: rewrite the darwin likelyHomeRouterIP from C to GoBrad Fitzpatrick5-220/+133
We basically already had the RIB-parsing Go code for this in both net/interfaces and wgengine/monitor, for other reasons. Fixes #1426 Fixes #1471 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-03-08net/interfaces, wgengine/monitor: fix false positives link changesBrad Fitzpatrick1-0/+24
interfaces.State.String tries to print a concise summary of the network state, removing any interfaces that don't have any or any interesting IP addresses. On macOS and iOS, for instance, there are a ton of misc things. But the link monitor based its are-there-changes decision on interfaces.State.Equal, which just used reflect.DeepEqual, including comparing all the boring interfaces. On macOS, when turning wifi on or off, there are a ton of misc boring interface changes, resulting in hitting an earlier check I'd added on suspicion this was happening: [unexpected] network state changed, but stringification didn't This fixes that by instead adding a new interfaces.State.RemoveUninterestingInterfacesAndAddresses method that does, uh, that. Then use that in the monitor. So then when Equal is used later, it's DeepEqualing the already-cleaned version with only interesting interfaces. This makes cmd/tailscaled debug --monitor much less noisy. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-03-05net/interfaces: log why when we failed to look up gateway on macOSBrad Fitzpatrick1-0/+2
Not beautiful, but I'm debugging connectivity problems on NEProvider.sleep+wake and need more clues. Updates #1426 Updates tailscale/corp#1289 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-03-04net/interfaces: sort returned addresses from LocalAddressesBrad Fitzpatrick1-3/+9
Also change the type to netaddr.IP while here, because it made sorting easier. Updates tailscale/corp#1397 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-03-02net/interfaces: merge darwin files for DefaultRouteInterface in sandboxBrad Fitzpatrick3-82/+67
DefaultRouteInterface was previously guarded by build tags such that it was only accessible to tailscaled-on-macos, but there was no reason for that. It runs fine in the sandbox and gives better default info, so merge its file into interfaces_darwin.go. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-03-01ipn/ipnlocal: transform default routes into "all but LAN" routes.David Anderson1-34/+44
Fixes #1177. Signed-off-by: David Anderson <danderson@tailscale.com>
2021-02-25net/interfaces: go idle on macOS when wifi/etc is down, ignore utun* interfacesBrad Fitzpatrick1-8/+57
Updates tailscale/corp#1289 Updates tailscale/corp#1367 Updates tailscale/corp#1378 Updates tailscale/felicity#4
2021-02-14net/{interfaces,netns}: add some new tests, missed from prior commitBrad Fitzpatrick1-0/+17
I meant for these to be part of 52e24aa966ffa.
2021-02-14net/interfaces: fix staticcheck error on darwinBrad Fitzpatrick1-2/+2
2021-02-14net/{interfaces,ns}: add tailscaled-mode darwin routing looping preventionBrad Fitzpatrick2-1/+82
Fixes #1331 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-02-12net/interfaces: reconcile interface filtering with address printing in logsBrad Fitzpatrick1-10/+18
The interface.State logging tried to only log interfaces which had interesting IPs, but the what-is-interesting checks differed between the code that gathered the interface names to print and the printing of their addresses.
2021-02-02net/interfaces: use a uint32_t for ipv4 addressDavid Crawshaw1-4/+4
The code was using a C "int", which is a signed 32-bit integer. That means some valid IP addresses were negative numbers. (In particular, the default router address handed out by AT&T fiber: 192.168.1.254. No I don't know why they do that.) A negative number is < 255, and so was treated by the Go code as an error. This fixes the unit test failure: $ go test -v -run=TestLikelyHomeRouterIPSyscallExec ./net/interfaces === RUN TestLikelyHomeRouterIPSyscallExec interfaces_darwin_cgo_test.go:15: syscall() = invalid IP, false, netstat = 192.168.1.254, true --- FAIL: TestLikelyHomeRouterIPSyscallExec (0.00s) Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
2021-01-26net/interfaces: don't send over zt* interfacesBrad Fitzpatrick1-2/+17
Fixes #1208 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-01-26net/interfaces: remove IsTailscaleIP, make callers use tsaddr.David Anderson2-30/+5
Signed-off-by: David Anderson <danderson@tailscale.com>
2020-12-19net/interfaces: return IPv6 addresses from LocalAddresses.David Anderson1-5/+0
In practice, we already provide IPv6 endpoint addresses via netcheck, and that address is likely to match a local address anyway (i.e. no NAT66). The comment at that piece of the code mentions needing to figure out a good priority ordering, but that only applies to non-active-discovery clients, who already don't do anything with IPv6 addresses. Signed-off-by: David Anderson <danderson@tailscale.com>
2020-12-14go.mod: upgrade staticcheck to 0.1.0Josh Bleecher Snyder1-2/+2
Also run go.mod and fix some staticcheck warnings. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2020-11-19net/interfaces: make syscall and netstat agree when multiple gateways are ↵Josh Bleecher Snyder1-0/+5
present likelyHomeRouterIPDarwinSyscall iterates through the list of routes, looking for a private gateway, returning the first one it finds. likelyHomeRouterIPDarwinExec does the same thing, except that it returns the last one it finds. As a result, when there are multiple gateways, TestLikelyHomeRouterIPSyscallExec fails. (At least, I think that that is what is happening; I am going inferring from observed behavior.) Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2020-11-10net/interfaces: ignore bogus proxy URLs from winhttp [windows]Brad Fitzpatrick1-1/+7
Updates tailscale/corp#853
2020-10-13wgengine/router: unfork winipcfg-go package, use upstreamAlex Brainman1-17/+15
Use golang.zx2c4.com/wireguard/windows/tunnel/winipcfg instead of github.com/tailscale/winipcfg-go package. Updates #760 Signed-off-by: Alex Brainman <alex.brainman@gmail.com>
2020-10-06ipn, wgengine, magicsock, tsdns: be quieter and less aggressive when offlineBrad Fitzpatrick1-16/+33
If no interfaces are up, calm down and stop spamming so much. It was noticed as especially bad on Windows, but probably was bad everywhere. I just have the best network conditions testing on a Windows VM. Updates #604
2020-10-05ipn, wgengine: disable subnet routes if network has PAC configurationBrad Fitzpatrick1-0/+2
Not configurable yet. Updates tailscale/corp#653 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2020-10-02net/interfaces: add interfaces.State.String methodBrad Fitzpatrick2-0/+72
2020-10-01net/interfaces: quiet PAC detection logging in no-PAC case, add benchmarkBrad Fitzpatrick2-8/+34
2020-10-01net/interfaces: add State.PAC field, populate it on WindowsBrad Fitzpatrick2-0/+42
Not used for anything yet (except logging), but populate the current proxy autoconfig PAC URL in Interfaces.State. A future change will do things based on it.
2020-09-22net/interfaces, net/netns: move default route interface code to interfacesBrad Fitzpatrick2-4/+60
To populate interfaces.State.DefaultRouteInterface. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2020-09-14net/netns: add windows support.David Anderson1-0/+21
Also remove rebinding logic from the windows router. Magicsock will instead rebind based on link change signals. Signed-off-by: David Anderson <danderson@tailscale.com>
2020-08-18net/tshttpproxy: new package, support WPAD/PAC proxies on WindowsBrad Fitzpatrick1-0/+18
Updates tailscale/corp#553 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2020-08-13wgengine/monitor: add Windows linkchange monitorBrad Fitzpatrick1-2/+4
Updates tailscale/corp#553 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2020-08-12net/interfaces: include DefaultRouteInterface in interfaces.StateBrad Fitzpatrick2-0/+20
And log it in wgengine on change. Changing bug in #643. Updates #643
2020-08-10net/interfaces: remove old debug oldJosh Bleecher Snyder1-3/+0
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2020-08-10net/netns, net/interfaces: move defaultRouteInterface, add Android fallbackBrad Fitzpatrick2-0/+109
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2020-08-04net/interfaces: use syscalls to find private gateway IP addressJosh Bleecher Snyder5-7/+417
iOS doesn't let you run subprocesses, which means we can't use netstat to get routing information. Instead, use syscalls and grub around in the results. We keep the old netstat version around, both for use in non-cgo builds, and for use testing the syscall-based version. Note that iOS doesn't ship route.h, so we include a copy here from the macOS 10.15 SDK (which is itself unchanged from the 10.14 SDK). I have tested manually that this yields the correct gateway IP address on my own macOS and iOS devices. More coverage would be most welcome. Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
2020-07-31net/interfaces: don't try to fork on iOS in likelyHomeRouterIPDarwinBrad Fitzpatrick1-0/+8
No subprocesses allowed on iOS. Will need to do this differently later.
2020-07-28net/interfaces: fix likelyHomeRouterIP on AndroidBrad Fitzpatrick1-1/+59
2020-07-15net/interfaces: set SysProcAttr.HideWindow to prevent cmd.exe flash on WindowsBrad Fitzpatrick1-0/+2
2020-07-06net/tsaddr: new package to hold Tailscale-specific IPs/rangesBrad Fitzpatrick1-3/+3
And update existing callers with (near) duplicated cases.
2020-07-06netcheck, tailcfg, interfaces, magicsock: survey UPnP, NAT-PMP, PCPBrad Fitzpatrick2-5/+30
Don't do anything with UPnP, NAT-PMP, PCP yet, but see how common they are in the wild. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2020-07-06net/interfaces: add func LikelyHomeRouterIPBrad Fitzpatrick5-0/+213
For discovering where we might direct NAT-PMP/PCP/UPnP queries at in the future.
2020-05-28Make netcheck handle v6-only interfaces better, faster.Brad Fitzpatrick1-48/+37
Also: * add -verbose flag to cmd/tailscale netcheck * remove some API from the interfaces package * convert some of the interfaces package to netaddr.IP * don't even send IPv4 probes on machines with no IPv4 (or only v4 loopback) * and once three regions have replied, stop waiting for other probes at 2x the slowest duration. Updates #376