Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(aya-ebpf): BTF maps #1117

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

vadorovsky
Copy link
Member

@vadorovsky vadorovsky commented Dec 16, 2024

Before this change, Aya supported only legacy BPF map definitions, which are instances of the bpf_map_def struct and end up in the maps ELF section. This change introduces BTF maps, with custom structs indicating the metadata of the map, which end up in the .maps section.

Legacy maps are not supported by libbpf anymore and not even by the kernel for newer types of maps like inode/task storage.

Add support of BTF maps in aya-ebpf under the btf-maps feature flag.

Usage of this feature requires emitting debug info for the eBPF crate and passing the --btf flag to bpf-linker.


This change is Reviewable

Copy link

netlify bot commented Dec 16, 2024

Deploy Preview for aya-rs-docs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 484234c
🔍 Latest deploy log https://app.netlify.com/sites/aya-rs-docs/deploys/678e5a150acc0b00085067fb
😎 Deploy Preview https://deploy-preview-1117--aya-rs-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@mergify mergify bot added aya-bpf This is about aya-bpf (kernel) aya-obj Relating to the aya-obj crate test A PR that improves test cases or CI labels Dec 16, 2024
match btf.string_at(m.name_offset)?.as_ref() {
"__0" => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of this quirk, the eBPF programs written with aya-ebpf are not loadable by libbpf. We would have to port exactly the same quirk there.

But I didn't see any issues on the kernel side with it.

@vadorovsky vadorovsky force-pushed the btf-maps-v2 branch 11 times, most recently from f327ceb to d102383 Compare December 16, 2024 13:12
@hikaricai
Copy link

Good job, I am expecting socket_map!!!

@vadorovsky
Copy link
Member Author

The only major blocker in getting this green are failing ring buf integration tests:

https://github.com/aya-rs/aya/actions/runs/12353399024/job/34472421762?pr=1117

The issue is that for some reason, the type stored in the ring buf shows as FORWARD, not STRUCT in BTF. I'm worried that it's a bug in bpf-linker and we're miscompiling stuff. 😢 Still investigating that.

Copy link

mergify bot commented Jan 7, 2025

@vadorovsky, this pull request is now in conflict and requires a rebase.

@mergify mergify bot added the needs-rebase label Jan 7, 2025
@mergify mergify bot removed the needs-rebase label Jan 18, 2025
@vadorovsky vadorovsky force-pushed the btf-maps-v2 branch 4 times, most recently from 6fb04c5 to 69c00ac Compare January 19, 2025 19:08
@vadorovsky vadorovsky marked this pull request as ready for review January 20, 2025 10:19
Before this change, Aya supported only legacy BPF map definitions, which
are instances of the `bpf_map_def` struct and end up in the `maps` ELF
section. This change introduces BTF maps, with custom structs indicating
the metadata of the map, which end up in the `.maps` section.

Legacy maps are not supported by libbpf anymore and not even by the
kernel for newer types of maps like inode/task storage.

Add support of BTF maps in aya-ebpf under the `btf-maps` feature flag.

Usage of this feature requires emitting debug info for the eBPF crate
and passing the `--btf` flag to bpf-linker.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aya-bpf This is about aya-bpf (kernel) aya-obj Relating to the aya-obj crate test A PR that improves test cases or CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants