Skip to content

Commit 6032ebb

Browse files
tammelaanakryiko
authored andcommitted
libbpf: Fix bail out from 'ringbuf_process_ring()' on error
The current code bails out with negative and positive returns. If the callback returns a positive return code, 'ring_buffer__consume()' and 'ring_buffer__poll()' will return a spurious number of records consumed, but mostly important will continue the processing loop. This patch makes positive returns from the callback a no-op. Fixes: bf99c93 ("libbpf: Add BPF ring buffer support") Signed-off-by: Pedro Tammela <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 0023224 commit 6032ebb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/lib/bpf/ringbuf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ static int ringbuf_process_ring(struct ring* r)
227227
if ((len & BPF_RINGBUF_DISCARD_BIT) == 0) {
228228
sample = (void *)len_ptr + BPF_RINGBUF_HDR_SZ;
229229
err = r->sample_cb(r->ctx, sample, len);
230-
if (err) {
230+
if (err < 0) {
231231
/* update consumer pos and bail out */
232232
smp_store_release(r->consumer_pos,
233233
cons_pos);

0 commit comments

Comments
 (0)