Commit Graph

124 Commits

Author SHA1 Message Date
elad 0a57b5966b Kill some KAUTH_GENERIC_ISSUSER uses. 2006-10-25 20:28:45 +00:00
christos 4d595fd7b1 - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
2006-10-12 01:30:41 +00:00
christos 6d637b500d add missing initializer 2006-08-28 00:09:28 +00:00
martin f1dc5b61db Fix typo in comment 2006-08-04 23:18:53 +00:00
christos 224c697f91 Patch from Dheeraj S, inspired by the following FreeBSD change:
Rather than calling mircotime() in catchpacket(), make catchpacket()
take a timeval indicating when the packet was captured. Move
microtime() to the calling functions and grab the timestamp as soon
as we know that we're going to call catchpacket at least once.

This means that we call microtime() once per matched packet, as
opposed to once per matched packet per bpf listener. It also means
that we return the same timestamp to all bpf listeners, rather than
slightly different ones.

It would be more accurate to call microtime() even earlier for all
packets, as you have to grab (1+#listener) locks before you can
determine if the packet will be logged. You could always grab a
timestamp before the locks, but microtime() can be costly, so this
didn't seem like a good idea.

(I guess most ethernet interfaces will have a bpf listener these
days because of dhclient. That means that we could be doing two bpf
locks on most packets going through the interface.)
2006-07-26 13:54:13 +00:00
ad f474dceb13 Use the LWP cached credentials where sane. 2006-07-23 22:06:03 +00:00
tron d700257e96 Make this build with GCC 4.x. 2006-06-27 10:45:09 +00:00
elad 874fef3711 integrate kauth. 2006-05-14 21:19:33 +00:00
mrg 084c052803 quell GCC 4.1 uninitialised variable warnings.
XXX: we should audit the tree for which old ones are no longer needed
after getting the older compilers out of the tree..
2006-05-10 21:53:14 +00:00
rpaulo 7eace3f40d Kill BPF_KERN_FILTER. Seems like it died with the new pppd import.
No replies from tech-kern@, but who introduced this option 8 years ago
(Christos) said it's ok to remove it.
2005-12-26 15:45:48 +00:00
perry 0f0296d88a Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete. 2005-12-24 20:45:08 +00:00
rpaulo 08ac963d6f Correct typo in comments. 2005-12-14 22:46:52 +00:00
christos 95e1ffb156 merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
rpaulo dc5a3ff210 Use ANSI function declarations everywhere and a consistent indentation on
them.
2005-09-05 18:32:24 +00:00
rpaulo 2fcfc4c276 Implemented the kernel part of BPF statistics and BPF peers, net.bpf.stats
and net.bpf.peers sysctls respectively.

A new structure was added to describe the external (user viewable)
representation of a BPF file; a new entry was added to the bpf_d
structure to store the PID of the calling process; a simple_lock was added
to protect the insert/removal from the net.bpf.peers sysctl handler.

This idea came from FreeBSD (Christian S.J. Peron) but while it is
implemented with sysctl's it differs a bit.

Reviewed by: christos@ and atatat@ (who gave me the tip for the net.bpf.peers
sysctl helper function).
2005-08-04 19:30:47 +00:00
peter 26b3362b67 Missing m_freem() in bpf_write. PR/29138. 2005-06-22 10:36:16 +00:00
atatat df13e3579e Change the rest of the sysctl subsystem to use const consistently.
The __UNCONST macro is now used only where necessary and the RW macros
are gone.  Most of the changes here are consumers of the
sysctl_createv(9) interface that now takes a pair of const pointers
which used not to be.
2005-06-20 02:49:18 +00:00
perry f07677dd81 nuke trailing whitespace 2005-02-26 22:45:09 +00:00
christos be3704c73f pass the flag to fdclone. 2005-02-12 23:14:03 +00:00
christos 0146482549 Clonify bpf. I am not changing /dev/bpfX -> /dev/bpf until all userland
programs have been fixed.
2004-11-30 04:28:43 +00:00
christos 0f7d471853 Factor out the hand-crafting of mbufs from the interface files. Reviewed by
gimpy. XXX: I could have used bpf_mtap2 on some of the new functions, but I
chose not to, because I just wanted to do what amounts to a code move.
2004-08-19 20:58:23 +00:00
christos 396c380971 - ansify
- remove unnecessary casts
- change caddr_t to void *
- no functional change.
2004-08-19 18:33:24 +00:00
enami e3ad2a7b68 Don't refuse to attach an interface even if it is down so that one can
capture the very first packet when an interface is up.
2004-08-05 03:58:58 +00:00
dyoung e80559eec4 Per Matt Thomas' and Darren Reed's suggestions:
Add bpf_deliver prototype.

Rename bpf_measure to m_length and move it to sys/sys/mbuf.h.  I
make m_length an inline function in the header file to preserve
its performance characteristics, for better or for worse.

Optimize m_length: use the length in m_pkthdr.len, if M_PKTHDR.

In bpf_deliver, zero the on-stack mbuf before we do anything else
with it.
2004-06-06 04:35:53 +00:00
darrenr eda7e8d3e3 back out previous change - these diffs aren't what I'd tested. 2004-05-29 14:18:33 +00:00
darrenr 15f2ef8f2c add mmap(2) interface to bpf(4) devices, along with BIOCMMAPINFO ioctl call
for applications to interact with the bpf device for the purpose of using
mmap to examinen captured data.
2004-05-29 08:56:19 +00:00
atatat 4de3747b89 Sysctl descriptions under net subtree (net.key not done) 2004-05-25 04:33:59 +00:00
darrenr 643574e764 reapply a change that got undone with more recent changes to bpf to wakeup
any sleepers _after_ the device info has been updated, not before.
2004-05-19 13:09:11 +00:00
dyoung e0ea6bdc5d Add bpf_mtap2, which taps a packet whose head is in a void *buffer
and whose tail is in an mbuf chain.
2004-04-30 22:07:21 +00:00
darrenr 2466d2e86c If we timeout waiting for data on the bpf device, allow data in the current
storage buffer (bd_sbuf) to indicate that there is data present.
2004-04-20 10:51:09 +00:00
darrenr 4800529c7e Add a count of the number of packets that match the bpf filter applied to a
particule device.  In doing this, make a new the bpf_stat structure with
members that are u_long rather than u_int, matching the counters in the bpf_d.
the original bpf_stat is now bpf_stat_old and so to the original ioctl
is preserved as BIOCGSTATSOLD.
2004-04-15 14:56:57 +00:00
darrenr 6cfa637a10 * from bpf 1.2a1, use the IO_NDELAY flag in bpfread() to indicate whether or
not a read operation should be allowed to sleep.  This allows the use of
  bd_rtout with a value of "-1" to be eliminated (signed comparison and
  assignment to an unsigned long.)
* in 1.91, a change was introduced that had bpfpoll() returning POLLRDNORM
  set when the timeout expired.  This impacted poorly on performance as well
  as causing select to return an fd available for reading when it wasn't.
  Change the behaviour here to only allow the possibility of POLLIN being
  returned as active in the event of a timeout.
2004-04-14 21:34:26 +00:00
darrenr c4acd0486b from freebsd's kern/36219, the if expression in deciding whether or not
to return something check the value of bd_state in the wrong place.
2004-04-11 01:41:01 +00:00
darrenr eee3190c06 Fix bpf so that select will return for a timeout (from FreeBSD.)
Fix the behaviour of BIOCIMMEDIATE (fix from LBL BPF code via FreeBSD.)

In bpf_mtap(), optimise the calling of bpf_filter() and catchpacket()
based on whether or not the entire packet is in one mbuf (based on
similar change FreeBSD but fixes BIOC*SEESENT issue with that.)

Copy the implementation of BIOCSSEESENT, BIOCGSEESENT by FreeBSD.

Review Assistance: Guy Harris

PRs: kern/8674, kern/12170
2004-04-10 23:31:51 +00:00
atatat 19af35fd0d Tango on sysctl_createv() and flags. The flags have all been renamed,
and sysctl_createv() now uses more arguments.
2004-03-24 15:34:46 +00:00
jonathan 638afbfe26 Make bpf_maxbufsize writable via sysctl, as written by Andrew Brown. 2004-01-22 00:32:41 +00:00
jonathan 9369f19096 Fix an Emacs finger-glitch (missing semicolon#). 2004-01-21 23:59:12 +00:00
jonathan b0a71dcaf5 Update bpf buffer parameters, as per recent discussion on tech-net.
Increase the default bpf buffer size used by naive apps that don't do
BIOCSBLEN, from 8k to 32k.  The former value of 8192 is too small to
hold a normal jumbo Ethernet frame (circa 9k), 16k is a little small
for Large-jumbo (~16k) frames supported by newer gigabit
Ethernet/10Gbe, so (somewhat arbitrarily) increase the default to 32k.

Increase the upper limit to which BIOSBLEN can raise bpf buffer-size
drastically, to 1 Mbyte.  State-of-the-art for packet capture circa
1999 was around 256k; savvy NetBSD developers now use 1 Mbyte.
Note that libpcap has been updated to do binary-search on BIOCSBLEN
values up to 1 Mbyte.

Work is in progress to make both values sysctl'able. Source comments
note that consensus on tech-net is that we should find some heuristic
to set the boot-time default values dynamically, based on system memory.
2004-01-21 22:15:16 +00:00
christos 6edc0e184e - pass signo to fownsignal [ok by jd]
- make urg signal handling use fownsignal
- remove out of band detection in sowakeup
2003-09-22 12:59:55 +00:00
jdolecek 7cea8a1389 cleanup & uniform descriptor owner handling:
* introduce fsetown(), fgetown(), fownsignal() - this sets/retrieves/signals
  the owner of descriptor, according to appropriate sematics
  of TIOCSPGRP/FIOSETOWN/SIOCSPGRP/TIOCGPGRP/FIOGETOWN/SIOCGPGRP ioctl; use
  these routines instead of custom code where appropriate
* make every place handling TIOCSPGRP/TIOCGPGRP handle also FIOSETOWN/FIOGETOWN
  properly, and remove the translation of FIO[SG]OWN to TIOC[SG]PGRP
  in sys_ioctl() & sys_fcntl()
* also remove the socket-specific hack in sys_ioctl()/sys_fcntl() and
  pass the ioctls down to soo_ioctl() as any other ioctl

change discussed on tech-kern@
2003-09-21 19:16:48 +00:00
wrstuden 2d11b64df0 Include correct file for defopt. 2003-08-13 19:44:12 +00:00
agc aad01611e7 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22364, verified by myself.
2003-08-07 16:26:28 +00:00
fvdl d5aece61d6 Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
2003-06-29 22:28:00 +00:00
darrenr 42091f2362 From OpenBSD 1.33-1.34:
When using bpf(4) in immediate mode, and using kevent(2) to receive
notification of packet arrival, the usermode application isn't notified
until a second packet arrives.

This is because KNOTE() calls filt_bpfread() before bd_slen has been
updated with the newly arrived packet length, so it looks like there
is no data there.

Moving the bpf_wakeup() call for immediate mode to after bd_slen is set
fixes it.

From: wayne@epipe.com.au in pr 3175
2003-06-28 17:33:02 +00:00
darrenr 960df3c8d1 Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records.  The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
2003-06-28 14:20:43 +00:00
itojun b6625c38a4 avoid panic in malloc() under extremely low memory situation.
OpenBSD problem report 2235, 2236, 2640.  fix by Otto Moerbeek.
2003-06-19 06:25:41 +00:00
dsl 53d2320e25 Check that the process/process group id passed to TIOCSPRP is in the session
of the current process.
2003-03-13 10:18:35 +00:00
matt 65e5548a17 Add MBUFTRACE kernel option.
Do a little mbuf rework while here.  Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *).  These are not performance critical and making them
call m_get saves considerable space.  Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.
2003-02-26 06:31:08 +00:00
christos f5ff34bbc6 si_ -> sel_ 2002-11-26 18:51:18 +00:00
jdolecek e0cc03a09b merge kqueue branch into -current
kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
2002-10-23 09:10:23 +00:00