]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Fix netstat -gs with ip_mroute module and/or vnet
authorkarels <karels@FreeBSD.org>
Tue, 12 Nov 2019 01:03:08 +0000 (01:03 +0000)
committerkarels <karels@FreeBSD.org>
Tue, 12 Nov 2019 01:03:08 +0000 (01:03 +0000)
commit8f2598f3be634610dfc9b5da4bd9da5c32757bbf
tree6ca563f0c3d49d40e0be161b0047146b55b365a4
parentee979c9c45311b7cba7ecaf77a15497cd3bb1d40
Fix netstat -gs with ip_mroute module and/or vnet

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.

Reviewed by: bz
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D22311
usr.bin/netstat/mroute.c