summaryrefslogtreecommitdiffhomepage
AgeCommit message (Collapse)AuthorFilesLines
2021-05-17cmd/tailscale{,d}: combine into a single binaryonebinaryDenton Gentry19-4/+20
To reduce size, combine tailscaled and tailscale into a single binary which will figure out what it should do based on argv[0]. Signed-off-by: Denton Gentry <dgentry@tailscale.com>
2021-05-16all: adapt to opaque netaddr typesJosh Bleecher Snyder54-371/+358
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-14scripts: fix up installer script comments.David Anderson1-1/+3
Signed-off-by: David Anderson <danderson@tailscale.com>
2021-05-14scripts: detect curl vs. wget and use the right one.David Anderson1-2/+15
Signed-off-by: David Anderson <danderson@tailscale.com>
2021-05-14scripts: use codenames for ubuntu, since that's what our repo uses.David Anderson1-7/+7
Signed-off-by: David Anderson <danderson@tailscale.com>
2021-05-14scripts: add an install script.David Anderson1-0/+384
The script detects one of the supported OS/version combos, and issues the right install instructions for it. Co-authored-by: Christine Dodrill <xe@tailscale.com> Signed-off-by: David Anderson <danderson@tailscale.com>
2021-05-14tsnet: add Tailscale-as-a-library packageBrad Fitzpatrick3-2/+329
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-05-13cmd/tailscale: make ping --until-direct require direct connection to exit 0Josh Bleecher Snyder1-0/+3
If --until-direct is set, the goal is to make a direct connection. If we failed at that, say so, and exit with an error. RELNOTE=tailscale ping --until-direct (the default) now exits with a non-zero exit code if no direct connection was established. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-05-12ipnlocal: fix switching users while logged in + Stopped.Avery Pennarun2-72/+125
This code path is very tricky since it was originally designed for the "re-authenticate to refresh my keys" use case, which didn't want to lose the original session even if the refresh cycle failed. This is why it acts differently from the Logout(); Login(); case. Maybe that's too fancy, considering that it probably never quite worked at all, for switching between users without logging out first. But it works now. This was more invasive than I hoped, but the necessary fixes actually removed several other suspicious BUG: lines from state_test.go, so I'm pretty confident this is a significant net improvement. Fixes tailscale/corp#1756. Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
2021-05-12controlclient: update Persist.LoginName when it changes.Avery Pennarun1-2/+2
Well, that was anticlimactic. Fixes tailscale/corp#461. Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
2021-05-12ipnlocal: fix deadlock in RequestEngineStatusAndWait() error path.Avery Pennarun1-0/+8
If the engine was shutting down from a previous session (e.closing=true), it would return an error code when trying to get status. In that case, ipnlocal would never unblock any callers that were waiting on the status. Not sure if this ever happened in real life, but I accidentally triggered it while writing a test. Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
2021-05-12tstest/integration{,/testcontrol}: add node update support, two node testBrad Fitzpatrick2-9/+90
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-05-12tstest/integration: build test binaries with -race if test itself isBrad Fitzpatrick1-3/+4
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-05-12version: add func IsRace to report whether race detector enabledBrad Fitzpatrick2-0/+22
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-05-12tstest/integration: fix integration test on linux/386Brad Fitzpatrick1-3/+17
Apparently can't use GOBIN with GOARCH. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-05-12tstest/integration{,/testcontrol}: add testcontrol.RequireAuth mode, new testBrad Fitzpatrick2-60/+306
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-05-11wgengine: remove wireguard-go DeviceOptionsJosh Bleecher Snyder3-16/+4
We no longer need them. This also removes the 32 bytes of prefix junk before endpoints. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-05-11all: add extra information to serialized endpointsJosh Bleecher Snyder14-184/+242
magicsock.Conn.ParseEndpoint requires a peer's public key, disco key, and legacy ip/ports in order to do its job. We currently accomplish that by: * adding the public key in our wireguard-go fork * encoding the disco key as magic hostname * using a bespoke comma-separated encoding It's a bit messy. Instead, switch to something simpler: use a json-encoded struct containing exactly the information we need, in the form we use it. Our wireguard-go fork still adds the public key to the address when it passes it to ParseEndpoint, but now the code compensating for that is just a couple of simple, well-commented lines. Once this commit is in, we can remove that part of the fork and remove the compensating code. Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
2021-05-11wgengine/wglog: optimize wireguardGoStringJosh Bleecher Snyder1-7/+14
The new code is ugly, but much faster and leaner. name old time/op new time/op delta SetPeers-8 7.81µs ± 1% 3.59µs ± 1% -54.04% (p=0.000 n=9+10) name old alloc/op new alloc/op delta SetPeers-8 7.68kB ± 0% 2.53kB ± 0% -67.08% (p=0.000 n=10+10) name old allocs/op new allocs/op delta SetPeers-8 237 ± 0% 99 ± 0% -58.23% (p=0.000 n=10+10) Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-05-11wgengine/wglog: add BenchmarkSetPeerJosh Bleecher Snyder1-0/+28
Because it showed up on hello profiles. Cycle through some moderate-sized sets of peers. This should cover the "small tweaks to netmap" and the "up/down cycle" cases. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-05-11internal/deephash: rename from deepprintBrad Fitzpatrick6-17/+12
Yes, it printed, but that was an implementation detail for hashing. And coming optimization will make it print even less. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-05-11internal/deepprint: improve benchmarkJosh Bleecher Snyder1-10/+13
This more closely matches our real usage of deepprint. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-05-11internal/deepprint: close struct curly parensJosh Bleecher Snyder1-0/+1
Not that it matters, but we were missing a close parens. It's cheap, so add it. name old time/op new time/op delta Hash-8 6.64µs ± 0% 6.67µs ± 1% +0.42% (p=0.008 n=9+10) name old alloc/op new alloc/op delta Hash-8 1.54kB ± 0% 1.54kB ± 0% ~ (all equal) name old allocs/op new allocs/op delta Hash-8 37.0 ± 0% 37.0 ± 0% ~ (all equal) Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-05-11internal/deepprint: stop printing struct field namesJosh Bleecher Snyder1-4/+1
The struct field names don't change within a single run, so they are irrelevant. Use the field index instead. name old time/op new time/op delta Hash-8 6.52µs ± 0% 6.64µs ± 0% +1.91% (p=0.000 n=6+9) name old alloc/op new alloc/op delta Hash-8 1.67kB ± 0% 1.54kB ± 0% -7.66% (p=0.000 n=10+10) name old allocs/op new allocs/op delta Hash-8 53.0 ± 0% 37.0 ± 0% -30.19% (p=0.000 n=10+10) Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-05-11internal/deepprint: replace Fprintf(w, const) with w.WriteStringJosh Bleecher Snyder1-8/+7
name old time/op new time/op delta Hash-8 7.77µs ± 0% 6.29µs ± 1% -19.11% (p=0.000 n=9+10) name old alloc/op new alloc/op delta Hash-8 1.67kB ± 0% 1.67kB ± 0% ~ (all equal) name old allocs/op new allocs/op delta Hash-8 53.0 ± 0% 53.0 ± 0% ~ (all equal) Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-05-11internal/deepprint: special-case some common typesJosh Bleecher Snyder1-0/+75
These show up a lot in our data structures. name old time/op new time/op delta Hash-8 11.5µs ± 1% 7.8µs ± 1% -32.17% (p=0.000 n=10+10) name old alloc/op new alloc/op delta Hash-8 1.98kB ± 0% 1.67kB ± 0% -15.73% (p=0.000 n=10+10) name old allocs/op new allocs/op delta Hash-8 82.0 ± 0% 53.0 ± 0% -35.37% (p=0.000 n=10+10) Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-05-11internal/deepprint: buffer writesJosh Bleecher Snyder2-11/+10
The sha256 hash writer doesn't implement WriteString. (See https://github.com/golang/go/issues/38776.) As a consequence, we end up converting many strings to []byte. Wrapping a bufio.Writer around the hash writer lets us avoid these conversions by using WriteString. Using a bufio.Writer is, perhaps surprisingly, almost as cheap as using unsafe. The reason is that the sha256 writer does internal buffering, but doesn't do any when handed larger writers. Using a bufio.Writer merely shifts the data copying from one buffer to a different one. Using a concrete type for Print and print cuts 10% off of the execution time. name old time/op new time/op delta Hash-8 15.3µs ± 0% 11.5µs ± 0% -24.84% (p=0.000 n=10+10) name old alloc/op new alloc/op delta Hash-8 2.82kB ± 0% 1.98kB ± 0% -29.57% (p=0.000 n=10+10) name old allocs/op new allocs/op delta Hash-8 140 ± 0% 82 ± 0% -41.43% (p=0.000 n=10+10) Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-05-11internal/deepprint: add BenchmarkHashJosh Bleecher Snyder1-0/+8
deepprint currently accounts for 15% of allocs in tailscaled. This is a useful benchmark to have. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-05-11go.mod: bump inet.af/netaddrJosh Bleecher Snyder2-1/+3
For IPPort.MarshalText optimizations. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-05-11Revert "wgengine/bench: skip flaky test"Josh Bleecher Snyder1-1/+0
This reverts commit d707e2f7e524a994ce38615d74f1793784705232. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-05-11wgengine/bench: ignore "engine closing" errorsJosh Bleecher Snyder2-1/+10
On benchmark completion, we shut down the wgengine. If we happen to poll for status during shutdown, we get an "engine closing" error. It doesn't hurt anything; ignore it. Fixes tailscale/corp#1776 Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-05-11wgengine/bench: skip flaky testBrad Fitzpatrick1-0/+1
Updates tailscale/corp#1776 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-05-10net/dns: don't use interfaces.Tailscale to find the tailscale interface index.David Anderson2-32/+21
interfaces.Tailscale only returns an interface if it has at least one Tailscale IP assigned to it. In the resolved DNS manager, when we're called upon to tear down DNS config, the interface no longer has IPs. Instead, look up the interface index on construction and reuse it throughout the daemon lifecycle. Fixes #1892. Signed-off-by: David Anderson <dave@natulte.net>
2021-05-10go.mod: bump wireguard-goBrad Fitzpatrick2-1/+3
2021-05-10ipn{,/ipnserver}: delay JSON marshaling of ipn.NotifiesBrad Fitzpatrick3-20/+51
If nobody is connected to the IPN bus, don't burn CPU & waste allocations (causing more GC) by encoding netmaps for nobody. This will notably help hello.ipn.dev. Updates tailscale/corp#1773 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-05-10util/dnsname: normalize leading dots in ToFQDN.David Anderson2-2/+6
Fixes #1888. Signed-off-by: David Anderson <dave@natulte.net>
2021-05-10go.mod: pull in wintun alignment fix from upstream wireguard-goJosh Bleecher Snyder2-1/+3
https://github.com/tailscale/wireguard-go/compare/6cd106ab1339...030c638da3df Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-05-10wf: implement windows firewall using inet.af/wf.Maisem Ali4-7/+527
Signed-off-by: Maisem Ali <maisem@tailscale.com>
2021-05-10wgengine/bench: hold lock in TrafficGen.GotPacket while calling first packet ↵Josh Bleecher Snyder1-3/+1
callback Without any synchronization here, the "first packet" callback can be delayed indefinitely, while other work continues. Since the callback starts the benchmark timer, this could skew results. Worse, if the benchmark manages to complete before the benchmark timer begins, it'll cause a data race with the benchmark shutdown performed by package testing. That is what is reported in #1881. This is a bit unfortunate, in that it means that users of TrafficGen have to be careful to keep this callback speedy and lightweight and to avoid deadlocks. Fixes #1881 Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-05-10wgengine/bench: handle multiple Engine status callbacksJosh Bleecher Snyder1-2/+4
It is possible to get multiple status callbacks from an Engine. We need to wait for at least one from each Engine. Without limiting to one per Engine, wait.Wait can exit early or can panic due to a negative counter. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-05-10wgengine/bench: close Engines on benchmark completionJosh Bleecher Snyder3-3/+10
This reduces the speed with which these benchmarks exhaust their supply fds. Not to zero unfortunately, but it's still helpful when doing long runs. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-05-10types/wgkey: optimize Key.ShortStringJosh Bleecher Snyder1-2/+10
name old time/op new time/op delta ShortString-8 82.6ns ± 0% 15.6ns ± 0% -81.07% (p=0.008 n=5+5) name old alloc/op new alloc/op delta ShortString-8 104B ± 0% 8B ± 0% -92.31% (p=0.008 n=5+5) name old allocs/op new allocs/op delta ShortString-8 3.00 ± 0% 1.00 ± 0% -66.67% (p=0.008 n=5+5) Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-05-10types/wgkey: add BenchmarkShortStringJosh Bleecher Snyder1-0/+10
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-05-10net/interface: remove darwin fetchRoutingTable workaroundBrad Fitzpatrick3-33/+10
Fixed upstream. Bump dep. Updates #1345 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-05-07tailcfg: optimize keyMarshalTextJosh Bleecher Snyder2-4/+15
This function accounted for ~1% of all allocs by tailscaled. It is trivial to improve, so may as well. name old time/op new time/op delta KeyMarshalText-8 197ns ± 0% 47ns ± 0% -76.12% (p=0.016 n=4+5) name old alloc/op new alloc/op delta KeyMarshalText-8 200B ± 0% 80B ± 0% -60.00% (p=0.008 n=5+5) name old allocs/op new allocs/op delta KeyMarshalText-8 5.00 ± 0% 1.00 ± 0% -80.00% (p=0.008 n=5+5) Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-05-07cmd/tailscale: rewrite the "up" checker, fix bugsBrad Fitzpatrick2-358/+375
The old way was way too fragile and had felt like it had more special cases than normal cases. (see #1874, #1860, #1834, etc) It became very obvious the old algorithm didn't work when we made the output be pretty and try to show the user the command they need to run in 5ecc7c7200bda43f02f9a04fb684ad4f3614c48a for #1746) The new algorithm is to map the prefs (current and new) back to flags and then compare flags. This nicely handles the OS-specific flags and the n:1 and 1:n flag:pref cases. No change in the existing already-massive test suite, except some ordering differences (the missing items are now sorted), but some new tests are added for behavior that was broken before. In particular, it now: * preserves non-pref boolean flags set to false, and preserves exit node IPs (mapping them back from the ExitNodeID pref, as well as ExitNodeIP), * doesn't ignore --advertise-exit-node when doing an EditPrefs call (#1880) * doesn't lose the --operator on the non-EditPrefs paths (e.g. with --force-reauth, or when the backend was not in state Running). Fixes #1880 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-05-07ipn/{ipnlocal,ipnstate}: add PeerStatus.ID stable ID to status --json outputBrad Fitzpatrick2-0/+8
Needed for the "up checker" to map back from exit node stable IDs (the ipn.Prefs.ExitNodeID) back to an IP address in error messages. But also previously requested so people can use it to then make API calls. The upcoming "tailscale admin" subcommand will probably need it too. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-05-06Revert "net/dns: set IPv4 auto mode in NM, so it lets us set DNS."David Anderson1-22/+12
This reverts commit 7d16c8228bcf70a3b82afe994e8c5fa42057c5f3. I have no idea how I ended up here. The bug I was fixing with this change fails to reproduce on Ubuntu 18.04 now, and this change definitely does break 20.04, 20.10, and Debian Buster. So, until we can reliably reproduce the problem this was meant to fix, reverting. Part of #1875 Signed-off-by: David Anderson <dave@natulte.net>
2021-05-06.github: remove verbose issue templates, add triage label.David Anderson2-50/+2
Signed-off-by: David Anderson <danderson@tailscale.com>
2021-05-06net/dns: log the correct error when NM Reapply fails.David Anderson1-1/+1
Found while debugging #1870. Signed-off-by: David Anderson <danderson@tailscale.com>