{"id":16271481,"url":"https://github.com/shreyaskarnik/ebpf-xdp","last_synced_at":"2025-04-08T15:30:01.679Z","repository":{"id":140197804,"uuid":"509622893","full_name":"shreyaskarnik/ebpf-xdp","owner":"shreyaskarnik","description":null,"archived":false,"fork":false,"pushed_at":"2023-02-25T11:26:23.000Z","size":721,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-14T11:52:57.878Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shreyaskarnik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-02T00:45:41.000Z","updated_at":"2023-03-16T18:05:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"10485f81-2c50-4d5e-a301-e2419048f8f9","html_url":"https://github.com/shreyaskarnik/ebpf-xdp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shreyaskarnik%2Febpf-xdp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shreyaskarnik%2Febpf-xdp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shreyaskarnik%2Febpf-xdp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shreyaskarnik%2Febpf-xdp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shreyaskarnik","download_url":"https://codeload.github.com/shreyaskarnik/ebpf-xdp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247870769,"owners_count":21009922,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T18:13:39.105Z","updated_at":"2025-04-08T15:30:01.648Z","avatar_url":"https://github.com/shreyaskarnik.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ebpf-xdp\n\n* This repo contains code to build a tool to examine IP address a host is connecting to.\nHere [eBPF](https://ebpf.io/) is used to write a program in kernel space using [XDP](https://docs.cilium.io/en/stable/concepts/ebpf/intro/) to examine the packets and extract the IP address.\n\n* Since XDP is the earliest point where the packets can be intercepted it was very interesting to experiment with and learn.\n\n* All sorts of interesting things such as filtering and re-shaping plus introspection into the packet data can be performed using XDP.\n\n* Used Golang to write the userspace program to display the IP address with the count of packets.\n\n* Used [Cilium eBPF](https://github.com/cilium/ebpf) to write the userspace Go code. There is a very handy tool [bpf2go](github.com/cilium/ebpf/cmd/bpf2go) which can be used to generate the Go code from the eBPF code.\n\n* Used [Bubble-Table](https://github.com/Evertras/bubble-table) which is based on the [BubbleTea](https://github.com/charmbracelet/bubbletea) framework to product the TUI\n\n## Development\n\nPre-requisites:\n\n* Host OS with Docker installed\n* Currently cannot be run on Docker for Mac\n\n```bash\nmake docker-run\n```\n\nThis will open up a shell with the Docker container that has all the dependencies installed\n\n```bash\nmake build\n\n# on amd64 machine (use ebpf-xdp-arm64 if you are on arm64)\n./bin/ebpf-xdp \u003ciface_name\u003e\n# ./bin/ebpf-xdp eth0\n```\n\nExample Output:\n\n![Example Output](./example-output.png)\n\nXDP Kernel program can be found [here](./ebpf/xdp.c)\n\nThe header files for the XDP kernel program are generated and downloaded by [update.sh](./ebpf/headers/update.sh) and [vmlinux.sh](./ebpf/headers/vmlinux.sh)\n\n## TODOs\n\n* Add support for IPv6 addresses\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshreyaskarnik%2Febpf-xdp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshreyaskarnik%2Febpf-xdp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshreyaskarnik%2Febpf-xdp/lists"}