Date: Wed, 31 Jan 2007 01:51:41 GMT From: Robert Watson <rwatson@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 113744 for review Message-ID: <200701310151.l0V1pfTF034263@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=113744 Change 113744 by rwatson@rwatson_cinnamon on 2007/01/31 01:50:59 Disable bpfread() for BPF devices in anything but buffered mode until such time as we implement proper support methods for other buffer modes. I.e., a uiomove able to scatter-gather from the zbuf buffer layout. Move bpf_ready() from a macro inbpfdesc.h to bpf.c as a function. Add locking assertion to it. We will be reformulating this to take into account "ready to read" differences between buffer modes. Affected files ... .. //depot/projects/zcopybpf/src/sys/net/bpf.c#5 edit .. //depot/projects/zcopybpf/src/sys/net/bpfdesc.h#4 edit Differences ... ==== //depot/projects/zcopybpf/src/sys/net/bpf.c#5 (text+ko) ==== @@ -641,6 +641,15 @@ return (EINVAL); BPFD_LOCK(d); + if (d->bd_bufmode != BPF_BUFMODE_BUFFER) { + /* + * XXXRW: For now, we don't implement a uiomove for the + * scatter-gather buffers associated with BPF_BUFMODE_ZBUF, + * so simply disallow read(). + */ + BPFD_UNLOCK(d); + return (EOPNOTSUPP); + } if (d->bd_state == BPF_WAITING) callout_stop(&d->bd_callout); timed_out = (d->bd_state == BPF_TIMED_OUT); @@ -764,6 +773,20 @@ } static int +bpf_ready(struct bpf_d *d) +{ + + BPFD_LOCK_ASSERT(d); + + if (d->bd_hlen != 0) + return (1); + if ((d->bd_immediate || d->bd_state == BPF_TIMED_OUT) && + d->bd_slen != 0) + return (1); + return (0); +} + +static int bpfwrite(struct cdev *dev, struct uio *uio, int ioflag) { struct bpf_d *d = dev->si_drv1; ==== //depot/projects/zcopybpf/src/sys/net/bpfdesc.h#4 (text+ko) ==== @@ -108,12 +108,6 @@ NET_ASSERT_GIANT(); \ } while (0) -/* Test whether a BPF is ready for read(). */ -#define bpf_ready(bd) \ - ((bd)->bd_hlen != 0 || \ - (((bd)->bd_immediate || (bd)->bd_state == BPF_TIMED_OUT) && \ - (bd)->bd_slen != 0)) - /* * External representation of the bpf descriptor */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200701310151.l0V1pfTF034263>