Message ID | 20210325150115.138750-1-pctammela@mojatatu.com (mailing list archive) |
---|---|
State | Accepted |
Delegated to: | BPF |
Headers | show |
Series | [bpf-next] libbpf: fix bail out from 'ringbuf_process_ring()' on error | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for bpf-next |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | success | CCed 10 of 10 maintainers |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | warning | WARNING: From:/Signed-off-by: email address mismatch: 'From: Pedro Tammela <pctammela@gmail.com>' != 'Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>' |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/header_inline | success | Link |
On Thu, Mar 25, 2021 at 8:02 AM Pedro Tammela <pctammela@gmail.com> wrote: > > 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. > > Signed-off-by: Pedro Tammela <pctammela@mojatatu.com> > --- > tools/lib/bpf/ringbuf.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > Thanks. Applied to bpf tree and added: Fixes: bf99c936f947 ("libbpf: Add BPF ring buffer support") > diff --git a/tools/lib/bpf/ringbuf.c b/tools/lib/bpf/ringbuf.c > index 8caaafe7e312..e7a8d847161f 100644 > --- a/tools/lib/bpf/ringbuf.c > +++ b/tools/lib/bpf/ringbuf.c > @@ -227,7 +227,7 @@ static int ringbuf_process_ring(struct ring* r) > if ((len & BPF_RINGBUF_DISCARD_BIT) == 0) { > sample = (void *)len_ptr + BPF_RINGBUF_HDR_SZ; > err = r->sample_cb(r->ctx, sample, len); > - if (err) { > + if (err < 0) { > /* update consumer pos and bail out */ > smp_store_release(r->consumer_pos, > cons_pos); > -- > 2.25.1 >
diff --git a/tools/lib/bpf/ringbuf.c b/tools/lib/bpf/ringbuf.c index 8caaafe7e312..e7a8d847161f 100644 --- a/tools/lib/bpf/ringbuf.c +++ b/tools/lib/bpf/ringbuf.c @@ -227,7 +227,7 @@ static int ringbuf_process_ring(struct ring* r) if ((len & BPF_RINGBUF_DISCARD_BIT) == 0) { sample = (void *)len_ptr + BPF_RINGBUF_HDR_SZ; err = r->sample_cb(r->ctx, sample, len); - if (err) { + if (err < 0) { /* update consumer pos and bail out */ smp_store_release(r->consumer_pos, cons_pos);
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. Signed-off-by: Pedro Tammela <pctammela@mojatatu.com> --- tools/lib/bpf/ringbuf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)