summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2016-02-10 04:34:15 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2016-02-10 04:34:15 +0000
commit2552db1a3d486f404a30f2dc9bb1dd95fd3d0e63 (patch)
treedcea8a5c567fcb8de52259386cc393248a7dd4c2 /sys
parent3c641c6ffad9bd9ffde9816c9a72193aa4e72553 (diff)
protect the bpf ring with splnet as well as the kernel lock.
kernel lock protects it against other cpus, but splnet prevents bpf code running at splsoftnet (eg, like bridge does) from having the rings trampled by a hardware interrupt on the same cpu. ok mpi@ jmatthew@
Diffstat (limited to 'sys')
-rw-r--r--sys/net/bpf.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index 9dc0f4b59e8..8b46437fa5a 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.c,v 1.133 2016/02/05 13:17:37 dlg Exp $ */
+/* $OpenBSD: bpf.c,v 1.134 2016/02/10 04:34:14 dlg Exp $ */
/* $NetBSD: bpf.c,v 1.33 1997/02/21 23:59:35 thorpej Exp $ */
/*
@@ -1143,6 +1143,7 @@ bpf_tap(caddr_t arg, u_char *pkt, u_int pktlen, u_int direction)
size_t slen;
struct timeval tv;
int drop = 0, gottime = 0;
+ int s;
if (bp == NULL)
return (0);
@@ -1168,10 +1169,12 @@ bpf_tap(caddr_t arg, u_char *pkt, u_int pktlen, u_int direction)
microtime(&tv);
KERNEL_LOCK();
+ s = splnet();
if (d->bd_bif != NULL) {
bpf_catchpacket(d, pkt, pktlen, slen,
bcopy, &tv);
}
+ splx(s);
KERNEL_UNLOCK();
if (d->bd_fildrop)
@@ -1221,6 +1224,7 @@ _bpf_mtap(caddr_t arg, struct mbuf *m, u_int direction,
struct mbuf *m0;
struct timeval tv;
int gottime = 0;
+ int s;
if (m == NULL)
return;
@@ -1258,10 +1262,12 @@ _bpf_mtap(caddr_t arg, struct mbuf *m, u_int direction,
microtime(&tv);
KERNEL_LOCK();
+ s = splnet();
if (d->bd_bif != NULL) {
bpf_catchpacket(d, (u_char *)m, pktlen, slen,
cpfn, &tv);
}
+ splx(s);
KERNEL_UNLOCK();
if (d->bd_fildrop)