From: Ihor Solodrai <ihor.solodrai@linux.dev>
To: "Toke Høiland-Jørgensen" <toke@redhat.com>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Eduard Zingerman" <eddyz87@gmail.com>,
"Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
"Martin KaFai Lau" <martin.lau@linux.dev>,
"Song Liu" <song@kernel.org>,
"Yonghong Song" <yonghong.song@linux.dev>,
"Jiri Olsa" <jolsa@kernel.org>,
"Emil Tsalapatis" <emil@etsalapatis.com>
Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>, bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next 1/4] libbpf: Add bpf_program__add_flags() and bpf_program__clear_flags()
Date: Thu, 10 Sep 2026 09:07:24 -0700 [thread overview]
Message-ID: <5294a257-3b02-4452-b3e7-ad36769c16a4@linux.dev> (raw)
In-Reply-To: <87jyoteb0q.fsf@toke.dk>
On 2026-09-10 2:00 a.m., Toke Høiland-Jørgensen wrote:
> Ihor Solodrai <ihor.solodrai@linux.dev> writes:
>
>> On 9/3/26 2:24 AM, Toke Høiland-Jørgensen wrote:
>>> When changing BPF program flags, applications often need to just add or
>>> remove a single flag. The bpf_program__set_flags() function clobbers any
>>> existing flags value, making this awkward to do non-destructively.
>>
>> I think the whole "non-destructively" language in the series is misleading.
>>
>> bpf_program__add_flags(prog, BPF_F_XDP_DEV_BOUND_ONLY);
>>
>> does exactly the same thing as
>>
>> bpf_program__set_flags(prog, bpf_program__flags(prog) | BPF_F_XDP_DEV_BOUND_ONLY);
>>
>> That is: overwriting the prog->prog_flags value. Where is the
>> non-destructiveness?
>
> bpf_program__add_flags(prog, BPF_F_XDP_DEV_BOUND_ONLY) doesn't overwrite
> any existing flag values, but bpf_program__set_flags(prog,
> BPF_F_XDP_DEV_BOUND_ONLY) does. In your example you handle this in the
> caller, but you have to take pains to do that (which, judging from the
> fixups I had to do earlier, was not something everyone did :)).
Ah, I see. Yeah, __set_flags() may be interpreted as "set *these* flags
that I'm passing in", which is not the way it works here.
Still, I don't like the "destructive" framing of the issue. More like an
API that may be used incorrectly by unfamiliar user.
>
> However,
>
>> Let's call this for what it is: a convenience API.
>
> I don't mind changing the description - will respin with this change.
> Thanks for reviewing!
np, thanks for the patch
>
> -Toke
prev parent reply other threads:[~2026-09-10 16:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 9:24 [PATCH bpf-next 1/4] libbpf: Add bpf_program__add_flags() and bpf_program__clear_flags() Toke Høiland-Jørgensen
2026-09-03 9:24 ` [PATCH bpf-next 2/4] selftests/bpf: Add assertions for bpf_program__{add,clear}_flags() Toke Høiland-Jørgensen
2026-09-03 9:32 ` sashiko-bot
2026-09-03 9:24 ` [PATCH bpf-next 3/4] selftests/bpf: Adopt bpf_program__add_flags() helper Toke Høiland-Jørgensen
2026-09-03 9:24 ` [PATCH bpf-next 4/4] bpftool: " Toke Høiland-Jørgensen
2026-09-07 15:24 ` Quentin Monnet
2026-09-03 9:30 ` [PATCH bpf-next 1/4] libbpf: Add bpf_program__add_flags() and bpf_program__clear_flags() sashiko-bot
2026-09-09 19:04 ` Ihor Solodrai
2026-09-10 9:00 ` Toke Høiland-Jørgensen
2026-09-10 16:07 ` Ihor Solodrai [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=5294a257-3b02-4452-b3e7-ad36769c16a4@linux.dev \
--to=ihor.solodrai@linux.dev \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=jolsa@kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=song@kernel.org \
--cc=toke@redhat.com \
--cc=yonghong.song@linux.dev \
/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