aya: Ignore embedded BTF error if not truely required

This allows fallback to BTF manual relocation when BTF loading fail when not truely required.
pull/584/head
Mary 1 year ago
parent 242d8c33c4
commit 74b546827c

@ -389,9 +389,51 @@ impl<'a> BpfLoader<'a> {
let btf_fd = if let Some(features) = &FEATURES.btf() { let btf_fd = if let Some(features) = &FEATURES.btf() {
if let Some(btf) = obj.fixup_and_sanitize_btf(features)? { if let Some(btf) = obj.fixup_and_sanitize_btf(features)? {
// load btf to the kernel match load_btf(btf.to_bytes(), *verifier_log_level) {
let btf = load_btf(btf.to_bytes(), *verifier_log_level)?; Ok(btf_fd) => Some(btf_fd),
Some(btf) // 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 { } else {
None None
} }

Loading…
Cancel
Save