Skip to content

Commit 42faaf8

Browse files
committed
Update mud: losslimit per path
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
1 parent eee6a22 commit 42faaf8

File tree

5 files changed

+14
-5
lines changed

5 files changed

+14
-5
lines changed

mud

src/bind.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,8 @@ gt_bind(int argc, char **argv)
305305
req.path.rate_tx,
306306
req.path.rate_rx,
307307
req.path.beat,
308-
req.path.fixed_rate))
308+
req.path.fixed_rate,
309+
req.path.loss_limit))
309310
res.ret = errno;
310311
break;
311312
case CTL_CONF:

src/ctl.h

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ struct ctl_msg {
2727
unsigned long rate_rx;
2828
unsigned long beat;
2929
unsigned char fixed_rate;
30+
unsigned char loss_limit;
3031
} path;
3132
struct {
3233
char tun_name[64];

src/path.c

+10-2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ gt_path_print_status(struct mud_path *path, int term)
4040
" rtt: %.3f ms\n"
4141
" rttvar: %.3f ms\n"
4242
" rate: %s\n"
43+
" losslim: %u\n"
4344
" beat: %"PRIu64" ms\n"
4445
" tx:\n"
4546
" rate: %"PRIu64" bytes/sec\n"
@@ -52,7 +53,7 @@ gt_path_print_status(struct mud_path *path, int term)
5253
: "path %s %s"
5354
" %s %"PRIu16" %s %"PRIu16" %s %"PRIu16
5455
" %zu %.3f %.3f"
55-
" %s"
56+
" %s %u"
5657
" %"PRIu64
5758
" %"PRIu64" %"PRIu64" %"PRIu64
5859
" %"PRIu64" %"PRIu64" %"PRIu64
@@ -69,6 +70,7 @@ gt_path_print_status(struct mud_path *path, int term)
6970
(double)path->rtt.val / 1e3,
7071
(double)path->rtt.var / 1e3,
7172
path->conf.fixed_rate ? "fixed" : "auto",
73+
path->conf.loss_limit * 100 / 255,
7274
path->conf.beat / 1000,
7375
path->tx.rate,
7476
path->tx.loss * 100 / 255,
@@ -145,6 +147,7 @@ int
145147
gt_path(int argc, char **argv)
146148
{
147149
const char *dev = NULL;
150+
unsigned int loss_limit = 0;
148151

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

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

192196
int set = argz_is_set(pathz, "rate")
193-
|| argz_is_set(pathz, "beat");
197+
|| argz_is_set(pathz, "beat")
198+
|| argz_is_set(pathz, "losslimit");
194199

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

213+
if (loss_limit)
214+
req.path.loss_limit = loss_limit * 255 / 100;
215+
208216
if (argz_is_set(ratez, "fixed")) {
209217
req.path.fixed_rate = 3;
210218
} else if (argz_is_set(ratez, "auto")) {

src/set.c

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ gt_set(int argc, char **argv)
4747
{"tc", "CS|AF|EF", &req.conf.tc, gt_argz_tc},
4848
{"kxtimeout", "SECONDS", &req.conf.kxtimeout, argz_time},
4949
{"timetolerance", "SECONDS", &req.conf.timetolerance, argz_time},
50-
{"losslimit", "PERCENT", &req.conf.losslimit, argz_percent},
5150
{"keepalive", "SECONDS", &req.conf.keepalive, argz_time},
5251
{NULL}};
5352

0 commit comments

Comments
 (0)