From: "Toke Høiland-Jørgensen" <toke@kernel.org>
To: Daniel Xu <dxu@dxuuu.xyz>
Cc: bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net,
andrii@kernel.org, memxor@gmail.com, pablo@netfilter.org,
fw@strlen.de, netfilter-devel@vger.kernel.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH bpf-next v2 3/4] bpf: Add support for writing to nf_conn:mark
Date: Fri, 19 Aug 2022 15:05:51 +0200 [thread overview]
Message-ID: <87wnb4tmc0.fsf@toke.dk> (raw)
In-Reply-To: <20220818221032.7b4lcpa7i4gchdvl@kashmir.localdomain>
Daniel Xu <dxu@dxuuu.xyz> writes:
> Hi Toke,
>
> On Thu, Aug 18, 2022 at 09:52:08PM +0200, Toke Høiland-Jørgensen wrote:
>> Daniel Xu <dxu@dxuuu.xyz> writes:
>>
>> > Support direct writes to nf_conn:mark from TC and XDP prog types. This
>> > is useful when applications want to store per-connection metadata. This
>> > is also particularly useful for applications that run both bpf and
>> > iptables/nftables because the latter can trivially access this
>> > metadata.
>>
>> Looking closer at the nf_conn definition, the mark field (and possibly
>> secmark) seems to be the only field that is likely to be feasible to
>> support direct writes to, as everything else either requires special
>> handling (like status and timeout), or they are composite field that
>> will require helpers anyway to use correctly.
>>
>> Which means we're in the process of creating an API where users have to
>> call helpers to fill in all fields *except* this one field that happens
>> to be directly writable. That seems like a really confusing and
>> inconsistent API, so IMO it strengthens the case for just making a
>> helper for this field as well, even though it adds a bit of overhead
>> (and then solving the overhead issue in a more generic way such as by
>> supporting clever inlining).
>>
>> -Toke
>
> I don't particularly have a strong opinion here. But to play devil's
> advocate:
>
> * It may be confusing now, but over time I expect to see more direct
> write support via BTF, especially b/c there is support for unstable
> helpers now. So perhaps in the future it will seem more sensible.
Right, sure, for other structs. My point was that it doesn't look like
this particular one (nf_conn) is likely to grow any other members we can
access directly, so it'll be a weird one-off for that single field...
> * The unstable helpers do not have external documentation. Nor should
> they in my opinion as their unstableness + stale docs may lead to
> undesirable outcomes. So users of the unstable API already have to
> splunk through kernel code and/or selftests to figure out how to wield
> the APIs. All this to say there may not be an argument for
> discoverability.
This I don't buy at all. Just because it's (supposedly) "unstable" is no
excuse to design a bad API, or make it actively user-hostile by hiding
things so users have to go browse kernel code to know how to use it. So
in any case, we should definitely document everything.
> * Direct writes are slightly more ergnomic than using a helper.
This is true, and that's the main argument for doing it this way. The
point of my previous email was that since it's only a single field,
consistency weighs heavier than ergonomics :)
-Toke
next prev parent reply other threads:[~2022-08-19 13:05 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1660761470.git.dxu@dxuuu.xyz>
2022-08-17 18:42 ` [PATCH bpf-next v2 1/4] bpf: Remove duplicate PTR_TO_BTF_ID RO check Daniel Xu
2022-08-17 20:07 ` Kumar Kartikeya Dwivedi
2022-08-17 18:43 ` [PATCH bpf-next v2 2/4] bpf: Add stub for btf_struct_access() Daniel Xu
2022-08-17 20:07 ` Kumar Kartikeya Dwivedi
2022-08-17 18:43 ` [PATCH bpf-next v2 3/4] bpf: Add support for writing to nf_conn:mark Daniel Xu
2022-08-17 19:48 ` Kumar Kartikeya Dwivedi
2022-08-18 19:31 ` Daniel Xu
2022-08-17 21:30 ` Alexei Starovoitov
2022-08-17 22:05 ` Martin KaFai Lau
2022-08-18 19:31 ` Daniel Xu
2022-08-18 19:52 ` Toke Høiland-Jørgensen
2022-08-18 22:10 ` Daniel Xu
2022-08-19 13:05 ` Toke Høiland-Jørgensen [this message]
2022-08-19 16:39 ` Alexei Starovoitov
2022-08-17 18:43 ` [PATCH bpf-next v2 4/4] selftests/bpf: Add tests " Daniel Xu
2022-08-17 19:59 ` Kumar Kartikeya Dwivedi
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=87wnb4tmc0.fsf@toke.dk \
--to=toke@kernel.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=dxu@dxuuu.xyz \
--cc=fw@strlen.de \
--cc=linux-kernel@vger.kernel.org \
--cc=memxor@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
/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;
as well as URLs for NNTP newsgroup(s).