mirror of
https://github.com/xdp-project/bpf-examples.git
synced 2024-05-06 15:54:53 +00:00
9be0a6a8e4e275248771caed4e8e2b3805178fdd
When compiled with LLVM-15 (clang-15 and llc-15), the verifier would reject the tsmap_cleanup program as reported in #63. To prevent this add a NULL-check for df_state after the map lookup, to convince the verifier that we're not trying to dereference a pointer to a map value before checking for NULL. This fix ensures that the generated bytecode by LLVM-12 to LLVM-15 passes the verifier (tested on kernel 5.19.3). There was already an NULL-check for df_state in the (inlined by the compiler) function fstate_from_dfkey() which checked df_state before accessing its fields (the specific access that angered the verifier was df_state->dir2). However, with LLVM-15 the compiler reorders the operations so that df_state->dir2 is accessed before the NULL-check is performed, thus upsetting the verifier. This commit removes the internal NULL-check in fstate_from_dfkey() and instead performs the relevant NULL-check directly in the tsmap_cleanup prog instead. In all other places that fstate_from_dfkey() ends up being called there are already NULL-checks for df_state to enable early returns. Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
Practical BPF examples
This git repository contains a diverse set of practical BPF examples that solve (or demonstrate) a specific use-case using BPF.
It is meant to ease doing rapid prototyping and development, writing C-code BPF programs using libbpf. The goal is to make it easier for developers to get started coding.
Many developers struggle to get a working BPF build environment. The repo enviroment makes it easy to build/compile BPF programs by doing the necessary libbpf setup transparently and detect missing compile dependencies (via the configure script). It is a declared goal to make BPF programming more consumable by detecting and reporting issues (when possible).
Description
Languages
C
93.6%
Shell
4.7%
Makefile
1.6%