-
Notifications
You must be signed in to change notification settings - Fork 300
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
Miscellaneous fixes to allow running integration tests in bpf-linker #641
Conversation
✅ Deploy Preview for aya-rs-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
ca4fa44
to
620b2c8
Compare
cc @ajwerner |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
620b2c8
to
c883935
Compare
580e6d8
to
5a2d1fa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 16 of 29 files at r4, all commit messages.
Reviewable status: 16 of 30 files reviewed, all discussions resolved (waiting on @alessandrod)
5a2d1fa
to
7d50085
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some things to clarify here before merge
aya/Cargo.toml
Outdated
tokio = { version = "1.24.0", features = ["macros", "rt", "rt-multi-thread", "net"], optional = true } | ||
async-io = { version = "1.3", optional = true } | ||
log = "0.4" | ||
procfs = "0.15.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
procfs = "0.15.1" | |
procfs = { version: "0.15.1", default-features = false } |
This avoids pulling in chrono
as a dep.
Also how well maintained is this crate? and why should we switch from what we have.
Adding this to the commit message would be awesome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Looks pretty active to me.
aya/src/programs/mod.rs
Outdated
@@ -575,10 +575,14 @@ fn load_program<T: Link>( | |||
|
|||
let target_kernel_version = match *kernel_version { | |||
KernelVersion::Any => { | |||
let (major, minor, patch) = crate::sys::kernel_version().unwrap(); | |||
(major << 16) + (minor << 8) + patch | |||
let procfs::KernelVersion { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit gross having an aya KernelVersion and procfs::KernelVersion here.
Do we need both still?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, replaced the aya KernelVersion with Option
@@ -3,6 +3,8 @@ | |||
|
|||
use aya_bpf::{bindings::xdp_action, macros::xdp, programs::XdpContext}; | |||
|
|||
// Note: the `frags` attribute causes this probe to be incompatible with kernel versions < 5.18.0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bug.
This test should pass on older kernels too - we shouldn't set the flag for frags supported if isn't supported by the target kernel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, please fix in another PR.
@@ -168,8 +168,8 @@ fn pin_link() { | |||
#[test] | |||
fn pin_lifecycle() { | |||
let kernel_version = KernelVersion::current().unwrap(); | |||
if kernel_version < KernelVersion::new(5, 9, 0) { | |||
eprintln!("skipping test on kernel {kernel_version:?}, XDP uses netlink"); | |||
if kernel_version < KernelVersion::new(5, 18, 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test has nothing to do with those flags - it's just an unfortunate property of sharing the same bytecode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I realize, but I chose not to fix this here. Please fix it in another PR.
@@ -8,6 +8,12 @@ use aya::{ | |||
|
|||
#[test] | |||
fn xdp() { | |||
let kernel_version = KernelVersion::current().unwrap(); | |||
if kernel_version < KernelVersion::new(5, 18, 0) { | |||
eprintln!("skipping test on kernel {kernel_version:?}, support for BPF_F_XDP_HAS_FRAGS was added in 5.18.0; see https://github.com/torvalds/linux/commit/c2f2cdb"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above ☝️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed.
aya/src/bpf.rs
Outdated
let ret = retry_with_verifier_logs(10, &mut logger, |logger| { | ||
bpf_load_btf(raw_btf.as_slice(), logger) | ||
let (ret, verifier_log) = retry_with_verifier_logs(10, |logger| { | ||
bpf_load_btf(raw_btf.as_slice(), logger, VerifierLogLevel::default()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should come from the BpfLoader
instance, assuming default()
here would override someone who's explicitly disabled verifier logs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, done.
aya/src/programs/mod.rs
Outdated
@@ -474,7 +475,7 @@ impl<T: Link> ProgramData<T> { | |||
attach_btf_id, | |||
attach_prog_fd: None, | |||
btf_fd: None, | |||
verifier_log_level: 0, | |||
verifier_log_level: VerifierLogLevel::default(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should come from the BpfLoader
instance, assuming default()
here would override someone who's explicitly disabled verifier logs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no BpfLoader in hand here. Where do you suggest I get one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest plumbing in the verifier_log_level: VerifierLogLevel
as an argument to this function...
If BpfLoader
is never available in the call stack, then setting the log level should probably be part of the public API.
The option that's less work is to keep the existing behaviour and use VerifierLogLevel::None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plumbed it all the way to from_pin
, which is a public API. There's no loader object in sight.
Would you like me to break the public API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah okay, no need to expose that in from_pin
, You can safely use VerifierLogLevel::None
then, not default()
.
Programs are already loaded to the kernel so you won't get any verifier logs loading from pin in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's all the same to you, I'd rather leave default
here. If there aren't verifier logs to be had, then it doesn't matter. Agreed?
This allows the logic to be shared between aya and the integration tests without exposing additional public API surface.
Don't run `cargo build --verbose`; it's too noisy.
This type is really only used by one function.
7d50085
to
cd15fbd
Compare
b1bb810
to
b8252f4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
See individual commits and aya-rs/bpf-linker#69.