{"id":15282525,"url":"https://github.com/kubearmor/libbpf","last_synced_at":"2025-09-11T11:47:59.023Z","repository":{"id":46291191,"uuid":"389609889","full_name":"kubearmor/libbpf","owner":"kubearmor","description":"KubeArmor eBPF Go library based on Linux libbpf API","archived":false,"fork":false,"pushed_at":"2023-12-15T14:55:00.000Z","size":70,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-01T14:26:43.301Z","etag":null,"topics":["bpf","ebpf","go","golang","kubearmor"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kubearmor.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-26T11:30:52.000Z","updated_at":"2021-12-21T16:21:37.000Z","dependencies_parsed_at":"2024-06-21T14:11:41.417Z","dependency_job_id":"6f09f7ef-f72f-4c41-b0fb-9e5f2b248129","html_url":"https://github.com/kubearmor/libbpf","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/kubearmor%2Flibbpf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kubearmor%2Flibbpf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kubearmor%2Flibbpf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kubearmor%2Flibbpf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kubearmor","download_url":"https://codeload.github.com/kubearmor/libbpf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219847247,"owners_count":16556405,"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":["bpf","ebpf","go","golang","kubearmor"],"created_at":"2024-09-30T14:26:42.307Z","updated_at":"2024-10-14T14:20:56.039Z","avatar_url":"https://github.com/kubearmor.png","language":"Go","readme":"# libbpf\n\n## KubeArmor bpf library\n\nOne will only be able to `go get` and to use this go module (library) setting the `CGO_LDFLAGS` environment variable, since this is based on the aqua security [libbpfgo](https://github.com/aquasecurity/libbpfgo) that is a `cgo` wrapper of the C [libbpf](https://github.com/libbpf/libbpf).\n\n*So be aware that using this library in your go code turns it into cgo code.*\n\n---\n\n## General Dependencies\n\n### Ubuntu\n\n`linux-tools-generic`\n\n`libelf-dev`\n\n`zlib1g-dev`\n\n`clang`\n\n---\n\n## Using this library\n\nOne way is to use the shared library `libbpf.so` if it is already installed.\n\n`❯ CGO_LDFLAGS=\"/usr/lib/libbpf.so\" go get github.com/kubearmor/libbpf`\n\nHowever, currently, the most common is to use the `libbpf.a` (static version). To do so, follow the steps below.\n\n- Clone this repository.\n\n  `❯ git clone github.com/kubearmor/libbpf`\n\n- Inside the repository folder, run make to download the C libbpf code and compile it.\n\n  `❯ make`\n\n  This will generate the static `libbpf.a` file and the `vmlinux.h` and `bpf/*.h` headers inside `./include`.\n\n- Now one is able to make correct use of this library. Be sure to use absolute paths.\n\n  `❯ CGO_LDFLAGS=\"/path_to_this_repo/include/libbpf.a\" CGO_CFLAGS=\"-I /path_to_this_repo/include\" go get github.com/kubearmor/libbpf`\n\nThe same environment variable need to be set when building the final application that uses this library.\n\n`❯ CGO_LDFLAGS=\"/path_to_this_repo/include/libbpf.a\" CGO_CFLAGS=\"-I /path_to_this_repo/include\" go build`\n\n### Testing it\n\nThe use cases inside [tests](tests/) can be tested using make.\n\n`❯ make run-tests`\n\n---\n\n### KABPFMapElement interface\n\nTo satisfy `KABPFMapElement` interface, it's necessary to implement the following methods for an XXMapElem.\n\n```go\nfunc (pme *XXMapElem) KeyPointer() unsafe.Pointer {\n\t...\n}\n\nfunc (pme *XXMapElem) ValuePointer() unsafe.Pointer {\n\t...\n}\n\nfunc (pme *XXMapElem) SetFoundValue(value []byte) {\n\t...\n}\n\nfunc (pme *XXMapElem) MapName() string {\n\treturn \"map_name\"\n}\n```\n\nExamples can also be found in [tests](tests/).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkubearmor%2Flibbpf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkubearmor%2Flibbpf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkubearmor%2Flibbpf/lists"}