From: Shmulik Ladkani <shmulik@metanetworks.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>,
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 v5 bpf-next 2/4] bpf: Support setting variable-length tunnel options
Date: Tue, 30 Aug 2022 23:02:57 +0300 [thread overview]
Message-ID: <20220830230257.67468080@blondie> (raw)
In-Reply-To: <CAEf4BzZKts8NckT7L-FWBRWJxAgkHEZoR=wjaKBxYpTD_jjyAg@mail.gmail.com>
On Thu, 25 Aug 2022 11:20:31 -0700
Andrii Nakryiko <andrii.nakryiko@gmail.com> wrote:
> > + * long bpf_skb_set_tunnel_opt_dynptr(struct sk_buff *skb, struct bpf_dynptr *opt, u32 len)
>
> why can't we rely on dynptr's len instead of specifying extra one
> here? dynptr is a range of memory, so just specify that you take that
> entire range?
>
> And then we'll have (or partially already have) generic dynptr helpers
> to adjust internal dynptr offset and len.
Alright.
For my usecase I need to use *part* of the tunnel options that were
previously stored as a dynptr.
Therefore I need to introduce a new bpf helper that adjusts the dynptr.
How about this suggestion (sketch, not yet tried):
// adjusts the dynptr to point to *len* bytes starting from the
// specified *offset*
BPF_CALL_3(bpf_dynptr_slice, struct bpf_dynptr_kern *, ptr, u32, offset, u32, len)
{
int err;
u32 size;
if (!ptr->data)
return -EINVAL;
err = bpf_dynptr_check_off_len(ptr, offset, len);
if (err)
return err;
ptr->offset += offset;
size = bpf_dynptr_get_size(ptr) - len;
ptr->size = (ptr->size & ~(u32)DYNPTR_SIZE_MASK) | size;
return 0;
}
next prev parent reply other threads:[~2022-08-30 20:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-24 4:41 [PATCH v5 bpf-next 0/4] bpf: Support setting variable-length tunnel options Shmulik Ladkani
2022-08-24 4:41 ` [PATCH v5 bpf-next 1/4] bpf: Add 'bpf_dynptr_get_data' helper Shmulik Ladkani
2022-08-25 16:14 ` John Fastabend
2022-08-30 16:57 ` Shmulik Ladkani
2022-08-24 4:41 ` [PATCH v5 bpf-next 2/4] bpf: Support setting variable-length tunnel options Shmulik Ladkani
2022-08-25 18:20 ` Andrii Nakryiko
2022-08-30 20:02 ` Shmulik Ladkani [this message]
2022-08-30 20:13 ` Shmulik Ladkani
2022-08-30 23:35 ` Joanne Koong
2022-08-24 4:41 ` [PATCH v5 bpf-next 3/4] selftests/bpf: Simplify test_tunnel setup for allowing non-local tunnel traffic Shmulik Ladkani
2022-08-24 4:41 ` [PATCH v5 bpf-next 4/4] selftests/bpf: Add geneve with bpf_skb_set_tunnel_opt_dynptr test-case to test_progs Shmulik Ladkani
2022-08-25 16:33 ` John Fastabend
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=20220830230257.67468080@blondie \
--to=shmulik@metanetworks.com \
--cc=andrii.nakryiko@gmail.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 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.