Page MenuHomeFreeBSD

route(8): Add metric argument
Needs ReviewPublic

Authored by pouria on Apr 9 2026, 10:58 PM.
Tags
None
Referenced Files
F156433484: D56335.id175208.diff
Wed, May 13, 4:37 PM
Unknown Object (File)
Mon, May 11, 4:04 PM
Unknown Object (File)
Fri, May 8, 9:22 PM
Unknown Object (File)
Mon, May 4, 2:02 PM
Unknown Object (File)
Sun, May 3, 6:05 PM
Unknown Object (File)
Thu, Apr 30, 8:33 AM
Unknown Object (File)
Tue, Apr 28, 7:20 AM
Unknown Object (File)
Sun, Apr 26, 2:26 PM
Subscribers

Details

Reviewers
melifaro
markj
glebius
Group Reviewers
network
Summary

Add support for metric in route command.

Test Plan
[root@ftsr1] [~] # route -n6 add -net 3fff::/64 -gateway ::2 -weight 3 -metric 3
add net 3fff::/64: gateway ::2 fib 0
[root@ftsr1] [~] # netstat -On6W
Nexthop groups data

Internet6:
GrpIdx  NhIdx     Weight   Slots                                 Gateway     Netif  Refcnt
11        ------- ------- ------- --------------------------------------- ---------       2
9       2      25                                     ::3       lo0
10       3      39                                     ::2       lo0
[root@ftsr1] [~] # route -n6 get 3fff::/64
route to: 3fff::
destination: 3fff::
mask: ffff:ffff:ffff:ffff::
gateway: ::3
fib: 0
interface: lo0
flags: <UP,GATEWAY,DONE,STATIC>
recvpipe  sendpipe  ssthresh  rtt,msec    mtu       metric    weight    expire
0         0         0         0     16384         3         2         0
[root@ftsr1] [~] # route -on6 get 3fff::/64
route to: 3fff::
destination: 3fff::
mask: ffff:ffff:ffff:ffff::
fib: 0
flags: <UP,GATEWAY,DONE,STATIC>
nhops: 2
via gw ::3 iface lo0 metric 3 weight 2 mtu 16384 table inet6.0
via gw ::2 iface lo0 metric 3 weight 3 mtu 16384
[root@ftsr1] [~] # route -n6 add -net 3fff::/64 -gateway ::1 -weight 3 -metric 1
add net 3fff::/64: gateway ::1 fib 0
[root@ftsr1] [~] # route -n6 get 3fff::/64
route to: 3fff::
destination: 3fff::
mask: ffff:ffff:ffff:ffff::
gateway: ::3
fib: 0
interface: lo0
flags: <UP,GATEWAY,DONE,STATIC>
recvpipe  sendpipe  ssthresh  rtt,msec    mtu       metric    weight    expire
0         0         0         0     16384         3         2         0

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 72761
Build 69644: arc lint + arc unit

Event Timeline

pouria edited the test plan for this revision. (Show Details)

Replace err(3) with errx(3) for better error message.

This revision is now accepted and ready to land.Apr 12 2026, 7:51 PM

Remove extra macros based on parent revision.

This revision now requires review to proceed.Mon, May 4, 11:36 AM