diff options
author | Can Erkin Acar <canacar@cvs.openbsd.org> | 2004-05-25 17:36:50 +0000 |
---|---|---|
committer | Can Erkin Acar <canacar@cvs.openbsd.org> | 2004-05-25 17:36:50 +0000 |
commit | bdbc52ad1a66b22146c54eb9cb55d82fe01ea35f (patch) | |
tree | 41284828e7171ae1160fbf1cf8ce5286a105f336 /sys/net | |
parent | 467668f9955998b6d75e28ea5c7300e3461bb641 (diff) |
Return buffered packets when reading from a bpf descriptor and the
interface is detached, and wakeup any polling processes when the
bpf descriptor is closed. ok henning@, tedu@
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/bpf.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c index 39483fab5ec..94a8fb9b5bb 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bpf.c,v 1.45 2004/05/08 20:54:13 canacar Exp $ */ +/* $OpenBSD: bpf.c,v 1.46 2004/05/25 17:36:49 canacar Exp $ */ /* $NetBSD: bpf.c,v 1.33 1997/02/21 23:59:35 thorpej Exp $ */ /* @@ -373,6 +373,7 @@ bpfclose(dev, flag, mode, p) s = splimp(); if (d->bd_bif) bpf_detachd(d); + bpf_wakeup(d); D_PUT(d); splx(s); @@ -432,6 +433,16 @@ bpfread(dev, uio, ioflag) * have arrived to fill the store buffer. */ while (d->bd_hbuf == 0) { + if (d->bd_bif == NULL) { + /* interface is gone */ + if (d->bd_slen == 0) { + D_PUT(d); + splx(s); + return (EIO); + } + ROTATE_BUFFERS(d); + break; + } if (d->bd_immediate && d->bd_slen != 0) { /* * A packet(s) either arrived since the previous @@ -1301,11 +1312,8 @@ void bpf_freed(d) struct bpf_d *d; { - d->bd_ref--; - if (d->bd_ref > 0) { - bpf_wakeup(d); + if (--d->bd_ref > 0) return; - } if (d->bd_sbuf != 0) { free(d->bd_sbuf, M_DEVBUF); |