Skip to content

Commit 6c88ace

Browse files
committed
Add ringbuf support function
1 parent 0222fff commit 6c88ace

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

collector/lib/rust/host/src/info.rs

+16-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ use log::{debug, info, warn};
33
use std::io::Error;
44

55
use libbpf_rs::libbpf_sys::{
6-
libbpf_num_possible_cpus, libbpf_probe_bpf_prog_type, BPF_PROG_TYPE_TRACING,
6+
libbpf_num_possible_cpus, libbpf_probe_bpf_map_type, libbpf_probe_bpf_prog_type,
7+
BPF_MAP_TYPE_RINGBUF, BPF_PROG_TYPE_TRACING,
78
};
89

910
use crate::KernelVersion;
@@ -236,7 +237,20 @@ impl HostInfo {
236237
}
237238

238239
pub fn has_bpf_ringbuf_support(&self) -> bool {
239-
false
240+
let res = unsafe { libbpf_probe_bpf_map_type(BPF_MAP_TYPE_RINGBUF, std::ptr::null()) };
241+
242+
if res == 0 {
243+
info!(
244+
"BPF ringbuffer map type is not available (errno = {:?})",
245+
Error::last_os_error()
246+
);
247+
}
248+
249+
if res < 0 {
250+
warn!("Unable to check for the BPF ringbuffer availability. Assuming it is available.");
251+
}
252+
253+
res != 0
240254
}
241255
}
242256

0 commit comments

Comments
 (0)