{"id":16714210,"url":"https://github.com/flier/rust-ebpf","last_synced_at":"2025-04-10T06:09:45.571Z","repository":{"id":140004387,"uuid":"191927200","full_name":"flier/rust-ebpf","owner":"flier","description":null,"archived":false,"fork":false,"pushed_at":"2019-06-21T10:43:09.000Z","size":166,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T07:13:53.324Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flier.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2019-06-14T10:51:07.000Z","updated_at":"2020-08-01T14:33:37.000Z","dependencies_parsed_at":"2023-05-01T03:46:21.938Z","dependency_job_id":null,"html_url":"https://github.com/flier/rust-ebpf","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/flier%2Frust-ebpf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flier%2Frust-ebpf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flier%2Frust-ebpf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flier%2Frust-ebpf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flier","download_url":"https://codeload.github.com/flier/rust-ebpf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248166925,"owners_count":21058481,"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-12T20:49:52.362Z","updated_at":"2025-04-10T06:09:45.561Z","avatar_url":"https://github.com/flier.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rust-ebpf\n\n`rust-ebpf` is a experimental project that provides a toolchain to compile, load and run eBPF program.\n\n## Build\n\n`rust-ebpf` support to compile rust code to eBPF object.\n\nFirst, add the `ebpf-build` crate to your `Cargo.toml`.\n\n```toml\n[build-dependencies]\nebpf-build = \"0.1\"\n```\n\nThen, compile and build the kernel file to eBPF object.\n\n```rust\nextern crate ebpf_build;\n\nfn main() {\n    ebpf_build::Builder::new().build().expect(\"build kernel\");\n}\n```\n\nThen, the generated kernel file will be point by the `KERNEL` envrionment variable.\n\n```rust\nconst KERNEL: \u0026[u8] = include_bytes!(env!(\"KERNEL\"));\n```\n\n**Note:** Build eBPF object need install `llvm` first, and you can point to `llc` command with `LLC` envrionment variable.\n\n## Load\n\n`rust-ebpf` support to load the eBPF programs from a ELF file.\n\nFirst, add the `ebpf-loader` crate to your `Cargo.toml`.\n\n```toml\n[dependencies]\nebpf-loader = \"0.1\"\n```\n\nThen, load or parse the ELF file for programs.\n\n```rust\nlet obj = ebpf_loader::parse(KERNEL)?;\n```\n\n## Run\n\n## Reference\n\n* [PoC: compiling to eBPF from Rust](http://unhandledexpression.com/general/rust/2018/02/02/poc-compiling-to-ebpf-from-rust.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflier%2Frust-ebpf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflier%2Frust-ebpf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflier%2Frust-ebpf/lists"}