首页 关于
关于
取消

关于

projects for eBPF hub

LMP 项目目标:

  • 面向 eBPF 初学者和爱好者,提供 eBPF 学习资料、程序/项目案例,构建 eBPF 学习社区
  • 成为 eBPF 工具集散地,我们相信每一位 eBPF 初学者和爱好者都有无限的创造力
  • 孵化 eBPF 想法、相关工具、项目

Pre-requisites for use eBPF hub

Re-compiling your Kernel with CONFIG_DEBUG_INFO_BTF=y

libbpf probes to see if your sys fs exports the file /sys/kernel/btf/vmlinux (from Kernel 5.5+) or if you have the ELF version in your system code Please note the ELF file could exist without the BTF info in it. Your Kconfig should contain the options below

  1. Compile options
CONFIG_DEBUG_INFO_BTF=y
CONFIG_DEBUG_INFO=y
  1. Also, make sure that you have pahole 1.13 (or preferably 1.16+) during the kernel build (it comes from dwarves package). Without it, BTF won’t be generated, and on older kernels you’d get only warning, but still would build kernel successfully

Running in kernels without CONFIG_DEBUG_INFO_BTF=y

It’s possible to run some tools in kernels that don’t expose /sys/kernel/btf/vmlinux. For those cases, BTFGen and BTFHub can be used to generate small BTF files for the most popular Linux distributions that are shipped with the tools in order to provide the needed information to perform the CO-RE relocations when loading the eBPF programs.

If you haven’t cloned the btfhub-archive repository, you can run make and it’ll clone it for you into the $HOME/.local/share directory:

1
make ENABLE_MIN_CORE_BTFS=1 -j$(nproc)

If you have a local copy of such repository, you can pass it’s location to avoid cloning it again:

1
make ENABLE_MIN_CORE_BTFS=1 BTF_HUB_ARCHIVE=<path_to_btfhub-archive> -j$(nproc)

add new project

The project can be a dir or a git submodule, with at lease the following files:

  • a README,md
  • a config.json

If you use eunomia-bpf, the project will be build automaticly.

Tools are expected to follow a simple naming convention:

  • .bpf.c contains BPF C code, which gets compiled into `package.json`
  • .bpf.h can optionally contain types exported to userspace through pref event or ring buffer
  • .h can optionally contain any types and constants, shared by both BPF and userspace sides of a tool.

You can check the template project for more details.

reference

Most codes come from: