Compare commits

...

74 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
6 changed files with 652 additions and 623 deletions

4
.gitmodules vendored
View File

@@ -1,4 +0,0 @@
[submodule "aegis256"]
path = aegis256
url = https://github.com/angt/aegis256
ignore = dirty

View File

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

Submodule aegis256 deleted from 00fdf8a605

1197
mud.c

File diff suppressed because it is too large Load Diff

64
mud.h
View File

@@ -16,17 +16,19 @@ enum mud_state {
MUD_UP,
};
struct mud_pubkey {
unsigned char remote[MUD_PUBKEY_SIZE];
unsigned char local[MUD_PUBKEY_SIZE];
};
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;
@@ -35,22 +37,37 @@ struct mud_path {
uint64_t total;
uint64_t bytes;
uint64_t time;
uint64_t msg_time;
uint64_t rate;
uint64_t rate_max;
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;
uint64_t window;
uint64_t window_time;
struct mud_pubkey pk;
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;
unsigned msg_sent;
};
struct mud_bad {
@@ -64,29 +81,26 @@ struct mud_bad {
struct mud *mud_create (struct sockaddr *);
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_set_key (struct mud *, unsigned char *, size_t);
int mud_get_key (struct mud *, unsigned char *, size_t *);
void mud_set_mtu (struct mud *, size_t);
size_t mud_get_mtu (struct mud *);
int mud_get_bad (struct mud *, struct mud_bad *);
long mud_send_wait (struct mud *);
int mud_set_time_tolerance (struct mud *, unsigned long);
int mud_set_keyx_timeout (struct mud *, unsigned long);
int mud_set_tc (struct mud *, int);
int mud_set_aes (struct mud *);
int mud_set_aes (struct mud *);
int mud_set_conf (struct mud *, struct mud_conf *);
int mud_set_state (struct mud *, struct sockaddr *, enum mud_state,
unsigned long, unsigned long);
unsigned long, unsigned long, unsigned long,
unsigned char, unsigned char);
int mud_peer (struct mud *, struct sockaddr *);
int mud_recv (struct mud *, void *, size_t);
int mud_send (struct mud *, const void *, size_t, unsigned);
int mud_send (struct mud *, const void *, size_t);
struct mud_path *mud_get_paths(struct mud *, unsigned *);

7
test.c
View File

@@ -1,5 +1,4 @@
#include "mud.c"
#include "aegis256/aegis256.c"
#include <stdio.h>
#include <poll.h>
@@ -52,7 +51,7 @@ main(int argc, char **argv)
// ...from loopback at 1MBps (not 1Mbps)
if (mud_set_state(mud, (struct sockaddr *)&local,
MUD_UP, 1000 * 1000, 1000 * 1000)) {
MUD_UP, 1000 * 1000, 1000 * 1000, 0, 0, 0)) {
perror("mud_set_state");
return -1;
}
@@ -62,7 +61,7 @@ main(int argc, char **argv)
for (;;) {
// mandatory, mud have lot of work to do.
if (mud_send_wait(mud))
if (mud_update(mud))
usleep(100000); // don't use all the cpu
if (client) {
@@ -85,7 +84,7 @@ main(int argc, char **argv)
// we can safely call mud_send()
// even if the link is not ready
int r = mud_send(mud, argv[1], strlen(argv[1]), 0);
int r = mud_send(mud, argv[1], strlen(argv[1]));
if (r == -1) {
if (errno == EAGAIN)