Re: Reading Pinned maps in eBPF Programs


Ian
 

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?

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! 

Join iovisor-dev@lists.iovisor.org to automatically receive all group messages.