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

aya: add feature probing for program and map type #1063

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

tyrone-wu
Copy link
Contributor

@tyrone-wu tyrone-wu commented Oct 19, 2024

Add API for detecting whether kernel supports program type and map type.

Also add const fn bpf_insn::new(...) so that common bpf instructions are not re-computed every time from copy_instructions().

Assertions for LircMode2 and Lsm are disabled because they require certain kernel configs to be enabled, which are not by default in VM integration tests. Same with InodeStorage map assertion.


I tested the new integration tests against a ton of ubuntu mainline kernels. Basically on every version where the program/map type was introduced I was able to verify that they were passing as expected, except for ones below v4.4 since it gave errors on /sys/fs/bpf ENOENT: No such file or directory.

Copy link

netlify bot commented Oct 19, 2024

Deploy Preview for aya-rs-docs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 6075a11
🔍 Latest deploy log https://app.netlify.com/sites/aya-rs-docs/deploys/671a8b1c5011250008100ed3
😎 Deploy Preview https://deploy-preview-1063--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.

Copy link

mergify bot commented Oct 19, 2024

Hey @alessandrod, this pull request changes the Aya Public API and requires your review.

@mergify mergify bot added the api/needs-review Makes an API change that needs review label Oct 19, 2024
@mergify mergify bot requested a review from alessandrod October 19, 2024 20:16
@mergify mergify bot added aya This is about aya (userspace) aya-obj Relating to the aya-obj crate test A PR that improves test cases or CI labels Oct 19, 2024
@tyrone-wu tyrone-wu changed the title aya: add feature probing program types aya: add feature probing for program and map type Oct 21, 2024
@tyrone-wu tyrone-wu force-pushed the aya/probe-prog-types branch 4 times, most recently from 7628c03 to 0e67fa4 Compare October 22, 2024 01:07
When `aya::obj` was migrated to be its own crate `aya-obj`, the `obj`
alias was created to preserve existing imports that relied on
`crate::obj`.

This resulted in 3 ways to import `aya-obj` objects:
- `use aya_obj::*`
- `use obj::*`
- `use crate::obj::*`

The `obj` alias is now removed to avoid confusion, and all `obj` imports
should now refer to `aya_obj`.
Adds API that probes whether kernel supports a program type.

Additionally add `const fn bpf_insn::new()` so that common instructions
are not re-computed from `copy_instructions()`.

Assertions for `LircMode2` and `Lsm` are disabled because they require
certain kernel configs to be enabled, which are not by default in VM
tests.
Add API that probes whether kernel supports a map type.

Assertion for `InodeStorage` are disabled because they require
CONFIG_BPF_LSM to be enabled, which is not be default in VM tests.
Cached probed for ProgramInfo fields instead of exposing it through
global FEATURE. Probing operation happens on cache miss, which happens
when first accessing the field, *and* if the field is 0. No need to
probe if non-zero.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api/needs-review Makes an API change that needs review aya This is about aya (userspace) 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.

1 participant