libbpf: Fix incorrect module BTF fd index in warning
PATCH 1/1 libbpf: Fix incorrect module BTF fd index in warning
When the number of used module BTF slots in fd_array reaches INT16_MAX, resolving an extern func ksym fails with -E2BIG. However, the warning message logs mod_btf->fd_array_idx, which is guaranteed to be 0 at this point because it has not yet been assigned from obj->fd_array_used.
Use obj->fd_array_used with the %zu format specifier instead so that the actual overflowing index is logged.
Fixes 9dbe6015636c ("libbpf: Support kernel module function calls")
Signed-off-by Rahad Bhuiya <[email protected]>
--- tools/lib/bpf/libbpf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/lib/bpf/libbpf.c +2 -2
@@ -9553,8 +9553,8 @@ static int bpf_object__resolve_ksym_func_btf_id(struct bpf_object *obj,if (mod_btf && !mod_btf->fd_array_idx) {/* insn->off is s16 */ if (obj->fd_array_used ==INT16_MAX ) { -pr_warn ("extern (func ksym) '%s': module BTF fd index %d too big to fit in bpf_insn offset\n" , - ext->name, mod_btf->fd_array_idx); +pr_warn ("extern (func ksym) '%s': module BTF fd index %zu too big to fit in bpf_insn offset\n" , + ext->name, obj->fd_array_used);return -E2BIG ; }/* Cannot use index 0 for module BTF fd */
Signature · 1 line
2.55.0.windows.3
Quoted 1 line · Rahad Bhuiya
Fixes 9dbe6015636c ("libbpf: Support kernel module function calls")
That's not a fix. Nothing is broken.
One object has to call kfuncs from more than 32766 modules to see this message.
pw-bot: cr