Merge pull request #584 from marysaka/fix/btf-kern-optional

aya: Ignore embedded BTF error if not truely required
reviewable/pr629/r30
Alessandro Decina 1 year ago committed by GitHub
commit 0766e70548
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -389,9 +389,51 @@ impl<'a> BpfLoader<'a> {
let btf_fd = if let Some(features) = &FEATURES.btf() {
if let Some(btf) = obj.fixup_and_sanitize_btf(features)? {
// load btf to the kernel
let btf = load_btf(btf.to_bytes(), *verifier_log_level)?;
Some(btf)
match load_btf(btf.to_bytes(), *verifier_log_level) {
Ok(btf_fd) => Some(btf_fd),
// Only report an error here if the BTF is truely needed, otherwise proceed without.
Err(err) => {
for program in obj.programs.values() {
match program.section {
ProgramSection::Extension { .. }
| ProgramSection::FEntry { .. }
| ProgramSection::FExit { .. }
| ProgramSection::Lsm { .. }
| ProgramSection::BtfTracePoint { .. } => {
return Err(BpfError::BtfError(err))
}
ProgramSection::KRetProbe { .. }
| ProgramSection::KProbe { .. }
| ProgramSection::UProbe { .. }
| ProgramSection::URetProbe { .. }
| ProgramSection::TracePoint { .. }
| ProgramSection::SocketFilter { .. }
| ProgramSection::Xdp { .. }
| ProgramSection::SkMsg { .. }
| ProgramSection::SkSkbStreamParser { .. }
| ProgramSection::SkSkbStreamVerdict { .. }
| ProgramSection::SockOps { .. }
| ProgramSection::SchedClassifier { .. }
| ProgramSection::CgroupSkb { .. }
| ProgramSection::CgroupSkbIngress { .. }
| ProgramSection::CgroupSkbEgress { .. }
| ProgramSection::CgroupSockAddr { .. }
| ProgramSection::CgroupSysctl { .. }
| ProgramSection::CgroupSockopt { .. }
| ProgramSection::LircMode2 { .. }
| ProgramSection::PerfEvent { .. }
| ProgramSection::RawTracePoint { .. }
| ProgramSection::SkLookup { .. }
| ProgramSection::CgroupSock { .. }
| ProgramSection::CgroupDevice { .. } => {}
}
}
warn!("Object BTF couldn't be loaded in the kernel: {err}");
None
}
}
} else {
None
}

Loading…
Cancel
Save