OpenBSD CVS

CVS log for src/sys/net/bpf_filter.c


[BACK] Up to [local] / src / sys / net

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.34 / (download) - annotate - [select for diffs], Mon Aug 3 03:21:24 2020 UTC (3 years, 10 months ago) by dlg
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, OPENBSD_7_4_BASE, OPENBSD_7_4, OPENBSD_7_3_BASE, OPENBSD_7_3, OPENBSD_7_2_BASE, OPENBSD_7_2, OPENBSD_7_1_BASE, OPENBSD_7_1, OPENBSD_7_0_BASE, OPENBSD_7_0, OPENBSD_6_9_BASE, OPENBSD_6_9, OPENBSD_6_8_BASE, OPENBSD_6_8, HEAD
Changes since 1.33: +6 -1 lines
Diff to previous 1.33 (colored)

add a BPF_RND load location that provides a random value.

this will be used so a bpf filter can make a decision based on a
random number, which in turn will be used so a filter can perform
random sampling of packets rather than capturing all packets. random
sampling means that we don't have to figure out how to make bpf
coordinate multiple concurrent calls to do counter based sampling.

BPF_RND is currently backed with arc4random.

discussed with many including jmatthew@, alex wilson, claudio@,
sthen@, deraadt@, and tb@
ok kn@ tb@ jmatthew@

i call this extended bpf... xBPF.

