libbpf-bootstrap Development Guide: Concepts and How to Install

Table of contents

concept

How to install & use

git address

Use git clone to download the code

Install dependent environment

Install libbpf

Compile example


concept

libbpf-bootstrap is a project designed to help developers quickly start and develop programs that use eBPF (Extended Berkeley Packet Filter) and libbpf. eBPF is a program that can run in the Linux kernel and provides powerful network filtering, system call monitoring and performance analysis functions. libbpf is a library for loading and managing eBPF programs and maps.

libbpf-bootstrap provides some sample programs and templates to help developers understand how to use libbpf to create, load, manage eBPF programs, and interact with these programs.

Here are some of the main features of libbpf-bootstrap:

  1. Sample programs: libbpf-bootstrap provides some sample programs that demonstrate how to use libbpf and eBPF. These sample programs include different types of eBPF programs such as network monitoring and performance analysis.
  2. Build system integration: libbpf-bootstrap provides templates integrated into the build system to easily compile and link eBPF programs.
  3. BPF CO-RE (Compile Once - Run Everywhere) support: BPF CO-RE is a technology that allows eBPF programs to run on different versions of the Linux kernel. libbpf-bootstrap supports CO-RE, allowing the developed eBPF program to run on different versions of the Linux kernel without recompiling.
  4. Interaction between user space and kernel space programs: libbpf-bootstrap shows how to send data from a user space program to an eBPF program, and return data from an eBPF program to user space.
  5. Detailed documentation: libbpf-bootstrap provides detailed documentation, including how to install, how to use sample programs, and how to create your own eBPF programs.

How to install & use

git address

https://github.com/libbpf/libbpf-bootstraphttps://github.com/libbpf/libbpf-bootstrap

Use git clone to download the code

git clone --recursive  https://github.com/libbpf/libbpf-bootstrapgit clone --recursive  https://github.com/libbpf/libbpf-bootstrap

--recursive means downloading including sub-repositories

Install dependent environment

sudo apt install clang libelf1 libelf-dev zlib1g-devsudo apt install clang libelf1 libelf-dev zlib1g-dev

Install libbpf

cd libbpf/src/
make
sudo make installcd libbpf/src/
make
sudo make install

Compile example

cd examples/c/
make
sudo ./minimalcd examples/c/
make
sudo ./minimal

if it appears

Successfully started! Please run `sudo cat /sys/kernel/debug/tracing/trace_pipe` to see output of the BPF programs.Successfully started! Please run `sudo cat /sys/kernel/debug/tracing/trace_pipe` to see output of the BPF programs.

Even after completing the initial preparations

 

Guess you like

Origin blog.csdn.net/qq_32378713/article/details/131744499