Compare commits

...

199 Commits

Author SHA1 Message Date
e4988b9e9c switch to libsodium implementation of aegis256 2020-06-09 20:59:55 +02:00
0183b35acf remove aegis256 submodule 2020-06-09 20:44:38 +02:00
Adrien Gallouët
faeb599a19 Rework mud_set_conf()
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-04-17 21:25:08 +00:00
Adrien Gallouët
a4e72918df Inline and move some functions
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-04-03 08:32:20 +00:00
Adrien Gallouët
d7e8dbe0e7 Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-03-30 20:43:49 +00:00
Adrien Gallouët
71d16f25ff Don't use a static mtid
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-03-26 22:31:33 +00:00
Adrien Gallouët
c426cef08b Fix non little endian arch
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-03-25 20:43:54 +00:00
Adrien Gallouët
bda2c6eaa7 Wait a few packets before computing the loss
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-03-07 15:13:37 +00:00
Adrien Gallouët
d68aee8249 Allow a different loss_limit per path
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-03-07 14:27:47 +00:00
Adrien Gallouët
2f966bb365 Fix fixed rate
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-02-29 09:57:08 +00:00
Adrien Gallouët
4a7740f70f Fix beat conf
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-02-21 16:37:04 +00:00
Adrien Gallouët
5be4096452 Add a stupid dynamic rate limiter
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-02-05 14:00:41 +00:00
Adrien Gallouët
3747aa7abd Add a global mud_set_conf()
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-16 17:34:31 +00:00
Adrien Gallouët
e3eb1f96a5 Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-11 09:52:39 +00:00
Adrien Gallouët
2f5e346532 Add keepalive
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-11 09:08:04 +00:00
Adrien Gallouët
a9fdd76fa3 Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-10 09:56:13 +00:00
Adrien Gallouët
0a9a139409 Fix a bad typo
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-09 22:25:00 +00:00
Adrien Gallouët
2811e2383f Compute rate/loss only when mtu is ok
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-09 17:39:42 +00:00
Adrien Gallouët
ed6cc0e6f6 Degrade lossy path
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-08 14:35:25 +00:00
Adrien Gallouët
487474a80e Update loss computing
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-08 14:34:47 +00:00
Adrien Gallouët
edb86d27ad Update aegis256
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-08 13:10:39 +00:00
Adrien Gallouët
c0d2118a77 Use fixed rate by default
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-07 12:44:29 +00:00
Adrien Gallouët
70e80f76e0 Add a fixed rate mode
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-07 11:07:13 +00:00
Adrien Gallouët
e4092ebebd Cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-07 10:24:58 +00:00
Adrien Gallouët
2330e6470e Remove useless conversions
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-07 10:24:01 +00:00
Adrien Gallouët
7d59eedd39 Sanitize mud_decrypt_msg()
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-07 10:01:15 +00:00
Adrien Gallouët
c536bef802 Force MTU sync
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-04 16:15:18 +00:00
Adrien Gallouët
23a5cdfe31 Remove probe, let the system take its time
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-04 13:00:29 +00:00
Adrien Gallouët
6894867b9f Limit tx.rate to tx_max_rate...
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-04 12:38:14 +00:00
Adrien Gallouët
8f11ffa5a4 Slow down internal rate on dead paths
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-04 12:33:25 +00:00
Adrien Gallouët
1f18b731c4 Prepare the way before you run away
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-04 12:08:54 +00:00
Adrien Gallouët
e3689d29b7 Return MTU probing status in mud_update()
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-03 21:50:59 +00:00
Adrien Gallouët
2a812f332f Update aegis256
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-03 15:55:07 +00:00
Adrien Gallouët
b16a754713 Update LICENSE
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-03 15:51:02 +00:00
Adrien Gallouët
b6238c939e Count backup path
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-03 15:15:29 +00:00
Adrien Gallouët
6e8a3cef1e Update protocol
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-03 13:53:08 +00:00
Adrien Gallouët
e56abf5eaa Reimplement backup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-02 19:27:57 +00:00
Adrien Gallouët
6b1881e94c Send msg_timeout to the server
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-02 17:43:54 +00:00
Adrien Gallouët
7ff46e742b Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-02 15:07:28 +00:00
Adrien Gallouët
a87a277701 Cleanup path after a 1min silence
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-02 15:04:40 +00:00
Adrien Gallouët
ef41aa28ce Update now after mud_send_msg()
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-31 15:09:04 +00:00
Adrien Gallouët
d5322e187d Use EAFNOSUPPORT when necessary
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-28 22:05:27 +00:00
Adrien Gallouët
0a2b23bb88 Fix (and refactor) keyx with low timeout
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-28 13:24:21 +00:00
Adrien Gallouët
3a30c63eff God doesn't care about endianness
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-28 11:57:00 +00:00
Adrien Gallouët
9c27f92f9d Remove old keyx stuff
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-27 17:29:58 +00:00
Adrien Gallouët
9e3e2b358b Use the full 8bits range for loss
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-26 16:56:59 +00:00
Adrien Gallouët
a6acb8736c Increase MUD_MSG_SENT_MAX
This allows to support paths of <=500ms as written in
the glorytun README.

Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-26 15:02:53 +00:00
Adrien Gallouët
3d4e3a8fbe Burst shouldn't depend on MUD_MSG_TIMEOUT
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-26 15:01:51 +00:00
Adrien Gallouët
97407b2527 Reintroduce failover (and make it a little faster)
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-26 14:57:08 +00:00
Adrien Gallouët
dc22121739 Compute a global window for all paths
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-24 14:18:27 +00:00
Adrien Gallouët
06c0945ac5 Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-24 12:49:15 +00:00
Adrien Gallouët
2b19c80ae3 Fix tx_max_rate
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-24 12:33:05 +00:00
Adrien Gallouët
21b15727c5 Don't wait unnecessarily to compute RTT
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-23 10:57:50 +00:00
Adrien Gallouët
569e712248 Probe MTU before sending real packets
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-22 01:46:12 +00:00
Adrien Gallouët
8c033a12a1 Fix build
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-17 19:47:25 +00:00
Adrien Gallouët
6b58ebb993 Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-17 16:12:16 +00:00
Adrien Gallouët
7179de77da Small useless opt
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-17 16:08:25 +00:00
Adrien Gallouët
e6a8c8e013 Compute loss with packets (not bytes)
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-17 14:03:59 +00:00
Adrien Gallouët
137971e957 Apply TC on all packets
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-16 15:59:34 +00:00
Adrien Gallouët
9abb50a7e2 Clear path->msg on reset
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-16 10:40:11 +00:00
Adrien Gallouët
2766a94e3b Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-16 09:43:36 +00:00
Adrien Gallouët
c420e9494a First draft on the new protocol
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-15 21:30:44 +00:00
Adrien Gallouët
407db114c6 Use mem*() when touching sin{,6}_port
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-12 09:50:04 +00:00
Adrien Gallouët
0537b01d4b This commit doesn't exist
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-11-19 11:56:36 +00:00
Adrien Gallouët
79dc61e7dc Decrease rate instead of degrading the path
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-11-05 17:52:18 +00:00
Adrien Gallouët
67a660117e Setup rate_max
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-11-05 10:43:00 +00:00
Adrien Gallouët
831714e07f Force update after mud_reset_path()
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-11-04 15:01:31 +00:00
Adrien Gallouët
f047af8148 Remove useless call to mud_reset_path()
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-11-04 15:00:37 +00:00
Adrien Gallouët
8948d00545 Reorder
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-11-04 15:00:03 +00:00
Adrien Gallouët
2e8a13f135 Clear deleted paths
This should fix #5

Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-11-04 13:50:02 +00:00
Adrien Gallouët
f647519e1c Take the time to check loss before enabling a path
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-10-23 14:15:33 +00:00
Adrien Gallouët
94ae912138 Update mud.h
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-10-23 13:28:27 +00:00
Adrien Gallouët
e3b56376dc Naively degrade path with loss > loss_limit
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-10-22 15:54:48 +00:00
Adrien Gallouët
8c88934763 Update aegis256
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-10-22 13:12:27 +00:00
Adrien Gallouët
d0dc6076c8 Add mud_get_bad()
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-10-15 14:11:07 +00:00
Adrien Gallouët
842dadad94 Call unmapv4 only when it is necessary
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-10-15 12:21:38 +00:00
Adrien Gallouët
d086d7869d Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-10-14 13:50:03 +00:00
Adrien Gallouët
d4d97177eb Fix test.c
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-10-14 13:50:03 +00:00
Adrien Gallouët
7254e15a02 Update aegis256
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-10-08 08:51:09 +00:00
Adrien Gallouët
ee4b484a38 Get loss_rx from peer
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-10-07 14:01:27 +00:00
Adrien Gallouët
9a378aea99 Update aegis256
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-10-05 15:21:07 +00:00
Adrien Gallouët
3db88eb23c Add .gitignore
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-10-05 15:15:40 +00:00
Adrien Gallouët
c4d2ef7d97 Add a simple test.c with a Makefile
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-10-05 14:36:31 +00:00
Adrien Gallouët
00f18733d8 Compute loss for each path
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-10-05 09:46:14 +00:00
Adrien Gallouët
4d14689ff1 Update aegis256
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-09-24 09:56:57 +00:00
Adrien Gallouët
027196026b Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-09-20 08:19:43 +00:00
Adrien Gallouët
b59ab48407 Update rate every ms
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-09-19 08:12:26 +00:00
Adrien Gallouët
181e22011d Update README.md
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-09-17 08:28:16 +00:00
Adrien Gallouët
0397bc63e7 Import and use aegis256
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-09-17 08:21:25 +00:00
Adrien Gallouët
a6befda070 Use CLOCK_REALTIME if available
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-09-17 08:07:56 +00:00
Adrien Gallouët
5aeaf9e512 Revert "Block on sendmsg() for now"
This reverts commit 2c9d971437.
2019-09-16 10:37:19 +00:00
Adrien Gallouët
2c9d971437 Block on sendmsg() for now
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-09-09 16:08:21 +00:00
Adrien Gallouët
6623be1e69 Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-09-03 16:56:21 +00:00
Adrien Gallouët
67a7c91220 Remove old code
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-07-22 13:07:50 +00:00
Adrien Gallouët
a91f8e2971 DEGRADED/DOWN paths are useless server side
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-07-19 13:20:26 +00:00
Adrien Gallouët
b2ff2b6276 Use an adjusted monotonic clock
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-07-19 12:55:55 +00:00
Adrien Gallouët
0ae6656bdb Remove down paths after 10s of inactivity
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-07-17 14:59:28 +00:00
Adrien Gallouët
14893f9ea9 Move MUD_PATH_MAX in mud.h
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-07-17 14:29:08 +00:00
Adrien Gallouët
06e165e664 Explicit conversions
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-04-03 09:25:22 +00:00
Adrien Gallouët
a2106c248d Remove useless code
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-04-01 15:37:28 +00:00
Adrien Gallouët
7a5bb0690e Remove mud_sync()
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-03-09 15:03:47 +00:00
Adrien Gallouët
f67a5b4fed Don't wake up without paths
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-03-09 14:37:32 +00:00
Adrien Gallouët
eab4cdb1ad Update LICENSE
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-03-05 21:56:07 +00:00
Adrien Gallouët
bb60f5f15f Merge MTU probing with failover
This commit also fixes MTU probing in some corner cases.

Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-03-05 11:05:36 +00:00
Adrien Gallouët
adf3bf6710 Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-02-15 19:31:08 +00:00
Adrien Gallouët
bf75ac9cd9 One sec failover
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-02-15 19:29:00 +00:00
Adrien Gallouët
cef20db3c7 Correctly handle high latency paths
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-02-15 17:27:50 +00:00
Adrien Gallouët
40983ee4f1 Compute path->ok both sides
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-02-15 09:35:24 +00:00
Adrien Gallouët
9eac498d81 Rework failover with new proto
New proto totally destroy old failover.
This is a hack to improve the current situation waiting
for a better solution.

Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-02-10 21:14:20 +00:00
Adrien Gallouët
0b1793a93f Update mud->window when updating path->window
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-02-10 16:11:32 +00:00
Adrien Gallouët
5f86acee91 Fix build
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-02-09 16:17:07 +00:00
Adrien Gallouët
e47db2ea47 Use new proto (with static rate) and cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-02-09 15:58:29 +00:00
Adrien Gallouët
4030b4370b Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-12-02 15:56:18 +00:00
Adrien Gallouët
72019786eb Update path->window directly
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-12-02 09:32:33 +00:00
Adrien Gallouët
b732cb1b69 Skip down paths
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-12-02 08:27:41 +00:00
Adrien Gallouët
00c30c4fdf Remove mud->send_timeout
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-12-01 15:04:17 +00:00
Adrien Gallouët
1d4b06abda Boost boost 2018-12-01 15:01:41 +00:00
Adrien Gallouët
d74228e4a9 Be more aggressive about stats
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-12-01 11:22:49 +00:00
Adrien Gallouët
be5020cbae Rename mud_value to mud_stat
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-12-01 11:20:17 +00:00
Adrien Gallouët
6494b95700 Add a boost factor to estimate send.ratemax
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-12-01 11:17:39 +00:00
Adrien Gallouët
ff0c10b66c Send dt directly instead of sending lat/latmin
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-12-01 11:11:43 +00:00
Adrien Gallouët
79688de09e Use lowbw scheduler and clean old unused stuff
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-11-29 22:21:07 +00:00
Adrien Gallouët
b5289a8472 Re-estimate latmin when rate is low
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-11-09 17:57:11 +00:00
Adrien Gallouët
ff55d6a173 New scheduler and cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-11-08 17:40:38 +00:00
Adrien Gallouët
ccaac70a04 Simplify rate as MUD_STAT_TIMEOUT is const
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-11-05 11:14:43 +00:00
Adrien Gallouët
7f5c063ffb Allow bad use of mud_get_fd()
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-10-21 08:37:53 +00:00
Adrien Gallouët
1e7e8722ee Compute map directly
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-10-18 08:15:31 +00:00
Adrien Gallouët
2dd31a5f96 Trust compilers and cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-10-09 16:55:42 +00:00
Adrien Gallouët
5b9b3d5709 Remove duplicated checks
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-08-16 12:58:46 +00:00
Adrien Gallouët
22e065e5cb Add mud_sync()
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-06-15 10:05:42 +00:00
Adrien Gallouët
03be90b606 Update mud.h
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-06-05 13:56:15 +00:00
Adrien Gallouët
6ebda9368c Add mud_get_sync_elapsed_msec()
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-06-03 18:00:17 +00:00
Adrien Gallouët
964672adb5 Be nice with old good path
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-05-05 19:34:52 +00:00
Adrien Gallouët
1988ee1d78 Rework internal proto
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-05-05 12:54:22 +00:00
Adrien Gallouët
3668a2f9af Don't send packets to DOWN paths
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-05-05 12:50:31 +00:00
Adrien Gallouët
db7f48890a Fix mud_update_map()
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-05-05 12:49:53 +00:00
Adrien Gallouët
c8d949733a Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-27 15:29:42 +00:00
Adrien Gallouët
81afe325f6 Update ratemax softly
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-26 20:20:28 +00:00
Adrien Gallouët
04fc9b2894 Force update when creating a new path
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-25 20:58:18 +00:00
Adrien Gallouët
d896f9ff3c Don't touch a path if we don't have to
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-25 20:54:33 +00:00
Adrien Gallouët
c8b07c6edb Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-25 20:52:39 +00:00
Adrien Gallouët
9f38b7b6e0 Compute a pseudo ratevar to help bw probing
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-25 09:10:01 +00:00
Adrien Gallouët
ba9bef6268 Add a new rate based scheduler
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-23 20:52:31 +00:00
Adrien Gallouët
b2e4bc1b8f Compute latency-smoothed maximum rate
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-21 12:25:52 +00:00
Adrien Gallouët
a7044db87c Compute rate
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-18 16:35:27 +00:00
Adrien Gallouët
8e2b35525c Remove MUD_EPOCH and compute durations modulo 2^48
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-18 09:54:52 +00:00
Adrien Gallouët
875533a65f Recover lost connection slightly faster
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-07 16:43:46 +00:00
Adrien Gallouët
1f25f12e4a Compute rttvar for the next voip scheduler
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-06 16:46:09 +00:00
Adrien Gallouët
7fde67f3d3 Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-06 10:11:00 +00:00
Adrien Gallouët
2f304c1afc Set state to MUD_UP by default
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-05 15:52:29 +00:00
Adrien Gallouët
e0d7494a71 Don't inline
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-05 09:07:28 +00:00
Adrien Gallouët
1e9bb89764 Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-04 08:58:10 +00:00
Adrien Gallouët
e7851fa29d Compute RTT for each internal packet
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-04 08:52:01 +00:00
Adrien Gallouët
0c11ce5785 Add number of packets per path
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-03 09:02:02 +00:00
Adrien Gallouët
6d5738b931 Don't try to send something without path
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-02 08:50:42 +00:00
Adrien Gallouët
dcfaca04a5 Limit number of paths
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-02 08:44:59 +00:00
Adrien Gallouët
c63c94d7c8 Simplify MTU setup and allow big packets
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-03-26 13:03:27 +00:00
Adrien Gallouët
09acdee3e1 Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-03-25 14:48:59 +00:00
Adrien Gallouët
c2eb3e4095 Refuse truncated packets
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-03-25 14:22:52 +00:00
Adrien Gallouët
54bac4fcf6 Don't produce/reply to bad pubkeys
AFAIK, this should be useless as libsodium use constant-time code
But small order are rejected and so we don't want to produce one.

