Repository navigation
Read the NetBSD routing table with NetBSD's PF_ROUTE - #3814
Conversation
The NET_RT_DUMP request named protocol family 17, which is PF_ROUTE on macOS, FreeBSD, DragonFly BSD and OpenBSD but the obsolete AF_OROUTE on NetBSD, where PF_ROUTE is 34. On NetBSD every call failed, logged an error and fell back to running netstat, so the native routing table added in oshi#3742 was never read there. The value now sits in RouteTableDump.Layout beside the platform's other routing message values, and the JNA and FFM drivers take the layout from their callers. RouteComparisonTest now covers NetBSD as well, with the interface name in column 6 of its netstat output. Verified on a NetBSD 10.1 aarch64 VM: JNA and FFM read the same 45 routes netstat -rn lists, and the full -Paggregate-coverage run passes with all four comparison tests.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📜 Recent review details
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3814 +/- ##
============================================
- Coverage 80.86% 80.82% -0.05%
+ Complexity 657 655 -2
============================================
Files 725 725
Lines 26021 26024 +3
Branches 4421 4421
============================================
- Hits 21043 21034 -9
- Misses 2758 2768 +10
- Partials 2220 2222 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The
NET_RT_DUMPsysctl request used protocol family 17. That isPF_ROUTEon macOS, FreeBSD, DragonFly BSD and OpenBSD, but on NetBSD 17 is the obsoleteAF_OROUTEandPF_ROUTEis 34 (sys/socket.h). On NetBSD every call togetRoutes()loggedERROR Didn't get buffer length for NET_RT_DUMPand fell back to runningnetstat. The native read added in #3742 had never succeeded there.Changes
RouteTableDump.Layoutgains aPF_ROUTEcolumn, set to 34 for NetBSD and 17 for the others, beside each platform's other routing message values.BsdRouteDumpJNAandBsdRouteDumpFFMtake the layout from their callers rather than hard-coding 17. The FreeBSD callers passrouteLayout(), so DragonFly BSD keeps its own layout.RouteComparisonTestnow covers NetBSD as well, reading the interface name from column 6 of NetBSD'snetstatoutput. Thetestnetbsdjnajob inunix.yamlruns it on pushes to master.Testing
I tested on cfarm428, a NetBSD 10.1 evbarm aarch64 VM:
netstat -rn, 16 IPv4 routes plus 29 IPv6.netstatkeeps the embedded KAME scope in interface-local multicast routes (ff01:1::/32). The native read strips it (ff01::/32)../mvnw clean test -Paggregate-coveragewith the pkgsrclibjnidispatch, all fourRouteComparisonTesttests pass and every module reports 0 failures.SystemInfoTestreport no longer logs the error in any of three configurations: JNA without the native library, JNA with it, and FFM.Summary by CodeRabbit
netstatwhen the request fails.