Page MenuHomeFreeBSD

Simplify address parsing in DDB show route command.
ClosedPublic

Authored by melifaro on May 2 2020, 8:59 AM.

Details

Summary

Use db_get_line() to overcome parser limitation.

Test Plan
show route
Usage: 'show route <address>'
Currently accepts only IPv4 and IPv6 addresses
db> show route 1.1.1.1
Looking up route to destination '1.1.1.1'
dst <0.0.0.0> gateway <172.16.107.2> netmask <0.0.0.0> ifp <on link> ifa <172.16.107.128> flags UP,GATEWAY, STATIC
db> show route 172.16.167.3
Looking up route to destination '172.16.187.3'
dst <172.16.107.6> gateway <on link> netmask <255.255.255.0> ifp <on link> ifa <1?2.16.107.128> flags UP,PINNED
db> show route ::
Looking up route to destination '::'
dst <::> gateway <::1> netmask <ffff:ffff:ffff :ffff:ffff :ffff::> ifp <on link> ifa <::1> flags UP,GATEWAY,REJECT, STATIC
show route 1::1
Looking up route to destination '1::1'
dst <::> gateway <fe86:3: :925c:44ff:fe5b:1c5b> netmask <::> ifp <on link> ifa <fe8@:3: :26c:29ff :fed4b:dbb0> flags UP,GATEWAY
show route qqq
Usage: 'show route <address>’
Currently accepts only IPv4 and IPv6 addresses
db> show route a
Usage: ‘show route <address>’
Currently accepts only IPv4 and IPv6 addresses
db> show route a::
Looking up route to destination 'a::'
dst <::> gateway <fe86:3: :925c:44ff:fe5b:1c5b> netmask <::> ifp <on link> ifa <fe80:3: :26c:29ff :fed4b:dbb0> flags UP,GATEWAY
db>

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

lutz_donnerhacke.de added inline comments.
sys/net/route/route_ddb.c
241–242 ↗(On Diff #71270)

This is only for printing a canonized address?

sys/net/route/route_ddb.c
241–242 ↗(On Diff #71270)

Yes.

lutz_donnerhacke.de added inline comments.
sys/net/route/route_ddb.c
222–225 ↗(On Diff #71270)

You are not handling all types of whitespace (i.e. \t); is inet_pton able to ignore this itself?

This revision is now accepted and ready to land.May 3 2020, 12:45 AM
sys/net/route/route_ddb.c
222–225 ↗(On Diff #71270)

No, inet_pton doesn't handle it. I've updated the implementation to use isspace(), though I'm not sure if '\t' is even supported by our debugger.