Repository navigation
Fix network interface statistics on OpenBSD and DragonFly BSD, and gateways on DragonFly - #3788
Conversation
BsdNetworkIF read netstat -bI by fixed column index and gave up on fewer than 12 columns. FreeBSD prints 12, but DragonFly BSD has no Idrop column (11) and OpenBSD prints only Ibytes and Obytes with -b (6), so every counter was 0 on both. Parse the link-level row against the header instead, matching values from the end of the row because the loopback row has an empty Address column on DragonFly and OpenBSD. Where -b gives no packet counts (OpenBSD), read them from netstat -nI, which names its error and collision columns Ifail/Ofail/Colls. Pass -n so netstat does not resolve addresses to host names. FreeBSD's default gateway lookups used route -4/-6, which DragonFly's route does not accept, leaving both gateways empty there. Use route -n get [-inet6] default, as OpenBSD and NetBSD already do. Verified on cfarm152 (DragonFly 6.4) and cfarm430 (FreeBSD 16-CURRENT), JNA and FFM; OpenBSD by fixtures from cfarm220.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📜 Recent review details
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to No confirmed issue currently prevents merging. BSD platform behavior remains unverified in the available evidence. Pre-merge checks |
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3788 +/- ##
============================================
- Coverage 80.58% 80.53% -0.06%
- Complexity 83 530 +447
============================================
Files 724 724
Lines 25991 26005 +14
Branches 4391 4395 +4
============================================
- Hits 20946 20943 -3
- Misses 2800 2813 +13
- Partials 2245 2249 +4
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:
|
BsdNetworkIFreadnetstat -bI <if>by fixed column index and gave up when a row had fewer than 12 columns. Only FreeBSD prints 12:netstat -bIcounters-nadded so netstat no longer resolves host names-b, packets/errors/collisions fromnetstat -nI(Ifail/Ofail/Colls)The parser now reads the link-level row against the header, matching values from the end of the row, because the loopback row has an empty Address column on DragonFly and OpenBSD.
FreeBsdNetworkParams(also used by DragonFly) ranroute -4|-6 get default; DragonFly'sroutehas no-4/-6, so both gateways were empty. It now runsroute -n get defaultandroute -n get -inet6 default, the commands OpenBSD and NetBSD already use.All changes are in
oshi-common, so JNA and FFM share them.Verified
netstat; IPv4 gateway 140.211.167.129 (was empty). The box has no IPv6 default route, so the IPv6 gateway stays empty.netstat; gateways172.18.4.1and2600:3c18:e002:2e11::1.BsdNetworkIFTestfixtures taken from its real output.Not changed
netstatshows 0 packets on thevtnet0link row (the driver counts bytes only).NetworkInterfacedoes not return IPv6 addresses there; FreeBSD's JDK does. Not an OSHI issue.NetBsdNetworkIFduplicates the OpenBSD two-command path; folding it intoBsdNetworkIFis left for a follow-up.Summary by CodeRabbit