Check for a NULL free buffer pointer in BPF before invoking

bpf_canfreebuf() in order to avoid potentially calling a non-inlinable
but trivial function in zero-copy buffer mode for every packet
received when we couldn't free the buffer anyway.

MFC after:	4 months
This commit is contained in:
Robert Watson 2008-03-25 07:41:33 +00:00
parent 3c7e78d32d
commit fa0c2b3474
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=177596

View File

@ -1676,7 +1676,7 @@ catchpacket(struct bpf_d *d, u_char *pkt, u_int pktlen, u_int snaplen,
* run this check if we need the space), but for now it's a reliable
* spot to do it.
*/
if (bpf_canfreebuf(d)) {
if (d->bd_fbuf == NULL && bpf_canfreebuf(d)) {
d->bd_fbuf = d->bd_hbuf;
d->bd_hbuf = NULL;
d->bd_hlen = 0;