mirror of
https://github.com/xdp-project/bpf-examples.git
synced 2024-05-06 15:54:53 +00:00
48c25735acbc08e688dfc1c3b4b75fa0f387b8c2
Declare opt_size in pping_helpers.h/parse_tcp_ts volatile to ensure compiler always reads it from stack as u8, which avoids confusing the verifier into thinking it might have a negative value. Old solution of having &=0x3f before adding opt_size to pos could potentially cause weird behavior if a packet with an invalid TCP option size arrived (for example, if opt_size was 64 it would be interpreted as 0, and the loop would simply check the same position again on each iteration). Simply changing the check to 0xff was not possible because the compiler would optimize that away (as it knows that to have no effect on a u8). Also change check that TCP timestamp is not outside of boundaries from pos+opt_size to pos+10. Before declaring opt_size as volatile compiler automatically did this transformation, but now have to explicitly do this. If this conversion is not done the verifier will reject the program as it due to its goldfish memory isn't sure that opt_size has to be 10 at this point. 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 is 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)[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%