I'm looking for a method to send data from userspace to bpf program in Linux.
I use libbpf in userspace and bpf_helpers in bpf program in kernel.
I now can send data from kernel to user by ringbuf and other.
but I want to use stack and queue for this. I can't find function that handles queue or stack in userspace and I still confused.
My question is: how can I send data from userspace to bpf program using stack or queue and get it in my bpf program, as what we do in bcc with bpf['queue'].push
in userspace for example and queue.peek(&val);
in bpf program.
thank you for any help!
You should use the usual bpf_map_update_elem
and bpf_map_lookup_elem
functions for BPF_MAP_TYPE_QUEUE
and BPF_MAP_TYPE_STACK
maps.
You can find several examples in the kernel source code: