Skip to content

Commit 178e02f

Browse files
authored
[CHAOSPLT-579] Fix eBPF warnings + fix eBPF CI (#949)
* fix: architecture of ebpf program Generate the ebpf binary in a folder representing the build architecture to fix our internal CI. * fix: ebpf warnings Jira: CHAOSPLT-579
1 parent a4a639c commit 178e02f

File tree

6 files changed

+14
-7
lines changed

6 files changed

+14
-7
lines changed

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ build:make:
4242
script:
4343
- *install-make
4444
- export PATH="/usr/local/go/bin:${PATH}"
45-
- make GOBIN=/usr/local/go/bin install-go all docker-build-ebpf
45+
- make GOBIN=/usr/local/go/bin install-go all docker-build-ebpf_arm docker-build-ebpf_amd
4646
artifacts:
4747
paths:
4848
- bin/manager/manager_amd64

Makefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ docker-build-manager docker-build-only-manager: CONTAINER_NAME=$(MANAGER_IMAGE)
105105

106106
docker-build-ebpf:
107107
docker buildx build --platform linux/$(GOARCH) --build-arg BUILDGOVERSION=$(BUILDGOVERSION) -t ebpf-builder-$(GOARCH) -f bin/ebpf-builder/Dockerfile .
108-
-rm -r bin/injector/ebpf/
108+
-rm -r bin/injector/ebpf/$(GOARCH)/
109109
ifeq (true,$(USE_VOLUMES))
110110
# create a dummy container with volume to store files
111111
# circleci remote docker does not allow to use volumes, locally we fallbakc to standard volume but can call this target with USE_VOLUMES=true to debug if necessary
@@ -115,12 +115,19 @@ ifeq (true,$(USE_VOLUMES))
115115
-docker cp . ebpf-volume:/app
116116
-docker rm ebpf-builder
117117
docker run --platform linux/$(GOARCH) --volumes-from ebpf-volume --name=ebpf-builder ebpf-builder-$(GOARCH)
118-
docker cp ebpf-builder:/app/bin/injector/ebpf bin/injector/ebpf
118+
mkdir -p bin/injector/ebpf/$(GOARCH)
119+
docker cp ebpf-builder:/app/bin/injector/ebpf/$(GOARCH) bin/injector/ebpf/$(GOARCH)
119120
docker rm ebpf-builder
120121
else
121122
docker run --rm --platform linux/$(GOARCH) -v $(shell pwd):/app ebpf-builder-$(GOARCH)
122123
endif
123124

125+
docker-build-ebpf_arm:
126+
$(MAKE) docker-build-ebpf GOARCH=arm64
127+
128+
docker-build-ebpf_amd:
129+
$(MAKE) docker-build-ebpf GOARCH=amd64
130+
124131
lima-push-injector lima-push-handler lima-push-manager: FAKE_FOR=COMPLETION
125132

126133
_injector:;

bin/injector/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ COPY injector_${TARGETARCH} /usr/local/bin/chaos-injector
4545
COPY injector_${TARGETARCH} /usr/local/bin/injector
4646

4747
COPY dns_disruption_resolver.py /usr/local/bin/dns_disruption_resolver.py
48-
COPY ebpf/ /usr/local/bin/
48+
COPY ebpf/${TARGETARCH}/ /usr/local/bin/
4949

5050
ENTRYPOINT ["/usr/local/bin/chaos-injector"]
5151

ebpf/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
ARCH := x86
2-
BUILD_DIR := ../bin/injector/ebpf
2+
GOARCH := $(shell go env GOARCH)
3+
BUILD_DIR := ../bin/injector/ebpf/$(GOARCH)
34
TARGET_PREFIX := bpf-
45
UNAME_ARCH := $(shell uname -m)
56

ebpf/disk-failure/injection.bpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ int injection_disk_failure(struct pt_regs *ctx)
7171
char cmp_path_name[62];
7272
bpf_probe_read(&cmp_path_name, sizeof(cmp_path_name), path);
7373
char cmp_expected_path[62];
74-
bpf_probe_read(cmp_expected_path, sizeof(cmp_expected_path), filter_path);
74+
bpf_probe_read(cmp_expected_path, sizeof(cmp_expected_path), (const void *)filter_path);
7575
int filter_len = (int) (sizeof(filter_path) / sizeof(filter_path[0])) - 1;
7676

7777
if (filter_len > 62) {

ebpf/network-tc-filter/injection.bpf.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ static __always_inline bool validate_path(char* path) {
5353
bpf_probe_read_kernel_str(&request_path, sizeof(request_path), path);
5454

5555
// Check if the prefix match the method.
56-
#pragma unroll
5756
for (int j = 0; j < MAX_PATH_LEN; ++j) {
5857
// Break the loop if the prefix is completed
5958
if (expected_path[j] == '\0')

0 commit comments

Comments
 (0)