Skip to content

Commit 9537760

Browse files
Copilotyunwei37
andauthored
Fix tutorial 1 compilation with ecc by using vmlinux.h (#199)
* Initial plan * Fix tutorial 1 compilation by including vmlinux.h Co-authored-by: yunwei37 <34985212+yunwei37@users.noreply.github.com> * Update README documentation to reference vmlinux.h consistently Co-authored-by: yunwei37 <34985212+yunwei37@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: yunwei37 <34985212+yunwei37@users.noreply.github.com>
1 parent 98682ee commit 9537760

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/1-helloworld/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ We will start with a simple eBPF program that prints a message in the kernel. We
7777
```c
7878
/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
7979
#define BPF_NO_GLOBAL_DATA
80-
#include <linux/bpf.h>
80+
#include "vmlinux.h"
8181
#include <bpf/bpf_helpers.h>
8282
#include <bpf/bpf_tracing.h>
8383

@@ -157,7 +157,7 @@ If you're still not seeing output, make sure the program is actually loaded and
157157

158158
As mentioned above, the basic framework of an eBPF program includes:
159159

160-
- Including header files: You need to include <linux/bpf.h> and <bpf/bpf_helpers.h> header files, among others.
160+
- Including header files: You need to include "vmlinux.h" and <bpf/bpf_helpers.h> header files, among others.
161161
- Defining a license: You need to define a license, typically using "Dual BSD/GPL".
162162
- Defining a BPF function: You need to define a BPF function, for example, named handle_tp, which takes void *ctx as a parameter and returns int. This is usually written in the C language.
163163
- Using BPF helper functions: In the BPF function, you can use BPF helper functions such as bpf_get_current_pid_tgid() and bpf_printk().

src/1-helloworld/README.zh.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Packing ebpf object and config into /src/package.json...
7676
```c
7777
/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
7878
#define BPF_NO_GLOBAL_DATA
79-
#include <linux/bpf.h>
79+
#include "vmlinux.h"
8080
#include <bpf/bpf_helpers.h>
8181
#include <bpf/bpf_tracing.h>
8282

@@ -156,7 +156,7 @@ $ sudo sh -c 'echo 1 > /sys/kernel/debug/tracing/tracing_on'
156156

157157
如上所述, eBPF 程序的基本框架包括:
158158

159-
- 包含头文件:需要包含 <linux/bpf.h> 和 <bpf/bpf_helpers.h> 等头文件。
159+
- 包含头文件:需要包含 "vmlinux.h" 和 <bpf/bpf_helpers.h> 等头文件。
160160
- 定义许可证:需要定义许可证,通常使用 "Dual BSD/GPL"。
161161
- 定义 BPF 函数:需要定义一个 BPF 函数,例如其名称为 handle_tp,其参数为 void *ctx,返回值为 int。通常用 C 语言编写。
162162
- 使用 BPF 助手函数:在例如 BPF 函数中,可以使用 BPF 助手函数 bpf_get_current_pid_tgid() 和 bpf_printk()。

src/1-helloworld/minimal.bpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
22
#define BPF_NO_GLOBAL_DATA
3-
#include <linux/bpf.h>
3+
#include "vmlinux.h"
44
#include <bpf/bpf_helpers.h>
55
#include <bpf/bpf_tracing.h>
66

0 commit comments

Comments
 (0)