Add option path rate tx/rx

These two options are mandatory since dynamic shapping
is disabled for now.

Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
This commit is contained in:
Adrien Gallouët
2019-02-09 16:21:39 +00:00
parent 9131af6e85
commit a65cb2ad15
5 changed files with 21 additions and 15 deletions

2
argz

Submodule argz updated: 3ee68b227f...5398bb4f79

2
mud

Submodule mud updated: 72019786eb...5f86acee91

View File

@@ -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:

View File

@@ -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 {

View File

@@ -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)