summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2014-09-22 23:40:47 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2014-09-22 23:40:47 +0000
commit6f4b010919ad9de3806fa56c0296c4fe1b5aca4c (patch)
tree71b2c81a23b57eac5dcc0365c855c1d6acf2ff28 /sys
parent036c179a06fa472a6b3e6a42ea33dafc63ee2554 (diff)
stash a pointer to bpf_d in the knotes kn_hook instead of the device id.
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.
Diffstat (limited to 'sys')
-rw-r--r--sys/net/bpf.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index 0d9945a72d1..73dd9d5f6ba 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.c,v 1.106 2014/09/22 23:19:59 dlg Exp $ */
+/* $OpenBSD: bpf.c,v 1.107 2014/09/22 23:40:46 dlg Exp $ */
/* $NetBSD: bpf.c,v 1.33 1997/02/21 23:59:35 thorpej Exp $ */
/*
@@ -1062,7 +1062,7 @@ bpfkqfilter(dev_t dev, struct knote *kn)
return (EINVAL);
}
- kn->kn_hook = (caddr_t)((u_long)dev);
+ kn->kn_hook = d;
s = splnet();
D_GET(d);
@@ -1077,11 +1077,9 @@ bpfkqfilter(dev_t dev, struct knote *kn)
void
filt_bpfrdetach(struct knote *kn)
{
- dev_t dev = (dev_t)((u_long)kn->kn_hook);
- struct bpf_d *d;
+ struct bpf_d *d = kn->kn_hook;
int s;
- d = bpfilter_lookup(minor(dev));
s = splnet();
SLIST_REMOVE(&d->bd_sel.si_note, kn, knote, kn_selnext);
D_PUT(d);
@@ -1091,10 +1089,8 @@ filt_bpfrdetach(struct knote *kn)
int
filt_bpfread(struct knote *kn, long hint)
{
- dev_t dev = (dev_t)((u_long)kn->kn_hook);
- struct bpf_d *d;
+ struct bpf_d *d = kn->kn_hook;
- d = bpfilter_lookup(minor(dev));
kn->kn_data = d->bd_hlen;
if (d->bd_immediate)
kn->kn_data += d->bd_slen;