This commit does not improve security.
2018-03-19 22:28:03 +00:00
Adrien Gallouët
9a626f2889 Reset mtu in all paths
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-03-17 13:51:54 +00:00
Adrien Gallouët
c6fbe52fbd Use binded port in local_addr
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-03-16 21:07:25 +00:00
Adrien Gallouët
a505e22844 Try to compute the size of ctrl
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-03-16 20:05:05 +00:00
Adrien Gallouët
40be483e2b Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-03-16 08:12:33 +00:00
Adrien Gallouët
fd48ff08b9 Use LSB to mark mud packets
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-03-15 21:14:28 +00:00
Adrien Gallouët
0c037c5831 Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-03-15 20:42:51 +00:00
Adrien Gallouët
8b9fc86d12 Fix stats on links with latency > MUD_STAT_TIMEOUT
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-03-15 08:12:41 +00:00
Adrien Gallouët
66b8a7323d Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-03-14 22:47:33 +00:00
Adrien Gallouët
865c6aa640 Compute MTU only with usable paths
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-03-14 22:36:58 +00:00
Adrien Gallouët
2c5eb574f9 Add a specific timer for mtu probing
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-03-14 18:47:43 +00:00
Adrien Gallouët
ef319d2153 Add mud_set_keyx_timeout()
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-03-14 06:54:38 +00:00
Adrien Gallouët
467310bb4f Create ephemeral key at startup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-03-14 06:49:44 +00:00
Adrien Gallouët
b787bad536 Store addr on errors
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-03-14 06:40:37 +00:00
Adrien Gallouët
93d7d36b68 Hardening and fixes
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-03-13 18:32:14 +00:00
Adrien Gallouët
87d9806a88 Clear errno if no path
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-03-12 14:59:59 +00:00
Adrien Gallouët
ae3f4ed9ac Count and store last time of bad mud_decrypt()
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-03-12 10:28:05 +00:00
Adrien Gallouët
b53248b6da Send ip and port to peers
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-03-10 15:31:41 +00:00
Adrien Gallouët
bb6b87bb54 Hardening
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-03-09 22:14:10 +00:00
Adrien Gallouët
cd4ad61d1c Always kiss your friends <3 + add it in the nonce
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-03-06 16:00:12 +00:00
Adrien Gallouët
b809bf0785 First draft of path mtu disc without icmp
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-03-04 15:14:18 +00:00
Adrien Gallouët
c583e207c8 Return ENOTSUP if aes256gcm is not supported
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-03-04 14:58:52 +00:00
Adrien Gallouët
5aeb0a3cb2 Ask for a gnu99 compiler
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-02-27 09:28:16 +00:00
Adrien Gallouët
5a62bd7faa Add mud_get_paths() to export all paths
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-02-26 23:57:39 +00:00
Adrien Gallouët
81b279b060 Add up,backup and down states
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-02-24 15:26:38 +00:00
Adrien Gallouët
ac1ba977f4 Setup cmsg directly in mud_send_path()
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-02-24 14:54:44 +00:00
Adrien Gallouët
7303dea98c Let's decrypt everything
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-02-20 19:30:16 +00:00
Adrien Gallouët
1aded8ec29 Unset skip flag when adding a knwon path
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-02-17 20:21:45 +00:00
Adrien Gallouët
53f8d31f77 Use size_t for mtu
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-02-16 15:57:03 +00:00
Adrien Gallouët
7013d8e323 Cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-02-15 14:18:48 +00:00
Adrien Gallouët
6e5e2dea64 Autoselect ipv4/ipv6
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-02-15 14:10:28 +00:00
Adrien Gallouët
219e17edb6 Ask for sockaddr directly
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-02-14 21:30:17 +00:00
Adrien Gallouët
582eb29617 Use unsigned long in mud_set_x()
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-02-11 10:14:58 +00:00
Adrien Gallouët
d8ede46d8a Avoid useless copies and protect keys
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-02-06 18:10:39 +00:00
Adrien Gallouët
d4546ccae0 Add mud_del_path()
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-01-29 16:17:06 +00:00
Adrien Gallouët
61e7a23a11 Rework mud->peer and remove mud_ipaddr
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-01-29 16:17:06 +00:00
Adrien Gallouët
7c90d54b91 Add mud_add_path()
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-01-24 16:27:41 +00:00
Adrien Gallouët
a6555c8ab1 Format code
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-01-24 10:14:08 +00:00
Adrien Gallouët
8d861c9682 Allow client to add the first path
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-01-24 10:07:59 +00:00
Adrien Gallouët
368ab1b710 Add some checks in mud_set_path()
They are useless in theory but as we do not define
the macros CMSG_FIRSTHDR and CMSG_NXTHDR..

Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2017-12-01 11:02:33 +00:00
8 changed files with 1347 additions and 850 deletions

