https://cilium.isovalent.com/hubfs/Learning-eBPF%20-%20Full%20book.pdf
상기의 내용을 기반으로 아래의 링크에서 학습하던 와중 생긴 에러에 대한 처리
https://github.com/lizrice/learning-ebpf
GitHub - lizrice/learning-ebpf: Learning eBPF, published by O'Reilly - out now! Here's where you'll find a VM config for the exa
Learning eBPF, published by O'Reilly - out now! Here's where you'll find a VM config for the examples, and more - GitHub - lizrice/learning-ebpf: Learning eBPF, published by O'Reill...
github.com
처음에 계속 libbpf/src를 시작할떼 make build를 수행해 주었으나 path를 잡지 못해 에러를 처리하지 못하고 있었다.
그렇기에 기본으로 주어지는 makefile을 뜯어보니 참조하는 디렉터리가 달랐기에 수정하였다.
makefile의 -I플래그로 -I/home/username/bpf/learning-ebpf/libbpf/src \ 추가
-I 플래그 : 해당 디렉터리를 포함하도록 지정
수정된 makefile
TARGETS = hello hello-func
all: $(TARGETS)
.PHONY: all
$(TARGETS): %: %.bpf.o
%.bpf.o: %.bpf.c
clang \
-target bpf \
-I/home/hackin/bpf/learning-ebpf/libbpf/src \
-I/usr/include/$(shell uname -m)-linux-gnu \
-g \
-O2 -o $@ -c $<
clean:
- rm *.bpf.o
- rm -f /sys/fs/bpf/hello
- rm -f /sys/fs/bpf/hello-func
또한, 헤더파일들이 위치한 디렉터리는 src디렉터리 이기에 c code들도 모두 수정해 주었다.
각 소스코드의 <bpf/bpf_helper.h> -> <bpf_helper.h> 로 변경
이제 정상적으로 생성된 것을 확인할 수 있다.
그리고 정상적으로 이제 덤프가 떠지는 것까지 확인!
추후에 상기에 언급해뒀던 pdf 내용들도 좀 정리해야겠다....

옛날에는 이걸 못해서 학습이 막혔었는데.. 이걸 왜 못했을까...
'ebpf' 카테고리의 다른 글
Anatomy of an eBPF Program (0) | 2024.01.24 |
---|---|
eBPF programming (0) | 2024.01.09 |
JIT for BPF (0) | 2023.09.21 |
JIT(Just In Time) Compiler - Verifier - SAT/SMT solver (0) | 2023.09.17 |
Buzzer(eBPF fuzzer) build (0) | 2023.08.11 |