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)
Tue, Dec 10, 5:26 PM
Unknown Object (File)
Tue, Dec 3, 11:39 AM
Unknown Object (File)
Thu, Nov 28, 11:47 PM
Unknown Object (File)
Oct 28 2024, 10:45 PM
Unknown Object (File)
Oct 4 2024, 6:20 PM
Unknown Object (File)
Sep 20 2024, 5:50 PM
Unknown Object (File)
Sep 9 2024, 4:07 AM
Unknown Object (File)
Sep 8 2024, 8:20 PM
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 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.

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.