4
.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
.deps
.dirstamp
*.[ios]
test

View File

@@ -13,4 +13,4 @@ compiler:
script: script:
- git clone --depth=1 https://github.com/jedisct1/libsodium.git --branch=stable - git clone --depth=1 https://github.com/jedisct1/libsodium.git --branch=stable
- cd libsodium && ./configure --enable-minimal --disable-dependency-tracking && cd - - cd libsodium && ./configure --enable-minimal --disable-dependency-tracking && cd -
- make CPPFLAGS="-I./libsodium/src/libsodium/include" mud.o - make CFLAGS="-std=gnu99" CPPFLAGS="-I./libsodium/src/libsodium/include" mud.o

View File

@@ -1,4 +1,4 @@
Copyright (c) 2016, angt Copyright (c) 2016-2020, Adrien Gallouët <adrien@gallouet.fr>
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without

8
Makefile Normal file
View File

@@ -0,0 +1,8 @@
CFLAGS=-march=native -O2
LDLIBS=-lsodium
test:
.PHONY: clean
clean:
rm -f test

View File

@@ -1,23 +1,22 @@
# MUD # MUD
MUD is a secure, connectionless network protocol over UDP. MUD is a secure, multipath network protocol over UDP.
It enables the distribution of packets on multiple paths while maintaining a low latency (the bandwidth is sacrificed in favor of latency). See [glorytun](https://github.com/angt/glorytun) for details.
### Compatibility ### Compatibility
Linux is the platform of choice but it was successfully ported to OpenBSD and OSX. Linux is the platform of choice but it was successfully ported to OpenBSD and OSX.
### Dependencies
* A recent version of GCC or Clang.
* [libsodium](https://github.com/jedisct1/libsodium).
### Security ### Security
MUD uses [libsodium](https://github.com/jedisct1/libsodium) for all cryptographic operations. Encryption and authentication is done with AEGIS256 when aesni is available otherwise ChaCha20-Poly1305 is used.
Encryption (and authentication) is done with AES256-GCM when aesni is available otherwise ChaCha20-Poly1305 is used.
The Diffie-Hellman function X25519 is used for key exchange. The Diffie-Hellman function X25519 is used for key exchange.
### Performance
The scheduler is still in development but you will find some measurements to give you an idea of the performance [here](https://github.com/angt/mud/wiki/Perf).
### Issues ### Issues
For feature requests and bug reports, please create an [issue](https://github.com/angt/mud/issues). For feature requests and bug reports, please create an [issue](https://github.com/angt/mud/issues).

1942
mud.c

File diff suppressed because it is too large Load Diff

101
mud.h
View File

@@ -1,27 +1,106 @@
#pragma once #pragma once
#include <stddef.h> #include <stddef.h>
#include <inttypes.h>
#include <sys/socket.h>
#define MUD_PATH_MAX (32U)
#define MUD_PUBKEY_SIZE (32U)
struct mud; struct mud;
struct mud *mud_create (int, int, int); enum mud_state {
MUD_EMPTY = 0,
MUD_DOWN,
MUD_BACKUP,
MUD_UP,
};
struct mud_stat {
uint64_t val;
uint64_t var;
int setup;
};
struct mud_conf {
uint64_t keepalive;
uint64_t timetolerance;
uint64_t kxtimeout;
int tc;
};
struct mud_path {
enum mud_state state;
struct sockaddr_storage local_addr, addr, r_addr;
struct mud_stat rtt;
struct {
uint64_t total;
uint64_t bytes;
uint64_t time;
uint64_t rate;
uint64_t loss;
} tx, rx;
struct {
struct {
uint64_t total;
uint64_t bytes;
uint64_t time;
uint64_t acc;
uint64_t acc_time;
} tx, rx;
uint64_t time;
uint64_t sent;
uint64_t set;
} msg;
struct {
size_t min;
size_t max;
size_t probe;
size_t last;
size_t ok;
} mtu;
struct {
uint64_t tx_max_rate;
uint64_t rx_max_rate;
uint64_t beat;
unsigned char fixed_rate;
unsigned char loss_limit;
} conf;
uint64_t idle;
unsigned char ok;
};
struct mud_bad {
struct {
struct sockaddr_storage addr;
uint64_t time;
uint64_t count;
} decrypt, difftime, keyx;
};
struct mud *mud_create (struct sockaddr *);
void mud_delete (struct mud *); void mud_delete (struct mud *);
int mud_get_fd (struct mud *); int mud_update (struct mud *);
int mud_send_wait (struct mud *);
int mud_get_fd (struct mud *);
size_t mud_get_mtu (struct mud *);
int mud_get_bad (struct mud *, struct mud_bad *);
int mud_new_key (struct mud *);
int mud_set_key (struct mud *, unsigned char *, size_t); int mud_set_key (struct mud *, unsigned char *, size_t);
int mud_get_key (struct mud *, unsigned char *, size_t *); int mud_get_key (struct mud *, unsigned char *, size_t *);
int mud_set_mtu (struct mud *, int mtu); int mud_set_aes (struct mud *);
int mud_get_mtu (struct mud *); int mud_set_conf (struct mud *, struct mud_conf *);
int mud_set_send_timeout_msec (struct mud *, unsigned); int mud_set_state (struct mud *, struct sockaddr *, enum mud_state,
int mud_set_time_tolerance_sec (struct mud *, unsigned); unsigned long, unsigned long, unsigned long,
int mud_set_tc (struct mud *, int); unsigned char, unsigned char);
int mud_set_aes (struct mud *);
int mud_peer (struct mud *, const char *, const char *, int, int); int mud_peer (struct mud *, struct sockaddr *);
int mud_recv (struct mud *, void *, size_t); int mud_recv (struct mud *, void *, size_t);
int mud_send (struct mud *, const void *, size_t, int); int mud_send (struct mud *, const void *, size_t);
struct mud_path *mud_get_paths(struct mud *, unsigned *);

121
test.c Normal file
View File

@@ -0,0 +1,121 @@
#include "mud.c"
#include <stdio.h>
#include <poll.h>
int
main(int argc, char **argv)
{
if (argc > 2)
return -1;
int client = argc == 2;
struct sockaddr_in local = {
.sin_family = AF_INET,
.sin_port = htons(client + 20000),
.sin_addr = {
.s_addr = htonl(INADDR_LOOPBACK),
},
};
struct mud *mud = mud_create((struct sockaddr *)&local);
if (!mud) {
perror("mud_create");
return -1;
}
unsigned char key[] = "0123456789ABCDEF0123456789ABCDEF";
if (mud_set_key(mud, key, sizeof(key))) {
perror("mud_set_key");
return -1;
}
// client is little harder to setup
if (client) {
struct sockaddr_in remote = {
.sin_family = AF_INET,
.sin_port = htons(20000),
.sin_addr = {
.s_addr = htonl(INADDR_LOOPBACK),
},
};
// we are going to connect to remote...
if (mud_peer(mud, (struct sockaddr *)&remote)) {
perror("mud_peer");
return -1;
}
// ...from loopback at 1MBps (not 1Mbps)
if (mud_set_state(mud, (struct sockaddr *)&local,
MUD_UP, 1000 * 1000, 1000 * 1000, 0, 0, 0)) {
perror("mud_set_state");
return -1;
}
}
unsigned char buf[1500];
for (;;) {
// mandatory, mud have lot of work to do.
if (mud_update(mud))
usleep(100000); // don't use all the cpu
if (client) {
// when there is data, mud_recv() is mandatory
struct pollfd pollfd = {
.fd = mud_get_fd(mud),
.events = POLLIN,
};
switch (poll(&pollfd, 1, 0)) {
case -1:
perror("poll");
return -1;
case 1:
if (mud_recv(mud, buf, sizeof(buf)) == -1) {
perror("mud_recv");
return -1;
}
}
// we can safely call mud_send()
// even if the link is not ready
int r = mud_send(mud, argv[1], strlen(argv[1]));
if (r == -1) {
if (errno == EAGAIN)
continue;
perror("mud_send");
return -1;
}
// we sent everything, bye :)
if (r)
break;
} else {
int r = mud_recv(mud, buf, sizeof(buf));
if (r == -1) {
if (errno == EAGAIN)
continue;
perror("mud_recv");
return -1;
}
if (r) {
buf[r] = 0;
printf("%s\n", buf);
}
}
}
mud_delete(mud);
return 0;
}