public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Shmulik Ladkani <shmulik@metanetworks.com>
To: Joanne Koong <joannelkoong@gmail.com>
Cc: bpf@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	John Fastabend <john.fastabend@gmail.com>,
	Andrii Nakryiko <andrii@kernel.org>,
	Paul Chaignon <paul@isovalent.com>,
	Shmulik Ladkani <shmulik.ladkani@gmail.com>
Subject: Re: [PATCH v4 bpf-next 1/4] bpf: Add 'bpf_dynptr_get_data' helper
Date: Wed, 24 Aug 2022 07:07:01 +0300	[thread overview]
Message-ID: <20220824070701.40120145@blondie> (raw)
In-Reply-To: <CAJnrk1bYX5iZXGBOfPD43fgGvnKqynD2qgioS9PnEEDMzoYmgw@mail.gmail.com>

On Tue, 23 Aug 2022 12:11:38 -0700
Joanne Koong <joannelkoong@gmail.com> wrote:

> The "ptr->offset > size" check isn't quite correct because size is the
> number of usable bytes (more on this below :))
> 
> > +               return NULL;
> > +       *avail_bytes = size - ptr->offset;  
> 
> dynptr->size is already the number of usable bytes; this is noted in
> include/linux/bpf.h
> 
> /* the implementation of the opaque uapi struct bpf_dynptr */
> struct bpf_dynptr_kern {
>         void *data;
>         /* Size represents the number of usable bytes of dynptr data.

Thanks.

BTW, despite the comment I was under the impression the 'size' is the
*fixed* allocation size associated with 'data' (and not the usable bytes
left at data+offset), since (1) havn't encounterd 'size' adjustments in
the helpers code, and (2) 'size' arithmetic isn't trivial (due to
the flags stored into size's upper bits). Therefore, assumed it is
probably the fixed size.

Anyway will fix the new 'bpf_dynptr_get_data'.

Best,
Shmulik

  reply	other threads:[~2022-08-24  4:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-23 13:30 [PATCH v4 bpf-next 0/4] bpf: Support setting variable-length tunnel options Shmulik Ladkani
2022-08-23 13:30 ` [PATCH v4 bpf-next 1/4] bpf: Add 'bpf_dynptr_get_data' helper Shmulik Ladkani
2022-08-23 19:11   ` Joanne Koong
2022-08-24  4:07     ` Shmulik Ladkani [this message]
2022-08-23 13:30 ` [PATCH v4 bpf-next 2/4] bpf: Support setting variable-length tunnel options Shmulik Ladkani
2022-08-23 13:30 ` [PATCH v4 bpf-next 3/4] selftests/bpf: Simplify test_tunnel setup for allowing non-local tunnel traffic Shmulik Ladkani
2022-08-23 13:30 ` [PATCH v4 bpf-next 4/4] selftests/bpf: Add geneve with bpf_skb_set_tunnel_opt_dynptr test-case to test_progs Shmulik Ladkani

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=20220824070701.40120145@blondie \
    --to=shmulik@metanetworks.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=joannelkoong@gmail.com \
    --cc=john.fastabend@gmail.com \
    --cc=paul@isovalent.com \
    --cc=shmulik.ladkani@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox