-
Notifications
You must be signed in to change notification settings - Fork 20
341 lines (331 loc) · 12.2 KB
/
push.yml
File metadata and controls
341 lines (331 loc) · 12.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
name: Push actions
on:
push:
pull_request:
workflow_dispatch:
jobs:
test:
name: Run tests with ${{ matrix.flags.flags }} ${{ matrix.flags.args }}
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
strategy:
fail-fast: false
matrix:
arch: [amd64] # TODO: arm64 (bpftool not working)
flags:
- flags: CHECKSUM_HACK=kfunc
args: ""
desc: kfunc
- flags: CHECKSUM_HACK=kfunc USE_LIBXDP=0
args: ""
desc: kfunc-no-libxdp
- flags: CHECKSUM_HACK=kfunc USE_LIBXDP=1
args: ""
desc: kfunc-libxdp-use-libbpf
- flags: CHECKSUM_HACK=kfunc USE_LIBXDP=1
args: --use-libxdp
desc: kfunc-libxdp-use-libxdp
- flags: CHECKSUM_HACK=kprobe STRIP_BTF_EXT=1
args: ""
desc: kprobe-strip-btf-ext
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt update
sudo apt install python3 clang-15 llvm pahole \
linux-tools-common linux-tools-$(uname -r) linux-cloud-tools-$(uname -r) \
libbpf-dev libffi-dev libelf-dev libxdp-dev \
bats bc conntrack ethtool iperf3 jq socat tshark wireguard-tools
- name: Build & Test
run: |
export BPF_CC=clang-15
sudo cp /sys/kernel/btf/vmlinux /lib/modules/$(uname -r)/build
make -j ${{ matrix.flags.flags }}
sudo nft delete table filter # Docker's nftables rule drops IPv4 packets in tests
sudo nft list ruleset
sudo insmod out/mimic.ko
sudo env MIMIC_TEST_EXTRA_ARGS="${{ matrix.flags.args }}" make test ${{ matrix.flags.flags }}
- name: Upload captured packets
uses: actions/upload-artifact@v4
if: always()
with:
name: pcap-${{ matrix.flags.desc }}
path: out/*.pcapng
build-deb:
name: Build .deb packages for ${{ matrix.distro.name }}
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
strategy:
fail-fast: false
matrix:
arch: [amd64, arm64]
distro:
- name: Debian 12
codename: bookworm
image: debian:bookworm-slim
extra-repos: |
deb http://deb.debian.org/debian bookworm-backports main
extra-cmd: |
sed -i 's/clang/clang-16/' debian/control
sed -i 's/BPF_CC=clang/BPF_CC=clang-16 COMPAT_LINUX_6_1=1/' debian/rules
- name: Debian 13
codename: trixie
image: debian:trixie-slim
- name: Debian 14 (testing)
codename: forky
image: debian:forky-slim
- name: Debian sid
codename: sid
image: debian:sid-slim
- name: Ubuntu 24.04
codename: noble
image: ubuntu:noble
extra-repos-amd64: |
deb http://archive.ubuntu.com/ubuntu noble-backports main restricted universe multiverse
extra-repos-arm64: |
deb http://ports.ubuntu.com/ubuntu-ports noble-backports main restricted universe multiverse
extra-cmd: |
sed -i 's/clang,/clang, llvm,/' debian/control
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run pre-building script
run: |
${{ matrix.distro.extra-cmd }}
${{ matrix.arch == 'arm64' && matrix.distro.extra-cmd-arm64 || matrix.distro.extra-cmd-amd64 }}
- name: Build
uses: jtdor/build-deb-action@v1
with:
buildpackage-opts: -b -us -uc
docker-image: ${{ matrix.distro.image }}
extra-repos: |
${{ matrix.distro.extra-repos }}
${{ matrix.arch == 'arm64' && matrix.distro.extra-repos-arm64 || matrix.distro.extra-repos-amd64 }}
- name: Upload
uses: actions/upload-artifact@v4
with:
name: packages-${{ matrix.distro.codename }}-${{ matrix.arch }}
path: |
debian/artifacts/*.deb
debian/artifacts/*.ddeb
test-deb-install:
name: Test .deb installation
needs: build-deb
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
strategy:
fail-fast: false
matrix:
arch: [amd64] # TODO: arm64 (no BTF blob found)
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: packages-noble-${{ matrix.arch }}
path: packages-noble-${{ matrix.arch }}
- name: Test Install
run: |
sudo apt install ./packages-noble-${{ matrix.arch }}/*.deb linux-headers-`uname -r`
sudo modprobe mimic
- name: Upload log
if: always()
uses: actions/upload-artifact@v4
with:
name: dkms-make-log
path: /var/lib/dkms/mimic/*/build/make.log
build-exe:
name: Build Mimic CLI executable
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
strategy:
fail-fast: false
matrix:
arch: [amd64] # TODO: arm64 (bpftool not working)
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Add LLVM apt repository
shell: bash
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
# Ubuntu 24.04 officially packages LLVM 15 and 16
for _clang_version in {17..21}; do
sudo ./llvm.sh $_clang_version
done
sudo apt update
- name: Install dependencies
shell: bash
run: |
sudo apt install clang-{15..21} pahole \
linux-tools-common linux-tools-$(uname -r) linux-cloud-tools-$(uname -r) \
libbpf-dev libffi-dev libelf-dev libxdp-dev
- name: Build CLI
shell: bash
run: |
flags_name=(generic compat-6.1 compat-6.6)
flags=("" "COMPAT_LINUX_6_1=1" "COMPAT_LINUX_6_6=1")
for _i in {0..2}; do
for _clang_version in {15..21}; do
if [ $_clang_version -ge 20 ] && [ "${flags_name[$_i]}" == "compat-6.1" ]; then
continue
fi
export BPF_CC=clang-$_clang_version
make build-cli -j ${flags[$_i]}
mv out/mimic out/mimic-${flags_name[$_i]}-clang-$_clang_version
done
done
cd out
- name: Upload executable
uses: actions/upload-artifact@v4
with:
name: mimic-${{ matrix.arch }}
path: |
out/mimic-*
out/expect-fail/mimic-*
test-lvh:
name: Test LVH
needs: build-exe
runs-on: ubuntu-24.04
env:
lvh-version: v0.0.28
root-image-version: 20251113.115124-sid
strategy:
fail-fast: false
matrix:
arch: [amd64] # TODO: arm64 (see build-exe)
kernel:
- name: "6.1"
variant: compat-6.1
- name: "6.6"
variant: compat-6.6
- name: "6.12"
variant: generic
- name: bpf-next
variant: generic
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: mimic-${{ matrix.arch }}
path: out
- name: Install LVH CLI
uses: ./.github/actions/lvh-install-cli
with:
lvh-version: ${{ env.lvh-version }}
arch: ${{ matrix.arch }}
- name: Fetch cached root image
id: fetch-cached-root-image
uses: actions/cache/restore@v4
with:
path: lvh-image.qcow2
key: mimic-lvh-root-image-${{ matrix.arch }}-${{ env.root-image-version }}
- name: Fetch root image
if: steps.fetch-cached-root-image.outputs.cache-hit != 'true'
run: |
lvh images pull quay.io/lvh-images/root-images:${{ env.root-image-version }}
cp _data/images/kind.qcow2 lvh-image.qcow2
- name: Save root image to cache
if: steps.fetch-cached-root-image.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: lvh-image.qcow2
key: mimic-lvh-root-image-${{ matrix.arch }}-${{ env.root-image-version }}
- name: Install pahole
run: |
sudo apt update
sudo apt install pahole
- name: Prepare LVH kernel tree metadata
id: prepare-kernel-tree-metadata
run: |
mkdir -p _data/kernels
wget -O _data/kernels.json https://raw.githubusercontent.com/cilium/little-vm-helper-images/c19813941658d998100cf7caaeaf6670763c8e2c/_data/kernels.json
sed -i 's/\?depth=1/?depth=128/g' _data/kernels.json
git_url_with_branch="$(jq -r '.kernels.[] | select(.name=="${{ matrix.kernel.name }}") | .url' < _data/kernels.json | sed -E 's/\?depth=[0-9]+//')"
git_url="$(echo $git_url_with_branch | sed 's/#.*//')"
git_branch="$(echo $git_url_with_branch | sed -n 's/.*#\(.*\)/\1/p')"
if [ -z "$git_branch" ]; then
git_branch=HEAD
else
git_branch="refs/heads/$git_branch"
fi
echo lvh_kernel_rev=$(git ls-remote "$git_url" | grep "$git_branch" | awk '{print $1}') >> $GITHUB_OUTPUT
- name: Fetch cached LVH kernel
id: fetch-cached-kernel
uses: actions/cache@v4
with:
path: |
lvh-kernel
lvh-kernel-tree
key: mimic-lvh-kernel-${{ matrix.arch }}-${{ matrix.kernel.name }}-${{ steps.prepare-kernel-tree-metadata.outputs.lvh_kernel_rev }}
- name: Build LVH kernel
if: steps.fetch-cached-kernel.outputs.cache-hit != 'true'
run: |
sudo apt update
sudo apt install libncurses-dev gawk flex bison openssl libssl-dev dkms libelf-dev libudev-dev libpci-dev libiberty-dev autoconf llvm
if [ "${{ matrix.arch }}" == "arm64" ]; then
sudo apt install gcc-aarch64-linux-gnu
fi
lvh kernels --dir _data fetch ${{ matrix.kernel.name }}
cd _data/kernels/${{ matrix.kernel.name }}
git checkout ${{ steps.prepare-kernel-tree-metadata.outputs.lvh_kernel_rev }}
cd ${{ github.workspace }}
lvh kernels --dir _data build ${{ matrix.kernel.name }}
cd _data/kernels/${{ matrix.kernel.name }}/tar-install/boot
mv vmlinuz-* vmlinuz
cd ../..
make -C tools/bpf/resolve_btfids -j$(nproc)
rm -rf drivers/gpu arch/*/boot tools/perf .git *.tar Documentation vmlinux.unstripped .tmp*
find . -type f -name '*.o' -delete
cd ${{ github.workspace }}
cp _data/kernels/${{ matrix.kernel.name }}/tar-install/boot/vmlinuz lvh-kernel
rm -r _data/kernels/${{ matrix.kernel.name }}/tar-install
mv _data/kernels/${{ matrix.kernel.name }} lvh-kernel-tree
- name: Build mimic.ko
run: |
cd kmod
if [ "${{ matrix.arch }}" == "arm64" ]; then
export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-
fi
make SYSTEM_BUILD_DIR=../lvh-kernel-tree
- name: Provision LVH VMs
uses: ./.github/actions/lvh-run
with:
lvh-version: ${{ env.lvh-version }}
mem: 4G
cpu: 2
cpu-kind: ""
test-name: mimic-test
image-path: lvh-image.qcow2
kernel-path: lvh-kernel
arch: ${{ matrix.arch }}
install-dependencies: true
host-mount: ./
cmd: |
cd /host/lvh-kernel-tree
make modules_install
uname -a
cd /host
insmod kmod/mimic.ko
cd out
chmod +x mimic-*
for _mimic in ./mimic-${{ matrix.kernel.variant }}-*; do
echo Checking \$_mimic
\$_mimic run lo --check
done
- name: Extract kernel log
if: always()
uses: ./.github/actions/lvh-run
with:
provision: "false"
cmd: |
dmesg > /host/dmesg.log
- name: Upload kernel log
if: always()
uses: actions/upload-artifact@v4
with:
name: dmesg-${{ matrix.arch }}-${{ matrix.kernel.name }}.log
path: dmesg.log