Add rate fixed|auto option
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
This commit is contained in:
2
mud
2
mud
Submodule mud updated: c536bef802...c0d2118a77
@@ -304,7 +304,8 @@ gt_bind(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
case CTL_STATE:
|
case CTL_STATE:
|
||||||
if (mud_set_state(mud, (struct sockaddr *)&req.path.addr,
|
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;
|
res.ret = errno;
|
||||||
break;
|
break;
|
||||||
case CTL_PATH_STATUS:
|
case CTL_PATH_STATUS:
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ struct ctl_msg {
|
|||||||
enum mud_state state;
|
enum mud_state state;
|
||||||
unsigned long rate_tx;
|
unsigned long rate_tx;
|
||||||
unsigned long rate_rx;
|
unsigned long rate_rx;
|
||||||
|
unsigned char fixed_rate;
|
||||||
} path;
|
} path;
|
||||||
struct mud_path path_status;
|
struct mud_path path_status;
|
||||||
struct {
|
struct {
|
||||||
|
|||||||
14
src/path.c
14
src/path.c
@@ -31,8 +31,6 @@ gt_path_print_status(struct mud_path *path, int term)
|
|||||||
default: return;
|
default: return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *statusstr = path->ok ? "OK" : "DEGRADED";
|
|
||||||
|
|
||||||
printf(term ? "path %s\n"
|
printf(term ? "path %s\n"
|
||||||
" status: %s\n"
|
" status: %s\n"
|
||||||
" bind: %s port %"PRIu16"\n"
|
" bind: %s port %"PRIu16"\n"
|
||||||
@@ -41,6 +39,7 @@ gt_path_print_status(struct mud_path *path, int term)
|
|||||||
" mtu: %zu bytes\n"
|
" mtu: %zu bytes\n"
|
||||||
" rtt: %.3f ms\n"
|
" rtt: %.3f ms\n"
|
||||||
" rttvar: %.3f ms\n"
|
" rttvar: %.3f ms\n"
|
||||||
|
" rate: %s\n"
|
||||||
" tx:\n"
|
" tx:\n"
|
||||||
" rate: %"PRIu64" bytes/sec\n"
|
" rate: %"PRIu64" bytes/sec\n"
|
||||||
" loss: %"PRIu64" percent\n"
|
" loss: %"PRIu64" percent\n"
|
||||||
@@ -52,11 +51,12 @@ gt_path_print_status(struct mud_path *path, int term)
|
|||||||
: "path %s %s"
|
: "path %s %s"
|
||||||
" %s %"PRIu16" %s %"PRIu16" %s %"PRIu16
|
" %s %"PRIu16" %s %"PRIu16" %s %"PRIu16
|
||||||
" %zu %.3f %.3f"
|
" %zu %.3f %.3f"
|
||||||
|
" %s"
|
||||||
" %"PRIu64" %"PRIu64" %"PRIu64
|
" %"PRIu64" %"PRIu64" %"PRIu64
|
||||||
" %"PRIu64" %"PRIu64" %"PRIu64
|
" %"PRIu64" %"PRIu64" %"PRIu64
|
||||||
"\n",
|
"\n",
|
||||||
statestr,
|
statestr,
|
||||||
statusstr,
|
path->ok ? "OK" : "DEGRADED",
|
||||||
bindstr[0] ? bindstr : "-",
|
bindstr[0] ? bindstr : "-",
|
||||||
gt_get_port((struct sockaddr *)&path->local_addr),
|
gt_get_port((struct sockaddr *)&path->local_addr),
|
||||||
publstr[0] ? publstr : "-",
|
publstr[0] ? publstr : "-",
|
||||||
@@ -66,6 +66,7 @@ gt_path_print_status(struct mud_path *path, int term)
|
|||||||
path->mtu.ok,
|
path->mtu.ok,
|
||||||
(double)path->rtt.val / 1e3,
|
(double)path->rtt.val / 1e3,
|
||||||
(double)path->rtt.var / 1e3,
|
(double)path->rtt.var / 1e3,
|
||||||
|
path->conf.fixed_rate ? "fixed" : "auto",
|
||||||
path->tx.rate,
|
path->tx.rate,
|
||||||
path->tx.loss * 100 / 255,
|
path->tx.loss * 100 / 255,
|
||||||
path->tx.total,
|
path->tx.total,
|
||||||
@@ -150,6 +151,7 @@ gt_path(int argc, char **argv)
|
|||||||
}, res = {0};
|
}, res = {0};
|
||||||
|
|
||||||
struct argz ratez[] = {
|
struct argz ratez[] = {
|
||||||
|
{"fixed|auto", NULL, NULL, argz_option},
|
||||||
{"tx", "BYTES/SEC", &req.path.rate_tx, argz_bytes},
|
{"tx", "BYTES/SEC", &req.path.rate_tx, argz_bytes},
|
||||||
{"rx", "BYTES/SEC", &req.path.rate_rx, argz_bytes},
|
{"rx", "BYTES/SEC", &req.path.rate_rx, argz_bytes},
|
||||||
{NULL}};
|
{NULL}};
|
||||||
@@ -198,6 +200,12 @@ gt_path(int argc, char **argv)
|
|||||||
req.path.state = MUD_DOWN;
|
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;
|
int ret;
|
||||||
|
|
||||||
if (!req.path.addr.ss_family ||
|
if (!req.path.addr.ss_family ||
|
||||||
|
|||||||
Reference in New Issue
Block a user