Function redbpf::btf::tc_legacy_fix_btf_section[][src]

pub fn tc_legacy_fix_btf_section(elf_bytes: &[u8]) -> Result<Vec<u8>>
Expand description

Fix .BTF section for tc command that depends on legacy BPF

BTF types generated by rustc contain invalid characters from the point of view of BPF verifier. Since BPF verifier only allows type identifiers and variable names compatible with C language. Since the names of BTF types that are generated by rustc also contain generic types, but they are not compatible with C language thus it is failed to load them into the kernel.

This function is intended to be used by cargo-bpf to make tc utility load .BTF section successfully. To achieve this goal, .BTF section is fixed during compiling the ELF object file and some BTF types that are not supported by legacy BPF of tc command.

NOTE Currently while compiling tc command, the libbpf can be opted in so that the tc command can recognize new BTF types. But most distros do not provide tc with libbpf by default but so filtering. Perhaps it is possible that tc compiled with libbpf will be installed system wide by default in the future, but it will take time. Until then it’s better to fix BTF types for most users.