diff options
author | 2016-09-12 16:24:37 +0000 | |
---|---|---|
committer | 2016-09-12 16:24:37 +0000 | |
commit | 6f70de4933df9331382bd3c0555f471893aafb0c (patch) | |
tree | 53a844b96f6c81103c016f971a30bc457f479fde | |
parent | sync (diff) | |
download | wireguard-openbsd-6f70de4933df9331382bd3c0555f471893aafb0c.tar.xz wireguard-openbsd-6f70de4933df9331382bd3c0555f471893aafb0c.zip |
bpf_tap() is long dead! Long live bpf_mtap() & friends.
ok natano@ deraadt@
-rw-r--r-- | share/man/man9/bpf_mtap.9 | 9 | ||||
-rw-r--r-- | sys/net/bpf.c | 58 | ||||
-rw-r--r-- | sys/net/bpf.h | 3 |
3 files changed, 4 insertions, 66 deletions
diff --git a/share/man/man9/bpf_mtap.9 b/share/man/man9/bpf_mtap.9 index d59d3ea466e..2cf1da1830c 100644 --- a/share/man/man9/bpf_mtap.9 +++ b/share/man/man9/bpf_mtap.9 @@ -1,4 +1,4 @@ -.\" $OpenBSD: bpf_mtap.9,v 1.8 2016/05/10 23:51:50 dlg Exp $ +.\" $OpenBSD: bpf_mtap.9,v 1.9 2016/09/12 16:24:37 krw Exp $ .\" .\" Copyright (c) 2016 David Gwynne <dlg@openbsd.org> .\" @@ -14,14 +14,13 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: May 10 2016 $ +.Dd $Mdocdate: September 12 2016 $ .Dt BPF_MTAP 9 .Os .Sh NAME .Nm bpf_filter , .Nm bpf_mfilter , .Nm bpf_validate , -.Nm bpf_tap , .Nm bpf_mtap , .Nm bpf_mtap_hdr , .Nm bpf_mtap_af , @@ -45,8 +44,6 @@ .Ft int .Fn bpf_validate "struct bpf_insn *pc" "int len" .Ft int -.Fn bpf_tap "caddr_t bpf" "u_char *pkt" "u_int pktlen" "u_int direction" -.Ft int .Fn bpf_mtap "caddr_t bpf" "const struct mbuf *m" "u_int direction" .Ft int .Fo bpf_mtap_hdr @@ -167,7 +164,6 @@ and can be called from process context, or from an interrupt context. .Pp .Fn bpf_mtap , -.Fn bpf_tap , .Fn bpf_mtap , .Fn bpf_mtap_hdr , .Fn bpf_mtap_af , @@ -190,7 +186,6 @@ program. returns a non-zero value if the BPF program is valid, otherwise 0. .Pp -.Fn bpf_tap , .Fn bpf_mtap , .Fn bpf_mtap_hdr , .Fn bpf_mtap_af , diff --git a/sys/net/bpf.c b/sys/net/bpf.c index 98a367b70c4..bd85d5e1a77 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bpf.c,v 1.148 2016/08/22 10:40:36 mpi Exp $ */ +/* $OpenBSD: bpf.c,v 1.149 2016/09/12 16:24:37 krw Exp $ */ /* $NetBSD: bpf.c,v 1.33 1997/02/21 23:59:35 thorpej Exp $ */ /* @@ -1148,62 +1148,6 @@ filt_bpfread(struct knote *kn, long hint) } /* - * Incoming linkage from device drivers. Process the packet pkt, of length - * pktlen, which is stored in a contiguous buffer. The packet is parsed - * by each process' filter, and if accepted, stashed into the corresponding - * buffer. - */ -int -bpf_tap(caddr_t arg, u_char *pkt, u_int pktlen, u_int direction) -{ - struct bpf_if *bp = (struct bpf_if *)arg; - struct srp_ref sr; - struct bpf_d *d; - size_t slen; - struct timeval tv; - int drop = 0, gottime = 0; - int s; - - if (bp == NULL) - return (0); - - SRPL_FOREACH(d, &sr, &bp->bif_dlist, bd_next) { - atomic_inc_long(&d->bd_rcount); - - if ((direction & d->bd_dirfilt) != 0) - slen = 0; - else { - struct srp_ref sr; - struct bpf_program *bf; - struct bpf_insn *fcode = NULL; - - bf = srp_enter(&sr, &d->bd_rfilter); - if (bf != NULL) - fcode = bf->bf_insns; - slen = bpf_filter(fcode, pkt, pktlen, pktlen); - srp_leave(&sr); - } - - if (slen > 0) { - if (!gottime++) - microtime(&tv); - - KERNEL_LOCK(); - s = splnet(); - bpf_catchpacket(d, pkt, pktlen, slen, bcopy, &tv); - splx(s); - KERNEL_UNLOCK(); - - if (d->bd_fildrop) - drop = 1; - } - } - SRPL_LEAVE(&sr); - - return (drop); -} - -/* * Copy data from an mbuf chain into a buffer. This code is derived * from m_copydata in sys/uipc_mbuf.c. */ diff --git a/sys/net/bpf.h b/sys/net/bpf.h index 64188a9cf56..b38a04a48e9 100644 --- a/sys/net/bpf.h +++ b/sys/net/bpf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bpf.h,v 1.57 2016/09/11 13:57:57 deraadt Exp $ */ +/* $OpenBSD: bpf.h,v 1.58 2016/09/12 16:24:37 krw Exp $ */ /* $NetBSD: bpf.h,v 1.15 1996/12/13 07:57:33 mikel Exp $ */ /* @@ -287,7 +287,6 @@ struct ifnet; struct mbuf; int bpf_validate(struct bpf_insn *, int); -int bpf_tap(caddr_t, u_char *, u_int, u_int); int bpf_mtap(caddr_t, const struct mbuf *, u_int); int bpf_mtap_hdr(caddr_t, caddr_t, u_int, const struct mbuf *, u_int, void (*)(const void *, void *, size_t)); |