Re: [PATCH bpf-next v2 1/6] libbpf: Separate interfaces shared with in-tree tools

From: Ihor Solodrai

Date: Tue Nov 24 2026 - 17:52:52 EST


On 2026-11-24 3:47 p.m., Andrii Nakryiko wrote:
On Mon, Nov 23, 2026 at 9:44 AM Ihor Solodrai <ihor.solodrai@xxxxxxxxx> wrote:

On 2026-11-23 7:55 a.m., Quentin Monnet wrote:
2026-11-20 17:33 UTC-0700 ~ Ihor Solodrai <ihor.solodrai@xxxxxxxxx>
resolve_btfids links libbpf statically and uses its BTF header
accessor, field iterator and SHA-256 helper. libbpf_internal.h
also defines logging macros and poisons kernel integer typedefs,
so resolve_btfids wraps the hash helper in a separate source file.

Move the shared declarations to libbpf_tools.h and use them
directly in resolve_btfids. The header is for in-tree tools and
stays uninstalled. No shared-library symbols change.


Hi Ihor, the change in bpftool's Makefile looks OK and I understand the
motivation for libbpf_tools.h for resolve_btfids. But I find it a bit
confusing to move away from libbpf_internal.h only partially for
bpftool, and to have a split dependency on both libbpf_internal.h and
libbpf_tools.h. Have you considered moving the other objects that
bpftool requires from libbpf_internal.h to libbpf_tools.h as well?

Hi Quentin, thank you for taking a look.

I haven't considered that, and it seems like a good idea to me.

The way I thought about this is that in practice libbpf has at least
three levels of (userspace, non-BPF) API:
- public API defined in the symbols map
- internal API, shared helpers and such
- API for the in-tree users, that doesn't make sense to make
public

Hi, Andrii. Just saw your comment after posting.

Please see:
https://lore.kernel.org/bpf/10ad779b-708b-4b0b-b6af-54f3d7414f82@xxxxxxxxx/


well, I don't think encouraging this with extra "libbpf_tools.h" is a
good thing. I'd prefer to keep stuff like that in libbpf_internal.h
(because it is meant to be internal to libbpf, with bpftool and
resolve_btfids being a special case)

Do I understand correctly that the problem is mostly in poisoning?
should we just guard those pragmas with #ifdef check and let
resolve_btfids disable that, if desired?

Yes, this appears to be the root cause so to speak.
An #ifdef may help as well, yes.



I felt like the last one needs a header to reduce the amount of
copy-paste. I don't like "libbpf_tools.h", it gives me "10k loc
utils file" vibes, but I couldn't come up with a better name. Open
to suggestions.

I need to look into bots' feedback, and I expect there will be a v3,
so I'll see what bpftool parts can be moved to the new header as well.

Thanks!


Thanks,
Quentin