Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/23-http/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,28 @@ if (setsockopt(sock, SOL_SOCKET, SO_ATTACH_BPF, &prog_fd, sizeof(prog_fd))) {

The complete source code can be found at <https://github.com/eunomia-bpf/bpf-developer-tutorial/tree/main/src/23-http>. To compile and run the code:

The build uses a C header generated from BTF. This repository provides
`../third_party/vmlinux/$(ARCH)/vmlinux.h` (for example,
`src/third_party/vmlinux/x86/vmlinux.h`), selected by the Makefile's
`VMLINUX` variable. A normal `make` does not require BTF on the running
kernel. To generate a different header from a kernel that exposes BTF:

```console
$ bpftool btf dump file /sys/kernel/btf/vmlinux format c > vmlinux.h
$ make VMLINUX="$PWD/vmlinux.h"
```

Runtime BTF is a separate requirement. If `ecli` reports
"All ways tried to find vmlinux BTF", check whether
`/sys/kernel/btf/vmlinux` is readable on the target system. A kernel built
with `CONFIG_DEBUG_INFO_BTF=y` normally exposes this file. If it is absent,
use a kernel with BTF or supply a compatible BTF file for the **target
kernel** using `BTF_FILE_PATH=/path/to/target-kernel.btf` when running
`ecli`. The loader expects BTF data, not the generated C header
`vmlinux.h`. In a container, also check whether the host's BTF file is
visible inside it. See the
[eunomia-bpf loader documentation](https://github.com/eunomia-bpf/eunomia-bpf/tree/master/bpf-loader-rs#readme).

```console
$ git submodule update --init --recursive
$ make
Expand Down
23 changes: 22 additions & 1 deletion src/23-http/README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,28 @@ return skb->len;

### 编译运行

完整的源代码可以在 <https://github.com/eunomia-bpf/bpf-developer-tutorial/tree/main/src/23-http> 中找到。关于如何安装依赖,请参考:<https://eunomia.dev/tutorials/11-bootstrap/> 编译运行上述代码:
完整的源代码可以在 <https://github.com/eunomia-bpf/bpf-developer-tutorial/tree/main/src/23-http> 中找到。关于如何安装依赖,请参考:<https://eunomia.dev/tutorials/11-bootstrap/>

编译使用由 BTF 生成的 C 头文件。本仓库自带
`../third_party/vmlinux/$(ARCH)/vmlinux.h`(例如
`src/third_party/vmlinux/x86/vmlinux.h`),由 Makefile 的 `VMLINUX` 变量指定,
所以正常 `make` 不依赖运行内核的 BTF。如需从提供 BTF 的内核生成其他头文件:

```console
$ bpftool btf dump file /sys/kernel/btf/vmlinux format c > vmlinux.h
$ make VMLINUX="$PWD/vmlinux.h"
```

运行时的 BTF 是另一项要求。如果 `ecli` 报错
“All ways tried to find vmlinux BTF”,请检查目标系统中的
`/sys/kernel/btf/vmlinux` 是否可读。启用 `CONFIG_DEBUG_INFO_BTF=y` 的内核通常
会提供该文件。如果文件不存在,可换用提供 BTF 的内核,或在运行 `ecli` 时通过
`BTF_FILE_PATH=/path/to/target-kernel.btf` 指定与**目标内核**兼容的 BTF 文件。
加载器需要的是 BTF 数据,而不是生成的 C 头文件 `vmlinux.h`。在容器中还需检查
宿主机的 BTF 文件是否在容器内可见。参见
[eunomia-bpf 加载器文档](https://github.com/eunomia-bpf/eunomia-bpf/tree/master/bpf-loader-rs#readme)。

然后编译运行:

```console
$ git submodule update --init --recursive
Expand Down