-
I have a map, say Global, which is pinned to I want two different BPF programs to reference this pinned map. Is that possible? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Yes, you can do that by specifying MapOptions.PinPath. |
Beta Was this translation helpful? Give feedback.
-
Hi @chenhengqi, thank you for your quick response. I have an eBpf elf file that has multiple map sections. I only want to replace one of them with a pinned map. I checked the example and saw a snippet: ebpf/examples/kprobepin/main.go Lines 44 to 55 in 34be694 Seems that the |
Beta Was this translation helpful? Give feedback.
-
Hi @d0u9, thanks for the question. In order for the ELF loader to automatically pin or re-use a pinned map, the map definition needs to have its pinned flag set. See the example below: ebpf/examples/kprobepin/kprobe_pin.c Line 13 in 34be694 If you attempt to load this ELF (containing a map definition with the 'pinned' flag) without Specifying |
Beta Was this translation helpful? Give feedback.
Hi @d0u9, thanks for the question.
In order for the ELF loader to automatically pin or re-use a pinned map, the map definition needs to have its pinned flag set.
See the example below:
ebpf/examples/kprobepin/kprobe_pin.c
Line 13 in 34be694
If you attempt to load this ELF (containing a map definition with the 'pinned' flag) without
CollectionOptions.Maps.PinPath
set, map creation will fail with an error.Specifying
/sys/fs/bpf
will cause a map calledglobal
to be created and pinned to/sys/fs/bpf/global
. If an map at that path already exists, it will automatically open it and use that existing map in any programs loaded from the ELF. …