diff --git a/.github/workflows/static_code_analysis.yml b/.github/workflows/static_code_analysis.yml index 2f91d49b2..d61504803 100644 --- a/.github/workflows/static_code_analysis.yml +++ b/.github/workflows/static_code_analysis.yml @@ -32,6 +32,10 @@ jobs: id: agent_modified_files run: devops/check_modified_files.sh agent/ + - name: Generate eBPF object files and go bindings + id: generate_ebpf + run: make bpf + - name: Go lint - agent uses: golangci/golangci-lint-action@v2 if: steps.agent_modified_files.outputs.matched == 'true' diff --git a/.gitignore b/.gitignore index 4169c6803..95357b3c5 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,6 @@ tap/extensions/*/expect # Ignore *.log files *.log + +# Object files +*.o diff --git a/Makefile b/Makefile index bed2f3318..1afe22cfa 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ SHELL=/bin/bash # HELP # This will output the help for each task # thanks to https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html -.PHONY: help ui agent agent-debug cli tap docker +.PHONY: help ui agent agent-debug cli tap docker bpf clean-bpf help: ## This help. @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) @@ -20,6 +20,13 @@ TS_SUFFIX="$(shell date '+%s')" GIT_BRANCH="$(shell git branch | grep \* | cut -d ' ' -f2 | tr '[:upper:]' '[:lower:]' | tr '/' '_')" BUCKET_PATH=static.up9.io/mizu/$(GIT_BRANCH) export VER?=0.0 +ARCH=$(shell uname -m) +ifeq ($(ARCH),$(filter $(ARCH),aarch64 arm64)) + BPF_O_ARCH_LABEL=arm64 +else + BPF_O_ARCH_LABEL=x86 +endif +BPF_O_FILES = tap/tlstapper/tlstapper46_bpfel_$(BPF_O_ARCH_LABEL).o tap/tlstapper/tlstapper_bpfel_$(BPF_O_ARCH_LABEL).o ui: ## Build UI. @(cd ui; npm i ; npm run build; ) @@ -31,11 +38,17 @@ cli: ## Build CLI. cli-debug: ## Build CLI. @echo "building cli"; cd cli && $(MAKE) build-debug -agent: ## Build agent. +agent: bpf ## Build agent. @(echo "building mizu agent .." ) @(cd agent; go build -o build/mizuagent main.go) @ls -l agent/build +bpf: $(BPF_O_FILES) + +$(BPF_O_FILES): $(wildcard tap/tlstapper/bpf/**/*.[ch]) + @(echo "building tlstapper bpf") + @(./tap/tlstapper/bpf-builder/build.sh) + agent-debug: ## Build agent for debug. @(echo "building mizu agent for debug.." ) @(cd agent; go build -gcflags="all=-N -l" -o build/mizuagent main.go) @@ -76,6 +89,9 @@ clean-cli: ## Clean CLI. clean-docker: ## Run clean docker @(echo "DOCKER cleanup - NOT IMPLEMENTED YET " ) +clean-bpf: + @(rm $(BPF_O_FILES) ; echo "bpf cleanup done" ) + test-lint: ## Run lint on all modules cd agent && golangci-lint run cd shared && golangci-lint run diff --git a/tap/tlstapper/bpf-builder/build.sh b/tap/tlstapper/bpf-builder/build.sh index f06b979dc..9a2886905 100755 --- a/tap/tlstapper/bpf-builder/build.sh +++ b/tap/tlstapper/bpf-builder/build.sh @@ -9,7 +9,7 @@ docker build -t mizu-ebpf-builder . || exit 1 BPF_TARGET=amd64 BPF_CFLAGS="-O2 -g -D__TARGET_ARCH_x86" ARCH=$(uname -m) -if [[ $ARCH == "aarch64" ]]; then +if [[ $ARCH == "aarch64" || $ARCH == "arm64" ]]; then BPF_TARGET=arm64 BPF_CFLAGS="-O2 -g -D__TARGET_ARCH_arm64" fi @@ -18,7 +18,7 @@ docker run --rm \ --name mizu-ebpf-builder \ -v $MIZU_HOME:/mizu \ -v $(go env GOPATH):/root/go \ - -it mizu-ebpf-builder \ + mizu-ebpf-builder \ sh -c " BPF_TARGET=\"$BPF_TARGET\" BPF_CFLAGS=\"$BPF_CFLAGS\" go generate tap/tlstapper/tls_tapper.go chown $(id -u):$(id -g) tap/tlstapper/tlstapper*_bpf* diff --git a/tap/tlstapper/tlstapper46_bpfel_arm64.o b/tap/tlstapper/tlstapper46_bpfel_arm64.o deleted file mode 100644 index 89ece4597..000000000 Binary files a/tap/tlstapper/tlstapper46_bpfel_arm64.o and /dev/null differ diff --git a/tap/tlstapper/tlstapper46_bpfel_x86.o b/tap/tlstapper/tlstapper46_bpfel_x86.o deleted file mode 100644 index 393be0a48..000000000 Binary files a/tap/tlstapper/tlstapper46_bpfel_x86.o and /dev/null differ diff --git a/tap/tlstapper/tlstapper_bpfel_arm64.o b/tap/tlstapper/tlstapper_bpfel_arm64.o deleted file mode 100644 index 89ece4597..000000000 Binary files a/tap/tlstapper/tlstapper_bpfel_arm64.o and /dev/null differ diff --git a/tap/tlstapper/tlstapper_bpfel_x86.o b/tap/tlstapper/tlstapper_bpfel_x86.o deleted file mode 100644 index 7e2bf897d..000000000 Binary files a/tap/tlstapper/tlstapper_bpfel_x86.o and /dev/null differ