summaryrefslogtreecommitdiff
path: root/sys/net/bpf.c
AgeCommit message (Collapse)Author
2015-06-16Store a unique ID, an interface index, rather than a pointer to theMartin Pieuchot
receiving interface in the packet header of every mbuf. The interface pointer should now be retrieved when necessary with if_get(). If a NULL pointer is returned by if_get(), the interface has probably been destroy/removed and the mbuf should be freed. Such mechanism will simplify garbage collection of mbufs and limit problems with dangling ifp pointers. Tested by jmatthew@ and krw@, discussed with many. ok mikeb@, bluhm@, dlg@
2015-05-13test mbuf pointers against NULL not 0Jonathan Gray
ok krw@ miod@
2015-02-10First step towards making uiomove() take a size_t size argument:Miod Vallat
- rename uiomove() to uiomovei() and update all its users. - introduce uiomove(), which is similar to uiomovei() but with a size_t. - rewrite uiomovei() as an uiomove() wrapper. ok kettenis@
2015-02-10make bpf(4) able to filter based on a pf(4) queue ID for tcpdump -Q qnameMartin Pelikan
ALTQ version has been on tech@ for years, people were generally ok with it. ok henning
2015-01-29back bpf.c down to 1.113, from before most recent timeout changes.Ted Unangst
nmap is broken, as reported by kent fritz. pending further investigation, we should keep nmap working until a better fix is developed for the original problem.
2015-01-28when doing a blocking read with a timeout, after the sleep resetDavid Gwynne
the start time so the next read behaves the same. from Simon Mages
2015-01-09correctly handle no timeouts and make timeout handling in general better.Ted Unangst
problem reported by Mages Simon ok guenther
2014-12-16primary change: move uvm_vnode out of vnode, keeping only a pointer.Ted Unangst
objective: vnode.h doesn't include uvm_extern.h anymore. followup changes: include uvm_extern.h or lock.h where necessary. ok and help from deraadt
2014-12-02replace some malloc multiplies with mallocarry. ok deraadt henningTed Unangst
2014-11-23length argument for some free() calls; ok dougTheo de Raadt
2014-10-07when running bpf on an outgoing vlan interface that doesnt have aDavid Gwynne
parent that doesnt offload the tag insertion, we need to chop the vlan subheader out before the filter is run, not after. this moves the mbuf surgery out from the bpf layer into the vlan layer. ok henning@ jmatthew@
2014-09-23lock around the sysctl code that sets the bpf buffer sizes so if we everDavid Gwynne
get multiple processes in the kernel these sets cant race and allow people to set the default greater than the max.
2014-09-22remove a stupid comment above bpfilterattach about how we dont do anythingDavid Gwynne
in it cos its only called on new systems, when it actually does. we dont care about old or new systems, just ours. the code is called, the fact that it exists is enough to demonstrate that.
2014-09-22stash a pointer to bpf_d in the knotes kn_hook instead of the device id.David Gwynne
we refcount the bpf_d memory correctly so it cant go away. possibly worse is the bpf minor id could be reused between the kq calls, so this seems safer to me. also avoids a list walk on each op cos the ptr is just there.
2014-09-22it's easy to allow bpfwrites bigger than MCLBYTES now that we haveDavid Gwynne
large cluster pools and MCLGETI. we could chain mbufs if we want to go even bigger. with a fix from Mathieu- <naabed at poolp dot org>
2014-09-22if you request a read timeout and then use kqueues to wait for them, youDavid Gwynne
end up waiting until the ring is full cos the timeout doesnt get set up when the knote is registered.
2014-09-19passing M_NOWAIT to m_tag_get means it can fail, which could hitDavid Gwynne
the failure path which leaks all the stuff the previous code in bpf_movein allocates. since it's only called from bpfwrite, use M_WAIT instead to make it reliable and just get rid of the bogus failure code. ok miod@
2014-07-12add a size argument to free. will be used soon, but for now default to 0.Ted Unangst
after discussions with beck deraadt kettenis.
2014-07-12sizeof(afh), afh being uint32, is cooler than literal "4"Henning Brauer
spotted by Kent R. Spillner <kspillner acm org>
2014-07-10time to claim copyrightHenning Brauer
2014-07-10some say you don't need NULL checks before free(). Not 0 either.Henning Brauer
2014-07-10introduce the revolutionary concept of NULL pointers. ok gccHenning Brauer
2014-07-10introduce bpf_mcopy_stripvlan, which cuts the 4 extra bytes out of theHenning Brauer
ether_vlan_header to make it a regular ether_header while copying into the bpf buffer. add bpf_mtap_stripvlan, which is a 1-line wrapper around _bpf_mtap passing this copy function in. ok benno
2014-07-09Add support bpfwrite on DLT_LOOP interfaces.YASUOKA Masahiko
ok guenther
2014-07-09Herr Reyk correctly pointed out that we don't need the if_pflog.h includeHenning Brauer
here any more
2014-07-09tedu bpf_mtap_pflog().Henning Brauer
now that it is a trivial wrapper around the extended bpf_mtap_hdr, we can use bpf_mtap_hdr directly. added benefit: pflog_bpfcopy doesn't need to be exported any more and can stay private to if_pflog.c ok benno bluhm reyk
2014-07-09bpf code surgery / shuffling / simplification.Henning Brauer
the various bpf_mtap_* are very similiar, they differ in what (and to some extent how) they prepend something, and what copy function they pass to bpf_catchpacket. use an internal _bpf_mtap as "backend" for bpf_mtap and friends. extend bpf_mtap_hdr so that it covers all common cases: if dlen is 0, nothing gets prepended. copy function can be given, if NULL the default bpf_mcopy is used. adjust the existing bpf_mtap_hdr users to pass a NULL ptr for the copy fn. re-implement bpf_mtap_af as simple wrapper for bpf_mtap_hdr. re-implement bpf_mtap_ether using bpf_map_hdr re-implement bpf_mtap_pflog as trivial bpf_mtap_hdr wrapper ok bluhm benno
2014-04-23Don't attempt to deal with link types supported by no drivers in theJeremie Courreges-Anglas
tree. ok henning@
2014-04-14"struct pkthdr" holds a routing table ID, not a routing domain one.Martin Pieuchot
Avoid the confusion by using an appropriate name for the variable. Note that since routing domain IDs are a subset of the set of routing table IDs, the following idiom is correct: rtableid = rdomain But to get the routing domain ID corresponding to a given routing table ID, you must call rtable_l2(9). claudio@ likes it, ok mikeb@
2014-03-30Eliminates struct pcred by moving the real and saved ugids intoPhilip Guenther
struct ucred; struct process then directly links to the ucred Based on a discussion at c2k10 or so before noting that FreeBSD and NetBSD did this too. ok matthew@
2013-12-24rearrange/correct timeout conditionals to work better.Ted Unangst
fixes negative timeout panics. tested by sthen.
2013-11-29panics still being reported. send bpf.c back to 1.85Ted Unangst
2013-11-17speelingDavid Gwynne
2013-11-15calculate the line in the sand before comparing it to ticks, which looksDavid Gwynne
more like the original conditional. if this doesnt fix rd thrushs panic, then this should be reverted to r1.85.
2013-11-12try bpf.c r1.84 again, this time without semantic changes to if statements.David Gwynne
cheers to sthen@ and krw@ for properly dealing with the fallout of my first commit.
2013-11-11Revert bpf.c 1.84 / bpfdesc.h 1.19 for now, "panic: timeout_add: to_ticks (-1)Stuart Henderson
< 0" seen by RD Thrush, http://article.gmane.org/gmane.os.openbsd.bugs/20113 where he has a long-running process using bpf which is active at the time of panic. krw@ agrees with reverting for now.
2013-11-11replace the user of ticks in a condition like "interval + start < ticks"David Gwynne
with "ticks - start > interval" because the latter copes with the ticks value wrapping. pointed out by guenther@ ok krw@
2012-12-28change the malloc(9) flags from M_DONTWAIT to M_NOWAIT; OK millert@Gleydson Soares
2012-12-21Rather than calling mircotime in bpf_catchpacket each time it's calledMike Belopuhov
on a packet, make bpf_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. From NetBSD, ok deraadt, claudio, sthen
2012-12-21bpf allocates packet buffers in the ioctl path and can sleepMike Belopuhov
waiting for memory to become available obtained from netbsd with tweaks, with input from deraadt and blambert, ok deraadt, claudio
2012-04-14Use DLT_LOOP for all tunneling interfaces.YASUOKA Masahiko
Byte order adjustment for bpf was hidden behind bpf_mtap_af() and sizeof(u_int32_t) is used for length of the bpf header. tested by sebastia and mxb at alumni.chalmers.se. ok claudio
2012-01-16bpf devices behave similar to raw sockets and never block on write,Philip Guenthe
so always show as writable to poll()/select(). Behavior pointed out by Fernando Gont. ok deraadt@
2011-07-02kqueue attach functions should return an errno or 0, not a plain 1. FixNicholas Marriott
the obvious cases to return EINVAL and ENXIO. ok tedu deraadt
2011-01-04in bpf_movein(), range-check mbuf size against MCLBYTES beforeTheo de Raadt
size_t to int truncation ok claudio
2010-09-21pflog overhaulHenning Brauer
pflog was logging the "wrong" as in not yet rewritten (nat/rdr) addresses. to address this without making an extra copy of the mbuf chain: -introduce bpf_mtap_pflog, which is a 1:1 copy of bpf_mtap_hdr, except that it supplies bpf_catchpacket with pflog_bpfcopy as copy function instead of plain bcopy -said new shiny pflog_bpfcopy knows what a pflog packet looks like, copies everything into bpf's buffer, contructs a fake mbuf (which is allocated once at attach time and reused over and over) which points to the bpf buffer as data storage -call pf_setup_pdesc on said fake mbuf -then call pf_translate to rewrite the addresses as needed right in the bpf buffer this changes the pflog header as we have to pass the new addresses/ports around. relies on canacar's awesome work in libpcap to work olrite with the new, longer pflog header as well as with the old, shorter one. almost completely written at c2k10 in canada, finished here at j2k10 in japan. ok ryan dlg
2009-11-09Every selwakeup() should have a matching KNOTE() (even if kqueue isn'tNicholas Marriott
supported it doesn't do any harm), so put the KNOTE() in selwakeup() itself and remove it from any occurences where both are used, except one for kqueue itself and one in sys_pipe.c (where the selwakeup is under a PIPE_SEL flag). Based on a diff from tedu. ok deraadt
2009-10-26Set the rdomain in bpfwrite() to the interface rdomain so that bpf senderClaudio Jeker
like dhcpd/dhclinet can send packets out of interfaces in other rdomains without hitting the check in ether_output(). With and ok phessler@
2009-09-21Properly reference count bpf descriptors when using kqueue.Can Erkin Acar
Reported and fix tested by weerd@, ok claudio@
2009-09-07de-inline a function which gains absolutely no benefit at all from itTheo de Raadt
ok canacar
2008-11-26dont have bpf.h expose the kernel ticks variable wherever it is includeing.David Gwynne
it is very confusing like this. ok deraadt@ canacar@