Skip to content

Commit

Permalink
Update mud: losslimit per path
Browse files Browse the repository at this point in the history
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
  • Loading branch information
angt committed Mar 7, 2020
1 parent eee6a22 commit 42faaf8
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mud
Submodule mud updated 3 files
+15 −20 mud.c
+3 −2 mud.h
+1 −1 test.c
3 changes: 2 additions & 1 deletion src/bind.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@ gt_bind(int argc, char **argv)
req.path.rate_tx,
req.path.rate_rx,
req.path.beat,
req.path.fixed_rate))
req.path.fixed_rate,
req.path.loss_limit))
res.ret = errno;
break;
case CTL_CONF:
Expand Down
1 change: 1 addition & 0 deletions src/ctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ struct ctl_msg {
unsigned long rate_rx;
unsigned long beat;
unsigned char fixed_rate;
unsigned char loss_limit;
} path;
struct {
char tun_name[64];
Expand Down
12 changes: 10 additions & 2 deletions src/path.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ gt_path_print_status(struct mud_path *path, int term)
" rtt: %.3f ms\n"
" rttvar: %.3f ms\n"
" rate: %s\n"
" losslim: %u\n"
" beat: %"PRIu64" ms\n"
" tx:\n"
" rate: %"PRIu64" bytes/sec\n"
Expand All @@ -52,7 +53,7 @@ gt_path_print_status(struct mud_path *path, int term)
: "path %s %s"
" %s %"PRIu16" %s %"PRIu16" %s %"PRIu16
" %zu %.3f %.3f"
" %s"
" %s %u"
" %"PRIu64
" %"PRIu64" %"PRIu64" %"PRIu64
" %"PRIu64" %"PRIu64" %"PRIu64
Expand All @@ -69,6 +70,7 @@ gt_path_print_status(struct mud_path *path, int term)
(double)path->rtt.val / 1e3,
(double)path->rtt.var / 1e3,
path->conf.fixed_rate ? "fixed" : "auto",
path->conf.loss_limit * 100 / 255,
path->conf.beat / 1000,
path->tx.rate,
path->tx.loss * 100 / 255,
Expand Down Expand Up @@ -145,6 +147,7 @@ int
gt_path(int argc, char **argv)
{
const char *dev = NULL;
unsigned int loss_limit = 0;

struct ctl_msg req = {
.type = CTL_STATE,
Expand All @@ -165,6 +168,7 @@ gt_path(int argc, char **argv)
{"up|backup|down", NULL, NULL, argz_option},
{"rate", NULL, &ratez, argz_option},
{"beat", "SECONDS", &req.path.beat, argz_time},
{"losslimit", "PERCENT", &loss_limit, argz_percent},
{NULL}};

if (argz(pathz, argc, argv))
Expand All @@ -190,7 +194,8 @@ gt_path(int argc, char **argv)
}

int set = argz_is_set(pathz, "rate")
|| argz_is_set(pathz, "beat");
|| argz_is_set(pathz, "beat")
|| argz_is_set(pathz, "losslimit");

if (set && !req.path.addr.ss_family) {
gt_log("please specify a path\n");
Expand All @@ -205,6 +210,9 @@ gt_path(int argc, char **argv)
req.path.state = MUD_DOWN;
}

if (loss_limit)
req.path.loss_limit = loss_limit * 255 / 100;

if (argz_is_set(ratez, "fixed")) {
req.path.fixed_rate = 3;
} else if (argz_is_set(ratez, "auto")) {
Expand Down
1 change: 0 additions & 1 deletion src/set.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ gt_set(int argc, char **argv)
{"tc", "CS|AF|EF", &req.conf.tc, gt_argz_tc},
{"kxtimeout", "SECONDS", &req.conf.kxtimeout, argz_time},
{"timetolerance", "SECONDS", &req.conf.timetolerance, argz_time},
{"losslimit", "PERCENT", &req.conf.losslimit, argz_percent},
{"keepalive", "SECONDS", &req.conf.keepalive, argz_time},
{NULL}};

Expand Down

0 comments on commit 42faaf8

Please sign in to comment.