Brad Fitzpatrick and Brad Fitzpatrick
577f321c38
wgengine/magicsock: revise derp fallback logic
...
Revision to earlier 6284454ae5
Don't be sticky if we have no peers.
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com >
2020-03-25 13:09:18 -07:00
Brad Fitzpatrick
2e420ad8b6
wgengine, wgengine/filter: minor doc, style, performance, locking changes
...
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com >
2020-03-25 08:41:01 -07:00
Brad Fitzpatrick and Brad Fitzpatrick
6284454ae5
wgengine/magicsock: if UDP blocked, pick DERP where most peers are
...
Updates #207
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com >
2020-03-25 08:00:44 -07:00
Brad Fitzpatrick
d321190578
wgengine/magicsock: stringify [IPv6]:port normally in AddrSet.String
2020-03-24 13:40:43 -07:00
Brad Fitzpatrick
3c3ea8bc8a
wgengine/magicsock: finish IPv6 transport support
...
DEBUG_INCLUDE_IPV6=1 is still required, but works now.
Updates #18 (fixes it, once env var gate is removed)
2020-03-24 10:56:22 -07:00
Brad Fitzpatrick
82ed7e527e
wgengine/magicsock: remove log allocation
...
This was the whole point but I goofed at the last line.
2020-03-24 08:14:47 -07:00
Brad Fitzpatrick
8454bbbda5
wgengine/magicsock: more logging improvements
...
* remove endpoint discovery noise when results unchanged
* consistently spell derp nodes as "derp-N"
* replace "127.3.3.40:" with "derp-" in CreateEndpoint log output
* stop early DERP setup before SetPrivateKey is called;
it just generates log nosie
* fix stringification of peer ShortStrings (it had an old %x on it,
rendering it garbage)
* describe why derp routes are changing, with one of:
shared home, their home, our home, alt
2020-03-24 08:12:55 -07:00
Brad Fitzpatrick and Brad Fitzpatrick
64aff0db7b
control/controlclient: add TODO to delete the UAPI method
2020-03-24 07:25:14 -07:00
Brad Fitzpatrick and Brad Fitzpatrick
7740cbd8d9
ipn: call SetNetInfoCallback later, in Start
...
It was being called back into ultimately from magicsock before there
was a control client.
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com >
2020-03-23 22:19:40 -07:00
Brad Fitzpatrick
680311b3df
wgengine/magicsock: fix few remaining logs without package prefix
2020-03-23 22:11:49 -07:00
Brad Fitzpatrick
c473927558
wgengine/magicsock: clean up, add, improve DERP logs
2020-03-23 21:57:58 -07:00
Brad Fitzpatrick
e749377a56
derp/derphttp: remove a redundant log message
2020-03-23 21:23:36 -07:00
Brad Fitzpatrick
1d3f45f9be
derp/derphttp: ignore PeerGoneMessage in test
2020-03-23 14:13:49 -07:00
Brad Fitzpatrick
ea9310403d
wgengine/magicsock: re-STUN on DERP connection death
...
Fixes #201
2020-03-23 13:19:33 -07:00
Brad Fitzpatrick and Brad Fitzpatrick
1ab5b31c4b
derp, magicsock: send new "peer gone" frames when previous sender disconnects
...
Updates #150 (not yet enabled by default in magicsock)
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com >
2020-03-22 21:00:47 -07:00
Brad Fitzpatrick
b6f77cc48d
wgengine/magicsock: return early, outdent in derpWriteChanOfAddr
2020-03-22 14:08:59 -07:00
Brad Fitzpatrick
8c4cef60f8
derp: wait for send goroutine to finish before returning from run
...
I saw a test flake due to the sender goroutine logging (ultimately to
t.Logf) after the server was closed.
This makes sure the all goroutines are cleaned up before Server.Close
returns.
2020-03-22 13:10:07 -07:00
Brad Fitzpatrick
521ad7b0fc
derp: only flush writes to clients when we're out of things to write
...
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com >
2020-03-22 08:01:25 -07:00
Brad Fitzpatrick
0a25abcdaa
derp: remove TODO comment
...
It was done in bf704a5218
2020-03-22 07:54:50 -07:00
Brad Fitzpatrick
8519a1b29f
derp: revert rename of pkt to sendMsg
...
New plan, sorry.
Most reverts 77921a31b1 , except some doc changes.
2020-03-21 22:17:22 -07:00
Brad Fitzpatrick and Brad Fitzpatrick
c34b350efa
derp: remove the mutex around and closing of send channel
...
Makes it less complicated.
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com >
2020-03-21 22:00:04 -07:00
Brad Fitzpatrick
77921a31b1
derp: rename pkt to sendMsg, in prep for other types of writes
...
Updates #150
2020-03-21 20:34:49 -07:00
Brad Fitzpatrick
1453aecb44
derp: add sclient.done channel, simplify some context passing
...
This is mostly prep for a few future CLs, making sure we always have a
close-on-dead done channel available to select on when doing other
channel operations.
2020-03-21 18:28:34 -07:00
Brad Fitzpatrick and Dave Anderson
fd824df1fa
derp: export metric for server's initial MemStats.Sys reading
...
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com >
2020-03-20 15:37:36 -07:00
Brad Fitzpatrick
dd31285ad4
wgengine/magicsock: send IPv6 using pconn6, if available
...
In prep for IPv6 support. Nothing should make it this far yet.
2020-03-20 14:30:12 -07:00
Brad Fitzpatrick
af277a6762
controlclient, magicsock: add debug knob to request IPv6 endpoints
...
Add opt-in method to request IPv6 endpoints from the control plane.
For now they should just be skipped. A previous version of this CL was
unconditional and reportedly had problems that I can't reproduce. So
make it a knob until the mystery is solved.
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com >
2020-03-20 14:27:24 -07:00
Brad Fitzpatrick
221e7d7767
wgengine/magicsock: make log message include DERP port (node)
2020-03-20 13:51:20 -07:00
Brad Fitzpatrick
33bdcabf03
wgengine/magicsock: call stun callback w/ only valid part of STUN packet
2020-03-20 13:44:27 -07:00
Brad Fitzpatrick
f9cc4e8f53
tailcfg: restore MapRequest.IncludeIPv6 bool
...
Partially restores 0be475ba46
2020-03-20 08:13:47 -07:00
Brad Fitzpatrick
f9184ad12b
go.mod: update wireguard-go for https://github.com/tailscale/wireguard-go/pull/13
2020-03-19 22:46:36 -07:00
Brad Fitzpatrick and Brad Fitzpatrick
94024355ed
tailcfg, controlclient, magicsock: request IPv6 endpoints, but ignore them
...
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com >
2020-03-19 21:01:52 -07:00
Brad Fitzpatrick
51b669e4bd
ipn: skip tailscaled UDP ports in service list
2020-03-19 19:56:02 -07:00
Brad Fitzpatrick
60ea635c6d
wgengine/magicsock: delete inaccurate comment
...
I meant to include this in the earlier commit.
2020-03-19 19:48:02 -07:00
Brad Fitzpatrick and Brad Fitzpatrick
a184e05290
wgengine/magicsock: listen on udp6, use it for STUN, report endpoint
...
More steps towards IPv6 transport.
We now send it to tailcontrol, which ignores it.
But it doesn't actually actually support IPv6 yet (outside of STUN).
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com >
2020-03-19 13:54:38 -07:00
Brad Fitzpatrick
7caa288213
wgengine/magicsock: rename pconn field to pconn4, in prep for pconn6
2020-03-19 08:49:30 -07:00
Brad Fitzpatrick
5fa825f057
go.mod, go.sum: update
2020-03-19 08:49:12 -07:00
Brad Fitzpatrick
14a2564ef0
go.mod: bump wireguard-go
2020-03-18 13:26:08 -07:00
Brad Fitzpatrick
19a1704abd
netcheck: use best DERP server in past 5 minutes to avoid flip-flopping
...
Fixes #162
2020-03-18 13:07:13 -07:00
Brad Fitzpatrick
6de37f4cc0
tsweb: move some comments, add a TODO
2020-03-18 09:54:48 -07:00
Brad Fitzpatrick and Brad Fitzpatrick
f8d67bb591
portlist: ignore ports bound to localhost
...
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com >
2020-03-17 20:55:45 -07:00
Brad Fitzpatrick
c706731dc7
tsweb: add copyright header
...
And fix an unlikely but potential crash.
2020-03-17 20:08:13 -07:00
Brad Fitzpatrick
8f9fa6a842
logtail: minor style/simplification changes
2020-03-15 22:41:50 -07:00
Brad Fitzpatrick
8de67844bd
cmd/tailscale: make failure message when tailscaled down less technical
2020-03-15 22:40:41 -07:00
Brad Fitzpatrick
5aafe0ee96
cmd/tailscale: don't crash on too many non-flag args
2020-03-15 22:27:36 -07:00
Brad Fitzpatrick
d348b94505
stun, stunner: clarify an error log message more
...
But two earlier changes mean this doesn't show up anymore anyway.
But if it does, it'll be a nice message.
2020-03-15 22:19:45 -07:00
Brad Fitzpatrick and Brad Fitzpatrick
120273d7f6
portlist: document, clean up, fix an open fd spike, optimize a bit
...
I noticed portlist when looking at some profiles and hadn't looked at
the code much before. This is a first pass over it. It allocates a
fair bit. More love remains, but this does a bit:
name old time/op new time/op delta
GetList-8 9.92ms ± 8% 9.64ms ±12% ~ (p=0.247 n=10+10)
name old alloc/op new alloc/op delta
GetList-8 931kB ± 0% 869kB ± 0% -6.70% (p=0.000 n=10+10)
name old allocs/op new allocs/op delta
GetList-8 4.59k ± 0% 3.69k ± 1% -19.71% (p=0.000 n=10+10)
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com >
2020-03-13 21:06:41 -07:00
Brad Fitzpatrick
6c3820e8c4
cmd/tailscaled: rename relaynode reference in defaults file comment
2020-03-13 14:38:04 -07:00
Brad Fitzpatrick
19cc4f8b8e
control/controlclient: remove a number literal in string slice offset
2020-03-13 09:48:15 -07:00
Brad Fitzpatrick and Brad Fitzpatrick
db2436c7ff
wgengine/magicsock: don't interrupt endpoint updates, merge all mutex into one
...
Before, endpoint updates were constantly being interrupted and resumed
on Linux due to tons of LinkChange messages from over-zealous Linux
netlink messages (from router_linux.go)
Now that endpoint updates are fast and bounded in time anyway, just
let them run to completion, but note that another needs to be
scheduled after.
Now logs went from pages of noise to just:
root@taildoc:~# grep -i -E 'stun|endpoint update' log
2020/03/13 08:51:29 magicsock.Conn: starting endpoint update (initial)
2020/03/13 08:51:30 magicsock.Conn.ReSTUN: endpoint update active, need another later ("link-change-minor")
2020/03/13 08:51:31 magicsock.Conn: starting endpoint update (link-change-minor)
2020/03/13 08:51:31 magicsock.Conn.ReSTUN: endpoint update active, need another later ("link-change-minor")
2020/03/13 08:51:33 magicsock.Conn: starting endpoint update (link-change-minor)
2020/03/13 08:51:33 magicsock.Conn.ReSTUN: endpoint update active, need another later ("link-change-minor")
2020/03/13 08:51:35 magicsock.Conn: starting endpoint update (link-change-minor)
2020/03/13 08:51:35 magicsock.Conn.ReSTUN: endpoint update active, need another later ("link-change-minor")
Or, seen in another run:
2020/03/13 08:45:41 magicsock.Conn: starting endpoint update (periodic)
2020/03/13 08:46:09 magicsock.Conn: starting endpoint update (periodic)
2020/03/13 08:46:21 magicsock.Conn: starting endpoint update (link-change-major)
2020/03/13 08:46:37 magicsock.Conn: starting endpoint update (periodic)
2020/03/13 08:47:05 magicsock.Conn: starting endpoint update (periodic)
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com >
2020-03-13 09:34:11 -07:00
Brad Fitzpatrick and Brad Fitzpatrick
db31550854
wgengine: don't Reconfig on boring link changes
...
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com >
2020-03-13 07:45:59 -07:00
Brad Fitzpatrick and Brad Fitzpatrick
b9c6d3ceb8
netcheck: work behind UDP-blocked networks again, add tests
...
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com >
2020-03-12 14:49:06 -07:00
Brad Fitzpatrick
a87ee4168a
stunner: quiet a harmless log warning
2020-03-12 14:14:23 -07:00
Brad Fitzpatrick and Brad Fitzpatrick
bc73dcf204
wgengine/magicsock: don't block in Send waiting for derphttp.Send
...
Fixes #137
Updates #109
Updates #162
Updates #163
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com >
2020-03-12 12:19:12 -07:00
Brad Fitzpatrick and Brad Fitzpatrick
8807913be9
wgengine/magicsock: wait for previous DERP goroutines to end before new ones
...
Updates #109 (hopefully fixes, will wait for graphs to be happy)
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com >
2020-03-12 12:19:12 -07:00
Brad Fitzpatrick
eff6dcdb4e
wgengine/magicsock: log more about why we're re-STUNing
2020-03-12 12:09:25 -07:00
Brad Fitzpatrick
52c0cb12fb
stunner: return wrapped error (currently unused)
2020-03-12 11:21:19 -07:00
Brad Fitzpatrick
b4d02a251a
syncs: add new package for extra sync types
2020-03-12 11:13:33 -07:00
Brad Fitzpatrick
afc3479d04
netcheck: fix data races for staggler STUN packets arriving after GetReport
...
Fixes #179
2020-03-11 15:35:12 -07:00
Brad Fitzpatrick
b3ddf51a15
wgengine/magicsock: add a pointer value for logging
...
Updates #109
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com >
2020-03-11 15:12:19 -07:00
Brad Fitzpatrick and Brad Fitzpatrick
0d3f42e1d8
netcheck: ignore IPv4 STUN failures if we saw at least one reply
...
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com >
2020-03-11 13:57:23 -07:00
Brad Fitzpatrick and Brad Fitzpatrick
ed7e088729
netcheck: ignore IPv6 STUN failures
...
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com >
2020-03-11 12:44:59 -07:00
Brad Fitzpatrick and Brad Fitzpatrick
4fd29349b9
derp: add clients_replaced counter
...
Updates #109
2020-03-11 11:55:43 -07:00
Brad Fitzpatrick
b0f8931d26
wgengine/magicsock: make a test signature a bit more explicit
2020-03-11 09:51:33 -07:00
Brad Fitzpatrick and Brad Fitzpatrick
01b4bec33f
stunner: re-do how Stunner works
...
It used to make assumptions based on having Anycast IPs that are super
near. Now we're intentionally going to a bunch of different distant
IPs to measure latency.
Also, optimize how the hairpin detection works. No need to STUN on
that socket. Just use that separate socket for sending, once we know
the other UDP4 socket's endpoint. The trick is: make our test probe
also a STUN packet, so it fits through magicsock's existing STUN
routing.
This drops netcheck from ~5 seconds to ~250-500ms.
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com >
2020-03-11 08:08:48 -07:00
Brad Fitzpatrick and Brad Fitzpatrick
023df9239e
Move linkstate boring change filtering to magicsock
...
So we can at least re-STUN on boring updates.
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com >
2020-03-10 12:50:03 -07:00
Brad Fitzpatrick
5c1e443d34
wgengine/monitor: don't call LinkChange when interfaces look unchanged
...
Basically, don't trust the OS-level link monitor to only tell you
interesting things. Sanity check it.
Also, move the interfaces package into the net directory now that we
have it.
2020-03-10 11:03:19 -07:00
Brad Fitzpatrick and Brad Fitzpatrick
39c0ae1dba
derp/derpmap: new DERP config package, merge netcheck into magicsock more
...
Fixes #153
Updates #162
Updates #163
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com >
2020-03-10 10:37:25 -07:00
Brad Fitzpatrick
bd0e20f351
net/dnscache: ignore annoying staticcheck check
2020-03-09 22:12:22 -07:00
Brad Fitzpatrick
d44325295e
net/dnscache: initialize the single Resolver more directly
2020-03-09 21:05:01 -07:00
Brad Fitzpatrick
d07146aafb
go.mod, go.sum: update
2020-03-09 21:01:08 -07:00
Brad Fitzpatrick and Brad Fitzpatrick
5d8001d0ad
derp: add varz for home moves
...
Updates #162
Updates #163 (maybe)
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com >
2020-03-09 11:09:27 -07:00
Brad Fitzpatrick
8f0fd01efd
net/dnscache: add copyright header to test
2020-03-09 11:07:31 -07:00
Brad Fitzpatrick
4800926006
wgengine/magicsock: add AddrSet appendDests+UpdateDst tests
2020-03-09 09:13:28 -07:00
Brad Fitzpatrick and Brad Fitzpatrick
f42b9b6c9a
wgengine/magicsock: don't discard UDP packet on UDP+DERP race
...
Fixes #155
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com >
2020-03-07 14:09:06 -08:00
Brad Fitzpatrick
f6dd2128d9
version: bump
2020-03-06 14:57:27 -08:00
Brad Fitzpatrick
a9cd8f31de
tsweb: don't double import expvar; appease staticcheck
2020-03-06 13:08:32 -08:00
Brad Fitzpatrick
890f5dff40
tsweb: export runtime.MemStats var in Prometheus format
2020-03-06 13:02:01 -08:00
Brad Fitzpatrick
8abdbbdd1f
cmd/derper: also link to /debug/varz
2020-03-06 13:02:01 -08:00
Brad Fitzpatrick
946df89fa6
types/logger: add adapters for Logf to std Logger/Writer
2020-03-06 12:00:24 -08:00
Brad Fitzpatrick and Brad Fitzpatrick
61d83f759b
wgengine/magicsock: remove redundant derpMagicIP comparison
...
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com >
2020-03-06 11:31:39 -08:00
Brad Fitzpatrick
fbab12c94c
wgengine/magicsock: skip netcheck if external STUN aren't in use
...
Updates #146 (not a complete fix yet probably)
2020-03-06 07:47:54 -08:00
Brad Fitzpatrick
fe0051fafd
wgengine/magicsock: expand AddrSet.addrs comment
2020-03-05 21:17:41 -08:00
Brad Fitzpatrick
e733fa6f7e
derp: add some varz tests for active/home conns
2020-03-05 20:29:07 -08:00
Brad Fitzpatrick
dd456f04c5
derp: actually record client's preferred bit
2020-03-05 19:02:54 -08:00
Brad Fitzpatrick
61f3fda405
tsweb: let expvar.Ints be gauges too
2020-03-05 15:10:01 -08:00
Brad Fitzpatrick
6978b93bdd
derp, magicsock: track home (preferred) vs visiting connections for stats
2020-03-05 15:00:56 -08:00
Brad Fitzpatrick
12b77f30ad
wgengine/magicsock: close stale DERP connections
2020-03-05 12:49:37 -08:00
Brad Fitzpatrick
cf4aacde57
derp/derphttp: appease staticcheck
2020-03-05 12:34:57 -08:00
Brad Fitzpatrick
2cff9016e4
net/dnscache: add overly simplistic DNS cache package for selective use
...
I started to write a full DNS caching resolver and I realized it was
overkill and wouldn't work on Windows even in Go 1.14 yet, so I'm
doing this tiny one instead for now, just for all our netcheck STUN
derp lookups, and connections to DERP servers. (This will be caching a
exactly 8 DNS entries, all ours.)
Fixes #145 (can be better later, of course)
2020-03-05 12:23:37 -08:00
Brad Fitzpatrick
a36ccb8525
wgengine/magicsock: actually add to the activeDerp map
...
Fixes bug just introduced in 8f9849c140; not tested enough :(
2020-03-05 12:23:37 -08:00
Brad Fitzpatrick
8f9849c140
wgengine/magicsock: collapse three DERP maps down into one
2020-03-05 08:54:08 -08:00
Brad Fitzpatrick
7e1bed82bd
go.sum: update
2020-03-05 08:51:21 -08:00
Brad Fitzpatrick
40ebba1373
magicsock: use [unexpected] convention more
...
Fixes #136 (not entirely, but we have a convention now)
2020-03-05 08:18:55 -08:00
Brad Fitzpatrick
848a2bddf0
wgengine/magicsock: update set of DERP nodes
2020-03-05 08:18:55 -08:00
Brad Fitzpatrick
57de94c7aa
tsweb: add /debug/ access via &debugkey + TS_DEBUG_KEY_PATH
2020-03-04 13:49:30 -08:00
Brad Fitzpatrick
ff6b3c2c38
netcheck: include two more DERP nodes, show more in CLI report
2020-03-04 13:40:49 -08:00
Brad Fitzpatrick and Brad Fitzpatrick
eac62ec5ff
ipn, wgengine/magicsock: add ipn.Prefs.DisableDERP bool
...
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com >
2020-03-04 12:53:37 -08:00
Brad Fitzpatrick and Brad Fitzpatrick
bf704a5218
derp: protocol negotiation, add v2: send src pub keys to clients in packets
...
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com >
2020-03-04 09:55:13 -08:00
Brad Fitzpatrick
596fd449b9
netcheck: add TODO about alternate timing strategies
2020-03-04 08:20:38 -08:00
Brad Fitzpatrick and Brad Fitzpatrick
b27d4c017a
magicsock, wgengine, ipn, controlclient: plumb regular netchecks to map poll
...
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com >
2020-03-04 08:19:45 -08:00