All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Pedro Tammela <pctammela@gmail.com>
Cc: Pedro Tammela <pctammela@mojatatu.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
	Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH bpf-next] libbpf: fix bail out from 'ringbuf_process_ring()' on error
Date: Thu, 25 Mar 2021 21:31:39 -0700	[thread overview]
Message-ID: <CAEf4Bzby2eo3-s86rgEjOESrQdemBjYsfLCv=WPh0UHTOZQ7Tw@mail.gmail.com> (raw)
In-Reply-To: <20210325150115.138750-1-pctammela@mojatatu.com>

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
>

      reply	other threads:[~2021-03-26  4:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-25 15:01 [PATCH bpf-next] libbpf: fix bail out from 'ringbuf_process_ring()' on error Pedro Tammela
2021-03-26  4:31 ` Andrii Nakryiko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAEf4Bzby2eo3-s86rgEjOESrQdemBjYsfLCv=WPh0UHTOZQ7Tw@mail.gmail.com' \
    --to=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pctammela@gmail.com \
    --cc=pctammela@mojatatu.com \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.