The primary purpose of this patch is to restore -M functionality of netstat so that it can pull information out of crash dumps. Right now it just silently pulls stats from the running kernel for functions that use sysctl which is even worse than missing functionality: it lies. It also fixes a subtle bug in the recent IPSEC changes which didn't renumber the N_xxx constants in the name list after removing a symbol which currently breaks all the IPSec stats. The biggest things the patch does are: - Add a global 'live' variable that is true if netstat is running against the live kernel and false if -M has been specified. - Stop abusing the sysctl flag in the protocol tables to hold the protocol number. Instead, the protocol is now its own field in the tables, and it is passed as a separate parameter to the PCB and stat routines rather than overloading the KVM offset parameter. - Don't run PCB or stats functions who don't have a namelist offset if we are being run against a crash dump (!live). - For the inet and unix PCB routines, we generate the same buffer from KVM that the sysctl usually generates complete with the header and trailer. - Don't run bpf stats for !live (before it would just silently always run live). - kread() no longer trashes memory when opening the buffer if there is an error on open and the passed in buffer is smaller than _POSIX2_LINE_MAX. - The multicast routing code doesn't fallback to kvm on live kernels if the sysctl fails. Keeping this made the code rather hairy, and netstat is already tied to the kernel ABI anyway (even when using sysctl's since things like xinpcb contain an inpcb) so any kernels this is run against that have the multicast routing stuff should have the sysctls. - Don't try to dig around in the kernel linker in the netgraph PCB routine for core dumps. One thing not done: - sctp's PCB routine only works on live kernels, it looked rather complicated to generate all the same stuff via KVM. Someone can always add it later if desired though. Other stuff: - Fix the ipsec removal bug where N_xxx for IPSEC stats weren't renumbered. - Use sysctlbyname() everywhere rather than hardcoded mib values. Patch is at http://www.FreeBSD.org/~jhb/patches/netstat_core_7.patch A patch for 6.x is also available as netstat_core.patch Barring any objections/feedback I will be committing this to CVS in a few days (subject to re_at_ approval of course). -- John BaldwinReceived on Tue Jul 10 2007 - 17:07:16 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:14 UTC