From 1f5752adcf9b9e95a530398e0a9533fb9596c9c8 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Thu, 2 Jan 2025 13:35:44 +0000 Subject: [PATCH] more context on error --- mitmproxy-linux/src/main2.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mitmproxy-linux/src/main2.rs b/mitmproxy-linux/src/main2.rs index 35815a8f..67005b7a 100644 --- a/mitmproxy-linux/src/main2.rs +++ b/mitmproxy-linux/src/main2.rs @@ -62,7 +62,7 @@ async fn main() -> anyhow::Result<()> { .btf(Btf::from_sys_fs().ok().as_ref()) .set_global("INTERFACE_ID", &device_index, true) .load(BPF_PROG) - .with_context(|| format!("Failed to load eBPF program ({:x})", Bytes::from_static(&BPF_HASH)))?; + .context("failed to load eBPF program")?; if let Err(e) = aya_log::EbpfLogger::init(&mut ebpf) { // This can happen if you remove all log statements from your eBPF program. warn!("failed to initialize eBPF logger: {}", e); @@ -71,9 +71,9 @@ async fn main() -> anyhow::Result<()> { debug!("Attaching BPF_CGROUP_INET_SOCK_CREATE program..."); let prog: &mut CgroupSock = ebpf.program_mut("cgroup_sock_create").context("failed to get cgroup_sock_create")?.try_into()?; // root cgroup to get all events. - let cgroup = std::fs::File::open("/sys/fs/cgroup/")?; - prog.load()?; - prog.attach(&cgroup, CgroupAttachMode::Single)?; + let cgroup = fs::File::open("/sys/fs/cgroup/").context("failed to open \"/sys/fs/cgroup/\"")?; + prog.load().context("failed to load cgroup_sock_create program")?; + prog.attach(&cgroup, CgroupAttachMode::Single).context("failed to attach cgroup_sock_create program")?; debug!("Getting INTERCEPT_CONF map..."); let mut intercept_conf = {