BPF List
 help / color / mirror / Atom feed
From: "Toke Høiland-Jørgensen" <toke@redhat.com>
To: Ihor Solodrai <ihor.solodrai@linux.dev>,
	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 11:00:37 +0200	[thread overview]
Message-ID: <87jyoteb0q.fsf@toke.dk> (raw)
In-Reply-To: <261c5e00-31d8-4090-aab4-a633924d336c@linux.dev>

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 :)).

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!

-Toke


  reply	other threads:[~2026-09-10  9:00 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 [this message]
2026-09-10 16:07     ` Ihor Solodrai

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=87jyoteb0q.fsf@toke.dk \
    --to=toke@redhat.com \
    --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=ihor.solodrai@linux.dev \
    --cc=jolsa@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=song@kernel.org \
    --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