From a65cb2ad15902a6c7499f3cac162ad9008789066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Gallou=C3=ABt?= Date: Sat, 9 Feb 2019 16:21:39 +0000 Subject: [PATCH] Add option path rate tx/rx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These two options are mandatory since dynamic shapping is disabled for now. Signed-off-by: Adrien Gallouët --- argz | 2 +- mud | 2 +- src/bind.c | 3 ++- src/ctl.h | 2 ++ src/path.c | 27 +++++++++++++++------------ 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/argz b/argz index 3ee68b2..5398bb4 160000 --- a/argz +++ b/argz @@ -1 +1 @@ -Subproject commit 3ee68b227fd9a0e587162b5ff2bff893c499f333 +Subproject commit 5398bb4f794c214e7daeb85f61d10b8ba6459503 diff --git a/mud b/mud index 7201978..5f86ace 160000 --- a/mud +++ b/mud @@ -1 +1 @@ -Subproject commit 72019786eb1f2d542247ff87a21c7e6df183b8a0 +Subproject commit 5f86acee91ec7d64fc53ce52db43e92d3b317945 diff --git a/src/bind.c b/src/bind.c index da7e78b..ba70f7f 100644 --- a/src/bind.c +++ b/src/bind.c @@ -252,7 +252,8 @@ gt_bind(int argc, char **argv) case CTL_NONE: break; case CTL_STATE: - if (mud_set_state(mud, (struct sockaddr *)&req.path.addr, req.path.state)) + if (mud_set_state(mud, (struct sockaddr *)&req.path.addr, + req.path.state, req.path.rate_tx, req.path.rate_rx)) res.ret = errno; break; case CTL_PATH_STATUS: diff --git a/src/ctl.h b/src/ctl.h index 5688241..74e8635 100644 --- a/src/ctl.h +++ b/src/ctl.h @@ -23,6 +23,8 @@ struct ctl_msg { struct { struct sockaddr_storage addr; enum mud_state state; + unsigned long rate_tx; + unsigned long rate_rx; } path; struct mud_path path_status; struct { diff --git a/src/path.c b/src/path.c index c9820c4..7eee134 100644 --- a/src/path.c +++ b/src/path.c @@ -60,10 +60,10 @@ gt_path_status(int fd) " mtu: %zu bytes\n" " rtt: %.3f ms\n" " rttvar: %.3f ms\n" - " upload: %"PRIu64" bytes/s (max: %"PRIu64")\n" - " download: %"PRIu64" bytes/s (max: %"PRIu64")\n" - " output: %"PRIu64" packets\n" - " input: %"PRIu64" packets\n" + " rate tx: %"PRIu64" bytes/sec\n" + " rate rx: %"PRIu64" bytes/sec\n" + " total tx: %"PRIu64" packets\n" + " total rx: %"PRIu64" packets\n" : "path %s %s" " %s %"PRIu16 " %s %"PRIu16 @@ -74,8 +74,6 @@ gt_path_status(int fd) " %"PRIu64 " %"PRIu64 " %"PRIu64 - " %"PRIu64 - " %"PRIu64 "\n", statestr, statusstr, @@ -88,10 +86,8 @@ gt_path_status(int fd) res.path_status.mtu.ok, res.path_status.rtt.val / 1e3, res.path_status.rtt.var / 1e3, - res.path_status.r_rate * 10, - res.path_status.r_ratemax * 10, - res.path_status.rate.val * 10, - res.path_status.recv.ratemax * 10, + res.path_status.rate_tx, + res.path_status.rate_rx, res.path_status.send.total, res.path_status.recv.total); } while (res.ret == EAGAIN); @@ -108,10 +104,16 @@ gt_path(int argc, char **argv) .type = CTL_STATE, }, res = {0}; + struct argz ratez[] = { + {"tx", "BYTES/SEC", &req.path.rate_tx, argz_size}, + {"rx", "BYTES/SEC", &req.path.rate_rx, argz_size}, + {NULL}}; + struct argz pathz[] = { {NULL, "IPADDR", &req.path.addr, argz_addr}, {"dev", "NAME", &dev, argz_str}, {"up|backup|down", NULL, NULL, argz_option}, + {"rate", NULL, &ratez, argz_option}, {NULL}}; if (argz(pathz, argc, argv)) @@ -144,6 +146,8 @@ gt_path(int argc, char **argv) if (ret == -2) gt_log("bad reply from server\n"); } else { + req.path.state = MUD_EMPTY; + if (argz_is_set(pathz, "up")) { req.path.state = MUD_UP; } else if (argz_is_set(pathz, "backup")) { @@ -152,8 +156,7 @@ gt_path(int argc, char **argv) req.path.state = MUD_DOWN; } - if (req.path.state) - ret = ctl_reply(fd, &res, &req); + ret = ctl_reply(fd, &res, &req); } if (ret == -1)