iovisor / bcc

BCC - Tools for BPF-based Linux IO analysis, networking, monitoring, and more
Apache License 2.0
20.64k stars 3.89k forks source link

Using bpf_for_each_map_elem helper with BCC #3418

Open sebymiano opened 3 years ago

sebymiano commented 3 years ago

Hi all, I was trying to use the new bpf_for_each_map_elem helper within a BCC-based application. I have modified the rewriter to support a new function so that the helper can be called in this way:

map.for_each_elem(callback_function, &data, 0);

However, I get the following error when trying to deploy the program (kernel 5.13rc1, LLVM10):

HINT: The 'unknown opcode' can happen if you reference a global or static variable, or data in read-only section.

I guess the problem is within the "callback_function", which is not correctly relocated. Does anyone have an idea of how to solve this issue?

yonghong-song commented 3 years ago

@sebymiano Yes, currently bcc does not support callback functions. @davemarchevsky is working on bcc trying to incorporate more functionalities from libbpf repo to bcc. Once libbpf is "fully" available to bcc, we should be able to resolve this issue. Thanks!

sebymiano commented 3 years ago

@yonghong-song thanks a lot for the reply. If I can help you or @davemarchevsky in porting additional functionalities from libbpf to BCC I will be happy to do it, just let me know.

ek-nath commented 1 year ago

👋 Is this available now?

yonghong-song commented 1 year ago

Not yet. Currently, there is an effort to utilize the libbpf infrastructure (https://github.com/iovisor/bcc/pull/4405) which should be able to address this issue.