Revision 1.33 / (download) - annotate - [select for diffs], Fri Sep 8 05:36:53 2017 UTC (6 years, 9 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_6_7_BASE, OPENBSD_6_7, OPENBSD_6_6_BASE, OPENBSD_6_6, OPENBSD_6_5_BASE, OPENBSD_6_5, OPENBSD_6_4_BASE, OPENBSD_6_4, OPENBSD_6_3_BASE, OPENBSD_6_3, OPENBSD_6_2_BASE, OPENBSD_6_2
Changes since 1.32: +1 -2 lines
Diff to previous 1.32 (colored)

If you use sys/param.h, you don't need sys/types.h

Revision 1.32 / (download) - annotate - [select for diffs], Tue Sep 13 12:09:53 2016 UTC (7 years, 8 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.31: +3 -3 lines
Diff to previous 1.31 (colored)

Don't waste time zero'ing memory until there is some chance it might
be used.

Also noted by dlg@.

ok phessler@ mpi@

Revision 1.31 / (download) - annotate - [select for diffs], Mon Sep 12 14:05:40 2016 UTC (7 years, 9 months ago) by krw
Branch: MAIN
Changes since 1.30: +15 -15 lines
Diff to previous 1.30 (colored)

Kill some unsightly whitespace.

Revision 1.30 / (download) - annotate - [select for diffs], Sat Apr 2 10:26:58 2016 UTC (8 years, 2 months ago) by dlg
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE, OPENBSD_6_0
Changes since 1.29: +12 -9 lines
Diff to previous 1.29 (colored)

mark the bpf_mem ops as Static.

Static is a nop in _KERNEL, but is static in userland and therefore libpcap

Revision 1.29 / (download) - annotate - [select for diffs], Sat Apr 2 09:05:16 2016 UTC (8 years, 2 months ago) by dlg
Branch: MAIN
Changes since 1.28: +3 -2 lines
Diff to previous 1.28 (colored)

mark the program and buffer as const in bpf_filter()

other projects have already done this, and there's software (eg,
gopacket) which now expects it.

based on a discussion with jasper@ and canacar@
ok jasper@

Revision 1.28 / (download) - annotate - [select for diffs], Sat Apr 2 08:49:49 2016 UTC (8 years, 2 months ago) by dlg
Branch: MAIN
Changes since 1.27: +84 -182 lines
Diff to previous 1.27 (colored)

refactor bpf_filter a bit.

the code was confusing around how it dealt with packets in mbufs
vs plain memory buffers with a lenght.

this renames bpf_filter to _bpf_filter, and changes it so the packet
memory is referred to by an opaque pointer, and callers have to
provide a set of operations to extra values from that opaque pointer.

bpf_filter is now provided as a wrapper around _bpf_filter. it
provides a set of operators that work on a straight buffer with a
lenght.

this also adds a bpf_mfilter function which takes an mbuf instead
of a buffer, and it provides explicit operations for extracting
values from mbufs.

if we want to use bpf filters against other data structures (usb
or scsi packets maybe?) we are able to provide functions for
extracting payloads from them and use _bpf_filter as is.

ok canacar@

Revision 1.27 / (download) - annotate - [select for diffs], Wed May 13 10:42:46 2015 UTC (9 years, 1 month ago) by jsg
Branch: MAIN
CVS Tags: OPENBSD_5_9_BASE, OPENBSD_5_9, OPENBSD_5_8_BASE, OPENBSD_5_8
Changes since 1.26: +4 -4 lines
Diff to previous 1.26 (colored)

test mbuf pointers against NULL not 0
ok krw@ miod@

Revision 1.26 / (download) - annotate - [select for diffs], Fri Sep 19 11:43:31 2014 UTC (9 years, 8 months ago) by otto
Branch: MAIN
CVS Tags: OPENBSD_5_7_BASE, OPENBSD_5_7
Changes since 1.25: +5 -5 lines
Diff to previous 1.25 (colored)

better boundchecks in validation; from Guy Harris; ok millert@ dlg@

Revision 1.25 / (download) - annotate - [select for diffs], Thu Sep 18 10:44:37 2014 UTC (9 years, 8 months ago) by dlg
Branch: MAIN
Changes since 1.24: +5 -17 lines
Diff to previous 1.24 (colored)

ansify function declaration things.

ok mpi@ henning@ krw@

Revision 1.24 / (download) - annotate - [select for diffs], Sun Feb 13 22:41:10 2011 UTC (13 years, 4 months ago) by canacar
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE, OPENBSD_5_6, OPENBSD_5_5_BASE, OPENBSD_5_5, OPENBSD_5_4_BASE, OPENBSD_5_4, OPENBSD_5_3_BASE, OPENBSD_5_3, OPENBSD_5_2_BASE, OPENBSD_5_2, OPENBSD_5_1_BASE, OPENBSD_5_1, OPENBSD_5_0_BASE, OPENBSD_5_0, OPENBSD_4_9_BASE, OPENBSD_4_9
Changes since 1.23: +4 -2 lines
Diff to previous 1.23 (colored)

Unbreak userland as well, since bpf_filter.c is also used in libpcap.
Noticed by robert at openbsd pap st, thanks.

Revision 1.23 / (download) - annotate - [select for diffs], Sat Feb 12 20:58:28 2011 UTC (13 years, 4 months ago) by canacar
Branch: MAIN
Changes since 1.22: +2 -1 lines
Diff to previous 1.22 (colored)

Unbreak previous commit by adding the proper header file.

Revision 1.22 / (download) - annotate - [select for diffs], Sat Feb 12 20:45:19 2011 UTC (13 years, 4 months ago) by canacar
Branch: MAIN
Changes since 1.21: +3 -1 lines
Diff to previous 1.21 (colored)

Clear the filter memory area before using it. Leaving it uninitialized may
leak previous kernel stack contents through a malicioius BPF filter.
Reported by Dan Rosenberg via Alistair Crooks. ok deraadt@, krw@,
claudio@

Revision 1.21 / (download) - annotate - [select for diffs], Wed Apr 21 16:49:34 2010 UTC (14 years, 1 month ago) by otto
Branch: MAIN
CVS Tags: OPENBSD_4_8_BASE, OPENBSD_4_8
Changes since 1.20: +2 -2 lines
Diff to previous 1.20 (colored)

Fix validation of div by constant; from Guy Harris; ok deraadt@ miod@

Revision 1.20 / (download) - annotate - [select for diffs], Wed Jan 2 00:31:50 2008 UTC (16 years, 5 months ago) by canacar
Branch: MAIN
CVS Tags: OPENBSD_4_7_BASE, OPENBSD_4_7, OPENBSD_4_6_BASE, OPENBSD_4_6, OPENBSD_4_5_BASE, OPENBSD_4_5, OPENBSD_4_4_BASE, OPENBSD_4_4, OPENBSD_4_3_BASE, OPENBSD_4_3
Changes since 1.19: +4 -4 lines
Diff to previous 1.19 (colored)

Accept BPF_MUL as a valid instruction in bpf_validate() also improve
the comments. Based on diff from Guy Harris

Revision 1.19 / (download) - annotate - [select for diffs], Mon Aug 6 08:28:09 2007 UTC (16 years, 10 months ago) by tom
Branch: MAIN
CVS Tags: OPENBSD_4_2_BASE, OPENBSD_4_2
Changes since 1.18: +2 -2 lines
Diff to previous 1.18 (colored)

Fix some "that that"s.

ok miod@ jmc@

Revision 1.18 / (download) - annotate - [select for diffs], Sat Oct 28 06:34:19 2006 UTC (17 years, 7 months ago) by otto
Branch: MAIN
CVS Tags: OPENBSD_4_1_BASE, OPENBSD_4_1
Changes since 1.17: +7 -9 lines
Diff to previous 1.17 (colored)

Fix handling of errors wrt to MINDEX. From NetBSD bpf_filter 1.32;
ok henning@ deraadt@ canacar@

Revision 1.17 / (download) - annotate - [select for diffs], Mon Feb 27 14:32:49 2006 UTC (18 years, 3 months ago) by otto
Branch: MAIN
CVS Tags: OPENBSD_4_0_BASE, OPENBSD_4_0, OPENBSD_3_9_BASE, OPENBSD_3_9
Changes since 1.16: +2 -1 lines
Diff to previous 1.16 (colored)

add missing break; now filters containing a division can pass
validation; from NetBSD; ok deraadt@

Revision 1.16 / (download) - annotate - [select for diffs], Thu Dec 8 08:49:30 2005 UTC (18 years, 6 months ago) by otto
Branch: MAIN
Changes since 1.15: +3 -3 lines
Diff to previous 1.15 (colored)

Avoid sign extend by casting to u_char *; from NetBSD via Guy Harris.
Also change another cast, for the sake of consistency, as prompted by djm@
ok deraadt@ djm@ canacar@

Revision 1.15 / (download) - annotate - [select for diffs], Wed Sep 28 20:53:56 2005 UTC (18 years, 8 months ago) by miod
Branch: MAIN
Changes since 1.14: +3 -2 lines
Diff to previous 1.14 (colored)

No part of the code defines UNALIGNED_ACCESS, use reverted tests for
__STRICT_ALIGNMENT instead.

Help pedro@ deraadt@, ok deraadt@

Revision 1.6.4.5 / (download) - annotate - [select for diffs], Sat Jun 5 23:11:23 2004 UTC (20 years ago) by niklas
Branch: SMP
Changes since 1.6.4.4: +94 -30 lines
Diff to previous 1.6.4.4 (colored) to branchpoint 1.6 (colored) next main 1.7 (colored)

Merge with the trunk

Revision 1.11.2.1 / (download) - annotate - [select for diffs], Mon May 10 07:21:35 2004 UTC (20 years, 1 month ago) by brad
Branch: OPENBSD_3_4
Changes since 1.11: +85 -25 lines
Diff to previous 1.11 (colored) next main 1.12 (colored)

MFC:
Fix by otto@

more strict bpf code validation, preventing arbitrary kernel memory
read and writes.

ok deraadt@ otto@

Revision 1.13.2.1 / (download) - annotate - [select for diffs], Mon May 10 04:16:03 2004 UTC (20 years, 1 month ago) by brad
Branch: OPENBSD_3_5
Changes since 1.13: +85 -25 lines
Diff to previous 1.13 (colored) next main 1.14 (colored)

MFC:
Fix by otto@

more strict bpf code validation, preventing arbitrary kernel memory
read and writes.

ok deraadt@ otto@

Revision 1.14 / (download) - annotate - [select for diffs], Mon Apr 26 08:10:10 2004 UTC (20 years, 1 month ago) by otto
Branch: MAIN
CVS Tags: SMP_SYNC_B, SMP_SYNC_A, OPENBSD_3_8_BASE, OPENBSD_3_8, OPENBSD_3_7_BASE, OPENBSD_3_7, OPENBSD_3_6_BASE, OPENBSD_3_6
Changes since 1.13: +95 -32 lines
Diff to previous 1.13 (colored)

- make the k field in struct bpf_insn unsigned, as promised in the
manual page.
- more strict bpf code validation, preventing arbitrary kernel memory
read and writes.
Some help from frantzen@ and canacar@; testing jmc@ markus@;
ok canacar@ henning@ franzen@

Revision 1.13 / (download) - annotate - [select for diffs], Mon Feb 23 19:06:50 2004 UTC (20 years, 3 months ago) by markus
Branch: MAIN
CVS Tags: OPENBSD_3_5_BASE
Branch point for: OPENBSD_3_5
Changes since 1.12: +3 -2 lines
Diff to previous 1.12 (colored)

prevent backward jumps; pls@egsys.hu; ok canacar, deraadt

Revision 1.6.4.4 / (download) - annotate - [select for diffs], Thu Feb 19 10:57:20 2004 UTC (20 years, 3 months ago) by niklas
Branch: SMP
Changes since 1.6.4.3: +29 -25 lines
Diff to previous 1.6.4.3 (colored) to branchpoint 1.6 (colored)

Merge of current from two weeks agointo the SMP branch

Revision 1.12 / (download) - annotate - [select for diffs], Wed Dec 10 07:22:42 2003 UTC (20 years, 6 months ago) by itojun
Branch: MAIN
Changes since 1.11: +25 -25 lines
Diff to previous 1.11 (colored)

de-register.  deraadt ok

Revision 1.11 / (download) - annotate - [select for diffs], Fri Jul 18 23:05:13 2003 UTC (20 years, 10 months ago) by david
Branch: MAIN
CVS Tags: OPENBSD_3_4_BASE
Branch point for: OPENBSD_3_4
Changes since 1.10: +2 -1 lines
Diff to previous 1.10 (colored)

add missing includes
ok tedu@

Revision 1.10 / (download) - annotate - [select for diffs], Fri Jun 27 19:01:52 2003 UTC (20 years, 11 months ago) by deraadt
Branch: MAIN
Changes since 1.9: +4 -1 lines
Diff to previous 1.9 (colored)

protos for userland build

Revision 1.6.4.3 / (download) - annotate - [select for diffs], Sat Jun 7 11:06:06 2003 UTC (21 years ago) by ho
Branch: SMP
Changes since 1.6.4.2: +2 -6 lines
Diff to previous 1.6.4.2 (colored) to branchpoint 1.6 (colored)

Sync SMP branch to -current

Revision 1.9 / (download) - annotate - [select for diffs], Mon Jun 2 23:28:11 2003 UTC (21 years ago) by millert
Branch: MAIN
Changes since 1.8: +2 -6 lines
Diff to previous 1.8 (colored)

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999.  Proofed by myself and Theo.

Revision 1.7.8.1 / (download) - annotate - [select for diffs], Tue Jun 11 03:30:45 2002 UTC (22 years ago) by art
Branch: UBC
Changes since 1.7: +3 -3 lines
Diff to previous 1.7 (colored) next main 1.8 (colored)

Sync UBC branch to -current

Revision 1.6.4.2 / (download) - annotate - [select for diffs], Thu Mar 28 14:57:36 2002 UTC (22 years, 2 months ago) by niklas
Branch: SMP
Changes since 1.6.4.1: +3 -3 lines
Diff to previous 1.6.4.1 (colored) to branchpoint 1.6 (colored)

Merge in -current from roughly a week ago

Revision 1.8 / (download) - annotate - [select for diffs], Thu Mar 14 01:27:09 2002 UTC (22 years, 3 months ago) by millert
Branch: MAIN
CVS Tags: UBC_SYNC_B, UBC_SYNC_A, OPENBSD_3_3_BASE, OPENBSD_3_3, OPENBSD_3_2_BASE, OPENBSD_3_2, OPENBSD_3_1_BASE, OPENBSD_3_1
Changes since 1.7: +3 -3 lines
Diff to previous 1.7 (colored)

First round of __P removal in sys

Revision 1.6.4.1 / (download) - annotate - [select for diffs], Mon May 14 22:39:59 2001 UTC (23 years, 1 month ago) by niklas
Branch: SMP
Changes since 1.6: +2 -9 lines
Diff to previous 1.6 (colored)

merge in approximately 2.9 into SMP branch

Revision 1.7 / (download) - annotate - [select for diffs], Mon Jun 19 03:00:54 2000 UTC (23 years, 11 months ago) by jason
Branch: MAIN
CVS Tags: UBC_BASE, OPENBSD_3_0_BASE, OPENBSD_3_0, OPENBSD_2_9_BASE, OPENBSD_2_9, OPENBSD_2_8_BASE, OPENBSD_2_8
Branch point for: UBC
Changes since 1.6: +2 -9 lines
Diff to previous 1.6 (colored)

de-#ifdef-ize

Revision 1.6 / (download) - annotate - [select for diffs], Mon Sep 13 22:35:44 1999 UTC (24 years, 9 months ago) by niklas
Branch: MAIN
CVS Tags: kame_19991208, SMP_BASE, OPENBSD_2_7_BASE, OPENBSD_2_7, OPENBSD_2_6_BASE, OPENBSD_2_6
Branch point for: SMP
Changes since 1.5: +11 -11 lines
Diff to previous 1.5 (colored)

Remove statics (required renames)

Revision 1.5 / (download) - annotate - [select for diffs], Tue Jun 1 17:54:31 1999 UTC (25 years ago) by pefo
Branch: MAIN
Changes since 1.4: +2 -2 lines
Diff to previous 1.4 (colored)

Fix some mips -> __mips__ stuff.

Revision 1.4 / (download) - annotate - [select for diffs], Thu Aug 22 00:35:50 1996 UTC (27 years, 9 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_2_5_BASE, OPENBSD_2_5, OPENBSD_2_4_BASE, OPENBSD_2_4, OPENBSD_2_3_BASE, OPENBSD_2_3, OPENBSD_2_2_BASE, OPENBSD_2_2, OPENBSD_2_1_BASE, OPENBSD_2_1, OPENBSD_2_0_BASE, OPENBSD_2_0
Changes since 1.3: +1 -1 lines
Diff to previous 1.3 (colored)

__OpenBSD__

Revision 1.3 / (download) - annotate - [select for diffs], Sun Mar 3 21:07:02 1996 UTC (28 years, 3 months ago) by niklas
Branch: MAIN
Changes since 1.2: +6 -6 lines
Diff to previous 1.2 (colored)

From NetBSD: 960217 merge

Revision 1.2 / (download) - annotate - [select for diffs], Mon Oct 23 12:41:04 1995 UTC (28 years, 7 months ago) by davem
Branch: MAIN
Changes since 1.1: +2 -0 lines
Diff to previous 1.1 (colored)

For the '#ifdef sun [...] #endif' conditional we weren't bringing in the
proper definitions for 'struct mbuf' and friends for in.h, bringing in
'sys/socket.h' and 'net/if.h' fixes this.

Revision 1.1.1.1 / (download) - annotate - [select for diffs] (vendor branch), Wed Oct 18 08:53:05 1995 UTC (28 years, 8 months ago) by deraadt
CVS Tags: netbsd_1_1
Changes since 1.1: +0 -0 lines
Diff to previous 1.1 (colored)

initial import of NetBSD tree

Revision 1.1 / (download) - annotate - [select for diffs], Wed Oct 18 08:53:05 1995 UTC (28 years, 8 months ago) by deraadt
Branch: MAIN

Initial revision

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.