Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dorkamotorka/sockmap-ebpf
https://github.com/dorkamotorka/sockmap-ebpf
Last synced: 16 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/dorkamotorka/sockmap-ebpf
- Owner: dorkamotorka
- Created: 2024-06-06T09:30:33.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-08-29T08:58:23.000Z (4 months ago)
- Last Synced: 2024-08-29T10:14:22.587Z (4 months ago)
- Language: C
- Size: 2.32 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# eBPF SockMap
First we need to build and run the eBPF program:
```
go generate
go build
sudo ./sockmap
```Then we spawn a server and a client process in different network namespaces as well as setting up the cgroup(v2) and the veth pairs using:
```
mkdir -p /sys/fs/cgroup/unified/test.slice
ip netns add A
ip netns add B
ip -n A link add name veth0 type veth peer name veth0 netns B
ip -n A link set dev lo up
ip -n B link set dev lo up
ip -n A link set dev veth0 up
ip -n B link set dev veth0 up
ip -n A addr add 10.0.0.1/24 dev veth0
ip -n B addr add 10.0.0.2/24 dev veth0
```Network namespace A is where we run our server using:
```
echo $$ > /sys/fs/cgroup/unified/test.slice/cgroup.procs # Put current shell process into the cgroup to which our BPF program is attached to
ip netns exec A sockperf server -i 10.0.0.1 --tcp --daemonize # Run the server inside the network namespace A
```And then run the client (new shell) in the network namespace B using:
```
echo $$ > /sys/fs/cgroup/unified/test.slice/cgroup.procs # Put current shell process into the cgroup to which our BPF program is attached to
ip netns exec B sockperf ping-pong -i 10.0.0.1 --tcp --time 30 # Run the client inside the network namespace B
```The latency results I get on my machine is `18.282 usec` without the Sockmap, and with the latency reduces to `12.997 usec`, which is a aprox. `30%` improvement!