Page MenuHomeFreeBSD

ddb(4): Add 'show route <dest>' and 'show routetable [<af>]'
ClosedPublic

Authored by cem on Tue, Sep 3, 5:32 PM.

Details

Summary

These commands show the route resolved for a specified destination, or
print out the entire routing table for a given address family (or all
families, if none is explicitly provided).

Test Plan
db> show route 192.168.0.SSS
Looking up route to destination '192.168.0.SSS'
dst <192.168.0.0> gateway <on link> netmask <255.255.255.0> ifp <on link> ifa <192.168.0.CCC> flags UP,PINNED
db> show route 8.8.8.8
Looking up route to destination '8.8.8.8'
dst <0.0.0.0> gateway <192.168.0.GGG> netmask <0.0.0.0> ifp <on link> ifa <192.168.0.CCC> flags UP,GATEWAY,STATIC

db> show route fe80::2
Looking up route to destination 'fe80::2'
dst <fe80::> gateway <::1> netmask <ffc0::> ifp <on link> ifa <::1> flags UP,GATEWAY,REJECT,STATIC
db> show route ::1
Looking up route to destination '::1'
dst <::1> gateway <on link> netmask <NULL> ifp <on link> ifa <::1> flags UP,HOST,PINNED,LOCAL


db> show routetable
Route table for AF 2 (INET):
dst <0.0.0.0> gateway <192.168.0.GGG> netmask <0.0.0.0> ifp <on link> ifa <192.168.0.CCC> flags UP,GATEWAY,STATIC
dst <127.0.0.1> gateway <on link> netmask <NULL> ifp <on link> ifa <127.0.0.1> flags UP,HOST,PINNED,LOCAL
dst <192.168.0.0> gateway <on link> netmask <255.255.255.0> ifp <on link> ifa <192.168.0.CCC> flags UP,PINNED
dst <192.168.0.CCC> gateway <on link> netmask <NULL> ifp <on link> ifa <127.0.0.1> flags UP,HOST,STATIC,PINNED

Route table for AF 28 (INET6):
dst <::> gateway <::1> netmask <ffff:ffff:ffff:ffff:ffff:ffff::> ifp <on link> ifa <::1> flags UP,GATEWAY,REJECT,STATIC
dst <::1> gateway <on link> netmask <NULL> ifp <on link> ifa <::1> flags UP,HOST,PINNED,LOCAL
dst <::ffff:0.0.0.0> gateway <::1> netmask <ffff:ffff:ffff:ffff:ffff:ffff::> ifp <on link> ifa <::1> flags UP,GATEWAY,REJECT,STATIC
dst <fe80::> gateway <::1> netmask <ffc0::> ifp <on link> ifa <::1> flags UP,GATEWAY,REJECT,STATIC
dst <fe80:2::> gateway <on link> netmask <ffff:ffff:ffff:ffff::> ifp <on link> ifa <fe80:2::1> flags UP
dst <fe80:2::1> gateway <on link> netmask <NULL> ifp <on link> ifa <fe80:2::1> flags UP,HOST,STATIC,PINNED,LOCAL
dst <ff02::> gateway <::1> netmask <ffff::> ifp <on link> ifa <::1> flags UP,GATEWAY,REJECT,STATIC,MULTICAST


db> show routetable 2
Route table for AF 2 (INET):
dst <0.0.0.0> gateway <192.168.0.GGG> netmask <0.0.0.0> ifp <on link> ifa <192.168.0.CCC> flags UP,GATEWAY,STATIC
dst <127.0.0.1> gateway <on link> netmask <NULL> ifp <on link> ifa <127.0.0.1> flags UP,HOST,PINNED,LOCAL
dst <192.168.0.0> gateway <on link> netmask <255.255.255.0> ifp <on link> ifa <192.168.0.CCC> flags UP,PINNED
dst <192.168.0.CCC> gateway <on link> netmask <NULL> ifp <on link> ifa <127.0.0.1> flags UP,HOST,STATIC,PINNED

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

cem created this revision.Tue, Sep 3, 5:32 PM
cem updated this revision to Diff 61634.Wed, Sep 4, 12:26 AM

Rebase on lexer changes.

cem added a comment.Mon, Sep 9, 10:07 PM

Any objection in principle? Planning to review or ENOTIME? Suggestions for reviewers with free time and interest in this layer of the network stack?

markj added a comment.Mon, Sep 9, 10:11 PM
In D21510#470181, @cem wrote:

Any objection in principle? Planning to review or ENOTIME? Suggestions for reviewers with free time and interest in this layer of the network stack?

I have no objection. I plan to review the pending diffs in the next day or so, but am swamped this week and not particularly qualified to review this particular one, so please don't wait on me if you're in a hurry.

cem added a comment.Mon, Sep 9, 10:27 PM

I have no objection. I plan to review the pending diffs in the next day or so, but am swamped this week and not particularly qualified to review this particular one, so please don't wait on me if you're in a hurry.

Thanks. Yeah, I figure this one is fairly unobjectionable and low impact; I'd rather than your limited eyeball time on netgdb, when I can get it.

Overall LGTM

sys/net/rtsock.c
2068 ↗(On Diff #61634)

this seems a little odd/hackish to me, but not sure how better to represent this (omitting gateway for local, or something else)

cem added inline comments.Mon, Sep 9, 10:52 PM
sys/net/rtsock.c
2068 ↗(On Diff #61634)

Sure. It seemed clearest to me to always print something for gateway, and this is reasonable for that column in this scenario. It might be nicer to look up the specific interface represented by the AF_LINK sockaddr, but that was more complicated and this met my needs for debugging debugnet.

This revision was not accepted when it landed; it landed in state Needs Review.Mon, Sep 9, 10:54 PM
This revision was automatically updated to reflect the committed changes.