Commit Graph

913 Commits

Author SHA1 Message Date
Arceliar
5e81a0c421 Use a separate buffer per session for incoming packets, so 1 session that floods won't block other sessions 2019-08-07 18:08:31 -05:00
Arceliar
9ab08446ff make sure the sessionInfo.recvWorker doesn't block if sinfo.recv somehow fills 2019-08-07 17:40:50 -05:00
Neil Alexander
c99ed9fb60
Merge pull request #491 from Arceliar/flowkey
Fix the old flowkey stuff so congestion control actually works...
2019-08-07 10:33:17 +01:00
Arceliar
d795ab1b65 minor allocation fix 2019-08-06 20:51:38 -05:00
Arceliar
790524bd1c copy/paste old flowkey logic into a util function, add a struct of key and packet, make WriteNoCopy accept this instead of a slice 2019-08-06 19:25:55 -05:00
Arceliar
679866d5ff have createSession fill the sessionInfo.cancel field, have Conn use Conn.session.cancel instead of storing its own cancellation, this should prevent any of these things from being both nil and reachable at the same time 2019-08-05 19:11:28 -05:00
Arceliar
8a85149817 remove src/.DS_Store 2019-08-05 18:50:08 -05:00
Arceliar
84a4f54217 temporary fix to nil pointer, better to make sure it's never nil 2019-08-05 18:49:15 -05:00
Neil Alexander
bd3b42022b
Merge pull request #480 from Arceliar/speedup
Speedup
2019-08-05 10:24:54 +01:00
Neil Alexander
2ee00fcc09
Return box_pub_key as hex string in JSON (replaces #481) 2019-08-05 10:21:40 +01:00
Neil Alexander
3a2ae9d902
Update API to represent coords as []uint64 2019-08-05 10:17:19 +01:00
Neil Alexander
37533f157d
Make some API changes (currently broken) 2019-08-05 00:30:12 +01:00
Arceliar
979c3d4c07 move some potentially blocking operations out of session pool workers, minor cleanup 2019-08-04 16:29:58 -05:00
Arceliar
c55d7b4705 have the switch queue drop packts to ourself when the total size of all packets is at least queueTotalMaxSize, instead of an arbitrary unconfigurable packet count 2019-08-04 16:16:49 -05:00
Arceliar
6803f209b0 have tuntap code use Conn.ReadNoCopy and Conn.WriteNoCopy to avoid copying between slices 2019-08-04 15:59:51 -05:00
Arceliar
5d5486049b add Conn.ReadNoCopy and Conn.WriteNoCopy that transfer ownership of a slice instead of copying, have Read and Write use the NoCopy versions under the hood and just manage copying as needed 2019-08-04 15:53:34 -05:00
Arceliar
07f14f92ed disable crypto and switch buffer changes from testing 2019-08-04 15:25:14 -05:00
Arceliar
0ba8c6a34f have the stream code use bufio instead of copying manually to an input buffer, slightly reduces total uses of memmove 2019-08-04 15:21:04 -05:00
Arceliar
75b931f37e eliminate some more copying between slices 2019-08-04 14:50:19 -05:00
Arceliar
f52955ee0f WARNING: CRYPTO DISABLED while speeding up stream writeMsg 2019-08-04 14:18:59 -05:00
Arceliar
1e6a6d2160 use session.cancel in the router to make blocking safe, reduce size of fromRouter buffer so the drops in the switch are closer to the intended front-drop behavior 2019-08-04 02:21:41 -05:00
Arceliar
7bf5884ac1 remove some lossy channel sends that should be safe to allow to block 2019-08-04 02:14:45 -05:00
Arceliar
6da5802ae5 don't block forever in Write if the session is cancelled, cleanup Conn.Read slightly 2019-08-04 02:08:47 -05:00
Arceliar
144c823bee just use a sync.Pool as the bytestore to not overcomplicate things, the allocations from interface{} casting don't seem to actually hurt in practice right now 2019-08-04 00:28:13 -05:00
Arceliar
cbbb61b019 fix another drain on the bytestore 2019-08-04 00:00:41 -05:00
Arceliar
00e9c3dbd9 do session crypto work using the worker pool 2019-08-03 23:27:52 -05:00
Arceliar
befd1b43a0 refactor session worker code slightly 2019-08-03 23:14:51 -05:00
Arceliar
7a9ad0c8cc add workerpool to util 2019-08-03 23:10:37 -05:00
Arceliar
b9987b4fdc reduce time spent with a mutex held in sessionInfo.recvWorker 2019-08-03 22:47:10 -05:00
Arceliar
099bd3ae1e reduce part of sendWorker that needs to keep a mutex 2019-08-03 22:35:10 -05:00
Arceliar
72ed541bf3 a little cleanup to Conn functions 2019-08-03 22:07:38 -05:00
Arceliar
5dfc71e1ee put bytes back when done 2019-08-03 22:00:47 -05:00
Arceliar
df0090e32a Add per-session read/write workers, work in progress, they still unfortunately need to take a mutex for safety 2019-08-03 21:46:18 -05:00
Neil Alexander
853054eb62
Merge pull request #475 from Arceliar/misc
Misc
2019-07-29 20:24:49 +01:00
Arceliar
406e143f7f move some logic from TunAdapter.reader into a new function, TunAdapter.readerPacketHandler 2019-07-28 23:33:04 -05:00
Neil Alexander
7c4c1558ff
Merge pull request #474 from neilalexander/gomobile
Various API changes and simplifications to fix mobile builds
2019-07-28 19:34:06 +01:00
Neil Alexander
cbc8711dd3
Remove mobile module, since it can now be moved into another repository 2019-07-28 13:39:29 +01:00
Neil Alexander
c9554f82be
Formatting tweaks in api.go 2019-07-28 11:35:16 +01:00
Neil Alexander
24f4754f2b
Export NodeInfoPayload type, rename some API functions 2019-07-28 11:30:24 +01:00
Arceliar
38e1503b28 split up some of the tun reader logic into a separate worker, so the main loop can be mostly just syscalls 2019-07-27 20:09:43 -05:00
Arceliar
b66bea813b rename a couple of things and move a PutBytes so it happens sooner 2019-07-27 18:23:55 -05:00
Arceliar
9e118884d4 remove some commented code 2019-07-27 18:12:06 -05:00
Arceliar
e0a3055c2f get rid of session workers, new util.PutBytes/GetBytes logic 2019-07-27 18:10:32 -05:00
Neil Alexander
377f88512b
Remove commented out router function 2019-07-27 15:57:19 +01:00
Neil Alexander
de1005e4fa
Various API changes and simplifications to fix mobile builds 2019-07-27 15:00:09 +01:00
Neil Alexander
195d577151
Add IFF_NODAD/IFF_SECURED, define consts 2019-07-27 13:30:47 +01:00
Arceliar
e5bb9bcb8d change how searches are initialized so we actually send a dhtReq to ourself and get a response, in case we're the destination 2019-07-26 17:44:40 -05:00
Neil Alexander
6263fa287c
Merge pull request #467 from neilalexander/debugtext
Send PPROF output text to stderr
2019-07-23 08:15:03 +01:00
Neil Alexander
f208b7f542
Merge pull request #469 from neilalexander/fix468
Don't send IP back twice with getPeers
2019-07-23 08:14:49 +01:00
Neil Alexander
de9d0a6cf1
Redirect Conn session closure errors to debug channel 2019-07-22 22:41:55 +01:00
Neil Alexander
8669091a08
Don't send IP back twice with getPeers 2019-07-22 19:45:48 +01:00
Neil Alexander
34ac5c9197
Send PPROF output text to stderr instead of stdout so that it doesn't break -genconf 2019-07-20 21:56:53 +01:00
Neil Alexander
48ad3c5d7f
Update water go.mod references, fix some bugs in TAP mode (which should hopefully fix Windows support too) 2019-07-20 16:13:54 +01:00
Neil Alexander
36201895e7
Don't mangle bs slice in TAP mode 2019-07-20 12:10:05 +01:00
Neil Alexander
2582df752d
Fix resetting Windows adapter (reverting previous change) 2019-07-20 11:43:30 +01:00
Neil Alexander
1a5c2a4942
Update Windows module a bit - capture TAP setup errors earlier, refer to newer version of water which should fix #456 2019-07-19 22:21:30 +01:00
Arceliar
cf3ebe04a7 have Conn use Cancellation instead of manually setting up timers 2019-07-17 21:37:45 -05:00
Arceliar
6bf182e341 add util.CancellationChild() and run gofmt 2019-07-17 21:15:02 -05:00
Arceliar
06e8403aaf add cancellation code to util, like context but just the cancellation parts + some error logic 2019-07-17 21:09:22 -05:00
Arceliar
5301207480 fix possible unsafe memory use in Conn.Read 2019-07-17 18:25:38 -05:00
Neil Alexander
06330f503f
Recover if stillAlive fails 2019-07-18 00:02:16 +01:00
Neil Alexander
311c612f2e
Only flag stillAlive on successful write 2019-07-17 23:23:19 +01:00
Neil Alexander
307b24d8cb
Fix Conn.Read/Conn.Write behavior after Conn.Close, get rid of second TUN/TAP conn reader goroutine, no longer use deadlines 2019-07-17 21:42:17 +01:00
Neil Alexander
1bf1c6eb36
Revert "Remove stillAlive code from TUN/TAP conn as it is no longer required with the new deadlines"
This reverts commit eec70bf2f2.
2019-07-17 19:43:29 +01:00
Neil Alexander
eec70bf2f2
Remove stillAlive code from TUN/TAP conn as it is no longer required with the new deadlines 2019-07-17 13:53:16 +01:00
Neil Alexander
7d1c03d2ac
Only call stillAlive if channel read succeeds 2019-07-17 12:07:16 +01:00
Neil Alexander
747b50bb7c
Try to improve handling of timeouts 2019-07-17 11:13:53 +01:00
Neil Alexander
d34600b5f9
Try to fix TUN/TAP conn reader leakage 2019-07-17 10:12:10 +01:00
Neil Alexander
145a43e5f0
Fix #413 by always generating public keys from private ones instead of trusting public keys supplied by config 2019-07-16 09:49:28 +01:00
Neil Alexander
ea9d5db16d
Make admin socket output a bit friendlier (fixes #385) 2019-07-07 19:41:53 +01:00
Neil Alexander
30c03369cd
Try to fix CKR setup deadlock, fix some Windows output formatting 2019-07-06 20:08:32 +01:00
Neil Alexander
a10c141896
Fix data race on peermacs 2019-07-06 15:15:43 +01:00
Neil Alexander
e8272926a4
Fix TAP mode 2019-07-06 15:08:17 +01:00
Neil Alexander
618d46a7b3
Don't block on adding peers in case one is unreachable and we are forced to wait for timeout 2019-07-06 12:12:30 +01:00
Neil Alexander
12486b0557
Try to more gracefully handle shutdowns on Windows 2019-07-06 11:52:30 +01:00
Arceliar
86c30a1fc4 fix another panic from a send on a closed session worker channel, from races between Conn.Read/Write/Close 2019-07-01 18:55:07 -05:00
Arceliar
cd29fde178 temporary workaround to concurrency bug in sessions.getSharedKey 2019-06-29 19:32:15 -05:00
Arceliar
fbe44ea973 fix bug in session api code 2019-06-29 19:25:34 -05:00
Arceliar
40553a6a44 make GetSessions use the session workers to avoid races 2019-06-29 18:56:26 -05:00
Arceliar
d39428735d recover if we try to send to a closed session worker due to a race between a Conn.Write call and a Conn.Close call 2019-06-29 18:50:21 -05:00
Arceliar
28db566b37 fix concurrency bug in iface.go 2019-06-29 18:44:24 -05:00
Arceliar
7d58a7ef3e fix channel multiple close bug and concurrency bug in the way sessionInfo.close was being called 2019-06-29 17:44:28 -05:00
Arceliar
818eca90db fix nil pointer deref if searches fail, block dial until a search exceeds or a timeout passes (todo: replace timer with context) 2019-06-29 16:10:02 -05:00
Arceliar
8ecf99d8a9
Merge pull request #443 from Arceliar/dial
Bugfix in dial code
2019-06-29 12:21:19 -05:00
Arceliar
784acba823 I think this fixes the concurrent map read/write panic 2019-06-29 12:14:44 -05:00
Neil Alexander
0d23342358
Merge pull request #441 from Arceliar/dial
Dial
2019-06-29 10:52:05 +01:00
Arceliar
e88bef35c0 get rid of old buffered session packets 2019-06-28 20:02:58 -05:00
Arceliar
e7cb76cea3 clean up unused old session maps 2019-06-28 19:21:44 -05:00
Arceliar
c808be514f make tunAdapter.wrap return the right thing 2019-06-28 19:11:28 -05:00
Arceliar
5df110ac79 make Dial block until the search finishes, and use it as such 2019-06-28 18:42:31 -05:00
Neil Alexander
ac8ff740ee
Merge pull request #438 from neilalexander/multicast
Try and solidify multicast interface behavior
2019-06-29 00:38:38 +01:00
Neil Alexander
27b3b9b49b
Return new copy of interfaces on each Interfaces() call 2019-06-29 00:12:56 +01:00
Neil Alexander
93a323c62c
Add support for logging to file or syslog instead of stdout 2019-06-28 23:45:04 +01:00
Arceliar
29a0f8b572 some minor refactoring to dht callbacks and searches, work in progress 2019-06-25 19:31:29 -05:00
Neil Alexander
54f1804101
Try and solidify multicast interface behavior 2019-06-20 15:11:55 +01:00
Neil Alexander
2fd3ac6837
Merge pull request #432 from neilalexander/gatekeeper
Implement session gatekeeper functions
2019-06-13 23:41:42 +01:00
Neil Alexander
f545060e89
Add notes on isSessionAllowed checks 2019-06-13 23:37:53 +01:00
Neil Alexander
9a7d350884
Fix expressions 2019-06-11 23:48:00 +01:00
Neil Alexander
e229ad6e2b
Update comments 2019-06-11 12:52:13 +01:00
Neil Alexander
720a078a35
Add SetSessionGatekeeper
This allows you to define a function which determines whether a session connection (either incoming or outgoing) is allowed based on the public key.
2019-06-11 10:52:21 +01:00
Neil Alexander
17175b49f2
Add multicast interfaces to platform-specific defaults (this makes it easier to avoid bringing AWDL up by default on macOS as an example, or over L2 VPNs when not expected) 2019-06-11 10:18:59 +01:00
Arceliar
4b56849b08 fix issue with sessions dying and never being fixed 2019-06-10 22:09:12 -05:00
Arceliar
1addf08ccd don't have Conn.Read return an error for temorary crypto failures from e.g. out of order packets, just drop the packet and keep blocking until there's usable traffic 2019-05-31 17:51:01 -05:00
Neil Alexander
f0422dbd8b
Fix panic when determining if CKR is enabled 2019-05-30 17:33:59 +01:00
Neil Alexander
9e086e70f0
Don't indefinitely block TUN/TAP reader goroutine when a conn error happens 2019-05-30 12:44:47 +01:00
Neil Alexander
0096d1ae3e
Re-add ICMPv6 packet too big handling 2019-05-29 20:16:17 +01:00
Neil Alexander
3b6c726a3c
Fix bug where MTU was ignored by sessions, resulting in default 1280 2019-05-29 19:11:12 +01:00
Neil Alexander
78eb40cbad
Record session uptime (purely for the admin socket) 2019-05-29 12:59:36 +01:00
Arceliar
b2513fce56 have the tunConn close things after a 2 minute timeout 2019-05-28 18:35:52 -05:00
Arceliar
5ea864869a don't spam searches for unused connections. todo: timeout old connections somehow 2019-05-23 20:27:52 -05:00
Neil Alexander
70774fc3de
Reimplement get/setTunnelRouting, add/removeSourceSubnet, add/removeRoute, getRoutes, getSourceSubnets, make CKR threadsafe 2019-05-20 21:45:33 +01:00
Neil Alexander
5b8d8a9341
Reimplement getNodeInfo, dhtPing, get/add/removeAllowedEncryptionPublicKey, add/removePeer 2019-05-20 19:51:44 +01:00
Neil Alexander
e9e2d7bc6f
Remove debug println 2019-05-19 22:03:20 +01:00
Neil Alexander
d575b83ec1
Refactor admin socket somewhat, allow modules to set up their own handlers 2019-05-19 22:02:04 +01:00
Neil Alexander
8ef1978cb1
Start factoring out the admin socket into a separate module (not all functions implemented yet) 2019-05-19 17:27:48 +01:00
Neil Alexander
7ca5a2533d
Implement GetDHT, GetSwitchQueues, GetSessions 2019-05-19 16:29:04 +01:00
Neil Alexander
8a6f6f3b2b
Implement GetPeers and GetSwitchPeers API functions in Core, in preparation for breaking out the admin socket into a separate module 2019-05-18 17:21:02 +01:00
Neil Alexander
ce60609906
Remove wrappedConn as unnecessary 2019-05-18 16:16:32 +01:00
Neil Alexander
1b3ec0b93f
Fix multicast start check so that it shouldn't give up if interfaces aren't up when Yggdrasil starts (fixes #405) 2019-05-17 22:59:29 +01:00
Neil Alexander
ae2cc13d14
Fix configuration reloading support 2019-05-17 22:29:52 +01:00
Neil Alexander
71ccaf753e
Add crypto-key routing into TUN/TAP 2019-05-17 22:09:20 +01:00
Arceliar
9c01947b1c reduce allocations in switch 2019-05-16 18:10:47 -05:00
Arceliar
522ed147b1 use the subnet derived ID/mask when creating a connection based on a subnet address, fix a potential blocking channel send in tuntap/conn.go, and get debug.go compiling well enough to profile things (the sim is currently still broken) 2019-05-15 18:01:26 -05:00
Arceliar
efdaea1b5e fix some races and GetBytes/PutBytes usage, but this still seems to deadlock somewhere in iperf tests 2019-05-02 17:37:49 -05:00
Neil Alexander
5f66c4c95c
Try using separate workers for each TUN/TAP connection (sometimes produces duplicate packets when communicating with both the node address and a subnet address, sometimes also can't Ctrl-C to quit) 2019-04-28 17:14:09 +01:00
Arceliar
6469e39ff1 workaround to random timeouts 2019-04-26 22:42:05 -05:00
Arceliar
5d323861f0 properly fix the memory errors, it was caused by a function returning and PutBytes-ing a buffer before a worker had a chance to decrypt the buffer, so it would GetBytes the same buffer by dumb luck and then get an illegal overlap 2019-04-26 22:21:31 -05:00
Arceliar
01ea6d3d80 somehow this doesn't seem to deadlock or crash from buffer reuse (util.PutBytes), but I have no idea why it was doing that before and not now 2019-04-26 21:49:11 -05:00
Arceliar
15051b0a3c Add deadline timers, keep searches alive until they complete (or the conn is closed) to keep Write from blocking forever 2019-04-26 19:31:47 -05:00
Arceliar
0059baf36c add a newConn function that returns a pointer to a Conn with atomics properly initialized 2019-04-26 18:07:57 -05:00
Neil Alexander
75130f7735
Fix TAP support again 2019-04-23 11:46:16 +01:00
Neil Alexander
2b44f5d2f6
Fix TAP support 2019-04-23 11:37:32 +01:00
Neil Alexander
b4513ca2e8
Re-add support for TAP mode 2019-04-23 10:43:07 +01:00
Neil Alexander
870b2b6a2e
Remove CKR from src/yggdrasil (it will be moved into tuntap) 2019-04-23 10:28:40 +01:00
Neil Alexander
2bee3cd7ca
Update TODOs at top of tun.go 2019-04-23 00:04:22 +01:00
Neil Alexander
d7a1c04748
It works, sort of, amazingly 2019-04-22 23:58:59 +01:00
Neil Alexander
e1a2d666bf
Clean up router, tweaks 2019-04-22 23:12:13 +01:00
Neil Alexander
6e528799e9
Conn Read/Write operations will block while search completes 2019-04-22 22:38:37 +01:00
Neil Alexander
ea8948f378
TUN/TAP addr/subnet to Conn mappings, other fixes 2019-04-22 20:06:39 +01:00
Neil Alexander
9778f5d2b8
Fix search behaviour on closed Conns, various other fixes 2019-04-22 15:00:19 +01:00
Neil Alexander
bbd1246f7b
Fix bug in mask generation for outbound dials, change iface reader mutexes to read-only locks unless RW is needed 2019-04-22 11:49:47 +01:00
Neil Alexander
ccf03fd3b6
Don't write huge mostly empty buffers unnecessarily 2019-04-22 11:22:40 +01:00
Neil Alexander
47eb2fc47f
Break deadlock by creating session recv queue when session is created instead of repointing at search completion, also make expired atomic 2019-04-22 11:20:35 +01:00
Arceliar
5a02e2ff44 apparently it was these callbacks that were sometimes deadlocking things 2019-04-21 22:31:56 -05:00
Arceliar
9ce7fe2e3f fix tun/tap CIDR notation so things work on linux, may break other platforms for all I know 2019-04-21 20:56:12 -05:00
Arceliar
5dada3952c use a session worker to try to avoid mutex hell. compiles, but incomplete and doesn't work yet 2019-04-21 20:38:14 -05:00
Neil Alexander
0b8f5b5dda
Tweaks 2019-04-21 12:28:46 +01:00
Neil Alexander
781cd7571f
Fix race on tun conns, but still deadlocks if more than one connection is opened 2019-04-21 12:00:31 +01:00
Neil Alexander
79bcfbf175
Change some mutexes to atomics, change conns map to pointers, sort of works but seems to deadlock very easily 2019-04-21 11:50:41 +01:00
Neil Alexander
62621f2960
Some tweaks 2019-04-20 20:22:58 +01:00