Re: [PATCH bpf-next v2 2/3] bpftool: Compute light skeleton ctx.sz without relying on links
From: Quentin Monnet
Date: Thu Sep 17 2026 - 08:11:33 EST
On 09/09/2026 05:24, Thiébaud Weksteen wrote:
> When generating a light skeleton, gen_trace() unconditionally sets
> skel->ctx.sz using (char *)&skel->links - (char *)skel. However, if a
> BPF object has no programs and no struct_ops maps (prog_cnt +
> attach_map_cnt == 0), do_skeleton() omits the links struct, causing the
> generated skeleton header to fail compilation.
>
> Compute skel->ctx.sz from the end of progs (if prog_cnt > 0), maps (if
> map_cnt > 0), or ctx instead of relying on skel->links. Also remove the
> unused opts.data_sz argument passed to codegen().
>
> Fixes: d510296d331a ("bpftool: Use syscall/loader program in "prog load" and "gen skeleton" command.")
> Signed-off-by: Thiébaud Weksteen <tweek@xxxxxxxxxx>
Acked-by: Quentin Monnet <qmo@xxxxxxxxxx>
Thank you