Skip to content

Commit 87e7989

Browse files
committed
adding/updating ci files
1 parent fa70e60 commit 87e7989

File tree

8 files changed

+478
-18
lines changed

8 files changed

+478
-18
lines changed

.github/workflows/test.yml

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
name: bpf-ci
2+
3+
on:
4+
pull_request:
5+
6+
concurrency:
7+
group: ci-test-${{ github.head_ref }}
8+
cancel-in-progress: true
9+
10+
jobs:
11+
llvm-toolchain:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
llvm: ${{ steps.llvm-toolchain-impl.outputs.version }}
15+
steps:
16+
- id: llvm-version
17+
uses: libbpf/ci/get-llvm-version@master
18+
- id: llvm-toolchain-impl
19+
shell: bash
20+
run: echo "version=llvm-${{ steps.llvm-version.outputs.version }}" >> $GITHUB_OUTPUT
21+
set-matrix:
22+
needs: llvm-toolchain
23+
runs-on: ubuntu-latest
24+
outputs:
25+
build-matrix: ${{ steps.set-matrix-impl.outputs.build_matrix }}
26+
test-matrix: ${{ steps.set-matrix-impl.outputs.test_matrix }}
27+
steps:
28+
- id: set-matrix-impl
29+
shell: python3 -I {0}
30+
run: |
31+
from json import dumps
32+
import os
33+
34+
def set_output(name, value):
35+
"""Write an output variable to the GitHub output file."""
36+
with open(os.getenv("GITHUB_OUTPUT"), "a") as f:
37+
f.write(f"{name}={value}\n")
38+
39+
matrix = [
40+
{"kernel": "LATEST", "runs_on": ["ubuntu-latest", "self-hosted"], "arch": "x86_64", "toolchain": "gcc"},
41+
{"kernel": "LATEST", "runs_on": ["ubuntu-latest", "self-hosted"], "arch": "x86_64", "toolchain": "${{ needs.llvm-toolchain.outputs.llvm }}"},
42+
{"kernel": "LATEST", "runs_on": ["z15", "self-hosted"], "arch": "s390x", "toolchain": "gcc"},
43+
]
44+
self_hosted_repos = [
45+
"kernel-patches/bpf",
46+
"kernel-patches/vmtest",
47+
]
48+
49+
# Only a few repository within "kernel-patches" use self-hosted runners.
50+
if "${{ github.repository_owner }}" != "kernel-patches" or "${{ github.repository }}" not in self_hosted_repos:
51+
# Outside of those repositories, remove the self-hosted label and skip
52+
# any testing on s390x, as no suitable runners will be available.
53+
for idx in range(len(matrix) - 1, -1, -1):
54+
if "z15" in matrix[idx]["runs_on"]:
55+
del matrix[idx]
56+
else:
57+
matrix[idx]["runs_on"].remove("self-hosted")
58+
59+
build_matrix = {"include": matrix}
60+
set_output("build_matrix", dumps(build_matrix))
61+
62+
tests = ["test_progs", "test_progs_no_alu32", "test_maps", "test_verifier"]
63+
test_matrix = {"include": [{**config, **{"test": test}}
64+
for config in matrix
65+
for test in tests]}
66+
set_output("test_matrix", dumps(test_matrix))
67+
build:
68+
name: build for ${{ matrix.arch }} with ${{ matrix.toolchain }}
69+
needs: set-matrix
70+
runs-on: ${{ matrix.runs_on }}
71+
timeout-minutes: 100
72+
strategy:
73+
fail-fast: false
74+
matrix: ${{ fromJSON(needs.set-matrix.outputs.build-matrix) }}
75+
env:
76+
KERNEL: ${{ matrix.kernel }}
77+
REPO_ROOT: ${{ github.workspace }}
78+
REPO_PATH: ""
79+
steps:
80+
- uses: actions/checkout@v3
81+
- if: ${{ github.repository == 'kernel-patches/vmtest' }}
82+
name: Download bpf-next tree
83+
uses: libbpf/ci/get-linux-source@master
84+
with:
85+
dest: '.kernel'
86+
- if: ${{ github.repository == 'kernel-patches/vmtest' }}
87+
name: Move linux source in place
88+
shell: bash
89+
run: |
90+
rm -rf .kernel/.git
91+
cp -rf .kernel/. .
92+
rm -rf .kernel
93+
- uses: libbpf/ci/patch-kernel@master
94+
with:
95+
patches-root: '${{ github.workspace }}/ci/diffs'
96+
repo-root: '${{ github.workspace }}'
97+
- name: Setup build environment
98+
uses: libbpf/ci/setup-build-env@master
99+
- name: Build kernel image
100+
uses: libbpf/ci/build-linux@master
101+
with:
102+
arch: ${{ matrix.arch }}
103+
toolchain: ${{ matrix.toolchain }}
104+
- name: Build selftests
105+
uses: libbpf/ci/build-selftests@master
106+
with:
107+
vmlinux_btf: ${{ github.workspace }}/vmlinux
108+
toolchain: ${{ matrix.toolchain }}
109+
- name: Build samples
110+
uses: libbpf/ci/build-samples@master
111+
with:
112+
vmlinux_btf: ${{ github.workspace }}/vmlinux
113+
toolchain: ${{ matrix.toolchain }}
114+
- name: Tar artifacts
115+
run: |
116+
file_list=""
117+
if [ "${{ github.repository }}" == "kernel-patches/vmtest" ]; then
118+
# Package up a bunch of additional infrastructure to support running
119+
# 'make kernelrelease' and bpf tool checks later on.
120+
file_list="$(find . -iname Makefile | xargs) \
121+
scripts/ \
122+
tools/testing/selftests/bpf/ \
123+
tools/include/ \
124+
tools/bpf/bpftool/";
125+
fi
126+
# zstd is installed by default in the runner images.
127+
tar -cf - \
128+
.config \
129+
arch/*/boot/bzImage \
130+
include/config/auto.conf \
131+
include/generated/autoconf.h \
132+
${file_list} \
133+
--exclude '*.h' \
134+
selftests/bpf/ \
135+
vmlinux | zstd -T0 -19 -o vmlinux-${{ matrix.arch }}-${{ matrix.toolchain }}.tar.zst
136+
- uses: actions/upload-artifact@v3
137+
with:
138+
name: vmlinux-${{ matrix.arch }}-${{ matrix.toolchain }}
139+
if-no-files-found: error
140+
path: vmlinux-${{ matrix.arch }}-${{ matrix.toolchain }}.tar.zst
141+
test:
142+
name: ${{ matrix.test }} on ${{ matrix.arch }} with ${{ matrix.toolchain }}
143+
needs: [set-matrix, build]
144+
strategy:
145+
fail-fast: false
146+
matrix: ${{ fromJSON(needs.set-matrix.outputs.test-matrix) }}
147+
runs-on: ${{ matrix.runs_on }}
148+
timeout-minutes: 100
149+
env:
150+
KERNEL: ${{ matrix.kernel }}
151+
REPO_ROOT: ${{ github.workspace }}
152+
REPO_PATH: ""
153+
steps:
154+
- uses: actions/checkout@v3
155+
- uses: actions/download-artifact@v3
156+
with:
157+
name: vmlinux-${{ matrix.arch }}-${{ matrix.toolchain }}
158+
path: .
159+
- name: Untar artifacts
160+
# zstd is installed by default in the runner images.
161+
run: zstd -d -T0 vmlinux-${{ matrix.arch }}-${{ matrix.toolchain }}.tar.zst --stdout | tar -xf -
162+
- name: Prepare rootfs
163+
uses: libbpf/ci/prepare-rootfs@master
164+
with:
165+
project-name: 'libbpf'
166+
arch: ${{ matrix.arch }}
167+
kernel: ${{ matrix.kernel }}
168+
kernel-root: '.'
169+
image-output: '/tmp/root.img'
170+
test: ${{ matrix.test }}
171+
- name: Run selftests
172+
uses: libbpf/ci/run-qemu@master
173+
with:
174+
arch: ${{ matrix.arch}}
175+
img: '/tmp/root.img'
176+
vmlinuz: '${{ github.workspace }}/vmlinuz'
177+
kernel-root: '.'

README

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +0,0 @@
1-
Linux kernel
2-
============
3-
4-
There are several guides for kernel developers and users. These guides can
5-
be rendered in a number of formats, like HTML and PDF. Please read
6-
Documentation/admin-guide/README.rst first.
7-
8-
In order to build the documentation, use ``make htmldocs`` or
9-
``make pdfdocs``. The formatted documentation can also be read online at:
10-
11-
https://www.kernel.org/doc/html/latest/
12-
13-
There are various text files in the Documentation/ subdirectory,
14-
several of them using the Restructured Text markup notation.
15-
16-
Please read the Documentation/process/changes.rst file, as it contains the
17-
requirements for building and running the kernel, and information about
18-
the problems which may result by upgrading your kernel.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
From 01cc82fac426032c414258f2c322f63e75cf04c0 Mon Sep 17 00:00:00 2001
2+
From: Sumanth Korikkar <[email protected]>
3+
Date: Fri, 7 Oct 2022 10:13:27 +0200
4+
Subject: [PATCH] bpf: Fix sample_flags for bpf_perf_event_output
5+
6+
* Raw data is also filled by bpf_perf_event_output.
7+
* Add sample_flags to indicate raw data.
8+
* This eliminates the segfaults as shown below:
9+
Run ./samples/bpf/trace_output
10+
BUG pid 9 cookie 1001000000004 sized 4
11+
BUG pid 9 cookie 1001000000004 sized 4
12+
BUG pid 9 cookie 1001000000004 sized 4
13+
Segmentation fault (core dumped)
14+
15+
Fixes: 838d9bb62d13 ("perf: Use sample_flags for raw_data")
16+
Signed-off-by: Sumanth Korikkar <[email protected]>
17+
Signed-off-by: Andrii Nakryiko <[email protected]>
18+
Acked-by: Namhyung Kim <[email protected]>
19+
Acked-by: Jiri Olsa <[email protected]>
20+
Link: https://lore.kernel.org/bpf/[email protected]
21+
---
22+
kernel/trace/bpf_trace.c | 2 ++
23+
1 file changed, 2 insertions(+)
24+
25+
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
26+
index 688552df95ca..596335fe62e2 100644
27+
--- a/kernel/trace/bpf_trace.c
28+
+++ b/kernel/trace/bpf_trace.c
29+
@@ -687,6 +687,7 @@ BPF_CALL_5(bpf_perf_event_output, struct pt_regs *, regs, struct bpf_map *, map,
30+
31+
perf_sample_data_init(sd, 0, 0);
32+
sd->raw = &raw;
33+
+ sd->sample_flags |= PERF_SAMPLE_RAW;
34+
35+
err = __bpf_perf_event_output(regs, map, flags, sd);
36+
37+
@@ -745,6 +746,7 @@ u64 bpf_event_output(struct bpf_map *map, u64 flags, void *meta, u64 meta_size,
38+
perf_fetch_caller_regs(regs);
39+
perf_sample_data_init(sd, 0, 0);
40+
sd->raw = &raw;
41+
+ sd->sample_flags |= PERF_SAMPLE_RAW;
42+
43+
ret = __bpf_perf_event_output(regs, map, flags, sd);
44+
out:
45+
--
46+
2.30.2
47+
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
From de9c8d848d90cf2e53aced50b350827442ca5a4f Mon Sep 17 00:00:00 2001
2+
From: Martin KaFai Lau <[email protected]>
3+
Date: Wed, 12 Oct 2022 15:12:35 -0700
4+
Subject: [PATCH] selftests/bpf: S/iptables/iptables-legacy/ in the bpf_nf and
5+
xdp_synproxy test
6+
7+
The recent vm image in CI has reported error in selftests that use
8+
the iptables command. Manu Bretelle has pointed out the difference
9+
in the recent vm image that the iptables is sym-linked to the iptables-nft.
10+
With this knowledge, I can also reproduce the CI error by manually running
11+
with the 'iptables-nft'.
12+
13+
This patch is to replace the iptables command with iptables-legacy
14+
to unblock the CI tests.
15+
16+
Signed-off-by: Martin KaFai Lau <[email protected]>
17+
Signed-off-by: Andrii Nakryiko <[email protected]>
18+
Acked-by: David Vernet <[email protected]>
19+
Link: https://lore.kernel.org/bpf/[email protected]
20+
---
21+
tools/testing/selftests/bpf/prog_tests/bpf_nf.c | 6 +++---
22+
tools/testing/selftests/bpf/prog_tests/xdp_synproxy.c | 6 +++---
23+
2 files changed, 6 insertions(+), 6 deletions(-)
24+
25+
diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_nf.c b/tools/testing/selftests/bpf/prog_tests/bpf_nf.c
26+
index 8a838ea8bdf3..c8ba4009e4ab 100644
27+
--- a/tools/testing/selftests/bpf/prog_tests/bpf_nf.c
28+
+++ b/tools/testing/selftests/bpf/prog_tests/bpf_nf.c
29+
@@ -49,14 +49,14 @@ static int connect_to_server(int srv_fd)
30+
31+
static void test_bpf_nf_ct(int mode)
32+
{
33+
- const char *iptables = "iptables -t raw %s PREROUTING -j CONNMARK --set-mark 42/0";
34+
+ const char *iptables = "iptables-legacy -t raw %s PREROUTING -j CONNMARK --set-mark 42/0";
35+
int srv_fd = -1, client_fd = -1, srv_client_fd = -1;
36+
struct sockaddr_in peer_addr = {};
37+
struct test_bpf_nf *skel;
38+
int prog_fd, err;
39+
socklen_t len;
40+
u16 srv_port;
41+
- char cmd[64];
42+
+ char cmd[128];
43+
LIBBPF_OPTS(bpf_test_run_opts, topts,
44+
.data_in = &pkt_v4,
45+
.data_size_in = sizeof(pkt_v4),
46+
@@ -69,7 +69,7 @@ static void test_bpf_nf_ct(int mode)
47+
48+
/* Enable connection tracking */
49+
snprintf(cmd, sizeof(cmd), iptables, "-A");
50+
- if (!ASSERT_OK(system(cmd), "iptables"))
51+
+ if (!ASSERT_OK(system(cmd), cmd))
52+
goto end;
53+
54+
srv_port = (mode == TEST_XDP) ? 5005 : 5006;
55+
diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_synproxy.c b/tools/testing/selftests/bpf/prog_tests/xdp_synproxy.c
56+
index 75550a40e029..c72083885b6d 100644
57+
--- a/tools/testing/selftests/bpf/prog_tests/xdp_synproxy.c
58+
+++ b/tools/testing/selftests/bpf/prog_tests/xdp_synproxy.c
59+
@@ -94,12 +94,12 @@ static void test_synproxy(bool xdp)
60+
SYS("sysctl -w net.ipv4.tcp_syncookies=2");
61+
SYS("sysctl -w net.ipv4.tcp_timestamps=1");
62+
SYS("sysctl -w net.netfilter.nf_conntrack_tcp_loose=0");
63+
- SYS("iptables -t raw -I PREROUTING \
64+
+ SYS("iptables-legacy -t raw -I PREROUTING \
65+
-i tmp1 -p tcp -m tcp --syn --dport 8080 -j CT --notrack");
66+
- SYS("iptables -t filter -A INPUT \
67+
+ SYS("iptables-legacy -t filter -A INPUT \
68+
-i tmp1 -p tcp -m tcp --dport 8080 -m state --state INVALID,UNTRACKED \
69+
-j SYNPROXY --sack-perm --timestamp --wscale 7 --mss 1460");
70+
- SYS("iptables -t filter -A INPUT \
71+
+ SYS("iptables-legacy -t filter -A INPUT \
72+
-i tmp1 -m state --state INVALID -j DROP");
73+
74+
ctrl_file = SYS_OUT("./xdp_synproxy --iface tmp1 --ports 8080 \
75+
--
76+
2.30.2
77+

ci/vmtest/configs/DENYLIST

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# TEMPORARY
2+
btf_dump/btf_dump: syntax
3+
kprobe_multi_test/bench_attach
4+
core_reloc/enum64val
5+
core_reloc/size___diff_sz
6+
core_reloc/type_based___diff_sz

ci/vmtest/configs/DENYLIST.s390x

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
deny_namespace # not yet in bpf denylist
2+
tc_redirect/tc_redirect_dtime # very flaky
3+
lru_bug # not yet in bpf-next denylist
4+
usdt/basic # failing verifier due to bounds check after LLVM update
5+
usdt/multispec # same as above

ci/vmtest/helpers.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# $1 - start or end
2+
# $2 - fold identifier, no spaces
3+
# $3 - fold section description
4+
foldable() {
5+
local YELLOW='\033[1;33m'
6+
local NOCOLOR='\033[0m'
7+
if [ $1 = "start" ]; then
8+
line="::group::$2"
9+
if [ ! -z "${3:-}" ]; then
10+
line="$line - ${YELLOW}$3${NOCOLOR}"
11+
fi
12+
else
13+
line="::endgroup::"
14+
fi
15+
echo -e "$line"
16+
}
17+
18+
__print() {
19+
local TITLE=""
20+
if [[ -n $2 ]]; then
21+
TITLE=" title=$2"
22+
fi
23+
echo "::$1${TITLE}::$3"
24+
}
25+
26+
# $1 - title
27+
# $2 - message
28+
print_error() {
29+
__print error $1 $2
30+
}
31+
32+
# $1 - title
33+
# $2 - message
34+
print_notice() {
35+
__print notice $1 $2
36+
}

0 commit comments

Comments
 (0)