From 0b26eb108d6d9729e88dab8032cbdc0a4e1dd05f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Gallou=C3=ABt?= Date: Tue, 7 Jan 2020 12:46:28 +0000 Subject: [PATCH] Add rate fixed|auto option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Adrien Gallouët --- mud | 2 +- src/bind.c | 3 ++- src/ctl.h | 1 + src/path.c | 14 +++++++++++--- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/mud b/mud index c536bef..c0d2118 160000 --- a/mud +++ b/mud @@ -1 +1 @@ -Subproject commit c536bef8024512fe05dc0f23c4a36c26809a4ee9 +Subproject commit c0d2118a77d1e53d92105e43195cad2a856f2e8a diff --git a/src/bind.c b/src/bind.c index a408a71..aeb6d40 100644 --- a/src/bind.c +++ b/src/bind.c @@ -304,7 +304,8 @@ gt_bind(int argc, char **argv) break; case CTL_STATE: if (mud_set_state(mud, (struct sockaddr *)&req.path.addr, - req.path.state, req.path.rate_tx, req.path.rate_rx, 0)) + req.path.state, req.path.rate_tx, + req.path.rate_rx, 0, req.path.fixed_rate)) res.ret = errno; break; case CTL_PATH_STATUS: diff --git a/src/ctl.h b/src/ctl.h index ead0a34..6504b4e 100644 --- a/src/ctl.h +++ b/src/ctl.h @@ -28,6 +28,7 @@ struct ctl_msg { enum mud_state state; unsigned long rate_tx; unsigned long rate_rx; + unsigned char fixed_rate; } path; struct mud_path path_status; struct { diff --git a/src/path.c b/src/path.c index 35e3df3..cb32949 100644 --- a/src/path.c +++ b/src/path.c @@ -31,8 +31,6 @@ gt_path_print_status(struct mud_path *path, int term) default: return; } - const char *statusstr = path->ok ? "OK" : "DEGRADED"; - printf(term ? "path %s\n" " status: %s\n" " bind: %s port %"PRIu16"\n" @@ -41,6 +39,7 @@ gt_path_print_status(struct mud_path *path, int term) " mtu: %zu bytes\n" " rtt: %.3f ms\n" " rttvar: %.3f ms\n" + " rate: %s\n" " tx:\n" " rate: %"PRIu64" bytes/sec\n" " loss: %"PRIu64" percent\n" @@ -52,11 +51,12 @@ gt_path_print_status(struct mud_path *path, int term) : "path %s %s" " %s %"PRIu16" %s %"PRIu16" %s %"PRIu16 " %zu %.3f %.3f" + " %s" " %"PRIu64" %"PRIu64" %"PRIu64 " %"PRIu64" %"PRIu64" %"PRIu64 "\n", statestr, - statusstr, + path->ok ? "OK" : "DEGRADED", bindstr[0] ? bindstr : "-", gt_get_port((struct sockaddr *)&path->local_addr), publstr[0] ? publstr : "-", @@ -66,6 +66,7 @@ gt_path_print_status(struct mud_path *path, int term) path->mtu.ok, (double)path->rtt.val / 1e3, (double)path->rtt.var / 1e3, + path->conf.fixed_rate ? "fixed" : "auto", path->tx.rate, path->tx.loss * 100 / 255, path->tx.total, @@ -150,6 +151,7 @@ gt_path(int argc, char **argv) }, res = {0}; struct argz ratez[] = { + {"fixed|auto", NULL, NULL, argz_option}, {"tx", "BYTES/SEC", &req.path.rate_tx, argz_bytes}, {"rx", "BYTES/SEC", &req.path.rate_rx, argz_bytes}, {NULL}}; @@ -198,6 +200,12 @@ gt_path(int argc, char **argv) req.path.state = MUD_DOWN; } + if (argz_is_set(ratez, "fixed")) { + req.path.fixed_rate = 3; + } else if (argz_is_set(ratez, "auto")) { + req.path.fixed_rate = 1; + } + int ret; if (!req.path.addr.ss_family ||