BPF List
 help / color / mirror / Atom feed
* kfunc use newbie question
@ 2023-10-30  9:35 Jiri Pirko
  2023-10-30 10:14 ` Jiri Olsa
  0 siblings, 1 reply; 5+ messages in thread
From: Jiri Pirko @ 2023-10-30  9:35 UTC (permalink / raw)
  To: bpf

Hi BPF :)

I'm trying to use bpf_dynptr_from_skb() kfunc in my program. I compiled
it with having following declaration in the bpf .c file:
extern int bpf_dynptr_from_skb(struct __sk_buff *skb, __u64 flags,
                               struct bpf_dynptr *ptr__uninit) __ksym;

I have all "BPF/BTF" kernel config options on. During load,
I'm still getting:

libbpf: failed to find BTF for extern 'bpf_dynptr_from_skb': -3

I'm pretty much clueless about what may be wrong. Documentation didn't
help me either :/

Any idea what I may be doing wrong?

Thanks

Jiri

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: kfunc use newbie question
  2023-10-30  9:35 kfunc use newbie question Jiri Pirko
@ 2023-10-30 10:14 ` Jiri Olsa
  2023-10-30 11:02   ` Jiri Pirko
  0 siblings, 1 reply; 5+ messages in thread
From: Jiri Olsa @ 2023-10-30 10:14 UTC (permalink / raw)
  To: Jiri Pirko; +Cc: bpf

On Mon, Oct 30, 2023 at 10:35:59AM +0100, Jiri Pirko wrote:
> Hi BPF :)
> 
> I'm trying to use bpf_dynptr_from_skb() kfunc in my program. I compiled
> it with having following declaration in the bpf .c file:
> extern int bpf_dynptr_from_skb(struct __sk_buff *skb, __u64 flags,
>                                struct bpf_dynptr *ptr__uninit) __ksym;
> 
> I have all "BPF/BTF" kernel config options on. During load,
> I'm still getting:
> 
> libbpf: failed to find BTF for extern 'bpf_dynptr_from_skb': -3

heya,
error -3 suggests there's no BTF generated, is there .BTF section
in the object ? did you compile with -g ?

jirka

> 
> I'm pretty much clueless about what may be wrong. Documentation didn't
> help me either :/
> 
> Any idea what I may be doing wrong?
> 
> Thanks
> 
> Jiri
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: kfunc use newbie question
  2023-10-30 10:14 ` Jiri Olsa
@ 2023-10-30 11:02   ` Jiri Pirko
  2023-10-30 13:19     ` Jiri Olsa
  0 siblings, 1 reply; 5+ messages in thread
From: Jiri Pirko @ 2023-10-30 11:02 UTC (permalink / raw)
  To: Jiri Olsa; +Cc: bpf

Mon, Oct 30, 2023 at 11:14:51AM CET, olsajiri@gmail.com wrote:
>On Mon, Oct 30, 2023 at 10:35:59AM +0100, Jiri Pirko wrote:
>> Hi BPF :)
>> 
>> I'm trying to use bpf_dynptr_from_skb() kfunc in my program. I compiled
>> it with having following declaration in the bpf .c file:
>> extern int bpf_dynptr_from_skb(struct __sk_buff *skb, __u64 flags,
>>                                struct bpf_dynptr *ptr__uninit) __ksym;
>> 
>> I have all "BPF/BTF" kernel config options on. During load,
>> I'm still getting:
>> 
>> libbpf: failed to find BTF for extern 'bpf_dynptr_from_skb': -3
>
>heya,
>error -3 suggests there's no BTF generated, is there .BTF section
>in the object ? did you compile with -g ?

w/o -g. If I compile with -g, I'm getting this:
libbpf: failed to find valid kernel BTF
libbpf: Error loading vmlinux BTF: -3


>
>jirka
>
>> 
>> I'm pretty much clueless about what may be wrong. Documentation didn't
>> help me either :/
>> 
>> Any idea what I may be doing wrong?
>> 
>> Thanks
>> 
>> Jiri
>> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: kfunc use newbie question
  2023-10-30 11:02   ` Jiri Pirko
@ 2023-10-30 13:19     ` Jiri Olsa
  2023-10-30 13:45       ` Jiri Pirko
  0 siblings, 1 reply; 5+ messages in thread
From: Jiri Olsa @ 2023-10-30 13:19 UTC (permalink / raw)
  To: Jiri Pirko; +Cc: Jiri Olsa, bpf

On Mon, Oct 30, 2023 at 12:02:13PM +0100, Jiri Pirko wrote:
> Mon, Oct 30, 2023 at 11:14:51AM CET, olsajiri@gmail.com wrote:
> >On Mon, Oct 30, 2023 at 10:35:59AM +0100, Jiri Pirko wrote:
> >> Hi BPF :)
> >> 
> >> I'm trying to use bpf_dynptr_from_skb() kfunc in my program. I compiled
> >> it with having following declaration in the bpf .c file:
> >> extern int bpf_dynptr_from_skb(struct __sk_buff *skb, __u64 flags,
> >>                                struct bpf_dynptr *ptr__uninit) __ksym;
> >> 
> >> I have all "BPF/BTF" kernel config options on. During load,
> >> I'm still getting:
> >> 
> >> libbpf: failed to find BTF for extern 'bpf_dynptr_from_skb': -3
> >
> >heya,
> >error -3 suggests there's no BTF generated, is there .BTF section
> >in the object ? did you compile with -g ?
> 
> w/o -g. If I compile with -g, I'm getting this:
> libbpf: failed to find valid kernel BTF
> libbpf: Error loading vmlinux BTF: -3

hum, this one seems straightforward missing vmlinux btf,
(check btf__load_vmlinux_btf in tools/lib/bpf/btf.c)
could you please send your .config?

jirka

> 
> 
> >
> >jirka
> >
> >> 
> >> I'm pretty much clueless about what may be wrong. Documentation didn't
> >> help me either :/
> >> 
> >> Any idea what I may be doing wrong?
> >> 
> >> Thanks
> >> 
> >> Jiri
> >> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: kfunc use newbie question
  2023-10-30 13:19     ` Jiri Olsa
