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.
Details
- Reviewers
bz cem - Commits
- rS354633: Fix netstat -gs with ip_mroute module and/or vnet
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 Not Applicable - Unit
Tests Not Applicable
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.
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.