On Wed, 2024-06-26 at 14:11 +0800, Totoro W wrote: > Hi folks, > > This is my first time to ask questions in this mailing list. I'm the > author of https://github.com/tw4452852/zbpf which is a framework to > write BPF programs with Zig toolchain. > During the development, as the BTF is totally generated by the Zig > toolchain, some naming conventions will make the BTF verifier refuse > to load. > Right now I have to patch the libbpf to do some fixup before loading > into the kernel > (https://github.com/tw4452852/libbpf_zig/blob/main/0001-temporary-WA-for-invalid-BTF-info-generated-by-Zig.patch). > + // https://github.com/tw4452852/zbpf/issues/3 > + else if (btf_is_ptr(t)) { > + t->name_off = 0; As far as I understand, you control BTF generation, why generate names for pointers in a first place? > Even though this just work-around the issue, I'm still curious about > the current naming sanitation, I want to know some background about > it. Doing some git digging shows that name check was first introduced by the following commit: 2667a2626f4d ("bpf: btf: Add BTF_KIND_FUNC and BTF_KIND_FUNC_PROTO") And lived like that afterwards. My guess is that kernel BTF is used to work with kernel functions and data structures. All of which follow C naming convention. > If possible, could we relax this to accept more languages (like Zig) > to write BPF programs? Thanks in advance. Could you please elaborate a bit? Citation from [1]: Identifiers must start with an alphabetic character or underscore and may be followed by any number of alphanumeric characters or underscores. They must not overlap with any keywords. If a name that does not fit these requirements is needed, such as for linking with external libraries, the @"" syntax may be used. Paragraph 1 matches C naming convention and should be accepted by kernel/bpf/btf.c:btf_name_valid_identifier(). Paragraph 2 is basically any string. Which one do you want? [1] https://ziglang.org/documentation/master/#Identifiers