diff options
author | loos <loos@FreeBSD.org> | 2015-07-31 21:43:27 +0000 |
---|---|---|
committer | loos <loos@FreeBSD.org> | 2015-07-31 21:43:27 +0000 |
commit | bf2e4c78057eef31cf6b3f9fb821c49b900a87db (patch) | |
tree | 9061d7b2530d1551af11b9133664d91aa8ee7be6 /sys/net/bpf.h | |
parent | 89fd02fd8c0a24cebacf3d3426a7b7c94363b5e1 (diff) | |
download | FreeBSD-src-bf2e4c78057eef31cf6b3f9fb821c49b900a87db.zip FreeBSD-src-bf2e4c78057eef31cf6b3f9fb821c49b900a87db.tar.gz |
Remove two unnecessary sleeps from the hot path in bpf(4).
The first one never triggers because bpf_canfreebuf() can only be true for
zero-copy buffers and zero-copy buffers are not read with read(2).
The second also never triggers, because we check the free buffer before
calling ROTATE_BUFFERS(). If the hold buffer is in use the free buffer
will be NULL and there is nothing else to do besides drop the packet. If
the free buffer isn't NULL the hold buffer _is_ free and it is safe to
rotate the buffers.
Update the comment in ROTATE_BUFFERS macro to match the logic described
here.
While here fix a few typos in comments.
MFC after: 2 weeks
Sponsored by: Rubicon Communications (Netgate)
Diffstat (limited to 'sys/net/bpf.h')
-rw-r--r-- | sys/net/bpf.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/net/bpf.h b/sys/net/bpf.h index df326e6..a74b521 100644 --- a/sys/net/bpf.h +++ b/sys/net/bpf.h @@ -1436,9 +1436,9 @@ SYSCTL_DECL(_net_bpf); /* * Rotate the packet buffers in descriptor d. Move the store buffer into the - * hold slot, and the free buffer ino the store slot. Zero the length of the - * new store buffer. Descriptor lock should be held. Hold buffer must - * not be marked "in use". + * hold slot, and the free buffer into the store slot. Zero the length of the + * new store buffer. Descriptor lock should be held. One must be careful to + * not rotate the buffers twice, i.e. if fbuf != NULL. */ #define ROTATE_BUFFERS(d) do { \ (d)->bd_hbuf = (d)->bd_sbuf; \ |