summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2003-04-01 23:42:25 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2003-04-01 23:42:25 +0000
commite6a4b8c7dfa4c88e9971d69bf703864aa6e36ba5 (patch)
treeba8b66a379799f133d39dd5e3ac4907b499ab997 /sys
parentaee070148823050109cf7d6b3c9e95c93370a406 (diff)
When using bpf(4) in immediate mode, and using kevent(2) to receive
notification of packet arrival, the usermode application isn't notified until a second packet arrives. This is because KNOTE() calls filt_bpfread() before bd_slen has been updated with the newly arrived packet length, so it looks like there is no data there. Moving the bpf_wakeup() call for immediate mode to after bd_slen is set fixes it. From: wayne@epipe.com.au in pr 3175
Diffstat (limited to 'sys')
-rw-r--r--sys/net/bpf.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index 707609ad872..b502837083b 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.c,v 1.33 2002/06/06 21:34:16 provos Exp $ */
+/* $OpenBSD: bpf.c,v 1.34 2003/04/01 23:42:24 art Exp $ */
/* $NetBSD: bpf.c,v 1.33 1997/02/21 23:59:35 thorpej Exp $ */
/*
@@ -1163,13 +1163,6 @@ bpf_catchpacket(d, pkt, pktlen, snaplen, cpfn)
bpf_wakeup(d);
curlen = 0;
}
- else if (d->bd_immediate) {
- /*
- * Immediate mode is set. A packet arrived so any
- * reads should be woken up.
- */
- bpf_wakeup(d);
- }
/*
* Append the bpf header.
@@ -1186,6 +1179,14 @@ bpf_catchpacket(d, pkt, pktlen, snaplen, cpfn)
(*cpfn)(pkt, (u_char *)hp + hdrlen, (hp->bh_caplen = totlen - hdrlen));
d->bd_slen = curlen + totlen;
+ if (d->bd_immediate) {
+ /*
+ * Immediate mode is set. A packet arrived so any
+ * reads should be woken up.
+ */
+ bpf_wakeup(d);
+ }
+
if (d->bd_rdStart && (d->bd_rtout + d->bd_rdStart < ticks)) {
/*
* we could be selecting on the bpf, and we