Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libbpf: Error loading BTF: Invalid argument(22) #63

Closed
interduo opened this issue Sep 5, 2022 · 11 comments
Closed

libbpf: Error loading BTF: Invalid argument(22) #63

interduo opened this issue Sep 5, 2022 · 11 comments
Milestone

Comments

@interduo
Copy link
Contributor

interduo commented Sep 5, 2022

./xdp-cpumap-tc/src/xdp_iphash_to_cpu --dev ens16f1 --wan
libbpf: Error loading BTF: Invalid argument(22)
libbpf: magic: 0xeb9f
version: 1
flags: 0x0
hdr_len: 24
type_off: 0
type_len: 504
str_off: 504
str_len: 1726
btf_total_size: 2254
[1] PTR (anon) type_id=2
[2] STRUCT xdp_md size=24 vlen=6
	data type_id=3 bits_offset=0
	data_end type_id=3 bits_offset=32
	data_meta type_id=3 bits_offset=64
	ingress_ifindex type_id=3 bits_offset=96
	rx_queue_index type_id=3 bits_offset=128
	egress_ifindex type_id=3 bits_offset=160
[3] TYPEDEF __u32 type_id=4
[4] INT unsigned int size=4 bits_offset=0 nr_bits=32 encoding=(none)
[5] FUNC_PROTO (anon) return=6 args=(1 ctx)
[6] INT int size=4 bits_offset=0 nr_bits=32 encoding=SIGNED
[7] FUNC xdp_program type_id=5
[8] STRUCT bpf_map_def size=24 vlen=6
	type type_id=4 bits_offset=0
	key_size type_id=4 bits_offset=32
	value_size type_id=4 bits_offset=64
	max_entries type_id=4 bits_offset=96
	map_flags type_id=4 bits_offset=128
	inner_map_idx type_id=4 bits_offset=160
[9] VAR map_ip_hash type_id=8 linkage=1
[10] VAR map_txq_config type_id=8 linkage=1
[11] VAR map_ifindex_type type_id=8 linkage=1
[12] VAR cpu_map type_id=8 linkage=1
[13] VAR cpus_available type_id=8 linkage=1
[14] INT char size=1 bits_offset=0 nr_bits=8 encoding=SIGNED
[15] ARRAY (anon) type_id=14 index_type_id=16 nr_elems=4
[16] INT __ARRAY_SIZE_TYPE__ size=4 bits_offset=0 nr_bits=32 encoding=(none)
[17] VAR _license type_id=15 linkage=1
[18] DATASEC license size=0 vlen=1 size == 0

libbpf: Error loading ELF section .BTF: -22. Ignored and continue.
TC workaround for mapname: map_ifindex_type map_fd:7

The solution found on stackoverflow is:
xdp-project/xdp-tutorial#38 (comment)

and

Try to compile with the following flags: -g -c -O2
With Clang 8.0 this (the -O2 flag) solved the problem.

Second solution:

FYI, the error is due to [7] FUNC xdp_program type_id=5 vlen != 0 I guess you may have an old libbpf. The new libbpf should do sanitization for this. https://lore.kernel.org/bpf/20200110064124.1760511-2-ast@xxxxxxxxxx/

Maybe libbpf should be also compiled from source? There are many changes from 0.5 to 0.8 (not only this warning).

@interduo
Copy link
Contributor Author

interduo commented Sep 6, 2022

I tested it - if I get libbfp0 from ubuntu 22.10 there is no such error. So I leave a decision for main boss what to do with this issue.

@rchac
Copy link
Member

rchac commented Sep 6, 2022

So with libbfp0 from ubuntu 22.10 it doesn't do this?

@interduo
Copy link
Contributor Author

interduo commented Sep 6, 2022

Unfortunetly no - and in version libbpf 0.8 there are more errors like:

libbpf: map 'map_txq_config' (legacy): legacy map definitions are deprecated, use BTF-defined maps instead
libbpf: Use of BPF_ANNOTATE_KV_PAIR is deprecated, use BTF-defined maps in .maps section instead
libbpf: map 'map_ifindex_type' (legacy): legacy map definitions are deprecated, use BTF-defined maps instead
libbpf: Use of BPF_ANNOTATE_KV_PAIR is deprecated, use BTF-defined maps in .maps section instead
libbpf: map 'map_ip_hash' (legacy): legacy map definitions are deprecated, use BTF-defined maps instead
libbpf: Use of BPF_ANNOTATE_KV_PAIR is deprecated, use BTF-defined maps in .maps section instead
libbpf: map 'map_txq_config' (legacy): legacy map definitions are deprecated, use BTF-defined maps instead
libbpf: Use of BPF_ANNOTATE_KV_PAIR is deprecated, use BTF-defined maps in .maps section instead
libbpf: map 'map_ifindex_type' (legacy): legacy map definitions are deprecated, use BTF-defined maps instead
libbpf: Use of BPF_ANNOTATE_KV_PAIR is deprecated, use BTF-defined maps in .maps section instead
libbpf: map 'map_ip_hash' (legacy): legacy map definitions are deprecated, use BTF-defined maps instead
libbpf: Use of BPF_ANNOTATE_KV_PAIR is deprecated, use BTF-defined maps in .maps section instead

Maybe something needs to be recompiled with libbpf0-dev 0.8 version?

@rchac
Copy link
Member

rchac commented Sep 6, 2022

Gotcha. Since the libbpf library is under xdp-cpumap-tc it may be necessary to make a change in xdp-cpumap-tc to avoid these errors with more modern libbpf versions.

@interduo
Copy link
Contributor Author

interduo commented Sep 6, 2022

You are right so I did: libbpf/libbpf#580

@interduo
Copy link
Contributor Author

interduo commented Sep 6, 2022

Look at libbpf github header:
Please use this Github repository for building and packaging libbpf and when using it in your projects through Git submodule.

@interduo
Copy link
Contributor Author

interduo commented Sep 15, 2022

@rchac maybe You should add libbfp1 as a dependancy in wiki instruction (newest LTS of ubuntu uses obsolette 0.5) ?
(You probbably need to recompile xdp-cpumap-tc with new lib and remove this package from system if is installed by default)

@rchac
Copy link
Member

rchac commented Sep 15, 2022

@rchac maybe You should add libbfp1 as a dependancy in wiki instruction (newest LTS of ubuntu uses obsolette 0.5) ?
(You probbably need to recompile xdp-cpumap-tc with new lib and remove this package from system if is installed by default)

Tried removing libbpf0 but it breaks the OS (many things depend on it apparently).

I thought xdp-cpumap-tc just loaded the libbpf version it includes in it's directory. But when I tried that, I couldn't get xdp redirect to actually work. How did you manage to get it working?

@interduo
Copy link
Contributor Author

I do very dirty force upgrade using package libbpg1 from other ubuntu to test that and remove libbpf0.

@rchac
Copy link
Member

rchac commented Sep 15, 2022

I was able to figure it out. Installing 22.04 from scratch, and following the Wiki step-by-step works. I think it may have been that I installed libbpf from a bad package at some point a while ago on this particular machine. I use a mellanox card, and at one step during the ubuntu install it asks whether to install drivers for Mellanox/Intel. I chose yes this time. That may have helped. It should not be necessary to remove libbpf0.

@interduo
Copy link
Contributor Author

This warning no more occurs with libbpf1.0 on master state.

@dtaht dtaht added this to the v1.3 milestone Nov 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants