2

I know this question is asked before, but I failed to find any post that has an example on how to do it. Specifically, one BPF program defines a map, and the other BPF program accesses that map. Note that it is Not one BPF program defines a map, and another userspace program accesses it. BOTH BPF program run in the kernel space.

pyang
  • 109
  • 7
  • 1
    Doesn't this answer your question? [Map sharing between different ebpf program types](https://stackoverflow.com/questions/58455605/map-sharing-between-different-ebpf-program-types). It has examples of how to do it for libbpf. The How To will depend from loader to loader. – pchaigno Apr 17 '21 at 08:23
  • That post discussed some ideas. But I am quite new to the BPF stuff, and need a concrete example. Please sharing one if possible. Also It seems that it is talking about how to access the map in the user space, not another BPF program run in the kernel. – pyang Apr 19 '21 at 17:37

1 Answers1

0

pyang.

If you don't mind using RedBPF, a rust library for eBPF, you can do what you want.

Here are the exact examples you mentioned. https://github.com/foniod/redbpf/blob/main/examples/example-userspace/examples/sharemap1.rs

and

https://github.com/foniod/redbpf/blob/main/examples/example-userspace/examples/sharemap2.rs