From owner-cvs-all@FreeBSD.ORG Mon Jul 16 17:15:56 2007 Return-Path: X-Original-To: cvs-all@FreeBSD.org Delivered-To: cvs-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 69D3316A400; Mon, 16 Jul 2007 17:15:56 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 5925F13C461; Mon, 16 Jul 2007 17:15:56 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l6GHFuuq024553; Mon, 16 Jul 2007 17:15:56 GMT (envelope-from jhb@repoman.freebsd.org) Received: (from jhb@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l6GHFuXq024552; Mon, 16 Jul 2007 17:15:56 GMT (envelope-from jhb) Message-Id: <200707161715.l6GHFuXq024552@repoman.freebsd.org> From: John Baldwin Date: Mon, 16 Jul 2007 17:15:55 +0000 (UTC) To: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org X-FreeBSD-CVS-Branch: HEAD Cc: Subject: cvs commit: src/usr.bin/netstat atalk.c bpf.c if.c inet.c inet6.c ipsec.c ipx.c main.c mbuf.c mcast.c mroute.c mroute6.c netgraph.c netstat.h pfkey.c route.c sctp.c unix.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Jul 2007 17:15:56 -0000 jhb 2007-07-16 17:15:55 UTC FreeBSD src repository Modified files: usr.bin/netstat atalk.c bpf.c if.c inet.c inet6.c ipsec.c ipx.c main.c mbuf.c mcast.c mroute.c mroute6.c netgraph.c netstat.h pfkey.c route.c sctp.c unix.c Log: 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) Revision Changes Path 1.26 +4 -2 src/usr.bin/netstat/atalk.c 1.9 +1 -0 src/usr.bin/netstat/bpf.c 1.69 +13 -9 src/usr.bin/netstat/if.c 1.78 +306 -97 src/usr.bin/netstat/inet.c 1.29 +51 -43 src/usr.bin/netstat/inet6.c 1.17 +6 -4 src/usr.bin/netstat/ipsec.c 1.26 +4 -4 src/usr.bin/netstat/ipx.c 1.86 +134 -83 src/usr.bin/netstat/main.c 1.53 +2 -2 src/usr.bin/netstat/mbuf.c 1.9 +1 -0 src/usr.bin/netstat/mcast.c 1.30 +16 -27 src/usr.bin/netstat/mroute.c 1.21 +16 -26 src/usr.bin/netstat/mroute6.c 1.13 +6 -1 src/usr.bin/netstat/netgraph.c 1.51 +45 -43 src/usr.bin/netstat/netstat.h 1.5 +3 -1 src/usr.bin/netstat/pfkey.c 1.82 +1 -0 src/usr.bin/netstat/route.c 1.5 +13 -10 src/usr.bin/netstat/sctp.c 1.20 +133 -19 src/usr.bin/netstat/unix.c