Date: Wed, 20 May 2026 20:58:52 +0000 From: Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 2e2d402d061d - main - route(8): Add metric argument Message-ID: <6a0e208c.3ebd8.14f1859c@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch main has been updated by pouria: URL: https://cgit.FreeBSD.org/src/commit/?id=2e2d402d061dc0d091308c477ab800b3eda007ad commit 2e2d402d061dc0d091308c477ab800b3eda007ad Author: Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org> AuthorDate: 2026-05-02 21:22:17 +0000 Commit: Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org> CommitDate: 2026-05-20 20:55:08 +0000 route(8): Add metric argument Add support for metric in route command. Differential Revision: https://reviews.freebsd.org/D56335 --- sbin/route/keywords | 1 + sbin/route/route.c | 4 ++++ sbin/route/route_netlink.c | 2 ++ 3 files changed, 7 insertions(+) diff --git a/sbin/route/keywords b/sbin/route/keywords index cbd8799ffb6b..3dbfcd187773 100644 --- a/sbin/route/keywords +++ b/sbin/route/keywords @@ -50,6 +50,7 @@ ssthresh static sticky weight +metric x25 xns xresolve diff --git a/sbin/route/route.c b/sbin/route/route.c index f0d9515f9892..84c520bd4f39 100644 --- a/sbin/route/route.c +++ b/sbin/route/route.c @@ -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); diff --git a/sbin/route/route_netlink.c b/sbin/route/route_netlink.c index 20c82c25f5cf..051662688047 100644 --- a/sbin/route/route_netlink.c +++ b/sbin/route/route_netlink.c @@ -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);home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a0e208c.3ebd8.14f1859c>
