aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/netstat/route.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2007-07-16 17:15:55 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2007-07-16 17:15:55 +0000
commitfeda1a4372d5e340da97042375dfb783dea52eda (patch)
tree165174828db97bceab2299030940226f1b6620cf /usr.bin/netstat/route.c
parent72d73315396520151f86f8c6cb42b09d5a1073e5 (diff)
downloadsrc-feda1a4372d5e340da97042375dfb783dea52eda.tar.gz
src-feda1a4372d5e340da97042375dfb783dea52eda.zip
Restore netstat -M functionality for most statistics on core dumps. In
general, when support was added to netstat for fetching data using sysctl, no provision was left for fetching equivalent data from a core dump, and in fact, netstat would _always_ fetch data from the live kernel using sysctl even when -M was specified resulting in the user believing they were getting data from coredumps when they actually weren't. Some specific changes: - 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. Other notes: - 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. - Fix the ipsec removal bug where N_xxx for IPSEC stats weren't renumbered. - Use sysctlbyname() everywhere rather than hardcoded mib values. MFC after: 1 week Approved by: re (rwatson)
Notes
Notes: svn path=/head/; revision=171465
Diffstat (limited to 'usr.bin/netstat/route.c')
-rw-r--r--usr.bin/netstat/route.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c
index f13dff8c2d29..a0a8990a17bd 100644
--- a/usr.bin/netstat/route.c
+++ b/usr.bin/netstat/route.c
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/protosw.h>
#include <sys/socket.h>
+#include <sys/socketvar.h>
#include <sys/time.h>
#include <net/ethernet.h>