Thread (11 messages) flat view 11 messages, 4 authors, 1d ago

Re: [PATCH bpf-next v3 1/4] bpftool: Set BPF_F_XDP_DEV_BOUND_ONLY flag non-destructively

From: Andrii Nakryiko <hidden>
Date: 2026-09-03 00:22:33
Also in: bpf

On Tue, Sep 1, 2026 at 1:47 AM Toke Høiland-Jørgensen [off-list ref] wrote:
quoted hunk ↗ jump to hunk
When setting the XDP hints ifname, bpftool would set the
BPF_F_XDP_DEV_BOUND_ONLY without looking at the existing program flags,
overriding any other flag values. This was always a destructive action,
but after we change libbpf to carry the frags section flag in
prog_flags, this can impact bpftool loading of XDP frags programs.

Change the flag setting to be non-destructive by OR'ing it with the
existing flags.

Fixes: f46392ee3dec ("bpftool: Specify XDP Hints ifname when loading program")
Reviewed-by: Larysa Zaremba <redacted>
Signed-off-by: Toke Høiland-Jørgensen <redacted>
---
 tools/bpf/bpftool/prog.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
index a9f730d407a9..8c2f9255b36d 100644
--- a/tools/bpf/bpftool/prog.c
+++ b/tools/bpf/bpftool/prog.c
@@ -1769,7 +1769,7 @@ static int load_with_options(int argc, char **argv, bool first_prog_only)
                }

                if (prog_type == BPF_PROG_TYPE_XDP && xdpmeta_ifindex) {
-                       bpf_program__set_flags(pos, BPF_F_XDP_DEV_BOUND_ONLY);
+                       bpf_program__set_flags(pos, bpf_program__flags(pos) | BPF_F_XDP_DEV_BOUND_ONLY);
maybe we should just add bpf_program__add_flags() and
bpf_program__clear_flags() to make life a touch easier and code in
selftests and bpftool a touch less verbose?

                        bpf_program__set_ifindex(pos, xdpmeta_ifindex);
                } else {
                        bpf_program__set_ifindex(pos, offload_ifindex);

--
2.55.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help