summaryrefslogtreecommitdiffhomepage
AgeCommit message (Collapse)AuthorFilesLines
2021-07-26fix DHCPtps/tailscaledBrad Fitzpatrick1-8/+20
2021-07-23net/tstun: add TAP support on Linux, with DHCP+ARP serverBrad Fitzpatrick8-8/+431
Co-Author: David Crawshaw <crawshaw@tailscale.com> Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-07-22util/deephash: improve cycle detection (#2470)Joe Tsai4-332/+101
The previous algorithm used a map of all visited pointers. The strength of this approach is that it quickly prunes any nodes that we have ever visited before. The detriment of the approach is that pruning is heavily dependent on the order that pointers were visited. This is especially relevant for hashing a map where map entries are visited in a non-deterministic manner, which would cause the map hash to be non-deterministic (which defeats the point of a hash). This new algorithm uses a stack of all visited pointers, similar to how github.com/google/go-cmp performs cycle detection. When we visit a pointer, we push it onto the stack, and when we leave a pointer, we pop it from the stack. Before visiting a pointer, we first check whether the pointer exists anywhere in the stack. If yes, then we prune the node. The detriment of this approach is that we may hash a node more often than before since we do not prune as aggressively. The set of visited pointers up until any node is only the path of nodes up to that node and not any other pointers that may have been visited elsewhere. This provides us deterministic hashing regardless of visit order. We can now delete hashMapFallback and associated complexity, which only exists because the previous approach was non-deterministic in the presence of cycles. This fixes a failure of the old algorithm where obviously different values are treated as equal because the pruning was too aggresive. See https://github.com/tailscale/tailscale/issues/2443#issuecomment-883653534 The new algorithm is slightly slower since it prunes less aggresively: name old time/op new time/op delta Hash-8 66.1µs ± 1% 68.8µs ± 1% +4.09% (p=0.000 n=19+19) HashMapAcyclic-8 63.0µs ± 1% 62.5µs ± 1% -0.76% (p=0.000 n=18+19) TailcfgNode-8 9.79µs ± 2% 9.88µs ± 1% +0.95% (p=0.000 n=19+17) HashArray-8 643ns ± 1% 653ns ± 1% +1.64% (p=0.000 n=19+19) However, a slower but more correct algorithm seems more favorable than a faster but incorrect algorithm. Signed-off-by: Joe Tsai <joetsai@digital-static.net>
2021-07-22net/portmapper: disable UPnP on iOS for nowBrad Fitzpatrick2-0/+32
Updates #2495 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-07-22control/controlclient: grow goroutine debug buffer as neededBrad Fitzpatrick1-2/+11
To not allocate 1MB up front on iOS. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-07-22control/controlclient: don't use regexp in goroutine stack scrubbingBrad Fitzpatrick2-9/+72
To reduce binary size on iOS. Updates tailscale/corp#2238 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-07-22tstest/integration/vms: disable rDNS for sshd on centos (#2492)Christine Dodrill1-1/+3
This prevents centos tests from timing out because sshd does reverse dns lookups on every session being established instead of doing it once on the acutal ssh connection being established. This is odd. Appending this to the sshd config and restarting it seems to fix it though. Signed-off-by: Christine Dodrill <xe@tailscale.com>
2021-07-22tstest/integration/vms: disable nixos unstable (#2491)Christine Dodrill1-0/+4
cloud-init broke with the upgrade to python 3.9: https://github.com/NixOS/nixpkgs/issues/131098 Signed-off-by: Christine Dodrill <xe@tailscale.com>
2021-07-22net/dns: don't build init*.go on non-windowsBrad Fitzpatrick2-0/+4
To remove the regexp dep on iOS, notably. Updates tailscale/corp#2238 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-07-22net/dns/resolver: bound DoH usage on iOSBrad Fitzpatrick1-0/+24
Updates tailscale/corp#2238 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-07-21wgengine/netstack: implement UDP relaying to advertised subnetsBrad Fitzpatrick1-46/+96
TCP was done in 662fbd4a09664e849f0b898d1e8df13325d36efa. This does the same for UDP. Tested by hand. Integration tests will have to come later. I'd wanted to do it in this commit, but the SOCKS5 server needed for interop testing between two userspace nodes doesn't yet support UDP and I didn't want to invent some whole new userspace packet injection interface at this point, as SOCKS seems like a better route, but that's its own bug. Fixes #2302 RELNOTE=netstack mode can now UDP relay to subnets Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-07-21net/dns/resolver: fall back to IPv6 for well-known DoH servers if v4 failsBrad Fitzpatrick2-2/+39
Should help with IPv6-only environments when the tailnet admin only specified IPv4 DNS IPs. See https://github.com/tailscale/tailscale/issues/2447#issuecomment-884188562 Co-Author: Adrian Dewhurst <adrian@tailscale.com> Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-07-21net/dns/resolver: use correct Cloudflare DoH hostnamesBrad Fitzpatrick1-8/+8
We were using the wrong ones for the malware & adult content variants. Docs: https://developers.cloudflare.com/1.1.1.1/1.1.1.1-for-families/setup-instructions/dns-over-https Earlier commit which added them: 236eb4d04d33c43b0d73fb7372353cb26b62421b Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-07-21util/deephash: disambiguate hashing of AppendTo (#2483)Joe Tsai2-2/+12
Prepend size to AppendTo output. Fixes #2443 Signed-off-by: Joe Tsai <joetsai@digital-static.net>
2021-07-21util/deephash: include type as part of hash for interfaces (#2476)Joe Tsai2-1/+48
A Go interface may hold any number of different concrete types. Just because two underlying values hash to the same thing does not mean the two values are identical if they have different concrete types. As such, include the type in the hash.
2021-07-21net/portmapper: return correct upnp portjulianknodt1-1/+7
Previously, this was incorrectly returning the internal port, and using that with the external exposed IP when it did not use WANIPConnection2. In the case when we must provide a port, we return it instead. Noticed this while implementing the integration test for upnp. Signed-off-by: julianknodt <julianknodt@gmail.com>
2021-07-21util/deephash: introduce deliberate instability (#2477)Joe Tsai1-2/+15
Seed the hash upon first use with the current time. This ensures that the stability of the hash is bounded within the lifetime of one program execution. Hopefully, this prevents future bugs where someone assumes that this hash is stable. Signed-off-by: Joe Tsai <joetsai@digital-static.net>
2021-07-21wgengine/netstack: fix doc commentBrad Fitzpatrick1-1/+0
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-07-20wgengine/{monitor,router}: restore Linux ip rules when systemd deletes themBrad Fitzpatrick4-7/+125
Thanks. Fixes #1591 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-07-20tstest/integration: fix filch test flakeJosh Bleecher Snyder2-0/+9
Filch doesn't like having multiple processes competing for the same log files (#937). Parallel integration tests were all using the same log files. Add a TS_LOGS_DIR env var that the integration test can use to use separate log files per test. Fixes #2269 Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-07-20wgengine/router: take a link monitorBrad Fitzpatrick11-18/+56
Prep for #1591 which will need to make Linux's router react to changes that the link monitor observes. The router package already depended on the monitor package transitively. Now it's explicit. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-07-20safesocket: print full lsof command on failureJosh Bleecher Snyder1-3/+4
This makes it easier to manually run the command to discover why it is failing. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-07-20safesocket: reduce log spam while running integration testsJosh Bleecher Snyder1-6/+5
Instead of logging lsof execution failures to stdout, incorporate them into the returned error. While we're here, make it clear that the file success case always returns a nil error. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-07-20tstest/integration: shorten test namesJosh Bleecher Snyder1-3/+7
The maximum unix domain socket path length on darwin is 104 bytes, including the trailing NUL. On my machine, the path created by some newly added tests (6eecf3c9) was too long, resulting in cryptic test failures. Shorten the names of the tests, and add a check to make the diagnosis easier next time. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-07-20Merge pull request #2464 from tailscale/dsnet/opaque-hashJoe Tsai4-49/+27
util/deephash: make hash type opaque
2021-07-20util/deephash: make hash type opaqueJoe Tsai4-49/+27
The fact that Hash returns a [sha256.Size]byte leaks details about the underlying hash implementation. This could very well be any other hashing algorithm with a possible different block size. Abstract this implementation detail away by declaring an opaque type that is comparable. While we are changing the signature of UpdateHash, rename it to just Update to reduce stutter (e.g., deephash.Update). Signed-off-by: Joe Tsai <joetsai@digital-static.net>
2021-07-20derp: rate limit how often same-key clients can kick each other off serverBrad Fitzpatrick2-3/+180
Updates #392 Updates #506 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-07-19net/dns{,/resolver}: quiet DNS output loggingBrad Fitzpatrick3-2/+94
It was a huge chunk of the overall log output and made debugging difficult. Omit and summarize the spammy *.arpa parts instead. Fixes tailscale/corp#2066 (to which nobody had opinions, so)
2021-07-19ipn/ipnlocal: fix 'tailscale up' on Windows without GUIBrad Fitzpatrick2-10/+58
With this, I can now: * install Tailscale * stop the GUI * net stop Tailscale * net start Tailscale * tailscale up --unattended (where the middle three steps simulate what would happen on a Windows Server Core machine without a GUI) Fixes #2137 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-07-19cmd/tailscaled: add func to create ipnserver.OptsBrad Fitzpatrick2-15/+25
To unify the Windows service and non-service/non-Windows paths a bit. And provides a way to make Linux act like Windows for testing. (notably, for testing the fix to #2137) One perhaps visible change of this is that tailscaled.exe when run in cmd.exe/powershell (not as a Windows Service) no longer uses the "_daemon" autostart key. But in addition to being naturally what falls out of this change, that's also what Windows users would likely want, as otherwise the unattended mode user is ignored when the "_daemon" autostart key is specified. Notably, this would let people debug what their normally-run-as-a-service tailscaled is doing, even when they're running in Unattended Mode. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-07-19cmd/tailscale/cli: allow effective GOOS to be changed for integration testsBrad Fitzpatrick1-5/+12
Adds TS_DEBUG_UP_FLAG_GOOS for integration tests to make "tailscale up" act like other OSes. For an upcoming change to test #2137. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-07-19.github/workflows: add 'go generate' CI jobJosh Bleecher Snyder1-0/+34
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-07-19net/dnsfallback: regenerateJosh Bleecher Snyder1-0/+7
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-07-19cmd/addlicense: add command to add licenseheaders to generated codeJosh Bleecher Snyder3-2/+79
And use it to make our stringer invocations match the existing code. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-07-19scripts: remove special case for _strings.go files in check license headersJosh Bleecher Snyder2-3/+4
And add a license header for derp/dropreason_string.go to make it happy. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-07-19tstest/integration: generate deps for all platforms in deps generatorJosh Bleecher Snyder6-3/+254
We have different deps depending on the platform. If we pick a privileged platform, we'll miss some deps. If we use the union of all platforms, the integration test won't compile on some platforms, because it'll import packages that don't compile on that platform. Give in to the madness and give each platform its own deps file. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-07-19tempfork/wireguard-windows: remove unnecessary build tagJosh Bleecher Snyder1-2/+0
The _windows.go suffix suffices. This allows go:generate to run without creating a diff. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-07-19wgengine/magicsock: add debug envvar to force all traffic over DERPJosh Bleecher Snyder1-0/+8
This would have been useful during debugging DERP issues recently. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-07-19wgengine/monitor: don't spam about Linux RTM_NEWRULE eventsBrad Fitzpatrick1-0/+3
The earlier 2ba36c294b51b672073a36a599a61c758d0ffafa started listening for ip rule changes and only cared about DELRULE events, buts its subscription included all rule events, including new ones, which meant we were then catching our own ip rule creations and logging about how they were unknown. Stop that log spam. Updates #1591 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-07-19cmd/tailscaled: use state key constant from ipn packageBrad Fitzpatrick1-10/+2
Rather than redefining it again. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-07-19cmd/derpprobe: add in a delay to wait for mesh info to syncBrad Fitzpatrick1-0/+7
2021-07-18wgengine/monitor: subscribe to Linux ip rule events, log on rule deletesBrad Fitzpatrick1-1/+20
For debugging & working on #1591 where certain versions of systemd-networkd delete Tailscale's ip rule entries. Updates #1591 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-07-17ipn/ipnlocal: make state_test catch the bug fixed by #2445Avery Pennarun1-13/+40
Updates #2434 Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
2021-07-17ipn/ipnlocal: stay out of map poll when downBrad Fitzpatrick5-69/+124
Fixes #2434 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-07-16tstest/integration/vms: codegen for top level tests (#2441)Christine Dodrill11-149/+522
This moves the distribution definitions into a maintainable hujson file instead of just existing as constants in `distros.go`. Comments are maintained from the inline definitions. This uses jennifer[1] for hygenic source tree creation. This allows us to generate a unique top-level test for each VM run. This should hopefully help make the output of `go test` easier to read. This also separates each test out into its own top-level test so that we can better track the time that each distro takes. I really wish there was a way to have the `test_codegen.go` file _always_ run as a part of the compile process instead of having to rely on people remembering to run `go generate`, but I am limited by my tools. This will let us remove the `-distro-regex` flag and use `go test -run` to pick which distros are run. Signed-off-by: Christine Dodrill <xe@tailscale.com>
2021-07-16tstest/integration/vms: use one testcontrol instance per VM (#2437)Christine Dodrill5-101/+113
This paves the way for future MagicDNS tests. Signed-off-by: Christine Dodrill <xe@tailscale.com>
2021-07-15control/{controlknobs,controlclient}: simplify knobs API, fix controlclient ↵Brad Fitzpatrick5-49/+12
crash From integration tests elsewhere: panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x70 pc=0x845c9b] goroutine 226 [running]: tailscale.com/control/controlclient.(*Direct).sendMapRequest(0xc00053e1e0, 0x16670f0, 0xc000353780, 0xffffffffffffffff, 0xc0003e5f10, 0x0, 0x0) /home/runner/go/pkg/mod/tailscale.com@v1.1.1-0.20210715222212-1bb6abc604c1/control/controlclient/direct.go:803 +0x19bb tailscale.com/control/controlclient.(*Direct).PollNetMap(...) /home/runner/go/pkg/mod/tailscale.com@v1.1.1-0.20210715222212-1bb6abc604c1/control/controlclient/direct.go:574 tailscale.com/control/controlclient.(*Auto).mapRoutine(0xc00052a1e0) /home/runner/go/pkg/mod/tailscale.com@v1.1.1-0.20210715222212-1bb6abc604c1/control/controlclient/auto.go:464 +0x571 created by tailscale.com/control/controlclient.(*Auto).Start /home/runner/go/pkg/mod/tailscale.com@v1.1.1-0.20210715222212-1bb6abc604c1/control/controlclient/auto.go:151 +0x65 exit status 2 Also remove types/opt.Bool API addition which is now unnecessary. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-07-15net/portmapper: add upnp port mappingjulianknodt14-53/+432
Add in UPnP portmapping, using goupnp library in order to get the UPnP client and run the portmapping functions. This rips out anywhere where UPnP used to be in portmapping, and has a flow separate from PMP and PCP. RELNOTE=portmapper now supports UPnP mappings Fixes #682 Updates #2109 Signed-off-by: julianknodt <julianknodt@gmail.com>
2021-07-15net/dns/resolver: upgrade forwarded MagicDNS queries to DoH when IP knownBrad Fitzpatrick2-3/+205
Recognize Cloudflare, Google, Quad9 which are by far the majority of upstream DNS servers that people use. RELNOTE=MagicDNS now uses DNS-over-HTTPS when querying popular upstream resolvers, so DNS queries aren't sent in the clear over the Internet. Updates #915 (might fix it?) Updates #988 (gets us closer, if it fixes Android) Updates #74 (not yet configurable, but progress) Updates #2056 (not yet configurable, dup of #74?) Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-07-15Implemented Commandline Download Speedtest (#2064)Aaditya Chaudhary5-0/+490
Added the net/speedtest package that contains code for starting up a speedtest server and a client. The speedtest command for starting a client takes in a duration for the speedtest as well as the host and port of the speedtest server to connect to. The speedtest command for starting a server takes in a host:port pair to listen on. Signed-off-by: Aaditya Chaudhary <32117362+AadityaChaudhary@users.noreply.github.com>