Josh Bleecher Snyder
e577303dc7
derp: make writeUint32 and readUint32 not allocate
...
The allocations are small, but they're easy enough to avoid.
And it removes some clutter from the pprof output.
name old time/op new time/op delta
SendRecv/msgsize=10-8 10.1µs ± 9% 9.7µs ± 7% -3.45% (p=0.035 n=14+14)
SendRecv/msgsize=100-8 8.12µs ± 7% 7.38µs ± 9% -9.02% (p=0.000 n=15+15)
SendRecv/msgsize=1000-8 9.51µs ±25% 8.76µs ±22% ~ (p=0.202 n=15+15)
SendRecv/msgsize=10000-8 21.1µs ±25% 19.9µs ±14% ~ (p=0.270 n=15+14)
WriteUint32-8 25.1ns ± 4% 21.3ns ±12% -15.01% (p=0.000 n=14+14)
ReadUint32-8 35.4ns ± 4% 21.9ns ± 4% -38.06% (p=0.000 n=15+15)
name old alloc/op new alloc/op delta
SendRecv/msgsize=10-8 182B ± 2% 169B ± 1% -7.22% (p=0.000 n=15+13)
SendRecv/msgsize=100-8 282B ± 1% 265B ± 1% -5.85% (p=0.000 n=15+15)
SendRecv/msgsize=1000-8 1.19kB ± 1% 1.18kB ± 0% -1.26% (p=0.000 n=14+15)
SendRecv/msgsize=10000-8 19.3kB ± 4% 18.7kB ± 4% -3.44% (p=0.006 n=12+12)
WriteUint32-8 4.00B ± 0% 0.00B -100.00% (p=0.000 n=15+15)
ReadUint32-8 4.00B ± 0% 0.00B -100.00% (p=0.000 n=15+15)
name old allocs/op new allocs/op delta
SendRecv/msgsize=10-8 8.00 ± 0% 4.00 ± 0% -50.00% (p=0.000 n=15+15)
SendRecv/msgsize=100-8 8.00 ± 0% 4.00 ± 0% -50.00% (p=0.000 n=15+15)
SendRecv/msgsize=1000-8 8.00 ± 0% 4.00 ± 0% -50.00% (p=0.000 n=15+15)
SendRecv/msgsize=10000-8 8.47 ±17% 5.00 ± 0% -40.94% (p=0.000 n=15+14)
WriteUint32-8 1.00 ± 0% 0.00 -100.00% (p=0.000 n=15+15)
ReadUint32-8 1.00 ± 0% 0.00 -100.00% (p=0.000 n=15+15)
Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
2020-08-10 14:15:37 -07:00
Brad Fitzpatrick
4732722b87
derp: add frameClosePeer to move around clients within a region
...
For various reasons (mostly during rollouts or config changes on our
side), nodes may end up connecting to a fallback DERP node in a
region, rather than the primary one we tell them about in the DERP
map.
Connecting to the "wrong" node is fine, but it's in our best interest
for all nodes in a domain to connect to the same node, to reduce
intra-region packet forwarding.
This adds a privileged frame type used by the control system that can
kick off a client connection when they're connected to the wrong node
in a region. Then they hopefully reconnect immediately to the correct
location. (If not, we can leave them alone and stop closing them.)
Updates tailscale/corp#372
2020-06-25 09:33:10 -07:00
Brad Fitzpatrick
1cb7dab881
cmd/derper: support forwarding packets amongst set of peer DERP servers
...
Updates #388
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2020-06-05 10:14:33 -07:00
Brad Fitzpatrick
484b7fc9a3
derp, cmd/derper: add frameWatchConns, framePeerPresent for inter-DERP routing
...
This lets a trusted DERP client that knows a pre-shared key subscribe
to the connection list. Upon subscribing, they get the current set
of connected public keys, and then all changes over time.
This lets a set of DERP server peers within a region all stay connected to
each other and know which clients are connected to which nodes.
Updates #388
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2020-06-03 08:03:29 -07:00
Dmitry Adamushko
806645ea0e
derp: prevent readFrame() from reading more than len(b) bytes.
...
Signed-off-by: Dmitry Adamushko <da@stablebits.net>
2020-04-10 08:56:23 -07:00
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
6978b93bdd
derp, magicsock: track home (preferred) vs visiting connections for stats
2020-03-05 15:00:56 -08:00
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
379a3125fd
derp, wgengine/magicsock: support more than just packets from Client.Recv
...
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2020-02-20 22:08:13 -08:00
Brad Fitzpatrick
88f1cc0c98
derp, cmd/derper: add rate limiting support, add default 5Mbps limit
...
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2020-02-20 15:26:30 -08:00
Brad Fitzpatrick
f029c4c82d
derp: change the protocol framing to always include a length
...
Addresses one of crawshaw's TODOs.
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2020-02-20 13:37:44 -08:00
Brad Fitzpatrick
11048b8932
derp: add docs on current protocol overview, break accept apart a bit
...
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2020-02-20 09:57:05 -08:00
Brad Fitzpatrick
259406e797
derp: move away from [32]byte key types
...
And some minor cleanup in the process.
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2020-02-17 14:18:09 -08:00