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: expose BPF verifier log level configuration #371

Merged
merged 3 commits into from
Aug 29, 2022

Conversation

conectado
Copy link
Contributor

Hi!

Simple change that allows configuring verifier log level using BpfLoader.

Reducing the log level is very useful when debugging since the last line of the verifier error is its cause, so when the buffer is out of space you can't see the cause.

For reference: change discussed here

@netlify
Copy link

netlify bot commented Aug 28, 2022

Deploy Preview for aya-rs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit a602525
🔍 Latest deploy log https://app.netlify.com/sites/aya-rs/deploys/630ced35c06e5a000a6745a1
😎 Deploy Preview https://deploy-preview-371--aya-rs.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 settings.

Copy link
Collaborator

@alessandrod alessandrod left a comment

Choose a reason for hiding this comment

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

Thank you for doing this! Look good, see enum comment

aya/src/bpf.rs Outdated
/// # Ok::<(), aya::BpfError>(())
/// ```
///
pub fn verifier_log_level(&mut self, level: u32) -> &mut BpfLoader<'a> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think instead of u32 we should probably have an enum:

#[non_exhaustive]
#[repr(u32)]
pub enum VerifierLogLevel {
    Default = 4,
    Verbose = 1,
    Debug = 7,
}

See https://github.com/torvalds/linux/blob/f16214c102f0f64b2f3546e989498525bd7b7708/include/linux/bpf_verifier.h#L419. The Default/Verbose value correspond to what libbpf does too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated it here, changed the names and added some valid configurations.

Let me know if you still prefer the above variants, I just felt like this it was slightly clearer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could also change it up so that is similar to a bitmap, e.g. set it up like:

VerifierLogLevel::default().level_1(true).stats(true)

But might be too verbose for something like this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Updated it here, changed the names and added some valid configurations.

Let me know if you still prefer the above variants, I just felt like this it was slightly clearer.

I don't think this is cleaner - in fact it took me a good 10 minutes yesterday to understand why those names were used in the kernel and how they work. The names are bad, and I don't think we should surface the fact that log level s are implemented as a bitfield in the kernel all the way up to the aya API.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We should also have a Disable = 0 variant in addition to the ones I initially suggested tho

Copy link
Collaborator

@alessandrod alessandrod left a comment

Choose a reason for hiding this comment

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

Looks great, thank you!

@alessandrod alessandrod merged commit b95adc3 into aya-rs:main Aug 29, 2022
@dave-tucker dave-tucker added feature A PR that implements a new feature or enhancement aya This is about aya (userspace) labels Feb 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aya This is about aya (userspace) feature A PR that implements a new feature or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants