aya EbpfLoader::set_global does not work
cppcoffee opened this issue · 1 comments
cppcoffee commented
Ebpf defines TRACE_ALL
global variable:
#[no_mangle]
static TRACE_ALL: bool = false;
https://github.com/cppcoffee/rust-memleak/blob/dev-sharp/rust-memleak-ebpf/src/main.rs#L25
Call set_global to set TRACE_ALL
:
let mut ebpf = EbpfLoader::new()
.btf(Btf::from_sys_fs().ok().as_ref())
.set_global("TRACE_ALL", &(opt.verbose as u8), true)
https://github.com/cppcoffee/rust-memleak/blob/dev-sharp/rust-memleak/src/main.rs#L76
After running it, observe that the set_global
function does not work.
Ebpf TRACE_ALL
is expected to be set to 1.
alessandrod commented
See the example in the docs https://docs.rs/aya/latest/aya/struct.EbpfLoader.html#method.set_global, you must use read_volatile.