Page MenuHomeFreeBSD

Fix netstat -gs with ip_mroute module and/or vnet
ClosedPublic

Authored by karels on Nov 11 2019, 5:38 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 11, 1:27 PM
Unknown Object (File)
Sun, Apr 7, 4:53 PM
Unknown Object (File)
Sun, Apr 7, 4:50 PM
Unknown Object (File)
Mar 11 2024, 1:51 AM
Unknown Object (File)
Mar 11 2024, 1:38 AM
Unknown Object (File)
Jan 28 2024, 3:36 PM
Unknown Object (File)
Dec 20 2023, 2:37 AM
Unknown Object (File)
Nov 18 2023, 6:40 AM
Subscribers

Details

Summary

The code for "netstat -gs -f inet" failed if the kernel namelist did not
include the _mrtstat symbol. However, that symbol is not in a standard
kernel even with the ip_mroute module loaded, where the functionality is
available. It is also not in a kernel with MROUTING but also VIMAGE, as
there can be multiple sets of stats. However, when running the command
on a live system, the symbol is not used; a sysctl is used. Go ahead
and try the sysctl in any case, and complain that IPv4 MROUTING is not
present only if the sysctl fails with ENOENT. Also fail if _mrtstat is
not defined when running on a core file; netstat doesn't know about vnets,
so can only work if MROUTING was included, and VIMAGE was not.

Test Plan

tested on amd64 with MROUTING in kernel and not, with and
without ip_mroute loaded.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 27438
Build 25676: arc lint + arc unit

Event Timeline

So this fixes a single live && MROUTING && VIMAGE case, but leaves the !live && MROUTING && VIMAGE case broken, with the same misleading print, as well as any other !live && VIMAGE code. It seems like a better solution might be teaching it about VIMAGE.

libkvm does know about VNETs (see kvm_private.c / kvm_vnet.c) as much as it knows about DPCPU. I seem to remember however it needs something selected, such as a PID or curthread from the dump, as it gets VNET information from there. This is probably something that should be generally fixed for netstat and not just for mrouting, though I am sure I tested that on a core dump back then. People may have broken it or the netstat parts were never merged.

This revision is now accepted and ready to land.Nov 11 2019, 4:48 PM

Conrad: this fixes a current problem with live systems, debugging a multicast problem. I am not aware of any requests to get multicast stats from a kernel core.

This revision was automatically updated to reflect the committed changes.