Skip to content

Commit

Permalink
fix linter issues and add xdp in rust
Browse files Browse the repository at this point in the history
  • Loading branch information
yunwei37 committed Sep 8, 2024
1 parent e907159 commit 886948d
Show file tree
Hide file tree
Showing 20 changed files with 1,046 additions and 237 deletions.
4 changes: 2 additions & 2 deletions src/1-helloworld/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
要开发eBPF程序,您需要安装以下软件和工具:

- Linux 内核:由于eBPF是内核技术,因此您需要具备较新版本的Linux内核(至少 4.8 及以上版本,建议至少在 5.15 以上),以支持eBPF功能。
- 建议使用最新的 Ubuntu 版本(例如 Ubuntu 23.10)以获得最佳的学习体验,较旧的内核 eBPF 功能支持可能相对不全。
- 建议使用最新的 Ubuntu 版本(例如 Ubuntu 23.10)以获得最佳的学习体验,较旧的内核 eBPF 功能支持可能相对不全。
- LLVM 和 Clang:这些工具用于编译eBPF程序。安装最新版本的LLVM和Clang可以确保您获得最佳的eBPF支持。

eBPF 程序主要由两部分构成:内核态部分和用户态部分。内核态部分包含 eBPF 程序的实际逻辑,用户态部分负责加载、运行和监控内核态程序。
Expand Down Expand Up @@ -127,7 +127,7 @@ docker run -it -v `pwd`/:/src/ ghcr.io/eunomia-bpf/ecc-`uname -m`:latest

```console
$ sudo ./ecli run package.json
Runing eBPF program...
Running eBPF program...
```

运行这段程序后,可以通过查看 /sys/kernel/debug/tracing/trace_pipe 文件来查看 eBPF 程序的输出:
Expand Down
1 change: 0 additions & 1 deletion src/14-tcpstates/README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ $ sudo ./tcpstates
SKADDR PID COMM LADDR LPORT RADDR RPORT OLDSTATE -> NEWSTATE MS
ffff9bf61bb62bc0 164978 node 192.168.88.15 0 52.178.17.2 443 CLOSE -> SYN_SENT 0.000
ffff9bf61bb62bc0 0 swapper/0 192.168.88.15 41596 52.178.17.2 443 SYN_SENT -> ESTABLISHED 225.794".
format: Return only the translated content, not including the original text.```
"ffff9bf61bb62bc0 0 swapper/0 192.168.88.15 41596 52.178.17.2 443 ESTABLISHED -> CLOSE_WAIT 901.454
ffff9bf61bb62bc0 164978 node 192.168.88.15 41596 52.178.17.2 443 CLOSE_WAIT -> LAST_ACK 0.793
ffff9bf61bb62bc0 164978 node 192.168.88.15 41596 52.178.17.2 443 LAST_ACK -> LAST_ACK 0.086
Expand Down
3 changes: 1 addition & 2 deletions src/20-tc/README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ int tc_ingress(struct __sk_buff *ctx)
char __license[] SEC("license") = "GPL";
```
This code defines an eBPF program that can capture and process packets through Linux TC (Transmission Control). In this program, we limit it to capture only IPv4 protocol packets, and then print out the total length and Time-To-Live (TTL) value of the packet using the bpf_printk function.Here is the translated text:
This code defines an eBPF program that can capture and process packets through Linux TC (Transmission Control). In this program, we limit it to capture only IPv4 protocol packets, and then print out the total length and Time-To-Live (TTL) value of the packet using the bpf_printk function.
"
What needs to be noted is that we use some BPF library functions in the code, such as the functions bpf_htons and bpf_ntohs, which are used for conversion between network byte order and host byte order. In addition, we also use some comments to provide additional points and option information for TC. For example, at the beginning of this code, we use the following comments:
```c
Expand Down
2 changes: 0 additions & 2 deletions src/21-xdp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ XDP 运行在比传统 Linux 网络组件(如 cBPF)更低的层级,在网
1. **缺乏内核集成**:DPDK 及其他内核绕过解决方案无法利用现有的内核网络功能,开发者必须在用户空间重新实现许多协议和功能。

2. **安全边界**:这些绕过技术破坏了内核的安全模型,使得难以利用内核提供的安全工具。

3. **用户空间与内核的转换开销**:当用户空间数据包处理需要与传统内核网络交互时(例如基于套接字的应用程序),数据包必须重新注入到内核中,增加了开销和复杂性。

4. **专用 CPU 使用**:为了处理高流量,DPDK 和类似解决方案通常需要专用的 CPU 核心来处理数据包,这限制了通用系统的可扩展性和效率。

另一个替代 XDP 的方法是使用 Linux 网络栈中的 **内核模块****挂钩**。虽然这种方法可以很好地集成现有的内核功能,但它需要大量的内核修改,且由于在数据包处理管道的后期运行,无法提供与 XDP 相同的性能优势。
Expand Down
6 changes: 3 additions & 3 deletions src/21-xdp/README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ For those interested in further exploring eBPF, visit our tutorial code reposito

For more information, you can refer to:

+ <http://arthurchiao.art/blog/xdp-paper-acm-2018-zh/>
+ <http://arthurchiao.art/blog/linux-net-stack-implementation-rx-zh/>
+ <https://github.com/xdp-project/xdp-tutorial/tree/master/basic01-xdp-pass>
- <http://arthurchiao.art/blog/xdp-paper-acm-2018-zh/>
- <http://arthurchiao.art/blog/linux-net-stack-implementation-rx-zh/>
- <https://github.com/xdp-project/xdp-tutorial/tree/master/basic01-xdp-pass>

> The original link of this article: <https://eunomia.dev/tutorials/21-xdp>
2 changes: 1 addition & 1 deletion src/22-android/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Andorid 上使用 eBPF 程序
# Android 上使用 eBPF 程序

> 本文主要记录了笔者在 Android Studio Emulator 中测试高版本 Android Kernel 对基于 libbpf 的 CO-RE 技术支持程度的探索过程、结果和遇到的问题。
> 测试采用的方式是在 Android Shell 环境下构建 Debian 环境,并基于此尝试构建 eunomia-bpf 工具链、运行其测试用例。
Expand Down
2 changes: 1 addition & 1 deletion src/22-android/README_en.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# eBPF Tutorial by Example: Using eBPF Programs on Android

> This article mainly documents the author's exploration process, results, and issues encountered while testing the level of support for CO-RE technology based on the libbpf library on high version Android kernels in the Android Studio Emulator.
> This article mainly documents the author's exploration process, results, and issues encountered while testing the level of support for CO-RE technology based on the libbpf library on high version Android kernels in the Android Studio Emulator.
> The test was conducted by building a Debian environment in the Android Shell environment and attempting to build the eunomia-bpf toolchain and run its test cases based on this.
## Background
Expand Down
2 changes: 2 additions & 0 deletions src/41-xdp-tcpdump/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/src/bpf/.output
/target
Loading

0 comments on commit 886948d

Please sign in to comment.