route(8): Add metric argument
Add support for metric in route command. Differential Revision: https://reviews.freebsd.org/D56335
This commit is contained in:
@@ -50,6 +50,7 @@ ssthresh
|
||||
static
|
||||
sticky
|
||||
weight
|
||||
metric
|
||||
x25
|
||||
xns
|
||||
xresolve
|
||||
|
||||
@@ -813,6 +813,7 @@ set_metric(char *value, int key)
|
||||
caseof(K_RTT, RTV_RTT, rmx_rtt);
|
||||
caseof(K_RTTVAR, RTV_RTTVAR, rmx_rttvar);
|
||||
caseof(K_WEIGHT, RTV_WEIGHT, rmx_weight);
|
||||
caseof(K_METRIC, RTV_METRIC, rmx_metric);
|
||||
}
|
||||
rtm_inits |= flag;
|
||||
if (lockrest || locking)
|
||||
@@ -823,6 +824,8 @@ set_metric(char *value, int key)
|
||||
*valp = strtol(value, &endptr, 0);
|
||||
if (errno == 0 && *endptr != '\0')
|
||||
errno = EINVAL;
|
||||
if (flag & RTV_METRIC && *valp == RT_WILDCARD_METRIC)
|
||||
err(EX_USAGE, "Metric can not be zero");
|
||||
if (errno)
|
||||
err(EX_USAGE, "%s", value);
|
||||
if (flag & RTV_EXPIRE && (value[0] == '+' || value[0] == '-')) {
|
||||
@@ -999,6 +1002,7 @@ newroute(int argc, char **argv)
|
||||
case K_RTT:
|
||||
case K_RTTVAR:
|
||||
case K_WEIGHT:
|
||||
case K_METRIC:
|
||||
if (!--argc)
|
||||
usage(NULL);
|
||||
set_metric(*++argv, key);
|
||||
|
||||
@@ -270,6 +270,8 @@ rtmsg_nl_int(struct nl_helper *h, int cmd, int rtm_flags, int fib, int rtm_addrs
|
||||
if (rt_metrics->rmx_expire > 0)
|
||||
snl_add_msg_attr_u32(&nw, NL_RTA_EXPIRES, rt_metrics->rmx_expire);
|
||||
|
||||
if (rt_metrics->rmx_metric > 0)
|
||||
snl_add_msg_attr_u32(&nw, NL_RTA_PRIORITY, rt_metrics->rmx_metric);
|
||||
if (rt_metrics->rmx_weight > 0)
|
||||
snl_add_msg_attr_u32(&nw, NL_RTA_WEIGHT, rt_metrics->rmx_weight);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user