Skip to content

Commit a53481d

Browse files
authored
fix docker image content and add basic CI check (eunomia-bpf#41)
Replace ``` docker run -it -v `pwd`/:/src/ yunwei37/ebpm:latest ``` with: ``` docker run -it -v `pwd`/:/src/ ghcr.io/eunomia-bpf/ecc-`uname -m`:latest ``` Add a basic CI check for the hello world BPF program.
1 parent 5a28f7f commit a53481d

File tree

11 files changed

+45
-16
lines changed

11 files changed

+45
-16
lines changed

.github/workflows/test.yaml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Test example CI
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
schedule:
9+
- cron: '0 0 * * 0'
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
with:
16+
submodules: 'recursive'
17+
- name: install deps
18+
run: sudo apt install clang llvm
19+
- name: test hello world
20+
run: |
21+
wget https://github.com/eunomia-bpf/eunomia-bpf/releases/latest/download/ecc && chmod +x ./ecc
22+
wget https://aka.pw/bpf-ecli -O ecli && chmod +x ./ecli
23+
./ecc src/1-helloworld/minimal.bpf.c
24+
sudo timeout -s 2 3 ./ecli run src/1-helloworld/package.json || if [ $? = 124 ]; then exit 0; else exit $?; fi
25+
- name: install deps
26+
run: |
27+
sudo apt-get install -y --no-install-recommends \
28+
libelf1 libelf-dev zlib1g-dev libclang-13-dev \
29+
make git clang llvm pkg-config build-essential

ChatGPT.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ Packing ebpf object and config into package.json...
153153
或使用 docker 镜像进行编译:
154154

155155
```shell
156-
docker run -it -v `pwd`/:/src/ yunwei37/ebpm:latest
156+
docker run -it -v `pwd`/:/src/ ghcr.io/eunomia-bpf/ecc-`uname -m`:latest
157157
```
158158

159159
然后使用 ecli 运行编译后的程序:
@@ -472,7 +472,7 @@ Packing ebpf object and config into package.json...
472472
> 或使用 docker 镜像进行编译:
473473
474474
```sh
475-
docker run -it -v `pwd`/:/src/ yunwei37/ebpm:latest
475+
docker run -it -v `pwd`/:/src/ ghcr.io/eunomia-bpf/ecc-`uname -m`:latest
476476
```
477477

478478
> 然后使用 ecli 运行编译后的程序:
@@ -894,7 +894,7 @@ Packing ebpf object and config into package.json...
894894
或使用 docker 镜像进行编译:
895895

896896
```shell
897-
docker run -it -v `pwd`/:/src/ yunwei37/ebpm:latest
897+
docker run -it -v `pwd`/:/src/ ghcr.io/eunomia-bpf/ecc-`uname -m`:latest
898898
```
899899

900900
然后使用 ecli 运行编译后的程序:
@@ -1432,7 +1432,7 @@ char __license[] SEC("license") = "GPL";
14321432
编译运行
14331433

14341434
```console
1435-
docker run -it -v `pwd`/:/src/ yunwei37/ebpm:latest
1435+
docker run -it -v `pwd`/:/src/ ghcr.io/eunomia-bpf/ecc-`uname -m`:latest
14361436
```
14371437

14381438
or compile with `ecc`:

src/0-introduce/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ eBPF 是一项革命性的技术,起源于 Linux 内核,可以在操作系
1010

1111
对于浏览器而言,JavaScript 的引入带来的可编程性开启了一场巨大的革命,使浏览器发展成为几乎独立的操作系统。现在让我们回到 eBPF:为了理解 eBPF 对 Linux 内核的可编程性影响,对 Linux 内核的结构以及它如何与应用程序和硬件进行交互有一个高层次的理解是有帮助的[4]
1212

13-
![kernel-arch](https://raw.githubusercontent.com/bestgopher/bpf-developer-tutorial/main/src/0-introduce/kernel-arch.webp)
13+
![kernel-arch](https://raw.githubusercontent.com/eunomia-bpf/bpf-developer-tutorial/main/src/0-introduce/kernel-arch.webp)
1414

1515
Linux 内核的主要目的是抽象出硬件或虚拟硬件,并提供一个一致的API(系统调用),允许应用程序运行和共享资源。为了实现这个目的,我们维护了一系列子系统和层,以分配这些责任[5]。每个子系统通常允许某种程度的配置,以考虑到用户的不同需求。如果不能配置所需的行为,就需要改变内核,从历史上看,改变内核的行为,或者让用户编写的程序能够在内核中运行,就有两种选择:
1616

@@ -22,7 +22,7 @@ Linux 内核的主要目的是抽象出硬件或虚拟硬件,并提供一个
2222

2323
有了 eBPF,就有了一个新的选择,可以重新编程 Linux 内核的行为,而不需要改变内核的源代码或加载内核模块,同时保证在不同内核版本之间一定程度上的行为一致性和兼容性、以及安全性[6]。为了实现这个目的,eBPF 程序也需要有一套对应的 API,允许用户定义的应用程序运行和共享资源 --- 换句话说,某种意义上讲 eBPF 虚拟机也提供了一套类似于系统调用的机制,借助 eBPF 和用户态通信的机制,Wasm 虚拟机和用户态应用也可以获得这套“系统调用”的完整使用权,一方面能可编程地扩展传统的系统调用的能力,另一方面能在网络、文件系统等许多层次实现更高效的可编程 IO 处理。
2424

25-
![new-os](https://github.com/bestgopher/bpf-developer-tutorial/blob/main/src/0-introduce/new-os-model.jpg)
25+
![new-os](https://github.com/eunomia-bpf/bpf-developer-tutorial/blob/main/src/0-introduce/new-os-model.jpg?raw=true)
2626

2727
正如上图所示,当今的 Linux 内核正在向一个新的内核模型演化:用户定义的应用程序可以在内核态和用户态同时执行,用户态通过传统的系统调用访问系统资源,内核态则通过 BPF Helper Calls 和系统的各个部分完成交互。截止 2023 年初,内核中的 eBPF 虚拟机中已经有 220 多个Helper 系统接口,涵盖了非常多的应用场景。
2828

src/1-helloworld/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Usage: ecc [OPTIONS] <SOURCE_PATH> [EXPORT_EVENT_HEADER]
6161
也可以使用 docker 镜像进行编译:
6262

6363
```console
64-
$ docker run -it -v `pwd`/:/src/ yunwei37/ebpm:latest # 使用 docker 进行编译。`pwd` 应该包含 *.bpf.c 文件和 *.h 文件。
64+
$ docker run -it -v `pwd`/:/src/ ghcr.io/eunomia-bpf/ecc-`uname -m`:latest # 使用 docker 进行编译。`pwd` 应该包含 *.bpf.c 文件和 *.h 文件。
6565
export PATH=PATH:~/.eunomia/bin
6666
Compiling bpf object...
6767
Packing ebpf object and config into /src/package.json...
@@ -106,7 +106,7 @@ int handle_tp(void *ctx)
106106
要编译和运行这段程序,可以使用 ecc 工具和 ecli 命令。首先在 Ubuntu/Debian 上,执行以下命令:
107107
108108
```shell
109-
sudo apt install libclang-14-dev
109+
sudo apt install clang llvm
110110
```
111111

112112
使用 ecc 编译程序:
@@ -120,7 +120,7 @@ Packing ebpf object and config into package.json...
120120
或使用 docker 镜像进行编译:
121121

122122
```shell
123-
docker run -it -v `pwd`/:/src/ yunwei37/ebpm:latest
123+
docker run -it -v `pwd`/:/src/ ghcr.io/eunomia-bpf/ecc-`uname -m`:latest
124124
```
125125

126126
然后使用 ecli 运行编译后的程序:

src/14-tcpstates/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ ffff9bf7109d6900 88750 node 127.0.0.1 39755 127.0.0.1 50966
312312
Compile:
313313

314314
```shell
315-
docker run -it -v `pwd`/:/src/ yunwei37/ebpm:latest
315+
docker run -it -v `pwd`/:/src/ ghcr.io/eunomia-bpf/ecc-`uname -m`:latest
316316
```
317317

318318
或者

src/19-lsm-connect/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ int BPF_PROG(restrict_connect, struct socket *sock, struct sockaddr *address, in
113113
通过容器编译:
114114
115115
```console
116-
docker run -it -v `pwd`/:/src/ yunwei37/ebpm:latest
116+
docker run -it -v `pwd`/:/src/ ghcr.io/eunomia-bpf/ecc-`uname -m`:latest
117117
```
118118

119119
或是通过 `ecc` 编译:

src/20-tc/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ char __license[] SEC("license") = "GPL";
6969
通过容器编译:
7070

7171
```console
72-
docker run -it -v `pwd`/:/src/ yunwei37/ebpm:latest
72+
docker run -it -v `pwd`/:/src/ ghcr.io/eunomia-bpf/ecc-`uname -m`:latest
7373
```
7474

7575
或是通过 `ecc` 编译:

src/6-sigsnoop/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ eunomia-bpf 是一个结合 Wasm 的开源 eBPF 动态加载运行时和开发
9696
编译运行上述代码:
9797
9898
```shell
99-
docker run -it -v `pwd`/:/src/ yunwei37/ebpm:latest
99+
docker run -it -v `pwd`/:/src/ ghcr.io/eunomia-bpf/ecc-`uname -m`:latest
100100
```
101101

102102
或者

src/7-execsnoop/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ eunomia-bpf 是一个结合 Wasm 的开源 eBPF 动态加载运行时和开发
8383
使用容器编译:
8484
8585
```shell
86-
docker run -it -v `pwd`/:/src/ yunwei37/ebpm:latest
86+
docker run -it -v `pwd`/:/src/ ghcr.io/eunomia-bpf/ecc-`uname -m`:latest
8787
```
8888

8989
或者使用 ecc 编译:

src/8-exitsnoop/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ eunomia-bpf 是一个结合 Wasm 的开源 eBPF 动态加载运行时和开发
125125
Compile:
126126
127127
```shell
128-
docker run -it -v `pwd`/:/src/ yunwei37/ebpm:latest
128+
docker run -it -v `pwd`/:/src/ ghcr.io/eunomia-bpf/ecc-`uname -m`:latest
129129
```
130130

131131
Or

src/9-runqlat/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ eunomia-bpf 是一个结合 Wasm 的开源 eBPF 动态加载运行时和开发
363363
Compile:
364364

365365
```shell
366-
docker run -it -v `pwd`/:/src/ yunwei37/ebpm:latest
366+
docker run -it -v `pwd`/:/src/ ghcr.io/eunomia-bpf/ecc-`uname -m`:latest
367367
```
368368

369369
或者

0 commit comments

Comments
 (0)