Home

Awesome

Learning eBPF and some kernel tracing, probe DNS + TCP connection with portable bpf prog.

DevEnv

Ubuntu 20.04

wget https://golang.org/dl/go1.17.linux-amd64.tar.gz
tar xvf go1.17.linux-amd64.tar.gz
sudo mv go /usr/lib/go-1.17
sudo ln -s /usr/lib/go-1.17/bin/go /usr/bin/go
echo 'export GOPATH=~/go' >> ~/.profile
echo 'export PATH=$GOPATH/bin:$PATH' >> ~/.profile

sudo apt update
sudo apt install -y make clang llvm

sudo apt install -y libelf-dev
git clone https://github.com/libbpf/libbpf
cd libbpf/src
make -j
sudo make install

Notes, Refs

https://blogs.oracle.com/linux/post/bpf-in-depth-building-bpf-programs
sizeof(event_t)
unsafe.Sizeof(Event)

https://stackoverflow.com/questions/53324158/golang-ebpf-and-functions-duration

https://dave.cheney.net/2015/10/09/padding-is-hard

https://go101.org/article/memory-layout.html

https://medium.com/@liamkelly17/working-with-packed-c-structs-in-cgo-224a0a3b708b