@ 2023-10-30 13:45       ` Jiri Pirko
  0 siblings, 0 replies; 5+ messages in thread
From: Jiri Pirko @ 2023-10-30 13:45 UTC (permalink / raw)
  To: Jiri Olsa; +Cc: bpf

Mon, Oct 30, 2023 at 02:19:41PM CET, olsajiri@gmail.com wrote:
>On Mon, Oct 30, 2023 at 12:02:13PM +0100, Jiri Pirko wrote:
>> Mon, Oct 30, 2023 at 11:14:51AM CET, olsajiri@gmail.com wrote:
>> >On Mon, Oct 30, 2023 at 10:35:59AM +0100, Jiri Pirko wrote:
>> >> Hi BPF :)
>> >> 
>> >> I'm trying to use bpf_dynptr_from_skb() kfunc in my program. I compiled
>> >> it with having following declaration in the bpf .c file:
>> >> extern int bpf_dynptr_from_skb(struct __sk_buff *skb, __u64 flags,
>> >>                                struct bpf_dynptr *ptr__uninit) __ksym;
>> >> 
>> >> I have all "BPF/BTF" kernel config options on. During load,
>> >> I'm still getting:
>> >> 
>> >> libbpf: failed to find BTF for extern 'bpf_dynptr_from_skb': -3
>> >
>> >heya,
>> >error -3 suggests there's no BTF generated, is there .BTF section
>> >in the object ? did you compile with -g ?
>> 
>> w/o -g. If I compile with -g, I'm getting this:
>> libbpf: failed to find valid kernel BTF
>> libbpf: Error loading vmlinux BTF: -3
>
>hum, this one seems straightforward missing vmlinux btf,
>(check btf__load_vmlinux_btf in tools/lib/bpf/btf.c)
>could you please send your .config?

Hmm, I managed to get some debug print from libbpf (docs more or less
suck btw), and here it is:
libbpf: loading bpftest2.o
libbpf: elf: section(2) .text, size 48, link 0, flags 6, type=1
libbpf: sec '.text': found program 'parse_nl_attr' at insn offset 0 (0 bytes), code size 6 insns (48 bytes)
libbpf: elf: section(3) .rel.text, size 16, link 25, flags 40, type=9
libbpf: elf: section(4) socket, size 248, link 0, flags 6, type=1
libbpf: sec 'socket': found program 'main_prog' at insn offset 0 (0 bytes), code size 31 insns (248 bytes)
libbpf: elf: section(5) .relsocket, size 48, link 25, flags 40, type=9
libbpf: elf: section(6) .rodata, size 50, link 0, flags 2, type=1
libbpf: elf: section(7) license, size 4, link 0, flags 3, type=1
libbpf: license of bpftest2.o is GPL
libbpf: elf: section(16) .BTF, size 2032, link 0, flags 0, type=1
libbpf: elf: section(18) .BTF.ext, size 280, link 0, flags 0, type=1
libbpf: elf: section(25) .symtab, size 432, link 1, flags 0, type=2
libbpf: looking for externs among 18 symbols...
libbpf: collected 1 externs total
libbpf: extern (ksym) #0: symbol 16, name bpf_dynptr_from_skb
libbpf: map 'bpftest2.rodata' (global data): at sec_idx 6, offset 0, flags 480.
libbpf: map 0 is "bpftest2.rodata"
libbpf: sec '.rel.text': collecting relocation for section(2) '.text'
libbpf: sec '.rel.text': relo #0: insn #0 against '.rodata'
libbpf: prog 'parse_nl_attr': found data map 0 (bpftest2.rodata, sec 6, off 0) for insn 0
libbpf: sec '.relsocket': collecting relocation for section(4) 'socket'
libbpf: sec '.relsocket': relo #0: insn #7 against '.rodata'
libbpf: prog 'main_prog': found data map 0 (bpftest2.rodata, sec 6, off 0) for insn 7
libbpf: sec '.relsocket': relo #1: insn #15 against 'bpf_dynptr_from_skb'
libbpf: prog 'main_prog': found extern #0 'bpf_dynptr_from_skb' (sym 16) for insn #15
libbpf: sec '.relsocket': relo #2: insn #24 against '.text'
libbpf: Unsupported BTF_KIND:19
libbpf: loading kernel BTF '/sys/kernel/btf/vmlinux': -22
libbpf: failed to find valid kernel BTF
libbpf: Error loading vmlinux BTF: -3
libbpf: failed to load object 'bpftest2.o'


19 is BTF_KIND_ENUM64

Looks like I'm using some old libbpf (libbpf-0.8.0-2.fc37.x86_64):
https://lwn.net/ml/bpf/20220603015937.1190992-1-yhs@fb.com/


Will update, I'm sure it will help.


Thanks!



>
>jirka
>
>> 
>> 
>> >
>> >jirka
>> >
>> >> 
>> >> I'm pretty much clueless about what may be wrong. Documentation didn't
>> >> help me either :/
>> >> 
>> >> Any idea what I may be doing wrong?
>> >> 
>> >> Thanks
>> >> 
>> >> Jiri
>> >> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-10-30 13:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-30  9:35 kfunc use newbie question Jiri Pirko
2023-10-30 10:14 ` Jiri Olsa
2023-10-30 11:02   ` Jiri Pirko
2023-10-30 13:19     ` Jiri Olsa
2023-10-30 13:45       ` Jiri Pirko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox