{"id":17501888,"url":"https://github.com/rebpf/rebpf","last_synced_at":"2025-09-08T04:35:23.718Z","repository":{"id":53080220,"uuid":"249605304","full_name":"rebpf/rebpf","owner":"rebpf","description":"A Rust library to write and load bpf programs built on top of libbpf (no bcc dependency).","archived":false,"fork":false,"pushed_at":"2021-04-07T16:39:31.000Z","size":200,"stargazers_count":55,"open_issues_count":7,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-01T23:47:19.651Z","etag":null,"topics":["bpf","ebpf","libbpf","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/rebpf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-24T03:38:17.000Z","updated_at":"2025-07-22T07:44:22.000Z","dependencies_parsed_at":"2022-09-12T04:20:17.443Z","dependency_job_id":null,"html_url":"https://github.com/rebpf/rebpf","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rebpf/rebpf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rebpf%2Frebpf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rebpf%2Frebpf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rebpf%2Frebpf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rebpf%2Frebpf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rebpf","download_url":"https://codeload.github.com/rebpf/rebpf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rebpf%2Frebpf/sbom","scorecard":{"id":766993,"data":{"date":"2025-08-11","repo":{"name":"github.com/rebpf/rebpf","commit":"50e235721228c1ece2c685f9357a954bd4a322d3"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.8,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":4,"reason":"Found 4/10 approved changesets -- score normalized to 4","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/rust.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: third-party GitHubAction not pinned by hash: .github/workflows/rust.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/rebpf/rebpf/rust.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/rust.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/rebpf/rebpf/rust.yml/master?enable=pin","Info:   0 out of   1 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 26 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-23T01:07:58.869Z","repository_id":53080220,"created_at":"2025-08-23T01:07:58.869Z","updated_at":"2025-08-23T01:07:58.869Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274134911,"owners_count":25228201,"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","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["bpf","ebpf","libbpf","rust"],"created_at":"2024-10-19T20:15:44.500Z","updated_at":"2025-09-08T04:35:23.654Z","avatar_url":"https://github.com/rebpf.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rebpf\nrebpf is a Rust library built on top of libbpf (no bcc dependency) that allows to write and load bpf program, in details this library provides:\n\n- A raw binding of libbpf provide by [libbpf-sys](https://github.com/alexforster/libbpf-sys).\n- A safe wrapper of libbpf.\n- High level ebpf api built on top of libbpf wrapper.\n- Parse packets in bpf programs using [pdu](https://github.com/uccidibuti/pdu), for more details see [packet_parser](./examples/packet_parser).\n\nFor more details see [rebpf](./rebpf).\n\n## Usage\nTo create your first ebpf program with rebpf library you can copy and rename an [empty_project template](./examples/empty_project) and edit it changing \u003cyour_project_name\u003e/src/kern.rs and \u003cyour_project_name\u003e/src/user.rs files.\n\n### write your ebpf program\nCopy this content in \u003cyour_project_name\u003e/src/kern.rs:\n\n```rust\n#![no_std]\nuse rebpf::{\n    LICENSE,\n    VERSION,\n    rebpf_macro::{sec},\n    libbpf::{XdpAction, XdpMd},\n};\n\n#[sec(\"license\")]\npub static _license: [u8; 4] = LICENSE;\n\n#[sec(\"version\")]\npub static _version: u32 = VERSION;\n\n#[sec(\"xdp_drop\")]\npub fn _xdp_drop(ctx: \u0026XdpMd) -\u003e XdpAction {\n    XdpAction::DROP\n}\n```\nNote: this ebpf program drop every packets received.\n\n### write your ebpf loader program\nCopy this content in \u003cyour_project_name\u003e/src/user.rs:\n\n```rust\nuse rebpf::{libbpf, interface, error as rebpf_error};\nuse clap::{Arg, App};\nuse std::path::Path;\n\nconst DEFAULT_FILENAME: \u0026str = \"kern.o\";\nconst DEFAULT_DEV: \u0026str = \"wlan0\";\n\nfn load_bpf(interface: \u0026interface::Interface, bpf_program_path: \u0026Path, xdp_flags: libbpf::XdpFlags) -\u003e Result\u003c(), rebpf_error::Error\u003e {\n    let (_bpf_object, bpf_fd) = libbpf::bpf_prog_load(bpf_program_path, libbpf::BpfProgType::XDP)?;\n    libbpf::bpf_set_link_xdp_fd(\u0026interface, Some(\u0026bpf_fd), xdp_flags)?;\n    let info = libbpf::bpf_obj_get_info_by_fd(\u0026bpf_fd)?;\n    println!(\"Success Loading\\n XDP prog name: {}, id {} on device: {}\", info.name()?, info.id(), interface.ifindex());\n    \n    Ok(())\n}\n\nfn unload_bpf(interface: \u0026interface::Interface, xdp_flags: libbpf::XdpFlags) -\u003e Result\u003c(), rebpf_error::Error\u003e {\n    libbpf::bpf_set_link_xdp_fd(\u0026interface, None, xdp_flags)?;\n    println!(\"Success Unloading.\");\n\n    Ok(())\n}\n\nfn run(bpf_program_path: \u0026Path, interface_name: \u0026str, unload_program: bool) -\u003e Result\u003c(), rebpf_error::Error\u003e {\n    let interface = interface::get_interface(interface_name)?;\n    let xdp_flags = libbpf::XdpFlags::UPDATE_IF_NOEXIST | libbpf::XdpFlags::SKB_MODE;\n    if unload_program == false {\n        load_bpf(\u0026interface, bpf_program_path, xdp_flags)\n    } else {\n        unload_bpf(\u0026interface, xdp_flags)\n    }    \n}\n\nfn main() {\n    let bpf_program_path = Path::new(DEFAULT_FILENAME);\n    let unload_program = false;\n    match run(\u0026bpf_program_path, DEFAULT_DEV, unload_program) {\n        Err(err) =\u003e println!(\"{:?}\", err),\n        Ok(_) =\u003e {}\n    };\n}\n\n```\n\n### compile ebpf and loader programs\nMove into \u003cyour_project_name\u003e folder and run the script build.sh:\n```\ncd \u003cyour_project_name\u003e\n./build.sh\n```\n\n### load and run ebpf program\n```\ncd \u003cyour_project_name\u003e/ebpf_output\nsudo user\n```\nExpected output:\n```\nSuccess Loading\n XDP prog name: _xdp_drop, id 33 on device: 2\n```\n\n### about empty_project template\n[empty_project template](./examples/empty_project) allows to write bpf programs and bpf userspace loader in a single Rust project and compile both with [build.sh](./examples/empty_project/build.sh) script but it is also possible does two different project and compile both apart:\n- To compile bpf userspace loader project it is possible use \"cargo build --release\".\n- Because Rust compiler doesn't allow to emit bpf bytecode, to compile bpf project the only way is emit llvm-bytecode with Rust compiler and convert it with llc into bpf bytecode (llvm allows to compile llvm-bytecode into bpf-bytecode).\n\n## Examples\n[link](https://github.com/rebpf/rebpf/tree/master/examples).\n\n## Documentations\n[link](https://docs.rs/rebpf/latest/rebpf/).\n\n## About writing bpf programs in Rust\nTo allows that bpf verifier accept your Rust bpf program you must be sure that in your source code all functions are inline and that you check all array access explicity with a if condition (you must check the array pointer address and not the slice length). Besides there are some Rust core/std functions that internally call #inline(never) functions (i.e. [SliceIndex](https://doc.rust-lang.org/src/core/slice/mod.rs.html#2747)) and there isn't away to force Rust compiler to compile these functions inline, so to fix this problem i have made a bash scripts [build.sh](./examples/empty_project/build.sh) and [remove_undefined_functions.sh](./examples/empty_project/remove_undefined_functions.sh) that automatically remove these functions from llvm-bytecode before compile to bpf-bytecode and then allow you to use Rust core functions writing bpf programs in Rust.     \n\n## Requirements\n- A recent [linux kernel](https://github.com/iovisor/bcc/blob/master/docs/kernel-versions.md)\n- LLVM 9\n- libelf\n- zlib\n\n## Roadmap and contributions\nRoadmap is composed from all issues with label \"roadmap\". If you want contribute to this repo to avoid future conflicts you can describe what are you implementing in a new issue with label \"roadmap\".\n\n## License\nLicensed under The MIT License (MIT) https://mit-license.org/.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frebpf%2Frebpf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frebpf%2Frebpf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frebpf%2Frebpf/lists"}