This group is locked. No changes can be made to the group while it is locked.
Date 1 - 4 of 4
Accessing pinned eBPF map from the kernel
I have an eBPF map created and pinned by a userspace process.
Now I would like several eBPF programs to access this pinned eBPF map.
Is there any bcc APIs that can be used?
BPF_TABLE(), etc creates a new eBPF map, not loads an existing pinned map.
The following is an example in C++ to import an external map to BPF modules.toggle quoted message Show quoted text
You can use libbpf function `bpf_obj_get` to get a map fd in the above example.
On Wed, Jul 18, 2018 at 11:48 AM, <hyunseok@...> wrote:
toggle quoted message Show quoted text
Thanks for your reply.
BPF_TABLE("extern") seems to work only if the eBPF program is loaded by the same userspace process which creates the map, like in this example.
But, what if a map is created (and pinned) by process A, and an eBPF program is loaded by another process B?
Is there any way for the eBPF program to access the pinned map?
bpf_obj_get cannot be used by eBPF programs as it is a userspace API.
On Thu, Jul 19, 2018 at 3:33 PM, Y Song <ys114321@...> wrote:
The following is an example in C++ to import an external map to BPF modules.
On Thu, Jul 19, 2018 at 2:49 PM, Hyunseok <hyunseok@...> wrote:
Thanks for your reply.No. The example uses a locally-created map to illustrate the process,
but a pinned map
works in a similar way.
The user space application:
. using bpf_obj_get to get a FD for the pinned map.
. create TableDesc with the FD.
. Add TableDesc to the local_ts.
. Create a BPF object with the local_ts.
In the bpf program itself, declare the pinned map with "extern" type.
Just follow the above process, it should work. Facebook has used the
same mechanism for a while to access externally-pinned maps.
bpf_obj_get() intends to be used in userspace, not kernel.
|1 - 4 of 4|