summaryrefslogtreecommitdiffstats
path: root/usr.bin/netstat/bpf.c
Commit message (Collapse)AuthorAgeFilesLines
* Revert most part of 200420 as requested, as more review and polish isdelphij2009-12-131-0/+1
| | | | needed.
* Remove unneeded header includes from usr.bin/ except contributed code.delphij2009-12-111-1/+0
| | | | Tested with: make universe
* Implement the -z (zero counters) option for the various bpf counters.csjp2009-06-191-1/+8
| | | | | | | | Add necessary changes to the kernel for this (basically introduce a bpf_zero_counters() function). As well, update the man page. MFC after: 1 month Discussed with: rwatson
* Catch netstat up for the new bpf stats structures. Print 64 bit valuescsjp2008-03-241-2/+6
| | | | | | | properly. Sponsored by: Seccuris Inc MFC after: 4 months
* style(9)obrien2008-01-021-3/+5
| | | | | | | + kread is not a boolean, so check it as such + fix $FreeBSD$ Ids + denote copyrights with /*- + misc whitespace changes.
* Restore netstat -M functionality for most statistics on core dumps. Injhb2007-07-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* Add three new ioctl(2) commands for bpf(4).jkim2007-02-261-3/+6
| | | | | | | | | | | | | | | | | | | | | | - BIOCGDIRECTION and BIOCSDIRECTION get or set the setting determining whether incoming, outgoing, or all packets on the interface should be returned by BPF. Set to BPF_D_IN to see only incoming packets on the interface. Set to BPF_D_INOUT to see packets originating locally and remotely on the interface. Set to BPF_D_OUT to see only outgoing packets on the interface. This setting is initialized to BPF_D_INOUT by default. BIOCGSEESENT and BIOCSSEESENT are obsoleted by these but kept for backward compatibility. - BIOCFEEDBACK sets packet feedback mode. This allows injected packets to be fed back as input to the interface when output via the interface is successful. When BPF_D_INOUT direction is set, injected outgoing packet is not returned by BPF to avoid duplication. This flag is initialized to zero by default. Note that libpcap has been modified to support BPF_D_OUT direction for pcap_setdirection(3) and PCAP_D_OUT direction is functional now. Reviewed by: rwatson
* Don't shadow globals.yar2006-11-271-2/+2
| | | | | Found by: WARNS=6 MFC after: 3 days
* Achieve WARNS=2 by using uintmax_t to pass around 64-bit quantities,yar2006-07-281-0/+1
| | | | | | | including to printf(). Using uintmax_t is also robust to further extensions in both the C language and the bitwidth of kernel counters. Tested on: i386 amd64 ia64
* Use is '-' to imply that the flag is not set, rather than '.'.csjp2005-09-151-1/+1
|
* Print a warning if we fail to retrieve the process name for any reason.csjp2005-09-131-1/+3
|
* If there are'nt any bpf descriptors to process than dont bother attempting tocsjp2005-09-131-0/+2
| | | | | | retrieve statistic information for them. Pointed out by: Pawel Worach < pawel.worach at gmail.com >
* Free the bpf descriptor array after we are done with it. This probably isntcsjp2005-09-071-0/+1
| | | | | that critical as the program exits after this point anyway, but this may not always be the case.
* Merge bpfstat's functionality into the netstat(1) utility. This addscsjp2005-09-071-0/+119
a -B option which causes bpf peers to be printed. This option can be used in conjunction with -I if information about specific interfaces is desired. This is similar to what NetBSD added to their version of netstat. $ netstat -B Pid Netif Flags Recv Drop Match Sblen Hblen Command 1137 lo0 p--s-- 0 0 0 0 0 tcpdump 205 sis0 -ifs-l 37331 0 1 0 0 dhclient $ $ netstat -I lo0 -B Pid Netif Flags Recv Drop Match Sblen Hblen Command 1174 lo0 p--s-- 0 0 0 0 0 tcpdump $ -Add bpf.c which stores all the code for retrieving and parsing bpf related statistics. -Modify main.c to add support for the -B option and hook it into the program logic. -Add bpf.c to the build. -Document this new functionality in the man page and bump the revision date. -Add prototype for bpf_stats function.
OpenPOWER on IntegriCloud