On Mon, Aug 17, 2020 at 6:36 AM Ian <[email protected]> wrote:
>
> You can use bpf_obj_get() API to get a reference to the pinned map.
>
> It was my understanding that bpf_obj_get was intended to be used as a user 
> space API. I am looking to "open" or obtain a reference to a map in the 
> actual eBPF program that is loaded into the kernel space. My eBPF programs do 
> include linux/bpf.h but not the uapi bpf.h. Can/should you use it in the 
> actual BPF program? Or is there an a different way to achieve this?
>

Libbpf supports declarative pinning of maps, that's how you easily get
"map re-use" from BPF side. See [0] for example.

But there is also bpf_map__pin() and bpf_map__reuse_fd() API on
user-space side to set everything up, if you need to do it more
flexibly.

  [0] 
https://github.com/torvalds/linux/blob/master/tools/testing/selftests/bpf/progs/test_pinning.c

> I have seen a function called bpf_obj_get_user in linux/bpf.h but I cannot 
> find any documentation on it. It also just returns an unsupported error in my 
> kernel's source code.
>
> static inline int bpf_obj_get_user(const char __user *pathname, int flags)
>
> {
>
>         return -EOPNOTSUPP;
>
> }
>
> BPF_ANNOTATE_KV_PAIR is old way to provide map key/value types, mostly
> for pretty print. bcc still uses it. libbpf can use more advanced
> mechanisms with direct .maps section attribute.s
>
> Ahh interesting!
> 

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#1895): https://lists.iovisor.org/g/iovisor-dev/message/1895
Mute This Topic: https://lists.iovisor.org/mt/76194102/21656
Group Owner: [email protected]
Unsubscribe: https://lists.iovisor.org/g/iovisor-dev/unsub  
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to