FreeBSD/sys/net/bpf.c
/*
 * Reset a descriptor by flushing its packet buffer and clearing the receive
 * and drop counts.  This is doable for kernel-only buffers, but with
 * zero-copy buffers, we can't write to (or rotate) buffers that are
 * currently owned by userspace.  It would be nice if we could encapsulate
 * this logic in the buffer code rather than here.
 */
Reset a descriptor by flushing its packet buffer and clearing the receive
and drop counts.  This is doable for kernel-only buffers, but with
zero-copy buffers, we can't write to (or rotate) buffers that are
currently owned by userspace.  It would be nice if we could encapsulate
this logic in the buffer code rather than here.
Reset a descriptor by flushing its packet buffer and clearing the receive and drop counts . This is doable for kernel - only buffers but with zero - copy buffers we can ' t write to ( or rotate ) buffers that are currently owned by userspace . It would be nice if we could encapsulate this logic in the buffer code rather than here .
static void
reset_d(struct bpf_d *d)
{
	BPFD_LOCK_ASSERT(d);
	while (d->bd_hbuf_in_use)
		mtx_sleep(&d->bd_hbuf_in_use, &d->bd_lock, PRINET,
		    "bd_hbuf", 0);
	if ((d->bd_hbuf != NULL) &&
	    (d->bd_bufmode != BPF_BUFMODE_ZBUF || bpf_canfreebuf(d))) {
		d->bd_fbuf = d->bd_hbuf;
		d->bd_hbuf = NULL;
		d->bd_hlen = 0;
		bpf_buf_reclaimed(d);
	}
	if (bpf_canwritebuf(d))
		d->bd_slen = 0;
	d->bd_rcount = 0;
	d->bd_dcount = 0;
	d->bd_fcount = 0;
	d->bd_wcount = 0;
	d->bd_wfcount = 0;
	d->bd_wdcount = 0;
	d->bd_zcopy = 0;
}
static void reset_d ( struct bpf_d * d ) { BPFD_LOCK_ASSERT ( d ) ; while ( d -> bd_hbuf_in_use ) mtx_sleep ( & d -> bd_hbuf_in_use , & d -> bd_lock , PRINET , " " , 0 ) ; if ( ( d -> bd_hbuf != NULL ) && ( d -> bd_bufmode != BPF_BUFMODE_ZBUF || bpf_canfreebuf ( d ) ) ) { d -> bd_fbuf = d -> bd_hbuf ; d -> bd_hbuf = NULL ; d -> bd_hlen = 0 ; bpf_buf_reclaimed ( d ) ; } if ( bpf_canwritebuf ( d ) ) d -> bd_slen = 0 ; d -> bd_rcount = 0 ; d -> bd_dcount = 0 ; d -> bd_fcount = 0 ; d -> bd_wcount = 0 ; d -> bd_wfcount = 0 ; d -> bd_wdcount = 0 ; d -> bd_zcopy = 0 ; }
Reset a descriptor by flushing its packet buffer and clearing the receive
 and drop counts.
Reset a descriptor by flushing its packet buffer and clearing the receive and drop counts .
/* Free the hold buffer. */