diff options
author | jmg <jmg@FreeBSD.org> | 2005-03-02 21:59:39 +0000 |
---|---|---|
committer | jmg <jmg@FreeBSD.org> | 2005-03-02 21:59:39 +0000 |
commit | 37bd88d90f45d05afb9db766aefd525f77add2fe (patch) | |
tree | ebdd5a65b0b9b3394d295187d7d48a9c59448178 | |
parent | c85a3e95f78bb183ec62ae6ef948265e7ade6b7a (diff) | |
download | FreeBSD-src-37bd88d90f45d05afb9db766aefd525f77add2fe.zip FreeBSD-src-37bd88d90f45d05afb9db766aefd525f77add2fe.tar.gz |
fix a bug where bpf would try to wakeup before updating the state.. This
was causing kqueue not to see the correct state and not wake up a process
that is waiting...
Submitted by: nCircle Network Security, Inc.
-rw-r--r-- | sys/net/bpf.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c index 1678d11..3964d1d 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -1310,6 +1310,7 @@ catchpacket(d, pkt, pktlen, snaplen, cpfn) struct bpf_hdr *hp; int totlen, curlen; int hdrlen = d->bd_bif->bif_hdrlen; + int do_wakeup = 0; /* * Figure out how many bytes to move. If the packet is @@ -1340,7 +1341,7 @@ catchpacket(d, pkt, pktlen, snaplen, cpfn) return; } ROTATE_BUFFERS(d); - bpf_wakeup(d); + do_wakeup = 1; curlen = 0; } else if (d->bd_immediate || d->bd_state == BPF_TIMED_OUT) @@ -1349,7 +1350,7 @@ catchpacket(d, pkt, pktlen, snaplen, cpfn) * already expired during a select call. A packet * arrived, so the reader should be woken up. */ - bpf_wakeup(d); + do_wakeup = 1; /* * Append the bpf header. @@ -1363,6 +1364,9 @@ catchpacket(d, pkt, pktlen, snaplen, cpfn) */ (*cpfn)(pkt, (u_char *)hp + hdrlen, (hp->bh_caplen = totlen - hdrlen)); d->bd_slen = curlen + totlen; + + if (do_wakeup) + bpf_wakeup(d); } /* |